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

Deployment preparation: V3 Routers #127

Merged
merged 24 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const MAX_UINT96: BigNumber = maxUint(96);
export const MAX_UINT10: BigNumber = maxUint(10);
export const MAX_UINT31: BigNumber = maxUint(31);
export const MAX_UINT32: BigNumber = maxUint(32);
export const MAX_UINT48: BigNumber = maxUint(48);
export const MAX_UINT64: BigNumber = maxUint(64);

export const MIN_INT22: BigNumber = minInt(22);
Expand Down
2 changes: 1 addition & 1 deletion v3/tasks/20241205-v3-batch-router/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# V3 Batch Router
# 2024-12-05 - V3 Batch Router

Batch Router deployment for V3.
Contains `BatchRouter` for complex multi-hop swaps (supports single token add / remove types and buffer wrap / unwrap).
Expand Down
2 changes: 1 addition & 1 deletion v3/tasks/20241205-v3-buffer-router/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# V3 Buffer Router
# 2024-12-05 - V3 Buffer Router

Buffer Router deployment for V3.
Contains `BufferRouter` to initialize and manage liquidity positions for buffers.
Expand Down
35 changes: 33 additions & 2 deletions v3/tasks/20241205-v3-buffer-router/test/task.fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import { describeForkTest, getForkedNetwork, getSigner, impersonate, Task, TaskMode } from '@src';
import { Contract } from 'ethers';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { MAX_UINT48 } from '@helpers/constants';
import { fp } from '@helpers/numbers';
import input, { BufferRouterDeployment } from '../input';

Check warning on line 8 in v3/tasks/20241205-v3-buffer-router/test/task.fork.ts

View workflow job for this annotation

GitHub Actions / lint

'input' is defined but never used

describeForkTest('BufferRouter-V3', 'mainnet', 21336200, function () {
let task: Task;
let bufferRouter: Contract;
let wethSigner: SignerWithAddress, alice: SignerWithAddress;
let bufferRouter: Contract, vault: Contract, permit2: Contract, usdc: Contract;
let wethSigner: SignerWithAddress, alice: SignerWithAddress, usdcWhale: SignerWithAddress;

const WETH_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
const waUSDC_ADDRESS = '0x73edDFa87C71ADdC275c2b9890f5c3a8480bC9E6';
const USDC_ADDRESS = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';

const USDC_WHALE = '0x4B16c5dE96EB2117bBE5fd171E4d203624B014aa';

const versionNumber = 1;
const deploymentId = '20241205-v3-buffer-router';
Expand All @@ -19,12 +25,20 @@
task = new Task(deploymentId, TaskMode.TEST, getForkedNetwork(hre));
await task.run({ force: true });

const input = task.input() as BufferRouterDeployment;

bufferRouter = await task.deployedInstance('BufferRouter');
permit2 = await task.instanceAt('IPermit2', input.Permit2);

const testBALTokenTask = new Task('20220325-test-balancer-token', TaskMode.READ_ONLY, getForkedNetwork(hre));
const WETH = await testBALTokenTask.instanceAt('TestBalancerToken', WETH_ADDRESS);
wethSigner = await impersonate(WETH.address, fp(10e8));
alice = await getSigner();
usdcWhale = await impersonate(USDC_WHALE, fp(10));

const vaultTask = new Task('20241204-v3-vault', TaskMode.READ_ONLY, getForkedNetwork(hre));
vault = await vaultTask.deployedInstance('Vault');
usdc = await testBALTokenTask.instanceAt('TestBalancerToken', USDC_ADDRESS);
});

it('checks buffer router version', async () => {
Expand All @@ -47,4 +61,21 @@
});
await expect(aliceTx).to.be.reverted;
});

it('tests buffer initialization', async () => {
const initBalance = 1000000e6;
await usdc.connect(usdcWhale).approve(permit2.address, initBalance);
await permit2.connect(usdcWhale).approve(USDC_ADDRESS, bufferRouter.address, initBalance, MAX_UINT48);

// We need to call methods that don't exist in the vault.
const abi = [
'function isERC4626BufferInitialized(address) external view returns (bool)',
'function getERC4626BufferAsset(address) external view returns (address)',
];
jubeira marked this conversation as resolved.
Show resolved Hide resolved
const vaultAsExtension = new ethers.Contract(vault.address, abi, usdcWhale);

await bufferRouter.connect(usdcWhale).initializeBuffer(waUSDC_ADDRESS, 1000000e6, 0, 0);
expect(await vaultAsExtension.isERC4626BufferInitialized(waUSDC_ADDRESS)).to.be.true;
expect(await vaultAsExtension.getERC4626BufferAsset(waUSDC_ADDRESS)).to.be.eq(USDC_ADDRESS);
});
});
2 changes: 1 addition & 1 deletion v3/tasks/20241205-v3-composite-liquidity-router/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# V3 Composite Liquidity Router
# 2024-12-05 - V3 Composite Liquidity Router

Composite Liquidity Router deployment for V3.
Contains `CompositeLiquidityRouter` for complex liquidity operations involving pools with ERC4626 wrappers and nested pools.
Expand Down
2 changes: 1 addition & 1 deletion v3/tasks/20241205-v3-router/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# V3 Router
# 2024-12-05 - V3 Router

Base Router deployment for V3.
Contains `Router` for basic, single step operations (e.g., pool initialization, add, remove, swap).
Expand Down
Loading