Skip to main content

Oracle

Overview

This Oracle contract calculates a 1 day TWAP for a xy=k Astroport pool.

InstantiateMsg

Instantiates the Oracle contract.

json
oracle.rs
Copy

_15
{
_15
"factory_contract": "terra...",
_15
"asset_infos": [
_15
{
_15
"token": {
_15
"contract_addr": "..."
_15
}
_15
},
_15
{
_15
"native_token": {
_15
"denom": "..."
_15
}
_15
}
_15
]
_15
}

ParamsTypeDescription
factory_contractStringThe factory contract address
asset_infosVec<AssetInfo>The assets that have a pool for which this contract provides price feeds

ExecuteMsg

update

Updates the local TWAP value and the target pair's cumulative prices.

json
oracle.rs
Copy

_3
{
_3
"update": {}
_3
}

QueryMsg

consult

Multiplies a token amount (token that's present in the target pool for the TWAP) by the latest TWAP value for that token.

json
oracle.rs
Copy

_10
{
_10
"consult": {
_10
"token": {
_10
"native_token": {
_10
"denom": "..."
_10
}
_10
},
_10
"amount": "1000000"
_10
}
_10
}

ParamsTypeDescription
tokenAssetInfoThe asset for which to compute a new TWAP value
amountUint128The amount of tokens for which to compute the token price

Returns a vector that contains objects of type (AssetInfo, Uint256)