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

Commit

Permalink
added doQueryEulerConfig for general Euler config fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpawlowski committed Feb 27, 2023
1 parent af57f36 commit 4094c8d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions contracts/views/EulerGeneralView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ import "../modules/EToken.sol";
import "../modules/Markets.sol";
import "../BaseIRMLinearKink.sol";
import "../vendor/RPow.sol";
import "../IRiskManager.sol";

interface IExec {
function getPriceFull(address underlying) external view returns (uint twap, uint twapPeriod, uint currPrice);
function getPrice(address underlying) external view returns (uint twap, uint twapPeriod);
function detailedLiquidity(address account) external view returns (IRiskManager.AssetLiquidity[] memory assets);
function liquidity(address account) external view returns (IRiskManager.LiquidityStatus memory status);
function getRiskManagerSettings() external view returns (IRiskManager.RiskManagerSettings memory settings);
}

interface IInstaller {
function getUpgradeAdmin() external view returns (address);
}

interface IGovernance {
function getGovernorAdmin() external view returns (address);
}

contract EulerGeneralView is Constants {
Expand Down Expand Up @@ -84,10 +94,45 @@ contract EulerGeneralView is Constants {
address[] enteredMarkets;
}

struct ResponseModule {
uint moduleId;
address proxyAddress;
}

struct ResponseConfig {
uint defaultReserveFee;
uint defaultTWAPWindowSeconds;
uint defaultBorrowFactor;
address upgradeAdmin;
address governorAdmin;
IRiskManager.RiskManagerSettings riskManagerSettings;

ResponseModule[] modules;
}


// Implementation

function doQueryEulerConfig(address eulerContract) external view returns (ResponseConfig memory r) {
r.defaultReserveFee = DEFAULT_RESERVE_FEE;
r.defaultTWAPWindowSeconds = DEFAULT_TWAP_WINDOW_SECONDS;
r.defaultBorrowFactor = DEFAULT_BORROW_FACTOR;
r.modules = new ResponseModule[](7);

Euler eulerProxy = Euler(eulerContract);
r.modules[0] = ResponseModule(MODULEID__INSTALLER, eulerProxy.moduleIdToProxy(MODULEID__INSTALLER));
r.modules[1] = ResponseModule(MODULEID__MARKETS, eulerProxy.moduleIdToProxy(MODULEID__MARKETS));
r.modules[2] = ResponseModule(MODULEID__LIQUIDATION, eulerProxy.moduleIdToProxy(MODULEID__LIQUIDATION));
r.modules[3] = ResponseModule(MODULEID__GOVERNANCE, eulerProxy.moduleIdToProxy(MODULEID__GOVERNANCE));
r.modules[4] = ResponseModule(MODULEID__EXEC, eulerProxy.moduleIdToProxy(MODULEID__EXEC));
r.modules[5] = ResponseModule(MODULEID__SWAP, eulerProxy.moduleIdToProxy(MODULEID__SWAP));
r.modules[6] = ResponseModule(MODULEID__SWAPHUB, eulerProxy.moduleIdToProxy(MODULEID__SWAPHUB));

r.upgradeAdmin = IInstaller(r.modules[0].proxyAddress).getUpgradeAdmin();
r.governorAdmin = IGovernance(r.modules[3].proxyAddress).getGovernorAdmin();
r.riskManagerSettings = IExec(r.modules[4].proxyAddress).getRiskManagerSettings();
}

function doQueryBatch(Query[] memory qs) external view returns (Response[] memory r) {
r = new Response[](qs.length);

Expand Down

0 comments on commit 4094c8d

Please sign in to comment.