@@ -254,23 +254,32 @@ contract MockPyth is AbstractPyth {
254
254
);
255
255
}
256
256
257
+ /**
258
+ * @notice Creates TWAP price feed update data with simplified parameters for testing
259
+ * @param id The price feed ID
260
+ * @param price The price value
261
+ * @param conf The confidence interval
262
+ * @param expo Price exponent
263
+ * @param publishTime Timestamp when price was published
264
+ * @param publishSlot Slot number for this update
265
+ * @return twapData Encoded TWAP price feed data ready for parseTwapPriceFeedUpdates
266
+ */
257
267
function createTwapPriceFeedUpdateData (
258
268
bytes32 id ,
259
- int128 cumulativePrice ,
260
- uint128 cumulativeConf ,
261
- uint64 numDownSlots ,
269
+ int64 price ,
270
+ uint64 conf ,
262
271
int32 expo ,
263
272
uint64 publishTime ,
264
- uint64 prevPublishTime ,
265
273
uint64 publishSlot
266
274
) public pure returns (bytes memory twapData ) {
267
275
PythStructs.TwapPriceInfo memory twapInfo;
268
- twapInfo.cumulativePrice = cumulativePrice;
269
- twapInfo.cumulativeConf = cumulativeConf;
270
- twapInfo.numDownSlots = numDownSlots;
276
+ // Calculate cumulative values based on single price point
277
+ twapInfo.cumulativePrice = int128 (price);
278
+ twapInfo.cumulativeConf = uint128 (conf);
279
+ twapInfo.numDownSlots = 0 ; // Assume no down slots for test data
271
280
twapInfo.expo = expo;
272
281
twapInfo.publishTime = publishTime;
273
- twapInfo.prevPublishTime = prevPublishTime;
282
+ twapInfo.prevPublishTime = publishTime > 60 ? publishTime - 60 : 0 ; // Set a reasonable previous time
274
283
twapInfo.publishSlot = publishSlot;
275
284
276
285
twapData = abi.encode (id, twapInfo);
0 commit comments