From f68832fbade8e8eba3bcd2a960b84765b78af4e7 Mon Sep 17 00:00:00 2001 From: vedhavyas Date: Wed, 27 Nov 2024 12:39:32 +0530 Subject: [PATCH] include additional block time in the staleness check --- contracts/pyth-store-v2.clar | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/pyth-store-v2.clar b/contracts/pyth-store-v2.clar index d7593be..0ef5f70 100644 --- a/contracts/pyth-store-v2.clar +++ b/contracts/pyth-store-v2.clar @@ -10,6 +10,8 @@ (define-constant ERR_INVALID_UPDATES (err u5003)) (define-constant ERR_RESTRICTED_TO_TESTNET (err u5004)) +(define-constant STACKS_BLOCK_TIME u5) + (define-map prices (buff 32) { price: int, conf: uint, @@ -79,7 +81,7 @@ ;; Ensure that we have not processed a newer price (asserts! (is-price-update-more-recent (get price-identifier entry) (get publish-time entry)) ERR_NEWER_PRICE_AVAILABLE) ;; Ensure that price is not stale - (asserts! (>= (get publish-time entry) (- latest-bitcoin-timestamp stale-price-threshold)) ERR_STALE_PRICE) + (asserts! (>= (get publish-time entry) (+ (- latest-bitcoin-timestamp stale-price-threshold) STACKS_BLOCK_TIME)) ERR_STALE_PRICE) ;; Update storage (map-set prices (get price-identifier entry)