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

Commit af57f36

Browse files
feat: accessor for Risk Manager Settings
1 parent dfaa778 commit af57f36

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

contracts/IRiskManager.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ interface IRiskManager {
2626
LiquidityStatus status;
2727
}
2828

29+
struct RiskManagerSettings {
30+
address referenceAsset;
31+
address uniswapFactory;
32+
bytes32 uniswapPoolInitCodeHash;
33+
}
34+
2935
function getNewMarketParameters(address underlying) external returns (NewMarketParameters memory);
3036

3137
function requireLiquidity(address account) external view;
@@ -34,4 +40,5 @@ interface IRiskManager {
3440

3541
function getPrice(address underlying) external view returns (uint twap, uint twapPeriod);
3642
function getPriceFull(address underlying) external view returns (uint twap, uint twapPeriod, uint currPrice);
43+
function getRiskManagerSettings() external view returns (RiskManagerSettings memory settings);
3744
}

contracts/modules/Exec.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ contract Exec is BaseLogic {
8080
(twap, twapPeriod, currPrice) = abi.decode(result, (uint, uint, uint));
8181
}
8282

83+
/// @notice Retrieve Risk Manager Settings as per its constructor arguments used
84+
/// @return settings RiskManagerSettings struct
85+
function getRiskManagerSettings() external staticDelegate returns (IRiskManager.RiskManagerSettings memory settings) {
86+
bytes memory result = callInternalModule(MODULEID__RISK_MANAGER,
87+
abi.encodeWithSelector(IRiskManager.getRiskManagerSettings.selector));
88+
89+
(settings) = abi.decode(result, (IRiskManager.RiskManagerSettings));
90+
}
91+
8392

8493
// Custom execution methods
8594

contracts/modules/RiskManager.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ contract RiskManager is IRiskManager, BaseLogic {
3232
address immutable uniswapFactory;
3333
bytes32 immutable uniswapPoolInitCodeHash;
3434

35-
struct RiskManagerSettings {
36-
address referenceAsset;
37-
address uniswapFactory;
38-
bytes32 uniswapPoolInitCodeHash;
39-
}
40-
4135
constructor(bytes32 moduleGitCommit_, RiskManagerSettings memory settings) BaseLogic(MODULEID__RISK_MANAGER, moduleGitCommit_) {
4236
referenceAsset = settings.referenceAsset;
4337
uniswapFactory = settings.uniswapFactory;
@@ -284,6 +278,11 @@ contract RiskManager is IRiskManager, BaseLogic {
284278
}
285279
}
286280

281+
// Returns Risk Manager settings as per constructor arguments
282+
283+
function getRiskManagerSettings() external view override returns (RiskManagerSettings memory settings) {
284+
settings = RiskManagerSettings(referenceAsset, uniswapFactory, uniswapPoolInitCodeHash);
285+
}
287286

288287
// Liquidity
289288

0 commit comments

Comments
 (0)