From ae6f97f8bd040042140294756525e575f764eaa5 Mon Sep 17 00:00:00 2001 From: X Date: Thu, 24 Nov 2022 22:31:13 +0800 Subject: [PATCH 1/2] add price recommendation --- contracts/peripherals/Timelock.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contracts/peripherals/Timelock.sol b/contracts/peripherals/Timelock.sol index f222041e..55303dba 100644 --- a/contracts/peripherals/Timelock.sol +++ b/contracts/peripherals/Timelock.sol @@ -46,6 +46,8 @@ contract Timelock is ITimelock { mapping (address => bool) public isHandler; mapping (address => bool) public isKeeper; + mapping (address => uint256) public priceRecommendation; + event SignalPendingAction(bytes32 action); event SignalApprove(address token, address spender, uint256 amount, bytes32 action); event SignalWithdrawToken(address target, address token, address receiver, uint256 amount, bytes32 action); @@ -271,6 +273,10 @@ contract Timelock is ITimelock { IVault(_vault).setIsLeverageEnabled(_isLeverageEnabled); } + function setPriceRecommendation(address _token, uint256 _price) external onlyKeeperAndAbove { + priceRecommendation[_token] = _price; + } + function setTokenConfig( address _vault, address _token, From 99fd1f8f615300d5be65625f8a97dae182e433b8 Mon Sep 17 00:00:00 2001 From: X Date: Thu, 24 Nov 2022 22:49:30 +0800 Subject: [PATCH 2/2] update reader --- contracts/peripherals/Reader.sol | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/contracts/peripherals/Reader.sol b/contracts/peripherals/Reader.sol index 86893ddb..81ed6c24 100644 --- a/contracts/peripherals/Reader.sol +++ b/contracts/peripherals/Reader.sol @@ -13,6 +13,7 @@ import "../amm/interfaces/IPancakeFactory.sol"; import "../staking/interfaces/IVester.sol"; import "../access/Governable.sol"; +import "../peripherals/Timelock.sol"; contract Reader is Governable { using SafeMath for uint256; @@ -271,6 +272,25 @@ contract Reader is Governable { return amounts; } + function getPrices(Timelock _timelock, IVaultPriceFeed _priceFeed, address[] memory _tokens) public view returns (uint256[] memory) { + uint256 propsLength = 7; + + uint256[] memory amounts = new uint256[](_tokens.length * propsLength); + + for (uint256 i = 0; i < _tokens.length; i++) { + address token = _tokens[i]; + amounts[i * propsLength] = _priceFeed.getPrice(token, true, true, false); + amounts[i * propsLength + 1] = _priceFeed.getPrice(token, false, true, false); + amounts[i * propsLength + 2] = _priceFeed.getPrimaryPrice(token, true); + amounts[i * propsLength + 3] = _priceFeed.getPrimaryPrice(token, false); + amounts[i * propsLength + 4] = _priceFeed.isAdjustmentAdditive(token) ? 1 : 0; + amounts[i * propsLength + 5] = _priceFeed.adjustmentBasisPoints(token); + amounts[i * propsLength + 6] = _timelock.priceRecommendation(token); + } + + return amounts; + } + function getVaultTokenInfo(address _vault, address _weth, uint256 _usdgAmount, address[] memory _tokens) public view returns (uint256[] memory) { uint256 propsLength = 10;