Skip to content

Commit

Permalink
Merge branch 'main' into Change_mcr_default
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymx95 authored May 10, 2024
2 parents acf49ce + 781a2ac commit 6f2c145
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 70 deletions.
18 changes: 0 additions & 18 deletions contracts/AdminContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ contract AdminContract is IAdminContract, UUPSUpgradeable, OwnableUpgradeable, A
uint256 public constant MCR_DEFAULT = 1_052_631_578_947_368_421; // (100 / 95) %
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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 0 additions & 7 deletions contracts/Interfaces/IAdminContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -62,7 +60,6 @@ interface IAdminContract {
uint256 mcr,
uint256 minNetDebt,
uint256 mintCap,
uint256 percentDivisor,
uint256 redemptionFeeFloor
) external;

Expand All @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions scripts/deployment/deploy-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -333,7 +332,6 @@ export class CoreDeployer {
coll.MCR,
coll.minNetDebt,
coll.mintCap,
defaultPercentDivisor,
defaultRedemptionFeeFloor
)
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/timelockHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
39 changes: 0 additions & 39 deletions test/trinity/AdminContractTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)

Expand All @@ -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")
Expand All @@ -90,15 +85,13 @@ contract("AdminContract", async accounts => {
await adminContract.setMCR(ZERO_ADDRESS, "1052631578947368421")
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)
assert.equal((await adminContract.getCcr(ZERO_ADDRESS)).toString(), CCR)
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)
})

Expand All @@ -111,15 +104,13 @@ contract("AdminContract", async accounts => {
MCR,
MIN_NET_DEBT,
MINT_CAP,
PERCENT_DIVISOR,
REDEMPTION_FEE_FLOOR,
{ from: user }
)
)
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 }))
})
Expand Down Expand Up @@ -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))))
})
Expand Down Expand Up @@ -207,7 +185,6 @@ contract("AdminContract", async accounts => {
MCR,
MIN_NET_DEBT,
MINT_CAP,
PERCENT_DIVISOR,
REDEMPTION_FEE_FLOOR
)
)
Expand All @@ -219,7 +196,6 @@ contract("AdminContract", async accounts => {
MCR,
MIN_NET_DEBT,
MINT_CAP,
PERCENT_DIVISOR,
REDEMPTION_FEE_FLOOR
)
)
Expand All @@ -231,7 +207,6 @@ contract("AdminContract", async accounts => {
MCR_SAFETY_MAX.add(toBN(1)),
MIN_NET_DEBT,
MINT_CAP,
PERCENT_DIVISOR,
REDEMPTION_FEE_FLOOR
)
)
Expand All @@ -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
)
)
Expand All @@ -267,7 +229,6 @@ contract("AdminContract", async accounts => {
MCR,
MIN_NET_DEBT,
MINT_CAP,
PERCENT_DIVISOR,
REDEMPTION_FEE_FLOOR_SAFETY_MAX.add(toBN(1))
)
)
Expand Down
3 changes: 0 additions & 3 deletions test/utils/deploymentHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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
)
}
Expand Down

0 comments on commit 6f2c145

Please sign in to comment.