View Source: contracts/feeds/PriceFeedV1PoolOracle.sol
↗ Extends: IPriceFeedsExt, Ownable
The Price Feed V1 Pool Oracle contract.
- This contract implements V1 Pool Oracle query functionality, getting the price from v1 pool oracle.
Constants & Variables
address public v1PoolOracleAddress;
address public wRBTCAddress;
address public docAddress;
address public baseCurrency;
Events
event SetV1PoolOracleAddress(address indexed v1PoolOracleAddress, address changerAddress);
event SetWRBTCAddress(address indexed wRBTCAddress, address changerAddress);
event SetDOCAddress(address indexed docAddress, address changerAddress);
event SetBaseCurrency(address indexed baseCurrency, address changerAddress);
- constructor(address _v1PoolOracleAddress, address _wRBTCAddress, address _docAddress, address _baseCurrency)
- latestAnswer()
- _convertAnswerToUsd(uint256 _valueInBTC)
- setV1PoolOracleAddress(address _v1PoolOracleAddress)
- setRBTCAddress(address _wRBTCAddress)
- setDOCAddress(address _docAddress)
- setBaseCurrency(address _baseCurrency)
Initialize a new V1 Pool Oracle. *
function (address _v1PoolOracleAddress, address _wRBTCAddress, address _docAddress, address _baseCurrency) public nonpayable
Arguments
Name | Type | Description |
---|---|---|
_v1PoolOracleAddress | address | The V1 Pool Oracle address. |
_wRBTCAddress | address | The wrbtc token address. |
_docAddress | address | The doc token address. |
_baseCurrency | address |
Source Code
constructor(
address _v1PoolOracleAddress,
address _wRBTCAddress,
address _docAddress,
address _baseCurrency
) public {
setRBTCAddress(_wRBTCAddress);
setDOCAddress(_docAddress);
setV1PoolOracleAddress(_v1PoolOracleAddress);
setBaseCurrency(_baseCurrency);
}
undefined
Get the oracle price.
function latestAnswer() external view
returns(uint256)
Source Code
function latestAnswer() external view returns (uint256) {
IV1PoolOracle _v1PoolOracle = IV1PoolOracle(v1PoolOracleAddress);
uint256 _price = _v1PoolOracle.latestPrice(baseCurrency);
// Need to convert to USD, since the V1 pool return value is based on BTC
uint256 priceInUSD = _convertAnswerToUsd(_price);
require(priceInUSD != 0, "price error");
return priceInUSD;
}
function _convertAnswerToUsd(uint256 _valueInBTC) private view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
_valueInBTC | uint256 |
Source Code
function _convertAnswerToUsd(uint256 _valueInBTC) private view returns (uint256) {
address _priceFeeds = msg.sender;
uint256 precision = IPriceFeeds(_priceFeeds).queryPrecision(wRBTCAddress, docAddress);
uint256 valueInUSD =
IPriceFeeds(_priceFeeds).queryReturn(wRBTCAddress, docAddress, _valueInBTC);
/// Need to multiply by query precision (doc's precision) and divide by 1*10^18 (Because the based price in v1 pool is using 18 decimals)
return valueInUSD.mul(precision).div(1e18);
}
Set the V1 Pool Oracle address. *
function setV1PoolOracleAddress(address _v1PoolOracleAddress) public nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
_v1PoolOracleAddress | address | The V1 Pool Oracle address. |
Source Code
function setV1PoolOracleAddress(address _v1PoolOracleAddress) public onlyOwner {
require(Address.isContract(_v1PoolOracleAddress), "_v1PoolOracleAddress not a contract");
IV1PoolOracle _v1PoolOracle = IV1PoolOracle(_v1PoolOracleAddress);
address liquidityPool = _v1PoolOracle.liquidityPool();
require(
ILiquidityPoolV1Converter(liquidityPool).reserveTokens(0) == wRBTCAddress ||
ILiquidityPoolV1Converter(liquidityPool).reserveTokens(1) == wRBTCAddress,
"one of the two reserves needs to be wrbtc"
);
v1PoolOracleAddress = _v1PoolOracleAddress;
emit SetV1PoolOracleAddress(v1PoolOracleAddress, msg.sender);
}
Set the rBtc address. V1 pool based price is BTC, so need to convert the value from v1 pool to USD. That's why we need to get the price of the rBtc *
function setRBTCAddress(address _wRBTCAddress) public nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
_wRBTCAddress | address | The rBTC address |
Source Code
function setRBTCAddress(address _wRBTCAddress) public onlyOwner {
require(_wRBTCAddress != address(0), "wRBTC address cannot be zero address");
wRBTCAddress = _wRBTCAddress;
emit SetWRBTCAddress(wRBTCAddress, msg.sender);
}
Set the DoC address. V1 pool based price is BTC, so need to convert the value from v1 pool to USD. That's why we need to get the price of the DoC *
function setDOCAddress(address _docAddress) public nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
_docAddress | address | The DoC address |
Source Code
function setDOCAddress(address _docAddress) public onlyOwner {
require(_docAddress != address(0), "DOC address cannot be zero address");
docAddress = _docAddress;
emit SetDOCAddress(_docAddress, msg.sender);
}
Set the base currency address. That's the reserve address which is not WRBTC *
function setBaseCurrency(address _baseCurrency) public nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
_baseCurrency | address | The base currency address |
Source Code
function setBaseCurrency(address _baseCurrency) public onlyOwner {
require(_baseCurrency != address(0), "Base currency address cannot be zero address");
baseCurrency = _baseCurrency;
emit SetBaseCurrency(_baseCurrency, msg.sender);
}
- Address
- Administered
- AdminRole
- AdvancedToken
- AdvancedTokenStorage
- Affiliates
- AffiliatesEvents
- ApprovalReceiver
- BProPriceFeed
- CheckpointsShared
- Constants
- Context
- DevelopmentFund
- DummyContract
- EnumerableAddressSet
- EnumerableBytes32Set
- EnumerableBytes4Set
- ERC20
- ERC20Detailed
- ErrorDecoder
- Escrow
- EscrowReward
- FeedsLike
- FeesEvents
- FeeSharingCollector
- FeeSharingCollectorProxy
- FeeSharingCollectorStorage
- FeesHelper
- FourYearVesting
- FourYearVestingFactory
- FourYearVestingLogic
- FourYearVestingStorage
- GenericTokenSender
- GovernorAlpha
- GovernorVault
- IApproveAndCall
- IChai
- IContractRegistry
- IConverterAMM
- IERC1820Registry
- IERC20_
- IERC20
- IERC777
- IERC777Recipient
- IERC777Sender
- IFeeSharingCollector
- IFourYearVesting
- IFourYearVestingFactory
- IFunctionsList
- ILiquidityMining
- ILiquidityPoolV1Converter
- ILoanPool
- ILoanToken
- ILoanTokenLogicBeacon
- ILoanTokenLogicModules
- ILoanTokenLogicProxy
- ILoanTokenModules
- ILoanTokenWRBTC
- ILockedSOV
- IMoCState
- IModulesProxyRegistry
- Initializable
- InterestUser
- IPot
- IPriceFeeds
- IPriceFeedsExt
- IProtocol
- IRSKOracle
- ISovryn
- ISovrynSwapNetwork
- IStaking
- ISwapsImpl
- ITeamVesting
- ITimelock
- IV1PoolOracle
- IVesting
- IVestingFactory
- IVestingRegistry
- IWrbtc
- IWrbtcERC20
- LenderInterestStruct
- LiquidationHelper
- LiquidityMining
- LiquidityMiningConfigToken
- LiquidityMiningProxy
- LiquidityMiningStorage
- LoanClosingsEvents
- LoanClosingsLiquidation
- LoanClosingsRollover
- LoanClosingsShared
- LoanClosingsWith
- LoanClosingsWithoutInvariantCheck
- LoanInterestStruct
- LoanMaintenance
- LoanMaintenanceEvents
- LoanOpenings
- LoanOpeningsEvents
- LoanParamsStruct
- LoanSettings
- LoanSettingsEvents
- LoanStruct
- LoanToken
- LoanTokenBase
- LoanTokenLogicBeacon
- LoanTokenLogicLM
- LoanTokenLogicProxy
- LoanTokenLogicStandard
- LoanTokenLogicStorage
- LoanTokenLogicWrbtc
- LoanTokenSettingsLowerAdmin
- LockedSOV
- MarginTradeStructHelpers
- Medianizer
- ModuleCommonFunctionalities
- ModulesCommonEvents
- ModulesProxy
- ModulesProxyRegistry
- MultiSigKeyHolders
- MultiSigWallet
- Mutex
- Objects
- OrderStruct
- OrigingVestingCreator
- OriginInvestorsClaim
- Ownable
- Pausable
- PausableOz
- PreviousLoanToken
- PreviousLoanTokenSettingsLowerAdmin
- PriceFeedRSKOracle
- PriceFeeds
- PriceFeedsLocal
- PriceFeedsMoC
- PriceFeedV1PoolOracle
- ProtocolAffiliatesInterface
- ProtocolLike
- ProtocolSettings
- ProtocolSettingsEvents
- ProtocolSettingsLike
- ProtocolSwapExternalInterface
- ProtocolTokenUser
- Proxy
- ProxyOwnable
- ReentrancyGuard
- RewardHelper
- RSKAddrValidator
- SafeERC20
- SafeMath
- SafeMath96
- setGet
- SharedReentrancyGuard
- SignedSafeMath
- SOV
- sovrynProtocol
- StakingAdminModule
- StakingGovernanceModule
- StakingInterface
- StakingProxy
- StakingRewards
- StakingRewardsProxy
- StakingRewardsStorage
- StakingShared
- StakingStakeModule
- StakingStorageModule
- StakingStorageShared
- StakingVestingModule
- StakingWithdrawModule
- State
- SwapsEvents
- SwapsExternal
- SwapsImplLocal
- SwapsImplSovrynSwap
- SwapsUser
- TeamVesting
- Timelock
- TimelockHarness
- TimelockInterface
- TokenSender
- UpgradableProxy
- USDTPriceFeed
- Utils
- VaultController
- Vesting
- VestingCreator
- VestingFactory
- VestingLogic
- VestingRegistry
- VestingRegistry2
- VestingRegistry3
- VestingRegistryLogic
- VestingRegistryProxy
- VestingRegistryStorage
- VestingStorage
- WeightedStakingModule
- WRBTC