diff --git a/contracts/Constants.sol b/contracts/Constants.sol index b0dd4fa9..0a524352 100644 --- a/contracts/Constants.sol +++ b/contracts/Constants.sol @@ -25,6 +25,7 @@ abstract contract Constants { uint16 internal constant MIN_UNISWAP3_OBSERVATION_CARDINALITY = 144; uint24 internal constant DEFAULT_TWAP_WINDOW_SECONDS = 30 * 60; uint32 internal constant DEFAULT_BORROW_FACTOR = uint32(0.28 * 4_000_000_000); + uint32 internal constant SELF_COLLATERAL_FACTOR = uint32(0.95 * 4_000_000_000); // Implementation internals diff --git a/contracts/IRiskManager.sol b/contracts/IRiskManager.sol index ba71ee4b..b5c9cc17 100644 --- a/contracts/IRiskManager.sol +++ b/contracts/IRiskManager.sol @@ -35,6 +35,4 @@ interface IRiskManager { function getPrice(address underlying) external view returns (uint twap, uint twapPeriod); function getPriceFull(address underlying) external view returns (uint twap, uint twapPeriod, uint currPrice); - - function selfCollateralFactor() external view returns (uint32); } diff --git a/contracts/modules/Liquidation.sol b/contracts/modules/Liquidation.sol index d927fd86..f1478e65 100644 --- a/contracts/modules/Liquidation.sol +++ b/contracts/modules/Liquidation.sol @@ -7,7 +7,7 @@ import "../BaseLogic.sol"; /// @notice Liquidate users who are in collateral violation to protect lenders contract Liquidation is BaseLogic { - constructor(bytes32 moduleGitCommit_, uint32 selfCollateralFactor_) BaseLogic(MODULEID__LIQUIDATION, moduleGitCommit_) {} + constructor(bytes32 moduleGitCommit_) BaseLogic(MODULEID__LIQUIDATION, moduleGitCommit_) {} // How much of a liquidation is credited to the underlying's reserves. uint public constant UNDERLYING_RESERVES_FEE = 0.02 * 1e18; @@ -145,7 +145,7 @@ contract Liquidation is BaseLogic { // self-collateralization is an implicit override if (!overrideConfig.enabled && liqLocs.underlying == liqLocs.collateral) { overrideConfig.enabled = true; - overrideConfig.collateralFactor = getSelfCollateralFactor(); + overrideConfig.collateralFactor = SELF_COLLATERAL_FACTOR; } // the liquidated collateral has active override with liability if (overrideConfig.enabled) { @@ -395,9 +395,4 @@ contract Liquidation is BaseLogic { function emitLiquidationLog(LiquidationLocals memory liqLocs, uint repay, uint yield) private { emit Liquidation(liqLocs.liquidator, liqLocs.violator, liqLocs.underlying, liqLocs.collateral, repay, yield, liqLocs.liqOpp.healthScore, liqLocs.liqOpp.baseDiscount, liqLocs.liqOpp.discount); } - - function getSelfCollateralFactor() private returns (uint32) { - bytes memory result = callInternalModule(MODULEID__RISK_MANAGER, abi.encodeWithSelector(IRiskManager.selfCollateralFactor.selector)); - return abi.decode(result, (uint32)); - } } diff --git a/contracts/modules/RiskManager.sol b/contracts/modules/RiskManager.sol index 8380446f..5ecdacd3 100644 --- a/contracts/modules/RiskManager.sol +++ b/contracts/modules/RiskManager.sol @@ -25,8 +25,6 @@ interface IChainlinkAggregatorV2V3 { contract RiskManager is IRiskManager, BaseLogic { // Construction - uint32 immutable public selfCollateralFactor; - address immutable referenceAsset; // Token must have 18 decimals address immutable uniswapFactory; bytes32 immutable uniswapPoolInitCodeHash; @@ -37,12 +35,10 @@ contract RiskManager is IRiskManager, BaseLogic { bytes32 uniswapPoolInitCodeHash; } - constructor(bytes32 moduleGitCommit_, RiskManagerSettings memory settings, uint32 selfCollateralFactor_) BaseLogic(MODULEID__RISK_MANAGER, moduleGitCommit_) { + constructor(bytes32 moduleGitCommit_, RiskManagerSettings memory settings) BaseLogic(MODULEID__RISK_MANAGER, moduleGitCommit_) { referenceAsset = settings.referenceAsset; uniswapFactory = settings.uniswapFactory; uniswapPoolInitCodeHash = settings.uniswapPoolInitCodeHash; - - selfCollateralFactor = selfCollateralFactor_; } @@ -349,7 +345,7 @@ contract RiskManager is IRiskManager, BaseLogic { // self-collateralization is an implicit override if (!overrideConfig.enabled && singleLiability == underlying) { overrideConfig.enabled = true; - overrideConfig.collateralFactor = selfCollateralFactor; + overrideConfig.collateralFactor = SELF_COLLATERAL_FACTOR; } } diff --git a/test/lib/eTestLib.js b/test/lib/eTestLib.js index 4c802e08..d21b2167 100644 --- a/test/lib/eTestLib.js +++ b/test/lib/eTestLib.js @@ -17,8 +17,6 @@ const { verifyBatch } = require("./deployLib"); Error.stackTraceLimit = 10000; let conf; -const SELF_COLLATERAL_FACTOR = 0.95 * 4e9 - const moduleIds = { // Public single-proxy modules INSTALLER: 1, @@ -895,9 +893,9 @@ async function deployContracts(provider, wallets, tokenSetupName, verify = null) address: ctx.contracts.modules.markets.address, args: [gitCommit], contractPath: "contracts/modules/Markets.sol:Markets" }; - ctx.contracts.modules.liquidation = await (await ctx.factories.Liquidation.deploy(gitCommit, SELF_COLLATERAL_FACTOR)).deployed(); + ctx.contracts.modules.liquidation = await (await ctx.factories.Liquidation.deploy(gitCommit)).deployed(); verification.contracts.modules.liquidation = { - address: ctx.contracts.modules.liquidation.address, args: [gitCommit, SELF_COLLATERAL_FACTOR], contractPath: "contracts/modules/Liquidation.sol:Liquidation" + address: ctx.contracts.modules.liquidation.address, args: [gitCommit], contractPath: "contracts/modules/Liquidation.sol:Liquidation" }; ctx.contracts.modules.governance = await (await ctx.factories.Governance.deploy(gitCommit)).deployed(); @@ -930,9 +928,9 @@ async function deployContracts(provider, wallets, tokenSetupName, verify = null) address: ctx.contracts.modules.dToken.address, args: [gitCommit], contractPath: "contracts/modules/DToken.sol:DToken" }; - ctx.contracts.modules.riskManager = await (await ctx.factories.RiskManager.deploy(gitCommit, riskManagerSettings, SELF_COLLATERAL_FACTOR)).deployed(); + ctx.contracts.modules.riskManager = await (await ctx.factories.RiskManager.deploy(gitCommit, riskManagerSettings)).deployed(); verification.contracts.modules.riskManager = { - address: ctx.contracts.modules.riskManager.address, args: [gitCommit, riskManagerSettings, SELF_COLLATERAL_FACTOR], contractPath: "contracts/modules/RiskManager.sol:RiskManager" + address: ctx.contracts.modules.riskManager.address, args: [gitCommit, riskManagerSettings], contractPath: "contracts/modules/RiskManager.sol:RiskManager" }; ctx.contracts.modules.irmDefault = await (await ctx.factories.IRMDefault.deploy(gitCommit)).deployed();