Oracle
Overview
This Oracle contract calculates a 1 day TWAP for a constant product (xy=k) Astroport pool, from the pool's cumulative prices. It is a demo contract: it isn't part of Astroport's deployed contracts. To read prices on chain, you can also use a pool's own cumulative_prices query, or observe on stableswap and PCL pools (see Swap Pairs).
Links
- Contract Repo: https://github.com/astroport-fi/astroport-core/tree/main/contracts/periphery/oracle
- contract.rs: https://github.com/astroport-fi/astroport-core/blob/main/contracts/periphery/oracle/src/contract.rs
- oracle.rs: https://github.com/astroport-fi/astroport-core/blob/main/packages/astroport/src/oracle.rs
- Tests: https://github.com/astroport-fi/astroport-core/tree/main/contracts/periphery/oracle/tests
- Version documented:
astroport-oracle2.1.2
InstantiateMsg
Instantiates the oracle for the pool of the given assets. The pool must be a constant product pool registered in the factory.
| Params | Type | Description |
|---|---|---|
factory_contract | String | The factory contract address |
asset_infos | Vec<AssetInfo> | The assets of the pool this oracle provides prices for |
ExecuteMsg
update
Updates the TWAP from the pool's cumulative prices. It can only run once a full period (1 day) has passed since the last update. Anyone can call it.
QueryMsg
consult
Multiplies a token amount (of a token in the target pool) by the latest TWAP for that token. Returns a vector of (AssetInfo, Uint256): the other asset and the amount.
| Params | Type | Description |
|---|---|---|
token | AssetInfo | The asset to price |
amount | Uint128 | The amount of that asset |