get-valid-time-period.ts 800 B

123456789101112131415161718
  1. import { readApi, solidity, ethersJS } from "./common";
  2. export const getValidTimePeriod = readApi<never>({
  3. name: "getValidTimePeriod",
  4. summary: "Get the default valid time period of price freshness in seconds.",
  5. description: `
  6. This method returns the default valid time period of price freshness in **seconds**.
  7. This quantity is the maximum age of price updates returned by functions like [getPrice](getPrice) and
  8. [getEmaPrice](getEmaPrice); these functions revert if the current on-chain price
  9. is older than this period. The valid time period is configured to be a sane
  10. default for each blockchain.
  11. `,
  12. parameters: [],
  13. code: [
  14. solidity("uint validTimePeriod = pyth.getValidTimePeriod();"),
  15. ethersJS("const [validTimePeriod] = await contract.getValidTimePeriod();"),
  16. ],
  17. });