Skip to content

Commit

Permalink
test: new paraswap v6.2 selector offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
KanievskyiDanylo committed Oct 16, 2024
1 parent 7130dd7 commit ee4c7de
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/contract-helpers/src/commons/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ee4c7de

Please sign in to comment.