Skip to content

Commit

Permalink
updated flags for ex03
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Nov 21, 2024
1 parent 4e91269 commit 024ffa1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/dex/fluid-dex/fluid-dex-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand All @@ -86,7 +85,7 @@ function testForNetwork(
tokens[tokenBSymbol],
holders[tokenASymbol],
tokenBAmount,
SwapSide.SELL,
side,
dexKey,
contractMethod as ContractMethod,
network,
Expand All @@ -99,7 +98,7 @@ function testForNetwork(
tokens[tokenASymbol],
holders[tokenBSymbol],
tokenBAmount,
SwapSide.SELL,
side,
dexKey,
contractMethod as ContractMethod,
network,
Expand Down
1 change: 1 addition & 0 deletions src/dex/fluid-dex/fluid-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
exchangeData: swapData,
targetExchange: pool!.address,
returnAmountPos,
sendEthButSupportsInsertFromAmount: true,
};
}

Expand Down
12 changes: 10 additions & 2 deletions src/executor/Executor03BytecodeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder<
swappedAmountNotPresentInExchangeData,
specialDexFlag,
specialDexSupportsInsertFromAmount,
sendEthButSupportsInsertFromAmount,
} = exchangeParam;
const isSpecialDex =
specialDexFlag !== undefined && specialDexFlag !== SpecialDex.DEFAULT;
Expand All @@ -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
Expand Down

0 comments on commit 024ffa1

Please sign in to comment.