Skip to content

Commit

Permalink
fix incorrect dex flag for dexes which need send eth and dex func has…
Browse files Browse the repository at this point in the history
… recipient
  • Loading branch information
aburkut committed Oct 15, 2024
1 parent a4d3b40 commit e465729
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
10 changes: 3 additions & 7 deletions src/dex/bebop/bebop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
NumberAsString,
DexExchangeParam,
} from '../../types';
import { SwapSide, Network, ETHER_ADDRESS } from '../../constants';
import { SwapSide, Network } from '../../constants';
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
import { getDexKeysWithNetwork, Utils } from '../../utils';
import { IDex } from '../../dex/idex';
Expand Down Expand Up @@ -613,7 +613,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
return {
exchangeData: tx.data,
needWrapNative: this.needWrapNative,
dexFuncHasRecipient: srcToken.toLowerCase() !== ETHER_ADDRESS,
dexFuncHasRecipient: true,
targetExchange: this.settlementAddress,
returnAmountPos: undefined,
};
Expand All @@ -635,11 +635,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
sell_amounts: isSell ? optimalSwapExchange.srcAmount : undefined,
buy_amounts: isBuy ? optimalSwapExchange.destAmount : undefined,
taker_address: utils.getAddress(options.executionContractAddress),
receiver_address: utils.getAddress(
srcToken.address.toLowerCase() === ETHER_ADDRESS
? options.executionContractAddress
: options.recipient,
),
receiver_address: utils.getAddress(options.recipient),
gasless: false,
skip_validation: true,
source: BEBOP_AUTH_NAME,
Expand Down
7 changes: 5 additions & 2 deletions src/executor/Executor01BytecodeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
Flag.DONT_INSERT_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP; // 0

if (isEthSrc && !needWrap) {
dexFlag =
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5
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
} else if (isEthDest && !needUnwrap) {
dexFlag = forcePreventInsertFromAmount
? Flag.DONT_INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP
Expand Down Expand Up @@ -417,6 +418,8 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
maybeWethCallData,
);

console.log('FLAGS: ', flags);

Check failure on line 421 in src/executor/Executor01BytecodeBuilder.ts

View workflow job for this annotation

GitHub Actions / Node 16.x sample

Unexpected console statement

let swapsCalldata = exchangeParams.reduce<string>(
(acc, ep, index) =>
hexConcat([
Expand Down
5 changes: 3 additions & 2 deletions src/executor/Executor02BytecodeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
Flag.DONT_INSERT_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP; // 0

if (isEthSrc && !needWrap) {
dexFlag =
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5
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
} else if (isEthDest && !needUnwrap) {
dexFlag = forcePreventInsertFromAmount
? Flag.DONT_INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP
Expand Down
5 changes: 3 additions & 2 deletions src/executor/Executor03BytecodeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder<
Flag.DONT_INSERT_FROM_AMOUNT_DONT_CHECK_BALANCE_AFTER_SWAP; // 0

if (isEthSrc && !needWrap) {
dexFlag =
Flag.SEND_ETH_EQUAL_TO_FROM_AMOUNT_CHECK_SRC_TOKEN_BALANCE_AFTER_SWAP; // 5
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
} else if (isEthDest && !needUnwrap) {
dexFlag = forcePreventInsertFromAmount
? Flag.DONT_INSERT_FROM_AMOUNT_CHECK_ETH_BALANCE_AFTER_SWAP // 4
Expand Down

0 comments on commit e465729

Please sign in to comment.