-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from MattPereira/register-a-pool
Sketch out hh script for registering a pool
- Loading branch information
Showing
3 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
interface NetworkConfigEntryTypes { | ||
name: string; | ||
balancer: { | ||
vaultAddr: string; | ||
vaultExtensionAddr: string; | ||
routerAddr: string; | ||
batchRouterAddr: string; | ||
}; | ||
} | ||
|
||
// Contracts have constructors that require contract address args that are network specific | ||
const networkConfig: { [key: number]: NetworkConfigEntryTypes } = { | ||
11155111: { | ||
name: "sepolia", | ||
balancer: { | ||
vaultAddr: "0x1FC7F1F84CFE61a04224AC8D3F87f56214FeC08c", | ||
vaultExtensionAddr: "0x718e1176f01dDBb2409A77B2847B749c8dF4457f", | ||
routerAddr: "0xA0De078cd5cFa7088821B83e0bD7545ccfb7c883", | ||
batchRouterAddr: "0x8A8B9f35765899B3a0291700141470D79EA2eA88", | ||
}, | ||
}, | ||
}; | ||
|
||
const developmentChains: string[] = ["hardhat", "foundry", "localhost"]; | ||
|
||
export { networkConfig, developmentChains }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import hre from "hardhat"; | ||
import { networkConfig } from "../helper.config"; | ||
import { Contract } from "ethers"; | ||
|
||
/** | ||
* registerPool function | ||
* https://github.com/balancer/balancer-v3-monorepo/blob/2ad8501c85e8afb2f25d970344af700a571b1d0b/pkg/vault/contracts/VaultExtension.sol#L130-L149 | ||
* | ||
* VaultTypes (TokenType, TokenConfig, IRateProvider) | ||
* https://github.com/balancer/balancer-v3-monorepo/blob/main/pkg/interfaces/contracts/vault/VaultTypes.sol | ||
* | ||
*/ | ||
async function main() { | ||
const privateKey = process.env.DEPLOYER_PRIVATE_KEY; | ||
if (!privateKey) { | ||
console.log("🚫️ Please set a PRIVATE_KEY var at packages/hardhat/.env"); | ||
return; | ||
} | ||
if (hre.network.name !== "sepolia") { | ||
throw new Error("This script is only configured for sepolia network"); | ||
} | ||
const chainId = Number(await hre.ethers.provider.getNetwork().then(network => network.chainId)); | ||
|
||
// grab the VaultExtension contract | ||
const { vaultExtensionAddr } = networkConfig[chainId].balancer; | ||
const { abi: vaultExtensionAbi } = await hre.artifacts.readArtifact("IVaultExtension"); | ||
const [signer] = await hre.ethers.getSigners(); | ||
const vaultExtension = await hre.ethers.getContractAt(vaultExtensionAbi, vaultExtensionAddr, signer); | ||
|
||
// args for registerPool | ||
const { target: poolAddress } = await hre.ethers.getContract<Contract>("ConstantPricePool", signer); | ||
const tokenConfig = [ | ||
{ | ||
token: "0xB77EB1A70A96fDAAeB31DB1b42F2b8b5846b2613", // sepoliaDAI | ||
tokenType: 0, // STANDARD | ||
rateProvider: "???", // contract address that satisfies IRateProvider? | ||
yieldFeeExempt: false, | ||
}, | ||
{ | ||
token: "0x80D6d3946ed8A1Da4E226aa21CCdDc32bd127d1A", // sepoliaUSDC | ||
tokenType: 0, // STANDARD | ||
rateProvider: "???", // contract address that satisfies IRateProvider? | ||
yieldFeeExempt: false, | ||
}, | ||
]; | ||
const pauseWindowEndTime = 0; // The timestamp after which it is no longer possible to pause the pool | ||
const pauseManager = hre.ethers.ZeroAddress; // Optional contract the Vault will allow to pause the pool | ||
const hookConfig = [ | ||
// Flags indicating which hooks the pool supports | ||
{ | ||
shouldCallBeforeInitialize: false, | ||
shouldCallAfterInitialize: false, | ||
shouldCallBeforeSwap: false, | ||
shouldCallAfterSwap: false, | ||
shouldCallBeforeAddLiquidity: false, | ||
shouldCallAfterAddLiquidity: false, | ||
shouldCallBeforeRemoveLiquidity: false, | ||
shouldCallAfterRemoveLiquidity: false, | ||
}, | ||
]; | ||
const liquidityManagement = { | ||
supportsAddLiquidityCustom: false, | ||
supportsRemoveLiquidityCustom: false, | ||
}; | ||
|
||
console.log("Sending tx to register pool..."); | ||
const txResponse = await vaultExtension.registerPool( | ||
poolAddress, | ||
tokenConfig, | ||
pauseWindowEndTime, | ||
pauseManager, | ||
hookConfig, | ||
liquidityManagement, | ||
); | ||
console.log(txResponse); | ||
console.log("Waiting for tx to be mined..."); | ||
const txReceipt = await txResponse.wait(); | ||
console.log("Pool registered!!!"); | ||
console.log(txReceipt); | ||
} | ||
|
||
main().catch(error => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |