Преглед изворни кода

removed TODO, updated interface

Ayush Suresh пре 6 месеци
родитељ
комит
552a34fd36

+ 3 - 3
target_chains/ethereum/contracts/contracts/pyth/Pyth.sol

@@ -397,7 +397,7 @@ abstract contract Pyth is
             maxPublishTime,
             false,
             false,
-            true // TODO: Figure out when to use the flag
+            true
         );
     }
 
@@ -423,7 +423,7 @@ abstract contract Pyth is
                 maxPublishTime,
                 false,
                 true,
-                true // TODO: Figure out when to use the flag
+                true
             );
     }
 
@@ -634,7 +634,7 @@ abstract contract Pyth is
             maxPublishTime,
             true,
             false,
-            true // TODO: Figure out when to use flag
+            true
         );
     }
 

+ 31 - 0
target_chains/ethereum/sdk/solidity/IPyth.sol

@@ -126,6 +126,37 @@ interface IPyth is IPythEvents {
         uint64 maxPublishTime
     ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds);
 
+    /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published
+    /// within `minPublishTime` and `maxPublishTime,` but choose to store price updates if `storeUpdatesIfFresh`.
+    ///
+    /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;
+    /// otherwise, please consider using `updatePriceFeeds`. This method may store the price updates on-chain, if they
+    /// are more recent than the current stored prices.
+    ///
+    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
+    /// `getUpdateFee` with the length of the `updateData` array.
+    ///
+    /// This method will eventually allow the caller to determine whether parsed price feeds should update 
+    /// the stored values as well.
+    ///
+    /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
+    /// no update for any of the given `priceIds` within the given time range.
+    /// @param updateData Array of price update data.
+    /// @param priceIds Array of price ids.
+    /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
+    /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
+    /// @param storeUpdatesIfFresh flag for the parse function to 
+    /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
+    function parsePriceFeedUpdatesWithConfig(
+        bytes[] calldata updateData,
+        bytes32[] calldata priceIds,
+        uint64 minAllowedPublishTime,
+        uint64 maxAllowedPublishTime,
+        bool checkUniqueness,
+        bool checkUpdateDataIsMinimal,
+        bool storeUpdatesIfFresh
+    ) public returns ( PythStructs.PriceFeed[] memory priceFeeds, uint64[] memory slots);
+
     /// @notice Parse time-weighted average price (TWAP) from two consecutive price updates for the given `priceIds`.
     ///
     /// This method calculates TWAP between two data points by processing the difference in cumulative price values