From 1b6d0466b9ad1c6a5c3225e17e91c5a3a4c1428a Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Wed, 11 Oct 2023 19:34:10 +0300 Subject: [PATCH] update getAdapterParam --- src/dex/smardex/smardex.ts | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/dex/smardex/smardex.ts b/src/dex/smardex/smardex.ts index 2b50af0f4..0c2d77453 100644 --- a/src/dex/smardex/smardex.ts +++ b/src/dex/smardex/smardex.ts @@ -678,27 +678,29 @@ export class Smardex }; } - // Encode params required by the exchange adapter - // Used for multiSwap & megaSwap - // Hint: abiCoder.encodeParameter() could be useful + getWETHAddress(srcToken: Address, destToken: Address, weth?: Address) { + if (!isETHAddress(srcToken) && !isETHAddress(destToken)) + return NULL_ADDRESS; + return weth || this.dexHelper.config.data.wrappedNativeTokenAddress; + } + getAdapterParam( srcToken: Address, destToken: Address, srcAmount: NumberAsString, - toAmount: NumberAsString, // required for buy case + toAmount: NumberAsString, data: SmardexData, side: SwapSide, ): AdapterExchangeParam { - const pools = encodePools(data.pools); - const weth = this.getWETHAddress(srcToken, destToken, data.wethAddress); const payload = this.abiCoder.encodeParameter( { ParentStruct: { - weth: 'address', - pools: 'uint256[]', + path: 'address[] calldata', + receiver: 'address', + deadline: 'uint256' }, }, - { pools, weth }, + { path: data.path, receiver: data.receiver, deadline: data.deadline }, ); return { targetExchange: data.router, @@ -707,12 +709,6 @@ export class Smardex }; } - getWETHAddress(srcToken: Address, destToken: Address, weth?: Address) { - if (!isETHAddress(srcToken) && !isETHAddress(destToken)) - return NULL_ADDRESS; - return weth || this.dexHelper.config.data.wrappedNativeTokenAddress; - } - async getSimpleParam( src: Address, dest: Address,