$VANRY Token Price API

To ensure that the end users always get charged a fixed fee of $0.0005 in terms of fiat value for every transaction on Vanar, we have a rigorous system in place where the price is regularly updated at the protocol level using the market price of the VANRY token. The market price is validated via multiple sources including DEXs, CEXs and other data providers ( CoinGecko, CoinMarketCap, Binance) to ensure a reliable price. Outliers from any source that deviates from the others by a large margin is eliminated from the price calculation to avoid any price manipulation.

Below are the steps and components involved to fetch the VANRY price from different sources, aggregating and updating the transaction fee based on the current VANRY price:

  • Price fetcher - First an independent job constantly updates the VANRY price from different sources using APIs and RPCs at set intervals and logs this information along with the timestamp in a database which is to be used by the price aggregator to compute the latest transaction fees.

  • Price aggregator - The price aggregator then uses the price feed to calculate the VANRY price based on the latest price fetched from multiple sources. This aggregator only uses the latest price from each source fetched in the last 5 minutes.

    • Threshold - The price aggregator calculates the latest transaction fees only when the latest price is available from N number of available sources. For example, if we are fetching the VANRY price from 10 different sources and we have set the threshold value as 5, then the latest price from at least 5 sources must be available in last X minutes at the time of price aggregation.

    • System alerts - In the event the latest prices from different sources are not available (minimum threshold criteria not met), the system generates alerts in to notify the team to address the situation.

    • Price cleansing - While calculating the transaction fee based on the latest VANRY token price, we ensure that any price from a particular source that deviates from the sources by a large margin is considered an outlier and is not considered. This is to make sure that there is no impact due to sudden price movement.

  • Persist new price - Once the new price is calculated by the price aggregator, this price is updated at the protocol level and the latest blocks always read the transaction fees from this single source of truth that is available all the times at the protocol level.

This latest transaction fees and token price are stored in a highly available system to serve the feed to the protocol whenever it is needed, and is served via an API to the validator nodes.

How transaction fees are used

The latest transaction fees are fetched from the source via the transaction fee API every 100th block. The latest transaction fees is valid for next 100 blocks, after which time it is updated again via the API at protocol level.

If the block difference from the block number when the price was last updated to the current block is more than 100 then it retrieves to the latest price to use and updates it at protocol level.

Fallback mechanism

In the event that the protocol is not able to read the current transaction fees via the API for any reason (like service is down for example or request times out within 1 second time) then the new block will read the transaction fees from the parent/last block to make sure the most realistic price is used.

Last updated