Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 967a7ce

Browse files
committed
Remove self collateral factor configuration from risk manager
1 parent e3b1e3b commit 967a7ce

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

contracts/Constants.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ abstract contract Constants {
2525
uint16 internal constant MIN_UNISWAP3_OBSERVATION_CARDINALITY = 144;
2626
uint24 internal constant DEFAULT_TWAP_WINDOW_SECONDS = 30 * 60;
2727
uint32 internal constant DEFAULT_BORROW_FACTOR = uint32(0.28 * 4_000_000_000);
28+
uint32 internal constant SELF_COLLATERAL_FACTOR = uint32(0.95 * 4_000_000_000);
2829

2930

3031
// Implementation internals

contracts/IRiskManager.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ interface IRiskManager {
3535

3636
function getPrice(address underlying) external view returns (uint twap, uint twapPeriod);
3737
function getPriceFull(address underlying) external view returns (uint twap, uint twapPeriod, uint currPrice);
38-
39-
function selfCollateralFactor() external view returns (uint32);
4038
}

contracts/modules/Liquidation.sol

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "../BaseLogic.sol";
77

88
/// @notice Liquidate users who are in collateral violation to protect lenders
99
contract Liquidation is BaseLogic {
10-
constructor(bytes32 moduleGitCommit_, uint32 selfCollateralFactor_) BaseLogic(MODULEID__LIQUIDATION, moduleGitCommit_) {}
10+
constructor(bytes32 moduleGitCommit_) BaseLogic(MODULEID__LIQUIDATION, moduleGitCommit_) {}
1111

1212
// How much of a liquidation is credited to the underlying's reserves.
1313
uint public constant UNDERLYING_RESERVES_FEE = 0.02 * 1e18;
@@ -145,7 +145,7 @@ contract Liquidation is BaseLogic {
145145
// self-collateralization is an implicit override
146146
if (!overrideConfig.enabled && liqLocs.underlying == liqLocs.collateral) {
147147
overrideConfig.enabled = true;
148-
overrideConfig.collateralFactor = getSelfCollateralFactor();
148+
overrideConfig.collateralFactor = SELF_COLLATERAL_FACTOR;
149149
}
150150
// the liquidated collateral has active override with liability
151151
if (overrideConfig.enabled) {
@@ -395,9 +395,4 @@ contract Liquidation is BaseLogic {
395395
function emitLiquidationLog(LiquidationLocals memory liqLocs, uint repay, uint yield) private {
396396
emit Liquidation(liqLocs.liquidator, liqLocs.violator, liqLocs.underlying, liqLocs.collateral, repay, yield, liqLocs.liqOpp.healthScore, liqLocs.liqOpp.baseDiscount, liqLocs.liqOpp.discount);
397397
}
398-
399-
function getSelfCollateralFactor() private returns (uint32) {
400-
bytes memory result = callInternalModule(MODULEID__RISK_MANAGER, abi.encodeWithSelector(IRiskManager.selfCollateralFactor.selector));
401-
return abi.decode(result, (uint32));
402-
}
403398
}

contracts/modules/RiskManager.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ interface IChainlinkAggregatorV2V3 {
2525

2626
contract RiskManager is IRiskManager, BaseLogic {
2727
// Construction
28-
uint32 immutable public selfCollateralFactor;
29-
3028
address immutable referenceAsset; // Token must have 18 decimals
3129
address immutable uniswapFactory;
3230
bytes32 immutable uniswapPoolInitCodeHash;
@@ -37,12 +35,10 @@ contract RiskManager is IRiskManager, BaseLogic {
3735
bytes32 uniswapPoolInitCodeHash;
3836
}
3937

40-
constructor(bytes32 moduleGitCommit_, RiskManagerSettings memory settings, uint32 selfCollateralFactor_) BaseLogic(MODULEID__RISK_MANAGER, moduleGitCommit_) {
38+
constructor(bytes32 moduleGitCommit_, RiskManagerSettings memory settings) BaseLogic(MODULEID__RISK_MANAGER, moduleGitCommit_) {
4139
referenceAsset = settings.referenceAsset;
4240
uniswapFactory = settings.uniswapFactory;
4341
uniswapPoolInitCodeHash = settings.uniswapPoolInitCodeHash;
44-
45-
selfCollateralFactor = selfCollateralFactor_;
4642
}
4743

4844

@@ -349,7 +345,7 @@ contract RiskManager is IRiskManager, BaseLogic {
349345
// self-collateralization is an implicit override
350346
if (!overrideConfig.enabled && singleLiability == underlying) {
351347
overrideConfig.enabled = true;
352-
overrideConfig.collateralFactor = selfCollateralFactor;
348+
overrideConfig.collateralFactor = SELF_COLLATERAL_FACTOR;
353349
}
354350
}
355351

test/lib/eTestLib.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const { verifyBatch } = require("./deployLib");
1717
Error.stackTraceLimit = 10000;
1818
let conf;
1919

20-
const SELF_COLLATERAL_FACTOR = 0.95 * 4e9
21-
2220
const moduleIds = {
2321
// Public single-proxy modules
2422
INSTALLER: 1,
@@ -895,9 +893,9 @@ async function deployContracts(provider, wallets, tokenSetupName, verify = null)
895893
address: ctx.contracts.modules.markets.address, args: [gitCommit], contractPath: "contracts/modules/Markets.sol:Markets"
896894
};
897895

898-
ctx.contracts.modules.liquidation = await (await ctx.factories.Liquidation.deploy(gitCommit, SELF_COLLATERAL_FACTOR)).deployed();
896+
ctx.contracts.modules.liquidation = await (await ctx.factories.Liquidation.deploy(gitCommit)).deployed();
899897
verification.contracts.modules.liquidation = {
900-
address: ctx.contracts.modules.liquidation.address, args: [gitCommit, SELF_COLLATERAL_FACTOR], contractPath: "contracts/modules/Liquidation.sol:Liquidation"
898+
address: ctx.contracts.modules.liquidation.address, args: [gitCommit], contractPath: "contracts/modules/Liquidation.sol:Liquidation"
901899
};
902900

903901
ctx.contracts.modules.governance = await (await ctx.factories.Governance.deploy(gitCommit)).deployed();
@@ -930,9 +928,9 @@ async function deployContracts(provider, wallets, tokenSetupName, verify = null)
930928
address: ctx.contracts.modules.dToken.address, args: [gitCommit], contractPath: "contracts/modules/DToken.sol:DToken"
931929
};
932930

933-
ctx.contracts.modules.riskManager = await (await ctx.factories.RiskManager.deploy(gitCommit, riskManagerSettings, SELF_COLLATERAL_FACTOR)).deployed();
931+
ctx.contracts.modules.riskManager = await (await ctx.factories.RiskManager.deploy(gitCommit, riskManagerSettings)).deployed();
934932
verification.contracts.modules.riskManager = {
935-
address: ctx.contracts.modules.riskManager.address, args: [gitCommit, riskManagerSettings, SELF_COLLATERAL_FACTOR], contractPath: "contracts/modules/RiskManager.sol:RiskManager"
933+
address: ctx.contracts.modules.riskManager.address, args: [gitCommit, riskManagerSettings], contractPath: "contracts/modules/RiskManager.sol:RiskManager"
936934
};
937935

938936
ctx.contracts.modules.irmDefault = await (await ctx.factories.IRMDefault.deploy(gitCommit)).deployed();

0 commit comments

Comments
 (0)