Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aerodrome protocol integration #57

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions projects/aerodrome/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions projects/aerodrome/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4,
"printWidth": 180
}
33 changes: 33 additions & 0 deletions projects/aerodrome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# aerodrome

Integration with [Aerodrome](https://aerodrome.finance/)

## Supported Networks

- BASE

## Common Tasks

- "Retrieve me pool address for wETH and USDC with lowest fee"
- "Get tick spacing for existing pool at address"
- "Compute me path for given list of tokens and fees"
- "Estimate amount of USDC I will receive for swapping in 10 AERO"
- "Swap 10 USDC into AERO using V3 version of protocol and leverage both - V2 and V3 pools"
- "Swap 5 AERO into USDC using V2 version of protocol and only V2 pools"
- "Execute chain of commands: Wrap 1 ETH to wETH (code: `0b`), Swap wETH to AERO using V3 (code: `00`), Swap AERO to USDC using V2 (code: `08`)"

## Available Functions

- `getPool`: Get address of Pool from PoolFactory for given tokens and fee associated with pool
- `getTickSpacing`: Retrieve tick spacing of existing Pool
- `getPath`: Get path encoding multiple Pools from given tokens and fees
- `quoteExactInput`: Estimate output amount of swap without actually performing swap
- `swapV3`: Perform swap using Aerodrome V3 contracts (accepts V3 and V2 pools)
- `swapV2`: Perform swap using Aerodrome V2 contracts (accepts V2 pools only)
- `execute`: Execute arbitrary complex chain of commands. See available commands in `CommandCode` constant

## Installation

```bash
yarn add @heyanon/aerodrome
```
20 changes: 20 additions & 0 deletions projects/aerodrome/__mocks__/@heyanon/sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { vi } from 'vitest';

export const toResult = vi.fn().mockImplementation((data: string, isError: boolean) => ({ data, success: !isError }));

export const getChainFromName = vi.fn().mockImplementation((chainName: string) => {
switch (chainName) {
case 'Base':
return 8453;
case 'Ethereum':
return 1;
default:
return null;
}
});

export const checkToApprove = vi.fn();

export enum ChainId {
BASE = 8453,
}
84 changes: 84 additions & 0 deletions projects/aerodrome/abis/mixedQuoter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
export default [
{
inputs: [
{ internalType: 'address', name: '_factory', type: 'address' },
{ internalType: 'address', name: '_factoryV2', type: 'address' },
{ internalType: 'address', name: '_WETH9', type: 'address' },
],
stateMutability: 'nonpayable',
type: 'constructor',
},
{ inputs: [], name: 'WETH9', outputs: [{ internalType: 'address', name: '', type: 'address' }], stateMutability: 'view', type: 'function' },
{ inputs: [], name: 'factory', outputs: [{ internalType: 'address', name: '', type: 'address' }], stateMutability: 'view', type: 'function' },
{ inputs: [], name: 'factoryV2', outputs: [{ internalType: 'address', name: '', type: 'address' }], stateMutability: 'view', type: 'function' },
{
inputs: [
{ internalType: 'bytes', name: 'path', type: 'bytes' },
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
],
name: 'quoteExactInput',
outputs: [
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
{ internalType: 'uint160[]', name: 'v3SqrtPriceX96AfterList', type: 'uint160[]' },
{ internalType: 'uint32[]', name: 'v3InitializedTicksCrossedList', type: 'uint32[]' },
{ internalType: 'uint256', name: 'v3SwapGasEstimate', type: 'uint256' },
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'tokenIn', type: 'address' },
{ internalType: 'address', name: 'tokenOut', type: 'address' },
{ internalType: 'bool', name: 'stable', type: 'bool' },
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
],
internalType: 'struct IMixedRouteQuoterV1.QuoteExactInputSingleV2Params',
name: 'params',
type: 'tuple',
},
],
name: 'quoteExactInputSingleV2',
outputs: [{ internalType: 'uint256', name: 'amountOut', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'tokenIn', type: 'address' },
{ internalType: 'address', name: 'tokenOut', type: 'address' },
{ internalType: 'uint256', name: 'amountIn', type: 'uint256' },
{ internalType: 'int24', name: 'tickSpacing', type: 'int24' },
{ internalType: 'uint160', name: 'sqrtPriceLimitX96', type: 'uint160' },
],
internalType: 'struct IMixedRouteQuoterV1.QuoteExactInputSingleV3Params',
name: 'params',
type: 'tuple',
},
],
name: 'quoteExactInputSingleV3',
outputs: [
{ internalType: 'uint256', name: 'amountOut', type: 'uint256' },
{ internalType: 'uint160', name: 'sqrtPriceX96After', type: 'uint160' },
{ internalType: 'uint32', name: 'initializedTicksCrossed', type: 'uint32' },
{ internalType: 'uint256', name: 'gasEstimate', type: 'uint256' },
],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'int256', name: 'amount0Delta', type: 'int256' },
{ internalType: 'int256', name: 'amount1Delta', type: 'int256' },
{ internalType: 'bytes', name: 'path', type: 'bytes' },
],
name: 'uniswapV3SwapCallback',
outputs: [],
stateMutability: 'view',
type: 'function',
},
] as const;
Loading