JustLend DAO Docs
JustLend DAOAuditWhat's New
  • GETTING STARTED
    • Overview
    • Concepts
      • Supply
      • Borrow
      • Withdraw
      • Repay
      • Liquidations
      • Risks
      • Staked TRX
      • Energy Rental
    • Whitepaper
    • FAQs
      • ​​Wallet Connection Questions
      • More Questions
  • GOVERNANCE
    • JIPs
    • Tokenomics
    • Community Forum
  • DEVELOPERS
    • Contracts Overview
    • Supply and Borrow Market
      • SBM
      • Interest Rate Model
      • Governance
      • Price Oracle
      • Comptroller
    • Staked TRX
    • Energy Rental
    • Deployed Contracts
    • APIs
      • Supply and Borrow Market
        • Get Supply and Borrow Market Information
        • Get Account Information
        • Get Market Mining APY Information
        • Get User Supply Mining Reward Information
        • Get User Supply Mining Reward Distributions
      • Staked TRX and Energy Rental Market
        • Get Staked TRX and Energy Rental Markets Information
        • Get User Data of sTRX Liquidity Staking
        • Get User Data of Resource Rent
  • Resources
    • Community
      • Links
      • Wallet Integration Cooperation
    • Risk Warning
    • Audits
      • Supply & Borrow
      • Staked TRX
    • Terms of Service
      • Terms of Service
      • Privacy Policy
Powered by GitBook
On this page
  • Introduction
  • Contracts ABI
  • Anchor Token Price
  • Price Poster
  • Asset Prices
  • Get Price
  • Set Price (poster-only)
  1. DEVELOPERS
  2. Supply and Borrow Market

Price Oracle

PreviousGovernanceNextComptroller

Last updated 12 days ago

Introduction

As blockchain-powered smart contracts are unable to directly communicate with the external system, JustLend DAO protocol requires reliable price feeds. We have chosen Data Feeds as our primary Oracle on the Tron network to secure various markets. JustLend DAO protocol uses a contract to set and display token prices in sun(10^-6 TRX), scaled by 10^(tokenDecimal - 6). Prices of the underlying tokens are posted every 30 minutes via setPrice()by a specified poster.

SimplePriceOracle.sol allows users to:

  • Price Poster

  • Get Asset Price

  • Set Price

The source code is available on .

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: token prices in sun(10^-6 TRX), scaled by 10^(tokenDecimal - 6).


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 sun(10^-6 TRX), scaled by 10^(tokenDecimal - 6).


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 sun(10^-6 TRX), scaled by 10^(tokenDecimal - 6).


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.

Chainlink
PriceOracle
Github