diff --git a/package.json b/package.json index 2df83f3ba..ff7af5518 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "4.0.11", + "version": "4.0.12", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", diff --git a/src/dex/bebop/bebop-e2e.test.ts b/src/dex/bebop/bebop-e2e.test.ts index e56cf7648..3035e13fe 100644 --- a/src/dex/bebop/bebop-e2e.test.ts +++ b/src/dex/bebop/bebop-e2e.test.ts @@ -30,7 +30,7 @@ function testForNetwork( const nativeTokenSymbol = NativeTokenSymbols[network]; const sideToContractMethods = new Map([ - [SwapSide.SELL, [ContractMethod.swapExactAmountIn]], + // [SwapSide.SELL, [ContractMethod.swapExactAmountIn]], [SwapSide.BUY, [ContractMethod.swapExactAmountOut]], ]); @@ -50,34 +50,46 @@ function testForNetwork( contractMethod, network, provider, + undefined, + undefined, + undefined, + 100, ); }); - it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => { - await testE2E( - tokens[tokenASymbol], - tokens[nativeTokenSymbol], - holders[tokenASymbol], - side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount, - side, - dexKey, - contractMethod, - network, - provider, - ); - }); - it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => { - await testE2E( - tokens[tokenASymbol], - tokens[tokenBSymbol], - holders[tokenASymbol], - side === SwapSide.SELL ? tokenAAmount : tokenBAmount, - side, - dexKey, - contractMethod, - network, - provider, - ); - }); + // it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => { + // await testE2E( + // tokens[tokenASymbol], + // tokens[nativeTokenSymbol], + // holders[tokenASymbol], + // side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount, + // side, + // dexKey, + // contractMethod, + // network, + // provider, + // undefined, + // undefined, + // undefined, + // 100, + // ); + // }); + // it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => { + // await testE2E( + // tokens[tokenASymbol], + // tokens[tokenBSymbol], + // holders[tokenASymbol], + // side === SwapSide.SELL ? tokenAAmount : tokenBAmount, + // side, + // dexKey, + // contractMethod, + // network, + // provider, + // undefined, + // undefined, + // undefined, + // 100, + // ); + // }); }); }); }), diff --git a/src/dex/bebop/bebop.ts b/src/dex/bebop/bebop.ts index fe69a4f19..c17f2e737 100644 --- a/src/dex/bebop/bebop.ts +++ b/src/dex/bebop/bebop.ts @@ -55,7 +55,7 @@ import { } from './constants'; import BigNumber from 'bignumber.js'; import { getBigNumberPow } from '../../bignumber-constants'; -import { utils } from 'ethers'; +import { ethers, utils } from 'ethers'; import qs from 'qs'; import { isEqual } from 'lodash'; @@ -656,12 +656,28 @@ export class Bebop extends SimpleExchange implements IDex { srcAmount, // modify filledTakerAmount to make insertFromAmount work ]); + const fromAmount = ethers.utils.defaultAbiCoder.encode( + ['uint256'], + [srcAmount], + ); + + const filledTakerAmountIndex = exchangeData + .replace('0x', '') + .lastIndexOf(fromAmount.replace('0x', '')); + + const filledTakerAmountPos = + (filledTakerAmountIndex !== -1 + ? filledTakerAmountIndex + : exchangeData.length) / 2; + return { exchangeData: exchangeData, needWrapNative: this.needWrapNative, dexFuncHasRecipient: true, targetExchange: this.settlementAddress, returnAmountPos: undefined, + sendEthButSupportsInsertFromAmount: true, + insertFromAmountPos: filledTakerAmountPos, }; } else { throw new Error('Not supported method'); diff --git a/src/dex/cables/cables.ts b/src/dex/cables/cables.ts index eb14b3f8e..acfd89dc9 100644 --- a/src/dex/cables/cables.ts +++ b/src/dex/cables/cables.ts @@ -323,6 +323,7 @@ export class Cables extends SimpleExchange implements IDex { targetExchange: this.mainnetRFQAddress, returnAmountPos: undefined, insertFromAmountPos: filledAmountPos, + sendEthButSupportsInsertFromAmount: true, }; } diff --git a/src/executor/Executor03BytecodeBuilder.ts b/src/executor/Executor03BytecodeBuilder.ts index c9331b80c..f15b63c03 100644 --- a/src/executor/Executor03BytecodeBuilder.ts +++ b/src/executor/Executor03BytecodeBuilder.ts @@ -15,7 +15,6 @@ import { ExecutorBytecodeBuilder, SingleSwapCallDataParams, } from './ExecutorBytecodeBuilder'; -import { assert } from 'ts-essentials'; const { utils: { hexlify, hexDataLength, hexConcat, hexZeroPad, solidityPack }, @@ -330,6 +329,7 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder< let fromAmountPos = 0; let toAmountPos = 0; + if (insertAmount) { if (exchangeParam.insertFromAmountPos) { fromAmountPos = exchangeParam.insertFromAmountPos;