@@ -254,23 +254,32 @@ contract MockPyth is AbstractPyth {
254254 );
255255 }
256256
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+ */
257267 function createTwapPriceFeedUpdateData (
258268 bytes32 id ,
259- int128 cumulativePrice ,
260- uint128 cumulativeConf ,
261- uint64 numDownSlots ,
269+ int64 price ,
270+ uint64 conf ,
262271 int32 expo ,
263272 uint64 publishTime ,
264- uint64 prevPublishTime ,
265273 uint64 publishSlot
266274 ) public pure returns (bytes memory twapData ) {
267275 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
271280 twapInfo.expo = expo;
272281 twapInfo.publishTime = publishTime;
273- twapInfo.prevPublishTime = prevPublishTime;
282+ twapInfo.prevPublishTime = publishTime > 60 ? publishTime - 60 : 0 ; // Set a reasonable previous time
274283 twapInfo.publishSlot = publishSlot;
275284
276285 twapData = abi.encode (id, twapInfo);
0 commit comments