@@ -235,6 +235,38 @@ abstract contract Pyth is PythGetters, PythSetters, AbstractPyth {
235
235
);
236
236
}
237
237
238
+ // This is an overwrite of the same method in AbstractPyth.sol
239
+ // to be more gas efficient. It cannot move to PythGetters as it
240
+ // is overwriting the interface. Even indirect calling of a similar
241
+ // method from PythGetter has some gas overhead.
242
+ function getPriceUnsafe (
243
+ bytes32 id
244
+ ) public view override returns (PythStructs.Price memory price ) {
245
+ PythInternalStructs.PriceInfo storage info = _state.latestPriceInfo[id];
246
+ price.publishTime = info.publishTime;
247
+ price.expo = info.expo;
248
+ price.price = info.price;
249
+ price.conf = info.conf;
250
+
251
+ require (price.publishTime != 0 , "price feed for the given id is not pushed or does not exist " );
252
+ }
253
+
254
+ // This is an overwrite of the same method in AbstractPyth.sol
255
+ // to be more gas efficient. It cannot move to PythGetters as it
256
+ // is overwriting the interface. Even indirect calling of a similar
257
+ // method from PythGetter has some gas overhead.
258
+ function getEmaPriceUnsafe (
259
+ bytes32 id
260
+ ) public view override returns (PythStructs.Price memory price ) {
261
+ PythInternalStructs.PriceInfo storage info = _state.latestPriceInfo[id];
262
+ price.publishTime = info.publishTime;
263
+ price.expo = info.expo;
264
+ price.price = info.emaPrice;
265
+ price.conf = info.emaConf;
266
+
267
+ require (price.publishTime != 0 , "price feed for the given id is not pushed or does not exist " );
268
+ }
269
+
238
270
function parsePriceFeedUpdates (
239
271
bytes [] calldata updateData ,
240
272
bytes32 [] calldata priceIds ,
0 commit comments