From f7c83b33707890f503af523a52e0480ea17404a8 Mon Sep 17 00:00:00 2001 From: Razorback Date: Fri, 20 Sep 2024 11:07:05 +0800 Subject: [PATCH 1/2] feat: add script to update mcr --- scripts/dev/update_bnb_mcr.ts | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/dev/update_bnb_mcr.ts diff --git a/scripts/dev/update_bnb_mcr.ts b/scripts/dev/update_bnb_mcr.ts new file mode 100644 index 00000000..282923f5 --- /dev/null +++ b/scripts/dev/update_bnb_mcr.ts @@ -0,0 +1,58 @@ +import { ethers, upgrades } from "hardhat"; + +const SPOTTER = "0xa2882B6AC7cBA1b8784BF5D72F38CF0E6416263e"; + +const BNB_CLIPPER = "0x14DD6c86d24A72b42648D9a642318375A26ed108"; +const BNB_MAT = "1200000000000000000000000000"; // 120% mcr +const BNB_ILK = + "0x636541424e426300000000000000000000000000000000000000000000000000"; + +//////////// Adjust BNB MCR //////////// +/// 1. deploy LinearDecrease contract +/// 2. set tau to 5 hours +/// 3. set Clipper calc to new LinearDecrease +/// 4. set Clipper mat to new MCR +/// 5. verify LinearDecrease contract +async function main() { + const Abaci = await ethers.getContractFactory("LinearDecrease"); + const abaci = await upgrades.deployProxy(Abaci, []); + await abaci.waitForDeployment(); + + console.log("LinearDecrease deployed to:", abaci.target); + + const tau = "18000"; // 5 hours + await abaci.file(ethers.encodeBytes32String("tau"), tau); + + const Clipper = await ethers.getContractFactory("Clipper"); + const clipper = Clipper.attach(BNB_CLIPPER); + await clipper["file(bytes32,address)"]( + ethers.encodeBytes32String("calc"), + abaci.target + ); + + const Spotter = await ethers.getContractFactory("Spotter"); + const spotter = Spotter.attach(SPOTTER); + await spotter["file(bytes32,bytes32,uint256)"]( + BNB_ILK, + ethers.encodeBytes32String("mat"), + BNB_MAT + ); + + const { mat: newMat } = await spotter.ilks(BNB_ILK); + + console.log("tau set to: ", (await abaci.tau()).toString()); + console.log("Clipper calc set to: ", (await clipper.calc()).toString()); + console.log("Clipper mat set to: ", newMat.toString()); + + await run("verify:verify", { + address: abaci.target, + constructorArguments: [], + }); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); From 4692fe42ff200a28f7a97e49b5a3f056d388cffa Mon Sep 17 00:00:00 2001 From: Razorback Date: Fri, 20 Sep 2024 14:59:49 +0800 Subject: [PATCH 2/2] feat: adjust time for auction reset --- scripts/dev/update_bnb_mcr.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/dev/update_bnb_mcr.ts b/scripts/dev/update_bnb_mcr.ts index 282923f5..a3eb91de 100644 --- a/scripts/dev/update_bnb_mcr.ts +++ b/scripts/dev/update_bnb_mcr.ts @@ -6,10 +6,12 @@ const BNB_CLIPPER = "0x14DD6c86d24A72b42648D9a642318375A26ed108"; const BNB_MAT = "1200000000000000000000000000"; // 120% mcr const BNB_ILK = "0x636541424e426300000000000000000000000000000000000000000000000000"; +const TAU = "3600"; // 1 hour +const BNB_TAIL = "1200"; // 20 minutes elapsed before reset //////////// Adjust BNB MCR //////////// /// 1. deploy LinearDecrease contract -/// 2. set tau to 5 hours +/// 2. set tau to 1 hours /// 3. set Clipper calc to new LinearDecrease /// 4. set Clipper mat to new MCR /// 5. verify LinearDecrease contract @@ -20,8 +22,7 @@ async function main() { console.log("LinearDecrease deployed to:", abaci.target); - const tau = "18000"; // 5 hours - await abaci.file(ethers.encodeBytes32String("tau"), tau); + await abaci.file(ethers.encodeBytes32String("tau"), TAU); const Clipper = await ethers.getContractFactory("Clipper"); const clipper = Clipper.attach(BNB_CLIPPER); @@ -29,6 +30,10 @@ async function main() { ethers.encodeBytes32String("calc"), abaci.target ); + await clipper["file(bytes32,uint256)"]( + ethers.encodeBytes32String("tail"), + BNB_TAIL + ); const Spotter = await ethers.getContractFactory("Spotter"); const spotter = Spotter.attach(SPOTTER); @@ -42,7 +47,8 @@ async function main() { console.log("tau set to: ", (await abaci.tau()).toString()); console.log("Clipper calc set to: ", (await clipper.calc()).toString()); - console.log("Clipper mat set to: ", newMat.toString()); + console.log("Clipper tail set to: ", (await clipper.tail()).toString()); + console.log("Spotter mat set to: ", newMat.toString()); await run("verify:verify", { address: abaci.target,