Price Oracle¶
About this page
- Protocol: JustLend DAO
- Network:* TRON Mainnet
- Pattern:
PriceOracleProxy(entrypoint,TGnYnSn4G9PgWFj7QQemh4YMZKp3fkympJ) →PriceOracle(impl,TMiNCmvD3zdsv6mk7niBU6NPBzVNjYMQTV) - Data source: Chainlink Data Feeds. The
posteraddress relays Chainlink prices on-chain viasetPrice(asset, price) - Units: Prices are denominated in TRX , scaled by
1e^(33 - tokenDecimal). For an 18-decimal token like USDD, the value for the price feed is calculated based on the exchange rate of 1 USDD to TRX (assuming a price of 3.0266), Price Feed Value = 3.0266 * 1e^(33 - 18) = 3.0266 * 1e^15 - ABI:
abis/price-oracle.json.
Blockchain-powered smart contracts, by design, cannot access external market data directly. To ensure accurate and tamper-resistant pricing, the JustLend DAO protocol relies on a multi-source data aggregation system that draws from reputable and decentralized sources.
Chainlink Data Feeds are the key component of this process, helping to strengthen the security and reliability of pricing across markets.
PriceOracle.sol: allows users to:
- Price Poster
- Get Asset Price
- Set Price
The source code is available on Github.
Contracts ABI¶
Anchor Token Price¶
Calling this methods returns the current price anchor of a specified token.
function anchors(address) view returns(uint256, uint256)
- Parameter description:
token:the address of the underlying token(e.g. TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t for USDT).
- Returns:
period:the current time period. Calculated as: current block height/ 600 (the TRON network produces approx. 600 blocks per 30 mins);priceMantissa:the current price of the token in TRX, scaled by 1e^(33 - tokenDecimal).
Price Poster¶
Calling this methods returns the current price poster.
function poster() view returns(address)
- Parameter description: N/A.
- Returns: Address of the current poster.
Asset Prices¶
Calling this method returns the current price of the specified asset.
function assetPrices(address asset) public view returns (uint)
- Parameter description:
asset:the address of the token to query.
- Returns: the current price of the token in TRX, scaled by 1e^(33 - tokenDecimal).
Get Price¶
Calling this method returns the current price of the specified asset.
function getPrice(address asset) public view returns (uint)
- Parameter description:
asset:the address of the token to query.
- Returns: the current price of the token in in TRX, scaled by 1e^(33 - tokenDecimal).
Set Price (poster-only)¶
Calling this methods set a token price for the current time period.
function setPrice(address asset, uint requestedPriceMantissa) public returns (uint)
- Parameter description:
asset:the address of the underlying token (e.g. TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t for USDT);requestedPriceMantissa:new price, scaled by 10^27.- Returns: 0 for success, otherwise an error code.