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
Step 2 :: Interface with the Supra Pull Contract and Storage Contract
contractMockOracleClientisOwnable {// 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 receivedeventPairPrice(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
function GetDerivedPairPrice(bytes calldata _bytesProof, uint256 pair_id_1,uint256 pair_id_2,uint256 operation) external
{ supra_pull.verifyOracleProof(_bytesProof);// derivedData is the structure for derived price and dp stores the derived price data ISupraSValueFeed.derivedData memory dp = ISupraSValueFeed(supra_storage).getDerivedSvalue(pair_id_1,pair_id_2,operation);
}
Step 4 :: (Recommended) Update the Supra Pull and Storage Contracts