diff --git a/dex/fuzz/src/fuzz_pair.rs b/dex/fuzz/src/fuzz_pair.rs index 480eed510..cd22614cb 100644 --- a/dex/fuzz/src/fuzz_pair.rs +++ b/dex/fuzz/src/fuzz_pair.rs @@ -12,9 +12,8 @@ pub mod fuzz_pair_test { use rand::prelude::*; use crate::fuzz_data::fuzz_data_tests::*; - use pair::{ - pair_actions::{add_liq::AddLiquidityModule, remove_liq::RemoveLiquidityModule}, - *, + use pair::pair_actions::{ + add_liq::AddLiquidityModule, remove_liq::RemoveLiquidityModule, swap::SwapModule, }; pub fn add_liquidity( diff --git a/dex/pair/src/lib.rs b/dex/pair/src/lib.rs index 021f61d6f..b4dd4a3cf 100644 --- a/dex/pair/src/lib.rs +++ b/dex/pair/src/lib.rs @@ -18,7 +18,6 @@ pub mod safe_price_view; use crate::errors::*; use contexts::base::*; -use contexts::swap::SwapContext; use pair_actions::common_result_types::{ AddLiquidityResultType, RemoveLiquidityResultType, SwapTokensFixedInputResultType, SwapTokensFixedOutputResultType, @@ -43,6 +42,7 @@ pub trait Pair: + pair_actions::initial_liq::InitialLiquidityModule + pair_actions::add_liq::AddLiquidityModule + pair_actions::remove_liq::RemoveLiquidityModule + + pair_actions::swap::SwapModule + pair_actions::common_methods::CommonMethodsModule { #[init] @@ -100,191 +100,6 @@ pub trait Pair: #[endpoint] fn upgrade(&self) {} - #[payable("*")] - #[endpoint(swapNoFeeAndForward)] - fn swap_no_fee(&self, token_out: TokenIdentifier, destination_address: ManagedAddress) { - let caller = self.blockchain().get_caller(); - require!(self.whitelist().contains(&caller), ERROR_NOT_WHITELISTED); - - let mut storage_cache = StorageCache::new(self); - let (token_in, _, amount_in) = self.call_value().single_esdt().into_tuple(); - let swap_tokens_order = storage_cache.get_swap_tokens_order(&token_in, &token_out); - - require!( - self.can_swap(storage_cache.contract_state), - ERROR_SWAP_NOT_ENABLED - ); - - self.update_safe_price( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - - let initial_k = self.calculate_k_constant( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - - let mut swap_context = SwapContext::new( - token_in, - amount_in.clone(), - token_out, - BigUint::from(1u32), - swap_tokens_order, - ); - swap_context.final_input_amount = amount_in; - - let amount_out = self.swap_safe_no_fee( - &mut storage_cache, - swap_context.swap_tokens_order, - &swap_context.final_input_amount, - ); - require!(amount_out > 0u64, ERROR_ZERO_AMOUNT); - - swap_context.final_output_amount = amount_out; - - let new_k = self.calculate_k_constant( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - require!(initial_k <= new_k, ERROR_K_INVARIANT_FAILED); - - self.burn( - &swap_context.output_token_id, - &swap_context.final_output_amount, - ); - - self.emit_swap_no_fee_and_forward_event(swap_context, destination_address); - } - - #[payable("*")] - #[endpoint(swapTokensFixedInput)] - fn swap_tokens_fixed_input( - &self, - token_out: TokenIdentifier, - amount_out_min: BigUint, - ) -> SwapTokensFixedInputResultType { - require!(amount_out_min > 0, ERROR_INVALID_ARGS); - - let mut storage_cache = StorageCache::new(self); - let (token_in, _, amount_in) = self.call_value().single_esdt().into_tuple(); - let swap_tokens_order = storage_cache.get_swap_tokens_order(&token_in, &token_out); - - require!( - self.can_swap(storage_cache.contract_state), - ERROR_SWAP_NOT_ENABLED - ); - - let reserve_out = storage_cache.get_mut_reserve_out(swap_tokens_order); - require!(*reserve_out > amount_out_min, ERROR_NOT_ENOUGH_RESERVE); - - self.update_safe_price( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - - let initial_k = self.calculate_k_constant( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - - let mut swap_context = SwapContext::new( - token_in, - amount_in, - token_out, - amount_out_min, - swap_tokens_order, - ); - self.perform_swap_fixed_input(&mut swap_context, &mut storage_cache); - - let new_k = self.calculate_k_constant( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - require!(initial_k <= new_k, ERROR_K_INVARIANT_FAILED); - - if swap_context.fee_amount > 0 { - self.send_fee( - &mut storage_cache, - swap_context.swap_tokens_order, - &swap_context.input_token_id, - &swap_context.fee_amount, - ); - } - - let caller = self.blockchain().get_caller(); - let output_payments = self.build_swap_output_payments(&swap_context); - self.send_multiple_tokens_if_not_zero(&caller, &output_payments); - - self.emit_swap_event(&storage_cache, swap_context); - - self.build_swap_fixed_input_results(output_payments) - } - - #[payable("*")] - #[endpoint(swapTokensFixedOutput)] - fn swap_tokens_fixed_output( - &self, - token_out: TokenIdentifier, - amount_out: BigUint, - ) -> SwapTokensFixedOutputResultType { - require!(amount_out > 0, ERROR_INVALID_ARGS); - - let mut storage_cache = StorageCache::new(self); - let (token_in, _, amount_in_max) = self.call_value().single_esdt().into_tuple(); - let swap_tokens_order = storage_cache.get_swap_tokens_order(&token_in, &token_out); - - require!( - self.can_swap(storage_cache.contract_state), - ERROR_SWAP_NOT_ENABLED - ); - - let reserve_out = storage_cache.get_mut_reserve_out(swap_tokens_order); - require!(*reserve_out > amount_out, ERROR_NOT_ENOUGH_RESERVE); - - self.update_safe_price( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - - let initial_k = self.calculate_k_constant( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - - let mut swap_context = SwapContext::new( - token_in, - amount_in_max, - token_out, - amount_out, - swap_tokens_order, - ); - self.perform_swap_fixed_output(&mut swap_context, &mut storage_cache); - - let new_k = self.calculate_k_constant( - &storage_cache.first_token_reserve, - &storage_cache.second_token_reserve, - ); - require!(initial_k <= new_k, ERROR_K_INVARIANT_FAILED); - - if swap_context.fee_amount > 0 { - self.send_fee( - &mut storage_cache, - swap_context.swap_tokens_order, - &swap_context.input_token_id, - &swap_context.fee_amount, - ); - } - - let caller = self.blockchain().get_caller(); - let output_payments = self.build_swap_output_payments(&swap_context); - self.send_multiple_tokens_if_not_zero(&caller, &output_payments); - - self.emit_swap_event(&storage_cache, swap_context); - - self.build_swap_fixed_output_results(output_payments) - } - #[endpoint(setLpTokenIdentifier)] fn set_lp_token_identifier(&self, token_identifier: TokenIdentifier) { self.require_caller_has_owner_permissions(); @@ -398,76 +213,4 @@ pub trait Pair: sc_panic!(ERROR_UNKNOWN_TOKEN); } } - - #[inline] - fn can_swap(&self, state: State) -> bool { - state == State::Active - } - - fn perform_swap_fixed_input( - &self, - context: &mut SwapContext, - storage_cache: &mut StorageCache, - ) { - context.final_input_amount = context.input_token_amount.clone(); - - let reserve_in = storage_cache.get_reserve_in(context.swap_tokens_order); - let reserve_out = storage_cache.get_reserve_out(context.swap_tokens_order); - - let amount_out_optimal = - self.get_amount_out(&context.input_token_amount, reserve_in, reserve_out); - require!( - amount_out_optimal >= context.output_token_amount, - ERROR_SLIPPAGE_EXCEEDED - ); - require!(*reserve_out > amount_out_optimal, ERROR_NOT_ENOUGH_RESERVE); - require!(amount_out_optimal != 0u64, ERROR_ZERO_AMOUNT); - - context.final_output_amount = amount_out_optimal; - - let mut amount_in_after_fee = context.input_token_amount.clone(); - if self.is_fee_enabled() { - let fee_amount = self.get_special_fee_from_input(&amount_in_after_fee); - amount_in_after_fee -= &fee_amount; - - context.fee_amount = fee_amount; - } - - *storage_cache.get_mut_reserve_in(context.swap_tokens_order) += amount_in_after_fee; - *storage_cache.get_mut_reserve_out(context.swap_tokens_order) -= - &context.final_output_amount; - } - - fn perform_swap_fixed_output( - &self, - context: &mut SwapContext, - storage_cache: &mut StorageCache, - ) { - context.final_output_amount = context.output_token_amount.clone(); - - let reserve_in = storage_cache.get_reserve_in(context.swap_tokens_order); - let reserve_out = storage_cache.get_reserve_out(context.swap_tokens_order); - - let amount_in_optimal = - self.get_amount_in(&context.output_token_amount, reserve_in, reserve_out); - require!( - amount_in_optimal <= context.input_token_amount, - ERROR_SLIPPAGE_EXCEEDED - ); - require!(amount_in_optimal != 0, ERROR_ZERO_AMOUNT); - - context.final_input_amount = amount_in_optimal.clone(); - - let mut amount_in_optimal_after_fee = amount_in_optimal; - if self.is_fee_enabled() { - let fee_amount = self.get_special_fee_from_input(&amount_in_optimal_after_fee); - amount_in_optimal_after_fee -= &fee_amount; - - context.fee_amount = fee_amount; - } - - *storage_cache.get_mut_reserve_in(context.swap_tokens_order) += amount_in_optimal_after_fee; - *storage_cache.get_mut_reserve_out(context.swap_tokens_order) -= - &context.final_output_amount; - } } diff --git a/dex/pair/src/pair_actions/common_methods.rs b/dex/pair/src/pair_actions/common_methods.rs index 5d145e9bc..8839a85d5 100644 --- a/dex/pair/src/pair_actions/common_methods.rs +++ b/dex/pair/src/pair_actions/common_methods.rs @@ -8,4 +8,9 @@ pub trait CommonMethodsModule { fn is_state_active(&self, state: State) -> bool { state == State::Active || state == State::PartialActive } + + #[inline] + fn can_swap(&self, state: State) -> bool { + state == State::Active + } } diff --git a/dex/pair/src/pair_actions/mod.rs b/dex/pair/src/pair_actions/mod.rs index 13495c791..1b4c36ed1 100644 --- a/dex/pair/src/pair_actions/mod.rs +++ b/dex/pair/src/pair_actions/mod.rs @@ -3,3 +3,4 @@ pub mod common_methods; pub mod common_result_types; pub mod initial_liq; pub mod remove_liq; +pub mod swap; diff --git a/dex/pair/src/pair_actions/swap.rs b/dex/pair/src/pair_actions/swap.rs new file mode 100644 index 000000000..6e028bad0 --- /dev/null +++ b/dex/pair/src/pair_actions/swap.rs @@ -0,0 +1,277 @@ +use crate::{ + contexts::swap::SwapContext, StorageCache, ERROR_INVALID_ARGS, ERROR_K_INVARIANT_FAILED, + ERROR_NOT_ENOUGH_RESERVE, ERROR_NOT_WHITELISTED, ERROR_SLIPPAGE_EXCEEDED, + ERROR_SWAP_NOT_ENABLED, ERROR_ZERO_AMOUNT, +}; + +use super::common_result_types::{SwapTokensFixedInputResultType, SwapTokensFixedOutputResultType}; + +multiversx_sc::imports!(); + +#[multiversx_sc::module] +pub trait SwapModule: + crate::liquidity_pool::LiquidityPoolModule + + crate::amm::AmmModule + + crate::contexts::output_builder::OutputBuilderModule + + crate::locking_wrapper::LockingWrapperModule + + crate::events::EventsModule + + crate::safe_price::SafePriceModule + + crate::fee::FeeModule + + crate::config::ConfigModule + + token_send::TokenSendModule + + permissions_module::PermissionsModule + + pausable::PausableModule + + super::common_methods::CommonMethodsModule +{ + #[payable("*")] + #[endpoint(swapNoFeeAndForward)] + fn swap_no_fee(&self, token_out: TokenIdentifier, destination_address: ManagedAddress) { + let caller = self.blockchain().get_caller(); + require!(self.whitelist().contains(&caller), ERROR_NOT_WHITELISTED); + + let mut storage_cache = StorageCache::new(self); + let (token_in, _, amount_in) = self.call_value().single_esdt().into_tuple(); + let swap_tokens_order = storage_cache.get_swap_tokens_order(&token_in, &token_out); + + require!( + self.can_swap(storage_cache.contract_state), + ERROR_SWAP_NOT_ENABLED + ); + + self.update_safe_price( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + + let initial_k = self.calculate_k_constant( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + + let mut swap_context = SwapContext::new( + token_in, + amount_in.clone(), + token_out, + BigUint::from(1u32), + swap_tokens_order, + ); + swap_context.final_input_amount = amount_in; + + let amount_out = self.swap_safe_no_fee( + &mut storage_cache, + swap_context.swap_tokens_order, + &swap_context.final_input_amount, + ); + require!(amount_out > 0u64, ERROR_ZERO_AMOUNT); + + swap_context.final_output_amount = amount_out; + + let new_k = self.calculate_k_constant( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + require!(initial_k <= new_k, ERROR_K_INVARIANT_FAILED); + + self.burn( + &swap_context.output_token_id, + &swap_context.final_output_amount, + ); + + self.emit_swap_no_fee_and_forward_event(swap_context, destination_address); + } + + #[payable("*")] + #[endpoint(swapTokensFixedInput)] + fn swap_tokens_fixed_input( + &self, + token_out: TokenIdentifier, + amount_out_min: BigUint, + ) -> SwapTokensFixedInputResultType { + require!(amount_out_min > 0, ERROR_INVALID_ARGS); + + let mut storage_cache = StorageCache::new(self); + let (token_in, _, amount_in) = self.call_value().single_esdt().into_tuple(); + let swap_tokens_order = storage_cache.get_swap_tokens_order(&token_in, &token_out); + + require!( + self.can_swap(storage_cache.contract_state), + ERROR_SWAP_NOT_ENABLED + ); + + let reserve_out = storage_cache.get_mut_reserve_out(swap_tokens_order); + require!(*reserve_out > amount_out_min, ERROR_NOT_ENOUGH_RESERVE); + + self.update_safe_price( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + + let initial_k = self.calculate_k_constant( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + + let mut swap_context = SwapContext::new( + token_in, + amount_in, + token_out, + amount_out_min, + swap_tokens_order, + ); + self.perform_swap_fixed_input(&mut swap_context, &mut storage_cache); + + let new_k = self.calculate_k_constant( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + require!(initial_k <= new_k, ERROR_K_INVARIANT_FAILED); + + if swap_context.fee_amount > 0 { + self.send_fee( + &mut storage_cache, + swap_context.swap_tokens_order, + &swap_context.input_token_id, + &swap_context.fee_amount, + ); + } + + let caller = self.blockchain().get_caller(); + let output_payments = self.build_swap_output_payments(&swap_context); + self.send_multiple_tokens_if_not_zero(&caller, &output_payments); + + self.emit_swap_event(&storage_cache, swap_context); + + self.build_swap_fixed_input_results(output_payments) + } + + #[payable("*")] + #[endpoint(swapTokensFixedOutput)] + fn swap_tokens_fixed_output( + &self, + token_out: TokenIdentifier, + amount_out: BigUint, + ) -> SwapTokensFixedOutputResultType { + require!(amount_out > 0, ERROR_INVALID_ARGS); + + let mut storage_cache = StorageCache::new(self); + let (token_in, _, amount_in_max) = self.call_value().single_esdt().into_tuple(); + let swap_tokens_order = storage_cache.get_swap_tokens_order(&token_in, &token_out); + + require!( + self.can_swap(storage_cache.contract_state), + ERROR_SWAP_NOT_ENABLED + ); + + let reserve_out = storage_cache.get_mut_reserve_out(swap_tokens_order); + require!(*reserve_out > amount_out, ERROR_NOT_ENOUGH_RESERVE); + + self.update_safe_price( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + + let initial_k = self.calculate_k_constant( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + + let mut swap_context = SwapContext::new( + token_in, + amount_in_max, + token_out, + amount_out, + swap_tokens_order, + ); + self.perform_swap_fixed_output(&mut swap_context, &mut storage_cache); + + let new_k = self.calculate_k_constant( + &storage_cache.first_token_reserve, + &storage_cache.second_token_reserve, + ); + require!(initial_k <= new_k, ERROR_K_INVARIANT_FAILED); + + if swap_context.fee_amount > 0 { + self.send_fee( + &mut storage_cache, + swap_context.swap_tokens_order, + &swap_context.input_token_id, + &swap_context.fee_amount, + ); + } + + let caller = self.blockchain().get_caller(); + let output_payments = self.build_swap_output_payments(&swap_context); + self.send_multiple_tokens_if_not_zero(&caller, &output_payments); + + self.emit_swap_event(&storage_cache, swap_context); + + self.build_swap_fixed_output_results(output_payments) + } + + fn perform_swap_fixed_input( + &self, + context: &mut SwapContext, + storage_cache: &mut StorageCache, + ) { + context.final_input_amount = context.input_token_amount.clone(); + + let reserve_in = storage_cache.get_reserve_in(context.swap_tokens_order); + let reserve_out = storage_cache.get_reserve_out(context.swap_tokens_order); + + let amount_out_optimal = + self.get_amount_out(&context.input_token_amount, reserve_in, reserve_out); + require!( + amount_out_optimal >= context.output_token_amount, + ERROR_SLIPPAGE_EXCEEDED + ); + require!(*reserve_out > amount_out_optimal, ERROR_NOT_ENOUGH_RESERVE); + require!(amount_out_optimal != 0u64, ERROR_ZERO_AMOUNT); + + context.final_output_amount = amount_out_optimal; + + let mut amount_in_after_fee = context.input_token_amount.clone(); + if self.is_fee_enabled() { + let fee_amount = self.get_special_fee_from_input(&amount_in_after_fee); + amount_in_after_fee -= &fee_amount; + + context.fee_amount = fee_amount; + } + + *storage_cache.get_mut_reserve_in(context.swap_tokens_order) += amount_in_after_fee; + *storage_cache.get_mut_reserve_out(context.swap_tokens_order) -= + &context.final_output_amount; + } + + fn perform_swap_fixed_output( + &self, + context: &mut SwapContext, + storage_cache: &mut StorageCache, + ) { + context.final_output_amount = context.output_token_amount.clone(); + + let reserve_in = storage_cache.get_reserve_in(context.swap_tokens_order); + let reserve_out = storage_cache.get_reserve_out(context.swap_tokens_order); + + let amount_in_optimal = + self.get_amount_in(&context.output_token_amount, reserve_in, reserve_out); + require!( + amount_in_optimal <= context.input_token_amount, + ERROR_SLIPPAGE_EXCEEDED + ); + require!(amount_in_optimal != 0, ERROR_ZERO_AMOUNT); + + context.final_input_amount = amount_in_optimal.clone(); + + let mut amount_in_optimal_after_fee = amount_in_optimal; + if self.is_fee_enabled() { + let fee_amount = self.get_special_fee_from_input(&amount_in_optimal_after_fee); + amount_in_optimal_after_fee -= &fee_amount; + + context.fee_amount = fee_amount; + } + + *storage_cache.get_mut_reserve_in(context.swap_tokens_order) += amount_in_optimal_after_fee; + *storage_cache.get_mut_reserve_out(context.swap_tokens_order) -= + &context.final_output_amount; + } +} diff --git a/dex/pair/tests/pair_rs_test.rs b/dex/pair/tests/pair_rs_test.rs index eb90a88f6..5ff6fbce9 100644 --- a/dex/pair/tests/pair_rs_test.rs +++ b/dex/pair/tests/pair_rs_test.rs @@ -13,8 +13,10 @@ use multiversx_sc_scenario::{ managed_address, managed_biguint, managed_token_id, managed_token_id_wrapped, rust_biguint, whitebox_legacy::TxTokenTransfer, DebugApi, }; -// use pair::safe_price::MAX_OBSERVATIONS; -use pair::{config::MAX_PERCENTAGE, fee::FeeModule, locking_wrapper::LockingWrapperModule, Pair}; +use pair::{ + config::MAX_PERCENTAGE, fee::FeeModule, locking_wrapper::LockingWrapperModule, + pair_actions::swap::SwapModule, +}; use pair_setup::*; use simple_lock::{ locked_token::{LockedTokenAttributes, LockedTokenModule}, diff --git a/dex/pair/tests/pair_setup/mod.rs b/dex/pair/tests/pair_setup/mod.rs index d13f17d75..5ca0fcd84 100644 --- a/dex/pair/tests/pair_setup/mod.rs +++ b/dex/pair/tests/pair_setup/mod.rs @@ -21,6 +21,7 @@ pub const USER_TOTAL_WEGLD_TOKENS: u64 = 5_000_000_000; use pair::config::ConfigModule as PairConfigModule; use pair::pair_actions::add_liq::AddLiquidityModule; +use pair::pair_actions::swap::SwapModule; use pair::safe_price_view::*; use pair::*; use pausable::{PausableModule, State}; diff --git a/dex/pair/wasm-pair-full/src/lib.rs b/dex/pair/wasm-pair-full/src/lib.rs index b08a363d5..ea7c4e8d2 100644 --- a/dex/pair/wasm-pair-full/src/lib.rs +++ b/dex/pair/wasm-pair-full/src/lib.rs @@ -21,9 +21,6 @@ multiversx_sc_wasm_adapter::endpoints! { ( init => init upgrade => upgrade - swapNoFeeAndForward => swap_no_fee - swapTokensFixedInput => swap_tokens_fixed_input - swapTokensFixedOutput => swap_tokens_fixed_output setLpTokenIdentifier => set_lp_token_identifier getTokensForGivenPosition => get_tokens_for_given_position getReservesAndTotalSupply => get_reserves_and_total_supply @@ -75,6 +72,9 @@ multiversx_sc_wasm_adapter::endpoints! { addLiquidity => add_liquidity removeLiquidity => remove_liquidity removeLiquidityAndBuyBackAndBurnToken => remove_liquidity_and_burn_token + swapNoFeeAndForward => swap_no_fee + swapTokensFixedInput => swap_tokens_fixed_input + swapTokensFixedOutput => swap_tokens_fixed_output getLpTokensSafePriceByDefaultOffset => get_lp_tokens_safe_price_by_default_offset getLpTokensSafePriceByRoundOffset => get_lp_tokens_safe_price_by_round_offset getLpTokensSafePriceByTimestampOffset => get_lp_tokens_safe_price_by_timestamp_offset diff --git a/dex/pair/wasm/src/lib.rs b/dex/pair/wasm/src/lib.rs index b711412a3..268a50e9c 100644 --- a/dex/pair/wasm/src/lib.rs +++ b/dex/pair/wasm/src/lib.rs @@ -21,9 +21,6 @@ multiversx_sc_wasm_adapter::endpoints! { ( init => init upgrade => upgrade - swapNoFeeAndForward => swap_no_fee - swapTokensFixedInput => swap_tokens_fixed_input - swapTokensFixedOutput => swap_tokens_fixed_output setLpTokenIdentifier => set_lp_token_identifier getTokensForGivenPosition => get_tokens_for_given_position getReservesAndTotalSupply => get_reserves_and_total_supply @@ -75,6 +72,9 @@ multiversx_sc_wasm_adapter::endpoints! { addLiquidity => add_liquidity removeLiquidity => remove_liquidity removeLiquidityAndBuyBackAndBurnToken => remove_liquidity_and_burn_token + swapNoFeeAndForward => swap_no_fee + swapTokensFixedInput => swap_tokens_fixed_input + swapTokensFixedOutput => swap_tokens_fixed_output ) } diff --git a/dex/router/src/multi_pair_swap.rs b/dex/router/src/multi_pair_swap.rs index e537beed9..3b0f73620 100644 --- a/dex/router/src/multi_pair_swap.rs +++ b/dex/router/src/multi_pair_swap.rs @@ -1,9 +1,9 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use super::factory; +use pair::pair_actions::swap::ProxyTrait as _; -use pair::ProxyTrait as _; +use super::factory; type SwapOperationType = MultiValue4, ManagedBuffer, TokenIdentifier, BigUint>;