From da88c2ff5e33ab5b7a2ef02d3646e34e7928b126 Mon Sep 17 00:00:00 2001 From: szymx95 Date: Fri, 10 May 2024 14:30:45 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8C=20Remove=20percent=20divisor=20def?= =?UTF-8?q?ault=20from=20admin=20contract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/AdminContract.sol | 18 ------------ contracts/Interfaces/IAdminContract.sol | 7 ----- scripts/deployment/deploy-core.ts | 2 -- scripts/utils/timelockHelper.js | 2 +- test/trinity/AdminContractTest.js | 39 ------------------------- test/utils/deploymentHelpers.js | 3 -- 6 files changed, 1 insertion(+), 70 deletions(-) diff --git a/contracts/AdminContract.sol b/contracts/AdminContract.sol index a7ce2be..ee436e1 100644 --- a/contracts/AdminContract.sol +++ b/contracts/AdminContract.sol @@ -25,7 +25,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A uint256 public constant MCR_DEFAULT = 1.1 ether; // 110% uint256 public constant MIN_NET_DEBT_DEFAULT = 2_000 ether; uint256 public constant MINT_CAP_DEFAULT = 1_000_000 ether; // 1 million TRI - uint256 public constant PERCENT_DIVISOR_DEFAULT = 200; // dividing by 200 yields 0.5% uint256 public constant REDEMPTION_FEE_FLOOR_DEFAULT = 0; // 0% uint256 public constant REDEMPTION_BLOCK_TIMESTAMP_DEFAULT = type(uint256).max; // never bool public constant REDEMPTION_BASE_FEE_ENABLED_DEFAULT = false; @@ -121,7 +120,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A debtTokenGasCompensation: _debtTokenGasCompensation, minNetDebt: MIN_NET_DEBT_DEFAULT, mintCap: MINT_CAP_DEFAULT, - percentDivisor: PERCENT_DIVISOR_DEFAULT, redemptionFeeFloor: REDEMPTION_FEE_FLOOR_DEFAULT, redemptionBlockTimestamp: REDEMPTION_BLOCK_TIMESTAMP_DEFAULT, redemptionBaseFeeEnabled: REDEMPTION_BASE_FEE_ENABLED_DEFAULT @@ -140,7 +138,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A uint256 mcr, uint256 minNetDebt, uint256 mintCap, - uint256 percentDivisor, uint256 redemptionFeeFloor ) public override onlyTimelock { collateralParams[_collateral].active = true; @@ -149,7 +146,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A setMCR(_collateral, mcr); setMinNetDebt(_collateral, minNetDebt); setMintCap(_collateral, mintCap); - setPercentDivisor(_collateral, percentDivisor); setRedemptionFeeFloor(_collateral, redemptionFeeFloor); } @@ -220,16 +216,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A emit MintCapChanged(oldMintCap, mintCap); } - function setPercentDivisor( - address _collateral, - uint256 percentDivisor - ) public override onlyTimelock safeCheck("Percent Divisor", _collateral, percentDivisor, 2, 200) { - CollateralParams storage collParams = collateralParams[_collateral]; - uint256 oldPercent = collParams.percentDivisor; - collParams.percentDivisor = percentDivisor; - emit PercentDivisorChanged(oldPercent, percentDivisor); - } - function setRedemptionFeeFloor( address _collateral, uint256 redemptionFeeFloor @@ -312,10 +298,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A return collateralParams[_collateral].minNetDebt; } - function getPercentDivisor(address _collateral) external view override returns (uint256) { - return collateralParams[_collateral].percentDivisor; - } - function getBorrowingFee(address _collateral) external view override returns (uint256) { return collateralParams[_collateral].borrowingFee; } diff --git a/contracts/Interfaces/IAdminContract.sol b/contracts/Interfaces/IAdminContract.sol index b4f320e..b8c3655 100644 --- a/contracts/Interfaces/IAdminContract.sol +++ b/contracts/Interfaces/IAdminContract.sol @@ -19,7 +19,6 @@ interface IAdminContract { uint256 debtTokenGasCompensation; // Amount of debtToken to be locked in gas pool on opening vessels uint256 minNetDebt; // Minimum amount of net debtToken a vessel must have uint256 mintCap; - uint256 percentDivisor; uint256 redemptionFeeFloor; uint256 redemptionBlockTimestamp; bool redemptionBaseFeeEnabled; @@ -38,7 +37,6 @@ interface IAdminContract { event MCRChanged(uint256 oldMCR, uint256 newMCR); event CCRChanged(uint256 oldCCR, uint256 newCCR); event MinNetDebtChanged(uint256 oldMinNet, uint256 newMinNet); - event PercentDivisorChanged(uint256 oldPercentDiv, uint256 newPercentDiv); event BorrowingFeeChanged(uint256 oldBorrowingFee, uint256 newBorrowingFee); event RedemptionFeeFloorChanged(uint256 oldRedemptionFeeFloor, uint256 newRedemptionFeeFloor); event MintCapChanged(uint256 oldMintCap, uint256 newMintCap); @@ -62,7 +60,6 @@ interface IAdminContract { uint256 mcr, uint256 minNetDebt, uint256 mintCap, - uint256 percentDivisor, uint256 redemptionFeeFloor ) external; @@ -72,8 +69,6 @@ interface IAdminContract { function setMinNetDebt(address _collateral, uint256 minNetDebt) external; - function setPercentDivisor(address _collateral, uint256 precentDivisor) external; - function setBorrowingFee(address _collateral, uint256 borrowingFee) external; function setRedemptionFeeFloor(address _collateral, uint256 redemptionFeeFloor) external; @@ -100,8 +95,6 @@ interface IAdminContract { function getMinNetDebt(address _collateral) external view returns (uint256); - function getPercentDivisor(address _collateral) external view returns (uint256); - function getBorrowingFee(address _collateral) external view returns (uint256); function getRedemptionFeeFloor(address _collateral) external view returns (uint256); diff --git a/scripts/deployment/deploy-core.ts b/scripts/deployment/deploy-core.ts index 7710d95..4da7b4e 100644 --- a/scripts/deployment/deploy-core.ts +++ b/scripts/deployment/deploy-core.ts @@ -322,7 +322,6 @@ export class CoreDeployer { console.log(`[${coll.name}] NOTICE: collateral params have already been set`) } else { console.log(`[${coll.name}] Setting collateral params...`) - const defaultPercentDivisor = await this.coreContracts.adminContract.PERCENT_DIVISOR_DEFAULT() const defaultBorrowingFee = await this.coreContracts.adminContract.BORROWING_FEE_DEFAULT() const defaultRedemptionFeeFloor = await this.coreContracts.adminContract.REDEMPTION_FEE_FLOOR_DEFAULT() await this.sendAndWaitForTransaction( @@ -333,7 +332,6 @@ export class CoreDeployer { coll.MCR, coll.minNetDebt, coll.mintCap, - defaultPercentDivisor, defaultRedemptionFeeFloor ) ) diff --git a/scripts/utils/timelockHelper.js b/scripts/utils/timelockHelper.js index 174f77d..8ff417f 100644 --- a/scripts/utils/timelockHelper.js +++ b/scripts/utils/timelockHelper.js @@ -13,7 +13,7 @@ const TARGET_ADDRESS = "0xf7Cc67326F9A1D057c1e4b110eF6c680B13a1f53" // Mainnet:: // const METHOD_ARG_TYPES = ["address","uint256","uint256"] // const METHOD_ARG_VALUES = ["0xA35b1B31Ce002FBF2058D22F30f95D405200A15b","200000000000000000000",18] -const METHOD_SIGNATURE = "setCollateralParameters(address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)" +const METHOD_SIGNATURE = "setCollateralParameters(address,uint256,uint256,uint256,uint256,uint256,uint256)" const METHOD_ARG_TYPES = ["address", "uint256", "uint256", "uint256", "uint256", "uint256", "uint256", "uint256"] const METHOD_ARG_VALUES = [ "0xA35b1B31Ce002FBF2058D22F30f95D405200A15b", diff --git a/test/trinity/AdminContractTest.js b/test/trinity/AdminContractTest.js index 5654b04..0af7693 100644 --- a/test/trinity/AdminContractTest.js +++ b/test/trinity/AdminContractTest.js @@ -37,7 +37,6 @@ contract("AdminContract", async accounts => { let MCR let MIN_NET_DEBT let MINT_CAP - let PERCENT_DIVISOR let REDEMPTION_FEE_FLOOR const MCR_SAFETY_MAX = toBN(dec(10, 18)) @@ -46,9 +45,6 @@ contract("AdminContract", async accounts => { const CCR_SAFETY_MAX = toBN(dec(10, 18)) const CCR_SAFETY_MIN = toBN(dec(0, 18)) - const PERCENT_DIVISOR_SAFETY_MAX = toBN(200) - const PERCENT_DIVISOR_SAFETY_MIN = toBN(2) - const BORROWING_FEE_SAFETY_MAX = toBN((0.1e18).toString()) // 10% const BORROWING_FEE_SAFETY_MIN = toBN(0) @@ -66,7 +62,6 @@ contract("AdminContract", async accounts => { MCR = await adminContract.MCR_DEFAULT() MIN_NET_DEBT = await adminContract.MIN_NET_DEBT_DEFAULT() MINT_CAP = await adminContract.MINT_CAP_DEFAULT() - PERCENT_DIVISOR = await adminContract.PERCENT_DIVISOR_DEFAULT() REDEMPTION_FEE_FLOOR = await adminContract.REDEMPTION_FEE_FLOOR_DEFAULT() initialSnapshotId = await network.provider.send("evm_snapshot") @@ -90,7 +85,6 @@ contract("AdminContract", async accounts => { await adminContract.setMCR(ZERO_ADDRESS, "1100000000000000000") await adminContract.setMinNetDebt(ZERO_ADDRESS, dec(2_000, 18)) await adminContract.setMintCap(ZERO_ADDRESS, dec(1_000_000, 18)) - await adminContract.setPercentDivisor(ZERO_ADDRESS, 200) await adminContract.setRedemptionFeeFloor(ZERO_ADDRESS, '0') assert.equal((await adminContract.getBorrowingFee(ZERO_ADDRESS)).toString(), BORROWING_FEE) @@ -98,7 +92,6 @@ contract("AdminContract", async accounts => { assert.equal((await adminContract.getMcr(ZERO_ADDRESS)).toString(), MCR) assert.equal((await adminContract.getMinNetDebt(ZERO_ADDRESS)).toString(), MIN_NET_DEBT) assert.equal((await adminContract.getMintCap(ZERO_ADDRESS)).toString(), MINT_CAP) - assert.equal((await adminContract.getPercentDivisor(ZERO_ADDRESS)).toString(), PERCENT_DIVISOR) assert.equal((await adminContract.getRedemptionFeeFloor(ZERO_ADDRESS)).toString(), REDEMPTION_FEE_FLOOR) }) @@ -111,7 +104,6 @@ contract("AdminContract", async accounts => { MCR, MIN_NET_DEBT, MINT_CAP, - PERCENT_DIVISOR, REDEMPTION_FEE_FLOOR, { from: user } ) @@ -119,7 +111,6 @@ contract("AdminContract", async accounts => { await assertRevert(adminContract.setMCR(ZERO_ADDRESS, MCR, { from: user })) await assertRevert(adminContract.setCCR(ZERO_ADDRESS, CCR, { from: user })) await assertRevert(adminContract.setMinNetDebt(ZERO_ADDRESS, MIN_NET_DEBT, { from: user })) - await assertRevert(adminContract.setPercentDivisor(ZERO_ADDRESS, PERCENT_DIVISOR, { from: user })) await assertRevert(adminContract.setBorrowingFee(ZERO_ADDRESS, BORROWING_FEE, { from: user })) await assertRevert(adminContract.setRedemptionFeeFloor(ZERO_ADDRESS, REDEMPTION_FEE_FLOOR, { from: user })) }) @@ -161,19 +152,6 @@ contract("AdminContract", async accounts => { assert.equal(MIN_NET_DEBT_SAFETY_MAX.toString(), await adminContract.getMinNetDebt(ZERO_ADDRESS)) }) - it("setPercentDivisor: Owner change parameter - Failing SafeCheck", async () => { - await assertRevert(adminContract.setPercentDivisor(ZERO_ADDRESS, PERCENT_DIVISOR_SAFETY_MIN.sub(toBN(1)))) - await assertRevert(adminContract.setPercentDivisor(ZERO_ADDRESS, PERCENT_DIVISOR_SAFETY_MAX.add(toBN(1)))) - }) - - it("setPercentDivisor: Owner change parameter - Valid SafeCheck", async () => { - await adminContract.setPercentDivisor(ZERO_ADDRESS, PERCENT_DIVISOR_SAFETY_MIN) - assert.equal(PERCENT_DIVISOR_SAFETY_MIN.toString(), await adminContract.getPercentDivisor(ZERO_ADDRESS)) - - await adminContract.setPercentDivisor(ZERO_ADDRESS, PERCENT_DIVISOR_SAFETY_MAX) - assert.equal(PERCENT_DIVISOR_SAFETY_MAX.toString(), await adminContract.getPercentDivisor(ZERO_ADDRESS)) - }) - it("setBorrowingFee: Owner change parameter - Failing SafeCheck", async () => { await assertRevert(adminContract.setBorrowingFee(ZERO_ADDRESS, BORROWING_FEE_SAFETY_MAX.add(toBN(1)))) }) @@ -207,7 +185,6 @@ contract("AdminContract", async accounts => { MCR, MIN_NET_DEBT, MINT_CAP, - PERCENT_DIVISOR, REDEMPTION_FEE_FLOOR ) ) @@ -219,7 +196,6 @@ contract("AdminContract", async accounts => { MCR, MIN_NET_DEBT, MINT_CAP, - PERCENT_DIVISOR, REDEMPTION_FEE_FLOOR ) ) @@ -231,7 +207,6 @@ contract("AdminContract", async accounts => { MCR_SAFETY_MAX.add(toBN(1)), MIN_NET_DEBT, MINT_CAP, - PERCENT_DIVISOR, REDEMPTION_FEE_FLOOR ) ) @@ -243,19 +218,6 @@ contract("AdminContract", async accounts => { MCR, MIN_NET_DEBT_SAFETY_MAX.add(toBN(1)), MINT_CAP, - PERCENT_DIVISOR, - REDEMPTION_FEE_FLOOR - ) - ) - await assertRevert( - adminContract.setCollateralParameters( - ZERO_ADDRESS, - BORROWING_FEE, - CCR, - MCR, - MIN_NET_DEBT, - MINT_CAP, - PERCENT_DIVISOR_SAFETY_MAX.add(toBN(1)), REDEMPTION_FEE_FLOOR ) ) @@ -267,7 +229,6 @@ contract("AdminContract", async accounts => { MCR, MIN_NET_DEBT, MINT_CAP, - PERCENT_DIVISOR, REDEMPTION_FEE_FLOOR_SAFETY_MAX.add(toBN(1)) ) ) diff --git a/test/utils/deploymentHelpers.js b/test/utils/deploymentHelpers.js index f493db2..23da855 100644 --- a/test/utils/deploymentHelpers.js +++ b/test/utils/deploymentHelpers.js @@ -169,7 +169,6 @@ class DeploymentHelper { (1.1e18).toString(), // mcr dec(300, 18), // minNetDebt dec(1_000_000, 18), // mintCap - 100, // percentDivisor defaultFee // redemptionFeeFloor ) await core.adminContract.setCollateralParameters( @@ -179,7 +178,6 @@ class DeploymentHelper { (1.1e18).toString(), // mcr dec(1_800, 18), // minNetDebt dec(10_000_000_000, 18), // mintCap - 200, // percentDivisor defaultFee // redemptionFeeFloor ) await core.adminContract.setCollateralParameters( @@ -189,7 +187,6 @@ class DeploymentHelper { (1.1e18).toString(), // mcr dec(1_800, 18), // minNetDebt dec(10_000_000_000, 18), // mintCap - 200, // percentDivisor defaultFee // redemptionFeeFloor ) }