diff --git a/packages/contract-helpers/src/commons/utils.test.ts b/packages/contract-helpers/src/commons/utils.test.ts index 2e2a0205..57cddfec 100644 --- a/packages/contract-helpers/src/commons/utils.test.ts +++ b/packages/contract-helpers/src/commons/utils.test.ts @@ -77,6 +77,32 @@ describe('Utils', () => { const offset = augustusToAmountOffsetFromCalldata('0x87a63926'); expect(offset).toEqual(68); }); + + it('Expects 132 when Augustus V6 swapExactAmountOut', () => { + const offset = augustusToAmountOffsetFromCalldata('0x7f457675'); + expect(offset).toEqual(132); + }); + + it('Expects 36 when Augustus V6 swapExactAmountOutOnBalancerV2', () => { + const offset = augustusToAmountOffsetFromCalldata('0xd6ed22e6'); + expect(offset).toEqual(36); + }); + + it('Expects 196 when Augustus V6 swapExactAmountOutOnUniswapV2', () => { + const offset = augustusToAmountOffsetFromCalldata('0xa76f4eb6'); + expect(offset).toEqual(196); + }); + + it('Expects 196 when Augustus V6 swapExactAmountOutOnUniswapV3', () => { + const offset = augustusToAmountOffsetFromCalldata('0x5e94e28d'); + expect(offset).toEqual(196); + }); + + it('Expects 100 when Augustus V6 swapExactAmountInOutOnMakerPSM', () => { + const offset = augustusToAmountOffsetFromCalldata('0x987e7d8e'); + expect(offset).toEqual(100); + }); + it('Expects Error', () => { expect(() => augustusToAmountOffsetFromCalldata('asdf')).toThrowError( `Unrecognized function selector for Augustus`, diff --git a/packages/contract-helpers/src/paraswap-liquiditySwapAdapter-contract/paraswapLiquiditySwapAdapter.test.ts b/packages/contract-helpers/src/paraswap-liquiditySwapAdapter-contract/paraswapLiquiditySwapAdapter.test.ts index 862636a2..fb61e2d3 100644 --- a/packages/contract-helpers/src/paraswap-liquiditySwapAdapter-contract/paraswapLiquiditySwapAdapter.test.ts +++ b/packages/contract-helpers/src/paraswap-liquiditySwapAdapter-contract/paraswapLiquiditySwapAdapter.test.ts @@ -136,6 +136,56 @@ describe('LiquiditySwapAdapterService', () => { expect(offset).toEqual(68); }); + + it('Expects 100 when Augustus V6 swapExactAmountIn', () => { + const callData = '0xe3ead59e0000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(100); + }); + + it('Expects 4 when Augustus V6 swapExactAmountInOnBalancerV2', () => { + const callData = '0xd85ca1730000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(4); + }); + + it('Expects 132 when Augustus V6 swapExactAmountInOnCurveV1', () => { + const callData = '0x1a01c5320000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(132); + }); + + it('Expects 196 when Augustus V6 swapExactAmountInOnCurveV2', () => { + const callData = '0xe37ed2560000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(196); + }); + + it('Expects 164 when Augustus V6 swapExactAmountInOnUniswapV2', () => { + const callData = '0xe8bb3b6c0000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(164); + }); + + it('Expects 164 when Augustus V6 swapExactAmountInOnUniswapV3', () => { + const callData = '0x876a02f60000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(164); + }); + + it('Expects 68 when Augustus V6 swapExactAmountInOutOnMakerPSM', () => { + const callData = '0x987e7d8e0000000000otherCallData000000000'; + const offset = augustusFromAmountOffsetFromCalldata(callData); + + expect(offset).toEqual(68); + }); + it('Expects to fail if non recognizable Augustus function selector', () => { const callData = 'bad calldata'; expect(() => augustusFromAmountOffsetFromCalldata(callData)).toThrowError(