Skip to content

Update configuration of loan and system settings #1637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 13, 2022
38 changes: 22 additions & 16 deletions publish/src/commands/deploy/configure-loans.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const { gray } = require('chalk');
const { toBytes32 } = require('../../../..');
const { allowZeroOrUpdateIfNonZero } = require('../../util.js');

module.exports = async ({
addressOf,
Expand Down Expand Up @@ -80,13 +81,14 @@ module.exports = async ({
comment: 'Ensure the CollateralEth contract has all associated synths added',
});

const issueFeeRate = (await getDeployParameter('COLLATERAL_ETH'))['ISSUE_FEE_RATE'];
await runStep({
contract: 'CollateralEth',
target: CollateralEth,
read: 'issueFeeRate',
expected: input => input !== '0', // only change if zero,
expected: allowZeroOrUpdateIfNonZero(issueFeeRate),
write: 'setIssueFeeRate',
writeArg: [(await getDeployParameter('COLLATERAL_ETH'))['ISSUE_FEE_RATE']],
writeArg: [issueFeeRate],
comment: 'Ensure the CollateralEth contract has its issue fee rate set',
});
}
Expand Down Expand Up @@ -121,13 +123,14 @@ module.exports = async ({
comment: 'Ensure the CollateralErc20 contract has all associated synths added',
});

const issueFeeRate = (await getDeployParameter('COLLATERAL_RENBTC'))['ISSUE_FEE_RATE'];
await runStep({
contract: 'CollateralErc20',
target: CollateralErc20,
read: 'issueFeeRate',
expected: input => input !== '0', // only change if zero
expected: allowZeroOrUpdateIfNonZero(issueFeeRate),
write: 'setIssueFeeRate',
writeArg: [(await getDeployParameter('COLLATERAL_RENBTC'))['ISSUE_FEE_RATE']],
writeArg: [issueFeeRate],
comment: 'Ensure the CollateralErc20 contract has its issue fee rate set',
});
}
Expand Down Expand Up @@ -167,67 +170,70 @@ module.exports = async ({
contract: 'CollateralShort',
target: CollateralShort,
read: 'issueFeeRate',
expected: input => (issueFeeRate === '0' ? true : input !== '0'),
expected: allowZeroOrUpdateIfNonZero(issueFeeRate),
write: 'setIssueFeeRate',
writeArg: [issueFeeRate],
comment: 'Ensure the CollateralShort contract has its issue fee rate set',
});

if (CollateralShort.interactionDelay) {
const interactionDelay = (await getDeployParameter('COLLATERAL_SHORT'))['INTERACTION_DELAY'];

await runStep({
contract: 'CollateralShort',
target: CollateralShort,
read: 'interactionDelay',
expected: input => input !== '0', // only change if zero
expected: allowZeroOrUpdateIfNonZero(interactionDelay),
write: 'setInteractionDelay',
writeArg: interactionDelay,
writeArg: [interactionDelay],
comment:
'Ensure the CollateralShort contract has an interaction delay to prevent frontrunning',
});
}
}

const maxDebt = collateralManagerDefaults['MAX_DEBT'];
await runStep({
contract: 'CollateralManager',
target: CollateralManager,
read: 'maxDebt',
expected: input => input !== '0', // only change if zero
expected: allowZeroOrUpdateIfNonZero(maxDebt),
write: 'setMaxDebt',
writeArg: [collateralManagerDefaults['MAX_DEBT']],
writeArg: [maxDebt],
comment: 'Set the max amount of debt in the CollateralManager',
});

if (CollateralManager.maxSkewRate) {
const maxSkewRate = collateralManagerDefaults['MAX_SKEW_RATE'];
await runStep({
contract: 'CollateralManager',
target: CollateralManager,
read: 'maxSkewRate',
expected: input => input !== '0', // only change if zero
expected: allowZeroOrUpdateIfNonZero(maxSkewRate),
write: 'setMaxSkewRate',
writeArg: [collateralManagerDefaults['MAX_SKEW_RATE']],
writeArg: [maxSkewRate],
comment: 'Set the max skew rate in the CollateralManager',
});
}

const baseBorrowRate = collateralManagerDefaults['BASE_BORROW_RATE'];
await runStep({
contract: 'CollateralManager',
target: CollateralManager,
read: 'baseBorrowRate',
expected: input => input !== '0', // only change if zero
expected: allowZeroOrUpdateIfNonZero(baseBorrowRate),
write: 'setBaseBorrowRate',
writeArg: [collateralManagerDefaults['BASE_BORROW_RATE']],
writeArg: [baseBorrowRate],
comment: 'Set the base borrow rate in the CollateralManager',
});

const baseShortRate = collateralManagerDefaults['BASE_SHORT_RATE'];
await runStep({
contract: 'CollateralManager',
target: CollateralManager,
read: 'baseShortRate',
expected: input => input !== '0', // only change if zero
expected: allowZeroOrUpdateIfNonZero(baseShortRate),
write: 'setBaseShortRate',
writeArg: [collateralManagerDefaults['BASE_SHORT_RATE']],
writeArg: [baseShortRate],
comment: 'Set the base short rate in the CollateralManager',
});

Expand Down
Loading