Always verify the timestamp of an oracle response before using the price.
Standard DIA price oracles return the price together with the UNIX timestamp of its last update. The oracle does not revert when a price is old: if updates stop or are paused, it keeps returning the last stored price. Your contract is responsible for deciding whether that price is recent enough to use.
Always check the timestamp of an oracle response. Using a price without checking its age can expose your protocol to stale-price attacks, such as borrowing, liquidating or swapping against an outdated value.
Why a price can be stale
Heartbeat interval. Oracles update on a price deviation or a heartbeat, whichever comes first. Between updates the stored price ages normally.
Market conditions. A feed can hold its last price during unusual market conditions.
Market hours. Real-world asset feeds (stocks, ETFs, FX, commodities) may not update while their markets are closed.
Infrastructure issues. An unfunded gas wallet, network congestion or a cross-chain delivery delay can delay updates.
Set a maximum delay
Define the maximum age of a price your protocol accepts. There is no single correct value: update settings differ per oracle, so base it on your oracle’s heartbeat plus a buffer for network delays.
// Your oracle's heartbeat plus a buffer, e.g. 1 hour heartbeat + 10 minutesuint128 constant MAX_DELAY = 70 minutes;
Do not set it below the heartbeat, or valid prices will be rejected between updates.
Set it per asset. A volatile token needs a tighter limit than a stablecoin.
For RWA feeds, decide how your protocol behaves when the market is closed: pause the affected actions, or accept the last close for a defined period.
The checks below go inside your contract’s functions. Each one first confirms the timestamp is not ahead of the current block, then checks its age, so a small clock difference between chains reverts with a clear message instead of an arithmetic error.
Using getValue
getValue returns the price first, then the timestamp.
Revert, pause the affected function, or switch to a fallback source. Never silently continue with the stale value.If the key has never been updated, the oracle returns 0 for both price and timestamp. The timestamp check above rejects this case, but you can also add require(price > 0) as an extra safeguard.
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"DIA · Blockchain Oracles","description":"Verifiable blockchain oracle infrastructure for DeFi and institutions. Market and fundamental price feeds, reserve verification, and more.","colors":{"primary":"#000000","light":"#B8FF9D","dark":"#000000"},"logo":{"light":"https://mintcdn.com/diadata/9lX_sa90a9XlPedd/logo/light.svg?fit=max\u0026auto=format\u0026n=9lX_sa90a9XlPedd\u0026q=85\u0026s=0647d9519c7b40aca228dfe6bcd68e40","dark":"https://mintcdn.com/diadata/9lX_sa90a9XlPedd/logo/dark.svg?fit=max\u0026auto=format\u0026n=9lX_sa90a9XlPedd\u0026q=85\u0026s=b37960e762410232222872b2f71763c5","href":"https://www.diadata.org/"},"favicon":"https://mintcdn.com/diadata/9lX_sa90a9XlPedd/favicon.svg?fit=max\u0026auto=format\u0026n=9lX_sa90a9XlPedd\u0026q=85\u0026s=1c340dddac7f3e5c9762c3f8d1f9b1c2","appearance":{"default":"system"},"background":{"color":{"light":"#FFFFFF","dark":"#000000"}},"navbar":{"links":[{"icon":"arrow-right","href":"https://www.diadata.org/app/","label":"Explore data"}],"primary":{"type":"button","label":"Talk to us","href":"https://www.diadata.org/contact/"}},"footer":{"socials":{"x":"https://twitter.com/DIAdata_org","discord":"https://discord.gg/RjHBcZ9mEH","telegram":"https://t.me/diadata_org","linkedin":"https://www.linkedin.com/company/diadata-org","medium":"https://www.diadata.org/blog","github":"https://github.com/diadata-org"}},"seo":{"metatags":{"google-site-verification":"9Cd9xvn3OiQzLUJ7cOS7cZ1Qejq8Cqa9j_lxzfXurDM"}},"fonts":{"heading":{"family":"Matter"},"body":{"family":"Matter"}},"styling":{"codeblocks":"system","latex":true},"integrations":{"posthog":{"apiKey":"phc_98rVByHjJm7K6tMshM85wvyM0Lc4rXaDp12JkKC5XdL","sessionRecording":true}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"navigation":{"global":{"anchors":[{"anchor":"Talk to a dev","icon":"discord","href":"https://discord.gg/RjHBcZ9mEH"},{"anchor":"Blog Updates","icon":"newspaper","href":"https://www.diadata.org/blog/"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"diadata","hasAudioNarration":false,"actualSubdomain":"diadata","customDomains":["www.diadata.org"],"gitSource":{"type":"github","owner":"diadata-org","repo":"dia-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af37cdb852f6902678afdf9","clientVersion":"0.0.4271","searchFilterCounts":[{"language":"default","tag":"Guides","count":107},{"language":"default","tag":"Chain-specific Guides","count":55},{"language":"default","tag":"Supported Chains","count":53},{"language":"default","tag":"API Reference","count":25},{"language":"default","tag":"Token Prices","count":20},{"language":"default","tag":"General Guides","count":19},{"language":"default","tag":"RestAPI","count":17},{"language":"default","tag":"DIA Stack","count":16},{"language":"default","tag":"Resources","count":12},{"language":"default","tag":"How-to Guides","count":11}]},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"@font-face{font-family:\"Matter\";src:url(\"https://www.diadata.org/docs/fonts/Matter-Regular.woff2\") format(\"woff2\"),\n url(\"https://www.diadata.org/docs/fonts/Matter-Regular.woff\") format(\"woff\");font-weight:400;font-style:normal}@font-face{font-family:\"Matter\";src:url(\"https://www.diadata.org/docs/fonts/Matter-SemiBold.woff2\") format(\"woff2\"),\n url(\"https://www.diadata.org/docs/fonts/Matter-SemiBold.woff\") format(\"woff\");font-weight:600;font-style:normal}@font-face{font-family:\"Matter Mono\";src:url(\"https://www.diadata.org/docs/fonts/MatterMono-Regular.woff2\") format(\"woff2\"),\n url(\"https://www.diadata.org/docs/fonts/MatterMono-Regular.woff\") format(\"woff\");font-weight:400;font-style:normal}@font-face{font-family:\"Matter\";src:url(\"https://www.diadata.org/docs/fonts/Matter-Medium.woff2\") format(\"woff2\");font-weight:500;font-style:normal}@font-face{font-family:\"Matter Mono\";src:url(\"https://www.diadata.org/docs/fonts/MatterMono-Medium.woff2\") format(\"woff2\");font-weight:500;font-style:normal}h1,h2,h3,h4,h5,h6{font-family:\"Matter\";font-weight:400}h1,h2{letter-spacing:-0.01em}body{font-family:\"Matter\";font-weight:400}.prose p,.prose li{color:#404040!important}.dark .prose p,.dark .prose li{color:#CCCCCC!important}.nav-tabs a,.nav-tabs-item,[class*=\"nav-tabs\"] a{font-family:\"Matter Mono\"!important;text-transform:uppercase!important;font-size:12px!important;letter-spacing:0.06em!important}#navigation-items h5,.sidebar-group-header h5{font-family:\"Matter Mono\"!important;text-transform:uppercase!important;font-size:11px!important;letter-spacing:0.08em!important;color:#999999!important}#navigation-items a:hover:not([class*=\"bg-primary\"]):not(.nav-anchor),#navigation-items button:hover{background-color:#F1F1F1!important;outline:none!important;border-radius:0!important}#navigation-items a[class*=\"bg-primary\"]{background-color:#F1F1F1!important;outline:none!important;box-shadow:inset 2px 0 0 #000000!important;color:#000000!important;border-radius:0!important}.dark #navigation-items a:hover:not([class*=\"bg-primary\"]):not(.nav-anchor),.dark #navigation-items button:hover{background-color:#1B1B1B!important;outline:none!important;border-radius:0!important}.dark #navigation-items a[class*=\"bg-primary\"]{background-color:#1B1B1B!important;outline:none!important;box-shadow:inset 2px 0 0 #B8FF9D!important;color:#FFFFFF!important;border-radius:0!important}.callout{background-color:#F1F1F1!important;border-color:#E5E5E5!important}.callout svg,.callout i{color:#000000!important;fill:#000000!important}.callout a{color:#000000!important;text-decoration:underline!important}.dark .callout{background-color:#1B1B1B!important;border-color:#262626!important}.dark .callout svg,.dark .callout i{color:#B8FF9D!important;fill:#B8FF9D!important}.dark .callout a{color:#B8FF9D!important}.card{background-color:#FFFFFF!important;border:1px solid #E5E5E5!important;border-radius:0!important;box-shadow:none!important}.card:hover{border-color:#000000!important;box-shadow:none!important}.dark .card{background-color:#000000!important;border-color:#262626!important}.dark .card:hover{border-color:#B8FF9D!important;box-shadow:none!important}.card h2,.card [class*=\"font-semibold\"]{font-family:\"Matter\"!important;font-weight:400!important;font-size:18px!important}.prose :not(pre)>code{border-radius:0!important;background-color:#F1F1F1!important;color:inherit!important;border:none!important}.dark .prose :not(pre)>code{background-color:#1B1B1B!important}.prose a{color:#000000!important;text-decoration:underline!important;text-decoration-color:#CCCCCC!important}.prose a:hover{text-decoration-color:#000000!important}.dark .prose a{color:#B8FF9D!important}#search-bar-entry,#assistant-entry,#assistant-entry-mobile,#page-context-menu-button,#page-context-menu-button+button,#feedback-thumbs-up,#feedback-thumbs-down,.card{border-radius:0!important}#feedback-thumbs-up:hover,#feedback-thumbs-down:hover{border-color:#000000!important}.dark #feedback-thumbs-up:hover,.dark #feedback-thumbs-down:hover{border-color:#B8FF9D!important}#page-context-menu-button:hover,#page-context-menu-button+button:hover{border-color:#000000!important;background-color:transparent!important}#page-context-menu-button:hover{border-right:1px solid #000000!important}.dark #page-context-menu-button:hover,.dark #page-context-menu-button+button:hover{border-color:#B8FF9D!important}.dark #page-context-menu-button:hover{border-right:1px solid #B8FF9D!important}[class*=\"border-t\"][class*=\"flex\"][class*=\"justify-between\"]{margin-top:3rem!important;padding-top:1.5rem!important}.dia-kicker{font-family:\"Matter Mono\"!important;font-weight:500!important;font-size:12px!important;text-transform:uppercase!important;letter-spacing:0.08em!important;color:#666666!important}.dark .dia-kicker{color:#999999!important}.dia-btn{position:relative;overflow:hidden;display:inline-flex!important;align-items:center;justify-content:space-between;gap:24px;min-width:220px;min-height:50px;padding:8px 16px;font-family:\"Matter Mono\"!important;font-weight:500;font-size:14px;line-height:1.2;text-transform:uppercase;letter-spacing:0.08em;text-align:left;text-decoration:none!important;border-radius:0!important;transition:all 0.3s ease}.dia-btn>span[data-as=\"p\"]{display:contents}.dia-btn-label{position:relative;z-index:1;max-width:14ch}.dia-btn-arrow{position:relative;z-index:1;width:24px;height:24px;flex-shrink:0;overflow:hidden;display:flex;align-items:center;justify-content:center}.dia-btn-arrow img{position:absolute;width:18px;height:11px;margin:0!important;transition:transform 0.3s ease}.dia-btn-arrow img:nth-child(1){transform:translateX(0)}.dia-btn-arrow img:nth-child(2){transform:translateX(-24px)}.dia-btn:hover .dia-btn-arrow img:nth-child(1){transform:translateX(24px)}.dia-btn:hover .dia-btn-arrow img:nth-child(2){transform:translateX(0)}.dia-btn::before{content:\"\";position:absolute;inset:0;background:url(\"images/brand/mesh-gradient.jpg\") no-repeat center / cover;opacity:0;transition:opacity 0.3s ease}.dia-btn:hover::before{opacity:1}.dia-btn-green{background:#B8FF9D!important;color:#000!important;border:1px solid #B8FF9D!important}.dia-btn-outline{background:transparent!important;color:#000!important;border:1px solid #000!important}.dia-btn:hover{border-color:transparent!important;color:#000!important}.dark .dia-btn-outline{color:#fff!important;border-color:#fff!important}.dark .dia-btn-outline:hover{color:#000!important}.dark .dia-btn-outline .dia-btn-arrow img{filter:invert(1)}.dark .dia-btn-outline:hover .dia-btn-arrow img{filter:none}.dia-btn-outline-dark{background:transparent!important;color:#fff!important;border:1px solid rgba(255,255,255,0.6)!important}.dia-btn-outline-dark:hover{color:#000!important;border-color:transparent!important}.dia-btn-outline-dark:hover .dia-btn-arrow img{filter:invert(1)}@media (max-width: 1023px){.dia-btn{min-width:0;flex:1 1 0;gap:12px;padding:8px 12px;font-size:12px}}.dia-hairline-row{border-top:1px solid #E5E5E5!important;padding:20px 0!important}.dark .dia-hairline-row{border-top-color:#262626!important}.dia-tile{position:relative;display:flex;flex-direction:column;justify-content:space-between;gap:24px;min-height:160px;padding:20px;background:#F1F1F1!important;border-radius:0!important;text-decoration:none!important;color:#000!important}.dia-tile::before{content:\"\";position:absolute;inset:0;background:url(\"images/brand/mesh-gradient.jpg\") no-repeat center / cover;opacity:0;transition:opacity 0.3s ease}.dia-tile:hover::before{opacity:1}.dia-tile>*{position:relative;z-index:1}.dark .dia-tile{background:#1B1B1B!important;color:#fff!important}.dark .dia-tile:hover,.dark .dia-tile:hover *{color:#000!important}.dia-tile-label{font-family:\"Matter Mono\"!important;font-weight:500!important;font-size:12px!important;text-transform:uppercase!important;letter-spacing:0.08em!important;color:#666666!important}.dark .dia-tile-label{color:#999999!important}.dia-tile-title{font-family:\"Matter\"!important;font-weight:400!important;font-size:24px!important;line-height:1.2!important;letter-spacing:-0.01em!important}.dia-tile-body{font-family:\"Matter\"!important;font-weight:400!important;font-size:15px!important;line-height:1.4!important;color:#666666!important}.dark .dia-tile-body{color:#999999!important}.dia-tile-arrow{align-self:flex-end}.dia-tile:hover .dia-btn-arrow img:nth-child(1){transform:translateX(24px)}.dia-tile:hover .dia-btn-arrow img:nth-child(2){transform:translateX(0)}.dark .dia-tile .dia-btn-arrow img{filter:invert(1)}.dark .dia-tile:hover .dia-btn-arrow img{filter:none}.dia-band-grey{background:#F1F1F1;padding:64px 0}@media (min-width: 1024px){.dia-band-grey{padding:96px 0}}.dark .dia-band-grey{background:#1B1B1B}.dia-band-grey .dia-tile{background:#FFFFFF!important}.dark .dia-band-grey .dia-tile{background:#000000!important}.dia-stat-value{font-family:\"Matter\"!important;font-weight:400!important;font-size:40px!important;letter-spacing:-0.02em!important}.dia-stat-label{font-family:\"Matter Mono\"!important;font-weight:500!important;font-size:12px!important;text-transform:uppercase!important;letter-spacing:0.08em!important;color:#666666!important}.dark .dia-stat-label{color:#999999!important}.dia-btn>span[data-as=\"p\"]{display:contents}.dia-fold{text-align:center}.dia-fold h1{font-size:36px;line-height:1;letter-spacing:-0.01em;font-weight:400}@media (min-width: 1024px){.dia-fold h1{font-size:64px}}.dia-fold-sub{font-family:\"Matter Mono\";font-size:15px;line-height:1.4;color:#404040;max-width:522px;margin:0 auto}.dark .dia-fold-sub{color:#CCCCCC}.dia-fold{position:relative;overflow:hidden}.dia-fold>.dia-fold-content{position:relative;z-index:1}.dia-dial{position:absolute;left:50%;top:50%;width:max(1100px, 80vw);aspect-ratio:1 / 1;pointer-events:none;z-index:0;transform:translate(-50%, -50%) rotate(0deg);animation:dia-dial-rotate 240s linear infinite}.dia-dial img{width:100%;height:100%;margin:0!important;max-width:none!important}.dia-dial-on-dark{display:none}.dark .dia-dial-on-light{display:none}.dark .dia-dial-on-dark{display:block}@keyframes dia-dial-rotate{from{transform:translate(-50%, -50%) rotate(0deg)}to{transform:translate(-50%, -50%) rotate(360deg)}}@media (max-width: 1023px){.dia-dial{display:none}}@media (prefers-reduced-motion: reduce){.dia-dial{animation:none}}.dia-layers{display:grid;gap:24px}@media (min-width: 1024px){.dia-layers{grid-template-columns:repeat(3, minmax(0, 1fr));gap:20px}}.dia-layer{position:relative;display:grid;text-decoration:none!important;color:#fff;border-style:solid;border-color:rgba(255,255,255,0.2);border-width:1px 0 0 0;padding-top:16px;grid-template-areas:\"title number\" \"text text\";grid-template-columns:1fr auto;gap:12px}@media (min-width: 1024px){.dia-layer{border-width:0 0 0 1px;padding-top:0;padding-left:20px;min-height:280px;grid-template-rows:auto 1fr;row-gap:48px}}.dia-layer-bg{position:absolute;inset:-10px -20px -10px 0;background:#1B1B1B;opacity:0;transition:opacity 0.4s ease;z-index:0}.dia-layer:hover .dia-layer-bg{opacity:1}.dia-layer-title{grid-area:title;position:relative;z-index:1;font-family:\"Matter\";font-weight:400;font-size:20px;line-height:1.2;letter-spacing:-0.01em;color:#fff;max-width:12ch}@media (min-width: 1024px){.dia-layer-title{font-size:24px}}.dia-layer-number{grid-area:number;position:relative;z-index:1;font-family:\"Matter Mono\";font-size:15px;line-height:1.4;color:#fff}.dia-layer-sub{display:block;margin-top:8px;font-family:\"Matter Mono\";font-weight:500;font-size:12px;line-height:1.2;text-transform:uppercase;letter-spacing:0.08em;color:#999999}.dia-layer-text{grid-area:text;align-self:end;position:relative;z-index:1;font-family:\"Matter Mono\";font-size:15px;line-height:1.4;color:#CCCCCC;margin:0}li.navbar-link>a,#topbar-cta-button>a{position:relative;overflow:hidden;display:inline-flex!important;align-items:center;justify-content:space-between;gap:24px;min-width:144px;min-height:38px;padding:4px 12px!important;border-radius:0!important;font-family:\"Matter Mono\"!important;font-weight:500!important;font-size:12px!important;line-height:1.2!important;text-transform:uppercase;letter-spacing:0.08em;white-space:normal!important;text-align:left;color:#000!important;isolation:isolate}li.navbar-link>a span,#topbar-cta-button>a span:not(.absolute){max-width:8ch;white-space:normal!important;overflow:visible!important;text-overflow:clip!important;color:#000!important;position:relative;z-index:1}li.navbar-link>a svg,#topbar-cta-button>a svg{display:none!important}li.navbar-link>a::after,#topbar-cta-button>a::after{content:\"\";position:relative;z-index:1;width:24px;height:24px;flex-shrink:0;background-image:url(\"/images/brand/arrow-right-black.svg\"), url(\"/images/brand/arrow-right-black.svg\");background-repeat:no-repeat, no-repeat;background-size:18px 11px, 18px 11px;background-position:3px center, -21px center;transition:background-position 0.3s ease}li.navbar-link>a:hover::after,#topbar-cta-button>a:hover::after{background-position:27px center, 3px center;transform:none}li.navbar-link>a::before,#topbar-cta-button>a::before{content:\"\";position:absolute;inset:0;background:url(\"/images/brand/mesh-gradient.jpg\") no-repeat center / cover;opacity:0;transition:opacity 0.3s ease;z-index:0}li.navbar-link>a:hover::before,#topbar-cta-button>a:hover::before{opacity:1}li.navbar-link>a{border:1px solid #404040;background:transparent}li.navbar-link>a:hover{border-color:transparent}.dark li.navbar-link>a{border-color:rgba(255,255,255,0.6);color:#fff!important}.dark li.navbar-link>a span{color:#fff!important}.dark li.navbar-link>a::after{filter:invert(1)}.dark li.navbar-link>a:hover span{color:#000!important}.dark li.navbar-link>a:hover::after{filter:none}#topbar-cta-button>a>span.absolute{background:#B8FF9D!important;border-radius:0!important;opacity:1!important;z-index:-1!important}#topbar-cta-button>a{border:1px solid #B8FF9D}#topbar-cta-button>a>div{gap:24px!important;position:relative;z-index:1}nav ul.space-x-6>li{margin-left:0!important;margin-right:0!important;margin-inline:0!important}nav ul.space-x-6{gap:8px}nav:has(li.navbar-link){margin-inline-end:0!important;margin-right:0!important}div:has(>#theme-preference-menu-trigger){margin-left:8px!important;margin-inline-start:8px!important}#theme-preference-menu-trigger{width:38px;height:38px;padding:0!important;border:1px solid #404040!important;border-radius:0!important;display:flex;align-items:center;justify-content:center;color:#000!important;background:transparent;transition:background-color 0.2s ease}#theme-preference-menu-trigger:hover{background:#F1F1F1}.dark #theme-preference-menu-trigger{border-color:rgba(255,255,255,0.6)!important;color:#fff!important}.dark #theme-preference-menu-trigger:hover{background:#1B1B1B}"}]}
{"page":{"pagePath":"title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la","slug":"/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la","pageMetadata":{"title":"Check Price Freshness","description":"Always verify the timestamp of an oracle response before using the price.","href":"/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Always verify the timestamp of an oracle response before using the price.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Standard DIA price oracles return the price together with the UNIX timestamp of its last update. The oracle does not revert when a price is old: if updates stop or are paused, it keeps returning the last stored price. Your contract is responsible for deciding whether that price is recent enough to use.`}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Always check the timestamp of an oracle response. Using a price without checking its age can expose your protocol to stale-price attacks, such as borrowing, liquidating or swapping against an outdated value.`})}),`\n`,_jsx(Heading,{level:`2`,id:`why-a-price-can-be-stale`,children:`Why a price can be stale`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Heartbeat interval.`}),` Oracles update on a price deviation or a heartbeat, whichever comes first. Between updates the stored price ages normally.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Market conditions.`}),` A feed can hold its last price during unusual market conditions.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Market hours.`}),` Real-world asset feeds (stocks, ETFs, FX, commodities) may not update while their markets are closed.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Infrastructure issues.`}),` An unfunded gas wallet, network congestion or a cross-chain delivery delay can delay updates.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`set-a-maximum-delay`,children:`Set a maximum delay`}),`\n`,_jsx(_components.p,{children:`Define the maximum age of a price your protocol accepts. There is no single correct value: update settings differ per oracle, so base it on your oracle’s heartbeat plus a buffer for network delays.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`solidity`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`solidity`,children:_jsxs(_components.code,{language:`solidity`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Your oracle's heartbeat plus a buffer, e.g. 1 hour heartbeat + 10 minutes`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint128`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` constant`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MAX_DELAY `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 70`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` minutes`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Do not set it below the heartbeat, or valid prices will be rejected between updates.`}),`\n`,_jsx(_components.li,{children:`Set it per asset. A volatile token needs a tighter limit than a stablecoin.`}),`\n`,_jsx(_components.li,{children:`For RWA feeds, decide how your protocol behaves when the market is closed: pause the affected actions, or accept the last close for a defined period.`}),`\n`,_jsxs(_components.li,{children:[`If you don’t know your oracle’s heartbeat, `,_jsx(_components.a,{href:`https://discord.gg/RjHBcZ9mEH`,children:`contact the DIA team`}),`.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`check-the-timestamp`,children:`Check the timestamp`}),`\n`,_jsx(_components.p,{children:`The checks below go inside your contract’s functions. Each one first confirms the timestamp is not ahead of the current block, then checks its age, so a small clock difference between chains reverts with a clear message instead of an arithmetic error.`}),`\n`,_jsx(Heading,{level:`3`,id:`using-getvalue`,children:`Using getValue`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`getValue`}),` returns the price first, then the timestamp.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`solidity`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`solidity`,children:_jsxs(_components.code,{language:`solidity`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint128`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` price, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint128`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` IDIAOracleV2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(oracle).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getValue`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BTC/USD\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` block`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.timestamp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026\u0026`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` block`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.timestamp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MAX_DELAY,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"DIA: stale price\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`using-push-or-pull-oracles`,children:`Using push or pull oracles`}),`\n`,_jsxs(_components.p,{children:[`Push and pull oracles store prices in the `,_jsx(_components.code,{children:`updates`}),` mapping. Note the return order: timestamp first, then price.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`solidity`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`solidity`,children:_jsxs(_components.code,{language:`solidity`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint128`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint128`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` price) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` diaOracle.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`updates`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BTC/USD\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` block`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.timestamp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026\u0026`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` block`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.timestamp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MAX_DELAY,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"DIA: stale price\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`using-the-dia-solidity-library`,children:`Using the DIA Solidity library`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`getPriceIfNotOlderThan`}),` returns the price and a flag that is `,_jsx(_components.code,{children:`false`}),` when the price is older than `,_jsx(_components.code,{children:`maxTimePassed`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`20`,language:`solidity`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`solidity`,children:_jsxs(_components.code,{language:`solidity`,numberOfLines:`20`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`pragma`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:` solidity`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` ^0.8.13`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`DIAOracleLib`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"./libraries/DIAOracleLib.sol\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`contract`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` MyContract`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` error`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` PriceTooOld`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` uint128`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` constant`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MAX_DELAY `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 70`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` minutes`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` address`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` oracle;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` constructor`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`address`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` _oracle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` oracle `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` _oracle;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` readPrice`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`external`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` view`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` returns`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint128`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` price`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` bool`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` inTime;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (price, inTime) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` DIAOracleLib.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getPriceIfNotOlderThan`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(oracle, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BTC/USD\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, MAX_DELAY);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`inTime) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`revert`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` PriceTooOld`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guides/how-to-guides/fetch-price-data/solidity`,children:`getValue Method`}),` for the full library reference.`]}),`\n`,_jsx(Heading,{level:`3`,id:`using-the-aggregatorv3interface-adapter`,children:`Using the AggregatorV3Interface adapter`}),`\n`,_jsxs(_components.p,{children:[`Check the `,_jsx(_components.code,{children:`updatedAt`}),` value returned by `,_jsx(_components.code,{children:`latestRoundData()`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`solidity`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`solidity`,children:_jsxs(_components.code,{language:`solidity`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`int256`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` answer, , `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`uint256`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt, ) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` feed.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`latestRoundData`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` block`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.timestamp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026\u0026`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` block`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.timestamp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` updatedAt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MAX_DELAY,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"DIA: stale price\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`what-to-do-when-the-price-is-stale`,children:`What to do when the price is stale`}),`\n`,_jsx(_components.p,{children:`Revert, pause the affected function, or switch to a fallback source. Never silently continue with the stale value.`}),`\n`,_jsxs(_components.p,{children:[`If the key has never been updated, the oracle returns `,_jsx(_components.code,{children:`0`}),` for both price and timestamp. The timestamp check above rejects this case, but you can also add `,_jsx(_components.code,{children:`require(price > 0)`}),` as an extra safeguard.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"system","config":{},"pageMetadata":{"title":"Check Price Freshness","description":"Always verify the timestamp of an oracle response before using the price.","href":"/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Why a price can be stale","slug":"why-a-price-can-be-stale","depth":2,"children":[]},{"title":"Set a maximum delay","slug":"set-a-maximum-delay","depth":2,"children":[]},{"title":"Check the timestamp","slug":"check-the-timestamp","depth":2,"children":[{"title":"Using getValue","slug":"using-getvalue","depth":3,"children":[]},{"title":"Using push or pull oracles","slug":"using-push-or-pull-oracles","depth":3,"children":[]},{"title":"Using the DIA Solidity library","slug":"using-the-dia-solidity-library","depth":3,"children":[]},{"title":"Using the AggregatorV3Interface adapter","slug":"using-the-aggregatorv3interface-adapter","depth":3,"children":[]}]},{"title":"What to do when the price is stale","slug":"what-to-do-when-the-price-is-stale","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/docs/_mintlify/custom/diadata/1f755b4caf5bd851/umami.js"],"subdomain":"diadata","siteName":"DIA · Blockchain Oracles","title":"Check Price Freshness - DIA · Blockchain Oracles","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-01T13:55:00.368Z","originalFileLocation":"title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Always verify the timestamp of an oracle response before using the price.\">\u003cmeta data-mint-head name=\"application-name\" content=\"DIA · Blockchain Oracles\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Check Price Freshness - DIA · Blockchain Oracles\">\u003cmeta data-mint-head property=\"og:description\" content=\"Always verify the timestamp of an oracle response before using the price.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"DIA · Blockchain Oracles\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://diadata.mintlify.site/docs/_mintlify/api/og/v2?division=Fetch+Price+Data\u0026amp;title=Check+Price+Freshness\u0026amp;description=Always+verify+the+timestamp+of+an+oracle+response+before+using+the+price.\u0026amp;theme=eb5dee49ad71e15e330c0f38\u0026amp;signature=a1975fa3abbbbd5606ef2f43bc41482151c2d8625634406e6c28d9eb747b56f1\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Check Price Freshness - DIA · Blockchain Oracles\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Always verify the timestamp of an oracle response before using the price.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://diadata.mintlify.site/docs/_mintlify/api/og/v2?division=Fetch+Price+Data\u0026amp;title=Check+Price+Freshness\u0026amp;description=Always+verify+the+timestamp+of+an+oracle+response+before+using+the+price.\u0026amp;theme=eb5dee49ad71e15e330c0f38\u0026amp;signature=a1975fa3abbbbd5606ef2f43bc41482151c2d8625634406e6c28d9eb747b56f1\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/diadata/c6N7sEkULIfDt5Bn/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"DIA · Blockchain Oracles\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#000000\">\u003cmeta data-mint-head name=\"google-site-verification\" content=\"9Cd9xvn3OiQzLUJ7cOS7cZ1Qejq8Cqa9j_lxzfXurDM\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.diadata.org/#organization\",\"name\":\"DIA · Blockchain Oracles\",\"url\":\"https://www.diadata.org\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/diadata/9lX_sa90a9XlPedd/logo/light.svg?fit=max\u0026auto=format\u0026n=9lX_sa90a9XlPedd\u0026q=85\u0026s=0647d9519c7b40aca228dfe6bcd68e40\"}},{\"@type\":\"WebSite\",\"@id\":\"https://www.diadata.org/docs#website\",\"name\":\"DIA · Blockchain Oracles\",\"url\":\"https://www.diadata.org/docs\",\"publisher\":{\"@id\":\"https://www.diadata.org/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la#webpage\",\"url\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la\",\"name\":\"Check Price Freshness\",\"description\":\"Always verify the timestamp of an oracle response before using the price.\",\"dateModified\":\"2026-10-01T13:55:00.368Z\",\"isPartOf\":{\"@id\":\"https://www.diadata.org/docs#website\"},\"breadcrumb\":{\"@id\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"How-to Guides\",\"item\":\"https://www.diadata.org/docs/guides/how-to-guides/fetch-price-data\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fetch Price Data\",\"item\":\"https://www.diadata.org/docs/guides/how-to-guides/fetch-price-data\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Check Price Freshness\",\"item\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la#article\",\"headline\":\"Check Price Freshness\",\"name\":\"Check Price Freshness\",\"description\":\"Always verify the timestamp of an oracle response before using the price.\",\"url\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la\",\"mainEntityOfPage\":{\"@id\":\"https://www.diadata.org/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la#webpage\"},\"dateModified\":\"2026-10-01T13:55:00.368Z\",\"publisher\":{\"@id\":\"https://www.diadata.org/#organization\"},\"isPartOf\":{\"@id\":\"https://www.diadata.org/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"DIA · Blockchain Oracles\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"DIA · Blockchain Oracles\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la.md","siteName":"DIA · Blockchain Oracles","nav":{"global":{"anchors":[{"anchor":"Talk to a dev","icon":"discord","href":"https://discord.gg/RjHBcZ9mEH"},{"anchor":"Blog Updates","icon":"newspaper","href":"https://www.diadata.org/blog/"}]},"tabs":[{"tab":"Get Started","pages":[{"title":"Get Started","href":"/home"}]},{"tab":"DIA Stack","pages":[{"title":"DIA Stack","href":"/dia-stack/overview"}]},{"tab":"Guides","groups":[{"group":" ","pages":[{"title":"Quickstart","icon":"rocket","iconType":"solid","href":"/guides/quickstart"}]},{"group":"How-to Guides","pages":[{"group":"Fetch Price Data","pages":[{"title":"Fetch Price Data","sidebarTitle":"Overview","href":"/guides/how-to-guides/fetch-price-data"},{"title":"getValue Method","description":"There are two ways that you can access the oracle in your dApp. You can either declare an IDIAOracleV2 interface or import the solidity library.","href":"/guides/how-to-guides/fetch-price-data/solidity"},{"title":"Check Price Freshness","href":"/title-check-price-freshness-description-always-verify-the-timestamp-of-an-oracle-response-before-using-the-price-every-dia-price-oracle-returns-the-price-together-with-the-unix-timestamp-of-its-la"},{"title":"updates Method","description":"The [Push Oracle ](/reference/architecture/data-delivery#push-model)model enables contracts to receive real-time updates based on predefined criteria such as fixed intervals, specific price deviations, or a combination of both. This design provides flexibility and efficiency for decentralized applications needing accurate and timely data.","href":"/guides/how-to-guides/fetch-price-data/push-based-oracles"},{"title":"request Method","href":"/guides/how-to-guides/fetch-price-data/pull-based-oracles"}]},{"group":"Generate Randomness","pages":[{"title":"Generate Randomness","sidebarTitle":"Overview","href":"/guides/how-to-guides/generate-randomness"},{"title":"Solidity","href":"/guides/how-to-guides/generate-randomness/solidity"}]},{"title":"Fund your Oracle","href":"/guides/how-to-guides/fund-the-oracle"},{"title":"Migrate from Chainlink","href":"/guides/how-to-guides/migrate-to-dia"},{"title":"Request a Custom Oracle","href":"/guides/how-to-guides/request-a-custom-oracle"},{"title":"Oracle Monitoring","href":"/oracle-monitoring"}]},{"group":"Chain-specific Guides","pages":[{"group":"Supported Chains","pages":[{"title":"Overview","sidebarTitle":"Overview","href":"/guides/chain-guides-overview"},{"title":"Alephium","href":"/guides/chain-specific-guide/alephium"},{"title":"Arbitrum","href":"/guides/chain-specific-guide/arbitrum"},{"title":"Astar","href":"/guides/chain-specific-guide/astar"},{"title":"Aurora","href":"/guides/chain-specific-guide/aurora"},{"title":"Avalanche","href":"/guides/chain-specific-guide/avalanche"},{"title":"Base","href":"/guides/chain-specific-guide/base"},{"title":"GEB Network","href":"/guides/chain-specific-guide/bevm"},{"title":"BNB Chain","href":"/guides/chain-specific-guide/bnb-chain"},{"title":"Boba Network","href":"/guides/chain-specific-guide/boba-network"},{"title":"Celo","href":"/guides/chain-specific-guide/celo"},{"title":"Clover","href":"/guides/chain-specific-guide/clover"},{"title":"CrossFi","href":"/guides/chain-specific-guide/crossfi"},{"title":"Edu Chain","href":"/guides/chain-specific-guide/edu-chain"},{"title":"Ethereum","href":"/guides/chain-specific-guide/ethereum"},{"title":"ETHPar","href":"/guides/chain-specific-guide/ethpar"},{"title":"Evmos","href":"/guides/chain-specific-guide/evmos"},{"title":"Fantom","href":"/guides/chain-specific-guide/fantom"},{"title":"Fuse","href":"/guides/chain-specific-guide/fuse"},{"title":"Gnosis Chain","href":"/guides/chain-specific-guide/gnosis-chain"},{"title":"Hemi","href":"/guides/chain-specific-guide/hemi"},{"title":"Hydration","href":"/guides/chain-specific-guide/hydration"},{"title":"HyperEVM","href":"/guides/chain-specific-guide/hyperevm"},{"title":"Linea","href":"/guides/chain-specific-guide/linea"},{"title":"LitVM","href":"/guides/chain-specific-guide/litvm"},{"title":"LUKSO","href":"/guides/chain-specific-guide/lukso"},{"title":"Metis","href":"/guides/chain-specific-guide/metis"},{"title":"Moonbase","href":"/guides/chain-specific-guide/moonbase"},{"title":"Moonbeam","href":"/guides/chain-specific-guide/moonbeam"},{"title":"Moonriver","href":"/guides/chain-specific-guide/moonriver"},{"title":"Nervos","href":"/guides/chain-specific-guide/nervos"},{"title":"OKT Chain (OKX)","href":"/guides/chain-specific-guide/okt-chain"},{"title":"Optimism","href":"/guides/chain-specific-guide/optimism"},{"title":"Plume","href":"/guides/chain-specific-guide/plume"},{"title":"Polygon","href":"/guides/chain-specific-guide/polygon"},{"title":"Polygon zkEVM","href":"/guides/chain-specific-guide/polygon-zkevm"},{"title":"Shiden","href":"/guides/chain-specific-guide/shiden"},{"title":"Shibuya","href":"/guides/chain-specific-guide/shibuya"},{"title":"Shido","href":"/guides/chain-specific-guide/shido"},{"title":"Somnia","href":"/guides/chain-specific-guide/somnia"},{"title":"Sonic","href":"/guides/chain-specific-guide/sonic"},{"title":"Stellar","href":"/guides/chain-specific-guide/stellar"},{"title":"Sei","href":"/guides/chain-specific-guide/sei"},{"title":"Stacks","href":"/guides/chain-specific-guide/stacks"},{"title":"Superseed","href":"/guides/chain-specific-guide/superseed"},{"title":"Swell","href":"/guides/chain-specific-guide/swell"},{"title":"Telos","href":"/guides/chain-specific-guide/telos"},{"title":"Unichain","href":"/guides/chain-specific-guide/unichain"},{"title":"Velas","href":"/guides/chain-specific-guide/velas"},{"title":"W Chain","href":"/guides/chain-specific-guide/w-chain"},{"title":"Wanchain","href":"/guides/chain-specific-guide/wanchain"},{"title":"XRP Ledger (XRPL)","href":"/guides/chain-specific-guide/xrp-ledger-xrpl"},{"title":"zkSync","href":"/guides/chain-specific-guide/zksync"}]},{"title":"Oracle Grants","href":"/guides/oracle-grants"},{"title":"DIA Deployments","href":"/guides/dia-deployments"}]},{"group":"Methodologies","pages":[{"title":"Methodologies","sidebarTitle":"Overview","href":"/guides/methodologies-overview"},{"group":"Data Processing","pages":[{"title":"Trades Collection","href":"/guides/methodologies/data-processing/trades-collection"},{"title":"Price Aggregation","href":"/guides/methodologies/data-processing/price-aggregation"},{"title":"Update Triggers","href":"/guides/methodologies/data-processing/update-triggers"}]},{"group":"Pricing Methodologies","pages":[{"title":"IR: Interquartile Range Filter","href":"/guides/methodologies/pricing-methodologies/ir-interquartile-range-filter"},{"title":"MAIR: Moving Average with Interquartile Range Filter","href":"/guides/methodologies/pricing-methodologies/mair-moving-average-with-interquartile-range-filter"},{"title":"VWAP: Volume Weighted Average Price","href":"/guides/methodologies/pricing-methodologies/vwap-volume-weighted-average-price"},{"title":"VWAPIR: Volume Weighted Average Price with Interquartile Range Filter","href":"/guides/methodologies/pricing-methodologies/vwapir-volume-weighted-average-price-with-interquartile-range-filter"},{"title":"LST Fair Price","href":"/guides/methodologies/pricing-methodologies/lst-fair-price"}]}]},{"group":"General Guides","pages":[{"group":"Smart Contracts","pages":[{"title":"DIAOracleV2.sol","href":"/guides/general-guides/smart-contracts/diaoraclev2.sol"},{"title":"DIARandomOracle.sol","href":"/guides/general-guides/smart-contracts/diarandomoracle.sol"},{"title":"OracleRequestRecipient.sol","href":"/guides/general-guides/smart-contracts/OracleRequestRecipient.sol"},{"title":"PushOracleReceiver.sol","href":"/guides/general-guides/smart-contracts/PushOracleReceiver.sol"}]},{"group":"Run a Feeder","pages":[{"title":"Run a Feeder","sidebarTitle":"Overview","href":"/guides/general-guides/run-a-feeder"},{"title":"Hardware Specs","href":"/guides/general-guides/run-a-feeder/hardware-specs"},{"group":"Setting Up the Node","pages":[{"title":"Setting Up the Node","sidebarTitle":"Overview","href":"/guides/general-guides/run-a-feeder/setting-up-the-node"},{"title":"Docker Compose","href":"/guides/general-guides/run-a-feeder/setting-up-the-node/docker-compose"},{"title":"Docker Run","href":"/guides/general-guides/run-a-feeder/setting-up-the-node/docker-run"},{"title":"Kubernetes","href":"/guides/general-guides/run-a-feeder/setting-up-the-node/kubernetes"}]}]},{"title":"DIA Staking","href":"/guides/general-guides/dia-staking"},{"group":"Build a Scraper","pages":[{"title":"Build a Scraper","sidebarTitle":"Overview","href":"/guides/general-guides/overview"},{"title":"Development Cluster Stack","href":"/guides/general-guides/tutorials/development-cluster-stack"},{"title":"DIA Test‐Space with Docker Compose","href":"/guides/general-guides/tutorials/dia-test-space-with-docker-compose"},{"title":"DIA Test‐Space with Minikube","href":"/guides/general-guides/tutorials/dia-test-space-with-minikube"},{"title":"Add a New Exchange Scraper","href":"/guides/general-guides/tutorials/add-a-new-exchange-scraper"},{"title":"Add a New Foreign Scraper","href":"/guides/general-guides/tutorials/add-a-new-foreign-scraper"},{"title":"Add a New Liquidity Scraper","href":"/guides/general-guides/tutorials/add-a-new-liquidity-scraper"},{"title":"Additional Notes","href":"/guides/general-guides/tutorials/additional-notes"}]}]},{"group":"Resources","pages":[{"title":"Audits","href":"/guides/resources/audits"},{"title":"Community \u0026 Support","href":"/guides/resources/community-and-support"},{"title":"Security Bounty Program","href":"/guides/resources/security-bounty-program"},{"group":"Research","pages":[{"title":"Research","sidebarTitle":"Overview","href":"/guides/resources/research"},{"title":"Return Rates in Crypto Farming","href":"/guides/resources/research/return-rates-in-crypto-farming"},{"title":"Crypto Volatility Index","href":"/guides/resources/research/cvi"},{"title":"Compounded Rates","href":"/guides/resources/research/compounded-rates"},{"title":"Polkadot Medianizer","href":"/guides/resources/research/polkadot-medianizer"}]},{"group":"T\u0026C","pages":[{"title":"Terms \u0026 Conditions","sidebarTitle":"Overview","href":"/guides/resources/t-and-c"},{"title":"Licence Agreement","href":"/guides/resources/t-and-c/licence-agreement"},{"title":"Contributor Covenant Code of Conduct","href":"/guides/resources/t-and-c/code_of_conduct"},{"title":"Disclaimer","href":"/guides/resources/t-and-c/disclaimer"}]}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/reference/apis"}]}]},"basePath":"","title":"Check Price Freshness - DIA · Blockchain Oracles","deploymentId":"dpl_B1qJC7o4Nbc1BrDLB8Y5TDHq3c2t","buildId":"dpl_B1qJC7o4Nbc1BrDLB8Y5TDHq3c2t","dynamics":[],"chunks":[]}