Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price recommendation #79

Open
wants to merge 2 commits into
base: updates
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
20 changes: 20 additions & 0 deletions contracts/peripherals/Reader.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions contracts/peripherals/Timelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down