githubEdit

Data Pair Conversion

The list of data pairs offered by Supra is getting longer every day, but sometimes you might not find the exact pair that you have been looking for. In such instances, the data pair conversion functionality will come in handy. The data pair conversion process requires just two simple steps:

Step 1: Request for the bytes proof of two input pairs you would be using to derive a new pair via Web2 and verify the prices with the Supra Pull contract. Step 2: Request for a data pair conversion by interacting with the Supra Storage Contract.

So, let's demonstrate how it works with an example case.

Step 1 : Inherit or copy these interfaces into the contract


interface ISupraSValueFeed {

    struct derivedData{
        int256 roundDifference;
        uint256 derivedPrice;
        uint256 decimals;
    }

    function getDerivedSvalue(uint256 pair_id_1,uint256 pair_id_2,uint256 operation)
        external
        view
        returns (derivedData memory);

}

Step 2 :: Interface with the Supra Pull Contract and Storage Contract

contract MockOracleClient is Ownable {
    // The oracle pull contract address
    ISupraOraclePull public supra_pull;
    // The oracle storage contract address
    ISupraSValueFeed public supra_storage;


    // Event emitted when a pair price is received
    event PairPrice(uint256 pair, uint256 price, uint256 decimals);

    constructor(ISupraOraclePull pull_, ISupraSValueFeed storage_) {
        supra_pull = pull_;
        supra_storage = storage_; // Supra storage contract address
    }
}

Step 3 :: Add this function to fetch the derived price pair

Step 4 :: (Recommended) Update the Supra Pull and Storage Contracts

Below is an example implementation on how your contract would look like:

Last updated