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

feat: accessor for Risk Manager Settings #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contracts/IRiskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ interface IRiskManager {
LiquidityStatus status;
}

struct RiskManagerSettings {
address referenceAsset;
address uniswapFactory;
bytes32 uniswapPoolInitCodeHash;
}

function getNewMarketParameters(address underlying) external returns (NewMarketParameters memory);

function requireLiquidity(address account) external view;
Expand All @@ -34,4 +40,5 @@ 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 getRiskManagerSettings() external view returns (RiskManagerSettings memory settings);
}
9 changes: 9 additions & 0 deletions contracts/modules/Exec.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ contract Exec is BaseLogic {
(twap, twapPeriod, currPrice) = abi.decode(result, (uint, uint, uint));
}

/// @notice Retrieve Risk Manager Settings as per its constructor arguments used
/// @return settings RiskManagerSettings struct
function getRiskManagerSettings() external staticDelegate returns (IRiskManager.RiskManagerSettings memory settings) {
bytes memory result = callInternalModule(MODULEID__RISK_MANAGER,
abi.encodeWithSelector(IRiskManager.getRiskManagerSettings.selector));

(settings) = abi.decode(result, (IRiskManager.RiskManagerSettings));
}


// Custom execution methods

Expand Down
11 changes: 5 additions & 6 deletions contracts/modules/RiskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ contract RiskManager is IRiskManager, BaseLogic {
address immutable uniswapFactory;
bytes32 immutable uniswapPoolInitCodeHash;

struct RiskManagerSettings {
address referenceAsset;
address uniswapFactory;
bytes32 uniswapPoolInitCodeHash;
}

constructor(bytes32 moduleGitCommit_, RiskManagerSettings memory settings) BaseLogic(MODULEID__RISK_MANAGER, moduleGitCommit_) {
referenceAsset = settings.referenceAsset;
uniswapFactory = settings.uniswapFactory;
Expand Down Expand Up @@ -284,6 +278,11 @@ contract RiskManager is IRiskManager, BaseLogic {
}
}

// Returns Risk Manager settings as per constructor arguments

function getRiskManagerSettings() external view override returns (RiskManagerSettings memory settings) {
settings = RiskManagerSettings(referenceAsset, uniswapFactory, uniswapPoolInitCodeHash);
}

// Liquidity

Expand Down