diff --git a/src/dex/fluid-dex/fluid-dex-e2e.test.ts b/src/dex/fluid-dex/fluid-dex-e2e.test.ts index fedbf0b56..fbdda8bad 100644 --- a/src/dex/fluid-dex/fluid-dex-e2e.test.ts +++ b/src/dex/fluid-dex/fluid-dex-e2e.test.ts @@ -68,7 +68,6 @@ function testForNetwork( ); const tokens = Tokens[network]; const holders = Holders[network]; - const nativeTokenSymbol = NativeTokenSymbols[network]; const sideToContractMethods = new Map([ [SwapSide.SELL, [ContractMethod.swapExactAmountIn]], @@ -86,7 +85,7 @@ function testForNetwork( tokens[tokenBSymbol], holders[tokenASymbol], tokenBAmount, - SwapSide.SELL, + side, dexKey, contractMethod as ContractMethod, network, @@ -99,7 +98,7 @@ function testForNetwork( tokens[tokenASymbol], holders[tokenBSymbol], tokenBAmount, - SwapSide.SELL, + side, dexKey, contractMethod as ContractMethod, network, diff --git a/src/dex/fluid-dex/fluid-dex.ts b/src/dex/fluid-dex/fluid-dex.ts index e794d0a20..8d511050a 100644 --- a/src/dex/fluid-dex/fluid-dex.ts +++ b/src/dex/fluid-dex/fluid-dex.ts @@ -334,6 +334,7 @@ export class FluidDex extends SimpleExchange implements IDex { exchangeData: swapData, targetExchange: pool!.address, returnAmountPos, + sendEthButSupportsInsertFromAmount: true, }; } diff --git a/src/executor/Executor03BytecodeBuilder.ts b/src/executor/Executor03BytecodeBuilder.ts index 5ed683903..0b34d7219 100644 --- a/src/executor/Executor03BytecodeBuilder.ts +++ b/src/executor/Executor03BytecodeBuilder.ts @@ -73,6 +73,7 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder< swappedAmountNotPresentInExchangeData, specialDexFlag, specialDexSupportsInsertFromAmount, + sendEthButSupportsInsertFromAmount, } = exchangeParam; const isSpecialDex = specialDexFlag !== undefined && specialDexFlag !== SpecialDex.DEFAULT; @@ -93,9 +94,16 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder< Flag.DONT_INSERT_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP; // 0 if (isEthSrc && !needWrap) { + const preventInsertForSendEth = + forcePreventInsertFromAmount || !sendEthButSupportsInsertFromAmount; + dexFlag = dexFuncHasRecipient - ? Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP // 9 - : Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5 + ? preventInsertForSendEth + ? Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP // 9 + : Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_PLUS_INSERT_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP // 18 + : preventInsertForSendEth + ? Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP // 5 + : Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_PLUS_INSERT_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 18 } else if (isEthDest && !needUnwrap) { dexFlag = forcePreventInsertFromAmount ? Flag.DONT_INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP // 4