Crates.io | drt-price-aggregator-sc |
lib.rs | drt-price-aggregator-sc |
version | 0.0.3 |
source | src |
created_at | 2024-08-28 03:56:04.187237 |
updated_at | 2024-09-02 02:18:44.080403 |
description | Dharitri Price aggregator Smart Contract |
homepage | https://dharitri.com/ |
repository | https://github.com/DharitriOne/drt-sdk-rs |
max_upload_size | |
id | 1354092 |
size | 199,425 |
The price-aggregator smart contract keeps track of the price between multiple pairs of tokens. Compared to the other chainlink contracts, it is a simplified and easier to use version.
Arguments:
staking_token
- the token used for staking and slashingstaking_amount
- the minimum staked amount required for a used to be considered a board memberslash_amount
- the amount to be slashed from a board member on a successful slash voteslash_quorum
- the minimum number of board members required for a vote to be considered successfuloracles
- the list of addresses which are allowed to submit price feed updatessubmission_count
- the minimum number of submissions from different oracles which trigger an update of the price feedThe number of decimals for a given token pair can be set by calling setPairDecimals(from, to, decimals)
. Notes:
An oracle can submit a price feed update using one of the endpoints:
submit
- submit a single price feed as 5 arguments (from
, to
, submission_timestamp
, price
and decimals
).submitBatch
- submit multiple price feeds simultaneously. The number of arguments must be a multiple of 5.Note: the decimals argument must match the value returned by getPairDecimals
for that specific pair, otherwise the submission will be rejected.
Price feeds from multiple oracles are collected. When a certain threshold number of submissions has been reached (given by submission_count
), a new round is created.
The price feed recorded in the round is the median value out of all submissions made.
Endpoints:
latestRoundData
takes no arguments and returns all the latest price feeds.latestPriceFeed
takes a filter (as the from
and to
token identifiers) and returns a single price feed. The transaction fails if there is no price feed for the given filter.latestPriceFeedOptional
behaves like latestPriceFeed
but it returns an option so that the caller can handle the lack of a price feed.A price feed contains:
round_id
- the ID of the current round (not related to the blockchain round ID)from
- the first tokento
- the second tokenprice
- the price between the two tokensdecimals
- the number of decimals for the price