BalancerV2PriceProvider
BalancerV2PriceProvider
Price provider contract that reads prices from BalancerV2
function acceptOwnership() external nonpayable
Transfers ownership of the contract to a pending owner Can only be called by the pending owner.
function assetSupported(address _asset) external view returns (bool)
Informs if PriceProvider is setup for asset. It does not means PriceProvider can provide price right away. Some providers implementations need time to "build" buffor for TWAP price, so price may not be available yet but this method will return true.
Name | Type | Description |
---|---|---|
_asset | address | asset in question |
Name | Type | Description |
---|---|---|
_0 | bool | TRUE if asset has been setup, otherwise false |
function assetsPools(address) external view returns (bytes32 poolId, address priceOracle, bool token0isAsset)
Maps asset address to BalancerPool struct
Name | Type | Description |
---|---|---|
_0 | address | undefined |
Name | Type | Description |
---|---|---|
poolId | bytes32 | undefined |
priceOracle | address | undefined |
token0isAsset | bool | undefined |
function changePeriodForAvgPrice(uint32 _period) external nonpayable
Change period for average price
Name | Type | Description |
---|---|---|
_period | uint32 | period in seconds for TWAP price, ie. 1800 means 30 min |
function changeSecondsAgo(uint32 _ago) external nonpayable
Change number of seconds in the past where calcualtions starts for average price
Name | Type | Description |
---|---|---|
_ago | uint32 | new seconds ago value in seconds, ie. 1800 means 30 min |
function changeSettings(uint32 _period, uint32 _ago) external nonpayable
Change period for average price and number of seconds in the past where calcualtions starts for average price
Name | Type | Description |
---|---|---|
_period | uint32 | period in seconds for TWAP price, ie. 1800 means 30 min |
_ago | uint32 | new seconds ago value in seconds, ie. 1800 means 30 min |
function getPoolQuoteLiquidity(bytes32 _poolId) external view returns (uint256)
Gets amount of quote token deposited in the pool
Name | Type | Description |
---|---|---|
_poolId | bytes32 | must be valid pool for asset, balancer will throw BAL#500 if it's not |
Name | Type | Description |
---|---|---|
_0 | uint256 | amount of quote token in the pool |
function getPrice(address _asset) external view returns (uint256 price)
Returns price for a given asset
Balancer docs: | Some pools (WeightedPool2Tokens and MetaStable Pools) have optional Oracle functionality. | This means that they can be used as sources of on-chain price data. | Note from balancer docs: that you can only call getWeightedTimeAverage after the buffer is full, | or it will revert with ORACLE_NOT_INITIALIZED. If you call getSample(1023) and it returns 0's, | that means the buffer's not full yet. We are using Resilient way (recommended by balancer for lending protocols), Less up-to-date but more resilient to manipulation
Name | Type | Description |
---|---|---|
_asset | address | asset address |
Name | Type | Description |
---|---|---|
price | uint256 | of asset in 18 decimals |
function owner() external view returns (address)
Returns the address of the current owner.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function pendingOwner() external view returns (address)
Returns the address of the pending owner.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function periodForAvgPrice() external view returns (uint256)
Information for a Time Weighted Average query.
Each query computes the average over a window of duration
secs
seconds that ended ago
seconds ago. For example, the average over the past 30 minutes is computed by settings secs to 1800 and ago to 0. If secs is 1800 and ago is 1800 as well, the average between 60 and 30 minutes ago is computed instead.Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function priceBufferReady(address _asset) external view returns (bool)
Checks if price buffer is ready for a BalancerV2 pool assigned to an asset
Name | Type | Description |
---|---|---|
_asset | address | asset address |
Name | Type | Description |
---|---|---|
_0 | bool | true if buffer ready, otherwise false |
function priceProviderPing() external pure returns (bool)
Helper method that allows easily detects, if contract is PriceProvider
this can save us from simple human errors, in case we use invalid address but this should NOT be treated as security check
Name | Type | Description |
---|---|---|
_0 | bool | always true |
function priceProvidersRepository() external view returns (contract IPriceProvidersRepository)
PriceProvidersRepository address
Name | Type | Description |
---|---|---|
_0 | contract IPriceProvidersRepository | undefined |
function quoteToken() external view returns (address)
Token address which prices are quoted in. Must be the same as PriceProvidersRepository.quoteToken
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function renounceOwnership() external nonpayable
Leaves the contract without owner. It will not be possible to call
onlyOwner
functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.function resolvePoolAddress(bytes32 _poolId) external pure returns (address)
Returns the address of a Pool's contract.
Due to how Pool IDs are created, this is done with no storage accesses and costs little gas.
Name | Type | Description |
---|---|---|
_poolId | bytes32 | valid pool for asset |
Name | Type | Description |
---|---|---|
_0 | address | pool address |
function secondsAgo() external view returns (uint256)
Information for a Time Weighted Average query
Each query computes the average over a window of duration
secs
seconds that ended ago
seconds ago.Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function setupAsset(address _asset, bytes32 _poolId) external nonpayable
Setup pool for asset. Use it also for update.
Name | Type | Description |
---|---|---|
_asset | address | asset address |
_poolId | bytes32 | BalancerV2 pool ID |
function transferOwnership(address newOwner) external nonpayable
Transfers ownership of the contract to a new account (
newOwner
). Can only be called by the current owner.Name | Type | Description |
---|---|---|
newOwner | address | undefined |
function transferPendingOwnership(address newPendingOwner) external nonpayable
Transfers pending ownership of the contract to a new account (
newPendingOwner
). Can only be called by the current owner.Name | Type | Description |
---|---|---|
newPendingOwner | address | undefined |
function vault() external view returns (contract IVault)
main BalancerV2 contract, something like router for Uniswap but much more
Name | Type | Description |
---|---|---|
_0 | contract IVault | undefined |
function verifyPool(bytes32 _poolId, address _asset) external view returns (contract IERC20[] tokens)
Checks if provided
_poolId
is valid pool for _asset
NOTICE: keep in ming anyone can register pool in balancer Vault https://github.com/balancer-labs/balancer-v2-monorepo /blob/09c69ed5dc4715a0076c1dc87a81c0b6c2669b5a/pkg/vault/contracts/PoolRegistry.sol#L67 Only some pools (WeightedPool2Tokens and MetaStable Pools) provides oracle functionality. To be 100% sure, if pool has build-in oracle, we need to do call for getLargestSafeQueryWindow() and see if it fails or not.
Name | Type | Description |
---|---|---|
_poolId | bytes32 | balancer poolId |
_asset | address | token address for which we want to check the pool |
Name | Type | Description |
---|---|---|
tokens | contract IERC20[] | IERC20[] pool tokens in original order, throws when pool is invalid |
event NewPeriod(uint32 period)
Emitted when TWAP period changes
Name | Type | Description |
---|---|---|
period | uint32 | new period in seconds, ie. 1800 means 30 min |
event NewSecondsAgo(uint32 ago)
Emitted when seconds ago changes
Name | Type | Description |
---|---|---|
ago | uint32 | new seconds ago value in seconds, ie. 1800 means 30 min |
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
Name | Type | Description |
---|---|---|
previousOwner indexed | address | undefined |
newOwner indexed | address | undefined |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
Name | Type | Description |
---|---|---|
previousOwner indexed | address | undefined |
newOwner indexed | address | undefined |
event PoolForAsset(address asset, bytes32 poolId)
Emitted when BalancerV2 pool is set for asset
Name | Type | Description |
---|---|---|
asset | address | asset address |
poolId | bytes32 | BalancerV2 pool ID |
Last modified 1yr ago