get-valid-time-period.ts 805 B

12345678910111213141516171819
  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.
  10. The valid time period is configured to be a same default for each blockchain.
  11. `,
  12. parameters: [],
  13. code: [
  14. solidity("uint validTimePeriod = pyth.getValidTimePeriod();"),
  15. ethersJS("const [validTimePeriod] = await contract.getValidTimePeriod();"),
  16. ],
  17. });