The following is an example of how you can integrate DIA’s oracle into your smart contract with Vyper:
# @version ^0.3.6 ORACLE: constant(address) = 0xCD5F78206ca1FF96Ff4c043C61a2299B2Febf3cB latestPrice: public(uint128) timestampOfLatestPrice: public(uint128) interface IDIAOracleV2: def getValue(key: String[7]) -> (uint128, uint128): nonpayable @external def getPriceInfo(key: String[7]): self.latestPrice, self.timestampOfLatestPrice = IDIAOracleV2(ORACLE).getValue(key) @view @external def checkPriceAge(maxTimePassed: uint128) -> bool: inTime: bool = False if (convert(block.timestamp, uint128) - self.timestampOfLatestPrice) < maxTimePassed: inTime = True else: inTime = False return inTime
Vyper integration example
Was this page helpful?