vToken APIs

There are three ways to query vToken exchange price:

  1. Use the Bifrost Runtime API, which is the most up-to-date and accurate method.

  2. Call EVM contract on Moonbeam.

  3. API for Frontend (with more vToken related storages)

Bifrost Runtime API (Get vToken Exchange Rate)

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fbifrost-polkadot-rpc.dwellir.com#/runtime

vtokenMintingRuntimeApi

  1. getCurrencyAmountByVCurrencyAmount

  2. getVCurrencyAmountByCurrencyAmount

As the showcase above, token2:0 is DOT and vtoken2:0 is vDOT on Bifrost Polkadot, getCurrencyAmountByVCurrencyAmount is to input vDOT amount (with decimals) to query the exchange price in DOT.

Check the Token indexs via here.

Bifrost Runtime API (Get vToken Price from Stable Swap)

Bifrost Runtime API (Get vToken Price from Stable Swap)

_calcOutGivenIn/_calcInGivenOut is the method we use to query vToken prices from the Stable Pool, querying the price from DOT/vDOT stable pool as shown in the example below:

Some parameter you need to get from Bifrost storage as explained below:

You can find poolBalances and futureA from stableAsset.pool:

You can find rateToken from stableAsset.tokenRateCaches:

Below is the full example of how we get vDOT-DOT price from Stable Pool:

EVM contract on Moonbeam

Query the exchange rate from SLPx contract on Moonbeam:

https://github.com/bifrost-io/slpx-contracts?tab=readme-ov-file#xcmoracle

Check more details at here.

API for Frontend

exchangeRatio is to get Token by vToken

Api 1: Includes the following queryable interfaces

Api 2: Includes the following queryable interfaces

Last updated

Was this helpful?