diff --git a/scripts/bootstrap/.env.example b/scripts/bootstrap/.env.example index 759f6e28..df952468 100644 --- a/scripts/bootstrap/.env.example +++ b/scripts/bootstrap/.env.example @@ -77,6 +77,12 @@ RATE_LIMIT_IMX_CAPACITY= RATE_LIMIT_IMX_REFILL_RATE= ## The large threshold of the rate limit policy of IMX token, unit is in 10^18. RATE_LIMIT_IMX_LARGE_THRESHOLD= +## The capacity of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_CAPACITY= +## The refill rate of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_REFILL_RATE= +## The large threshold of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_LARGE_THRESHOLD= # Set prior to 2_deployment_validation.js CHILD_GATEWAY_ADDRESS= diff --git a/scripts/bootstrap/8_root_initialisation.js b/scripts/bootstrap/8_root_initialisation.js index 50edd81c..66149064 100644 --- a/scripts/bootstrap/8_root_initialisation.js +++ b/scripts/bootstrap/8_root_initialisation.js @@ -29,6 +29,9 @@ async function run() { let rateLimitIMXCap = helper.requireEnv("RATE_LIMIT_IMX_CAPACITY"); let rateLimitIMXRefill = helper.requireEnv("RATE_LIMIT_IMX_REFILL_RATE"); let rateLimitIMXLargeThreshold = helper.requireEnv("RATE_LIMIT_IMX_LARGE_THRESHOLD"); + let rateLimitETHCap = helper.requireEnv("RATE_LIMIT_ETH_CAPACITY"); + let rateLimitETHRefill = helper.requireEnv("RATE_LIMIT_ETH_REFILL_RATE"); + let rateLimitETHLargeThreshold = helper.requireEnv("RATE_LIMIT_ETH_LARGE_THRESHOLD"); // Read from contract file. let data = fs.readFileSync(".child.bridge.contracts.json", 'utf-8'); @@ -100,6 +103,15 @@ async function run() { ); await helper.waitForReceipt(resp.hash, rootProvider); + // ETH + resp = await rootBridge.connect(rateAdminWallet).setRateControlThreshold( + await rootBridge.NATIVE_ETH(), + ethers.utils.parseEther(rateLimitETHCap), + ethers.utils.parseEther(rateLimitETHRefill), + ethers.utils.parseEther(rateLimitETHLargeThreshold) + ); + await helper.waitForReceipt(resp.hash, rootProvider); + // Initialise root adaptor let rootAdaptorObj = JSON.parse(fs.readFileSync('../../out/RootAxelarBridgeAdaptor.sol/RootAxelarBridgeAdaptor.json', 'utf8')); console.log("Initialise root adaptor..."); diff --git a/scripts/bootstrap/README.md b/scripts/bootstrap/README.md index 125d5e7d..bb430f05 100644 --- a/scripts/bootstrap/README.md +++ b/scripts/bootstrap/README.md @@ -102,6 +102,12 @@ RATE_LIMIT_IMX_CAPACITY= RATE_LIMIT_IMX_REFILL_RATE= ## The large threshold of the rate limit policy of IMX token, unit is in 10^18. RATE_LIMIT_IMX_LARGE_THRESHOLD= +## The capacity of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_CAPACITY= +## The refill rate of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_REFILL_RATE= +## The large threshold of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_LARGE_THRESHOLD= ``` 3. Fund deployer ``` diff --git a/scripts/e2e/e2e.js b/scripts/e2e/e2e.js index c17a33fa..964432e2 100644 --- a/scripts/e2e/e2e.js +++ b/scripts/e2e/e2e.js @@ -29,6 +29,7 @@ describe("Bridge e2e test", () => { let rootChainID = helper.requireEnv("ROOT_CHAIN_ID"); let childRPCURL = helper.requireEnv("CHILD_RPC_URL"); let childChainID = helper.requireEnv("CHILD_CHAIN_ID"); + let rootRateAdminSecret = helper.requireEnv("ROOT_BRIDGE_RATE_ADMIN_SECRET"); let testAccountKey = helper.requireEnv("TEST_ACCOUNT_SECRET"); let rootIMXAddr = helper.requireEnv("ROOT_IMX_ADDR"); let rootWETHAddr = helper.requireEnv("ROOT_WETH_ADDR"); @@ -46,6 +47,7 @@ describe("Bridge e2e test", () => { childProvider = new ethers.providers.JsonRpcProvider(childRPCURL, Number(childChainID)); rootTestWallet = new ethers.Wallet(testAccountKey, rootProvider); childTestWallet = new ethers.Wallet(testAccountKey, childProvider); + let rootRateAdminWallet = new ethers.Wallet(rootRateAdminSecret, rootProvider); let rootBridgeObj = JSON.parse(fs.readFileSync('../../out/RootERC20BridgeFlowRate.sol/RootERC20BridgeFlowRate.json', 'utf8')); rootBridge = new ethers.Contract(rootBridgeAddr, rootBridgeObj.abi, rootProvider); @@ -73,6 +75,14 @@ describe("Bridge e2e test", () => { // Mint tokens let resp = await rootCustomToken.connect(rootTestWallet).mint(rootTestWallet.address, ethers.utils.parseEther("1000.0").toBigInt()); await helper.waitForReceipt(resp.hash, rootProvider); + // Set rate control + resp = await rootBridge.connect(rootRateAdminWallet).setRateControlThreshold( + rootCustomToken.address, + ethers.utils.parseEther("20016.0"), + ethers.utils.parseEther("5.56"), + ethers.utils.parseEther("10008.0") + ); + await helper.waitForReceipt(resp.hash, rootProvider); }) it("should successfully deposit IMX to self from L1 to L2", async() => { diff --git a/scripts/localdev/.env.local b/scripts/localdev/.env.local index 87c203a9..5445df5d 100644 --- a/scripts/localdev/.env.local +++ b/scripts/localdev/.env.local @@ -77,6 +77,12 @@ RATE_LIMIT_IMX_CAPACITY=15516 RATE_LIMIT_IMX_REFILL_RATE=4.31 ## The large threshold of the rate limit policy of IMX token, unit is in 10^18. RATE_LIMIT_IMX_LARGE_THRESHOLD=7758 +## The capacity of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_CAPACITY=10.08 +## The refill rate of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_REFILL_RATE=0.0028 +## The large threshold of the rate limit policy of ETH token, unit is in 10^18. +RATE_LIMIT_ETH_LARGE_THRESHOLD=5.04 # Set prior to 2_deployment_validation.js CHILD_GATEWAY_ADDRESS=0xcf27F781841484d5CF7e155b44954D7224caF1dD