@@ -41,14 +41,14 @@ abstract contract Pyth is PythGetters, PythSetters, AbstractPyth {
41
41
PythInternalStructs.PriceInfo memory latestPrice = latestPriceInfo (attestation.priceId);
42
42
43
43
bool fresh = false ;
44
- if (newPriceInfo.priceFeed. price.publishTime > latestPrice.priceFeed .price.publishTime) {
44
+ if (newPriceInfo.price.publishTime > latestPrice.price.publishTime) {
45
45
freshPrices += 1 ;
46
46
fresh = true ;
47
47
setLatestPriceInfo (attestation.priceId, newPriceInfo);
48
48
}
49
49
50
- emit PriceFeedUpdate (attestation.priceId, fresh, vm.emitterChainId, vm.sequence, latestPrice.priceFeed. price.publishTime,
51
- newPriceInfo.priceFeed. price.publishTime, newPriceInfo.priceFeed. price.price, newPriceInfo.priceFeed .price.conf);
50
+ emit PriceFeedUpdate (attestation.priceId, fresh, vm.emitterChainId, vm.sequence, latestPrice.price.publishTime,
51
+ newPriceInfo.price.publishTime, newPriceInfo.price.price, newPriceInfo.price.conf);
52
52
}
53
53
54
54
emit BatchPriceFeedUpdate (vm.emitterChainId, vm.sequence, batch.attestations.length , freshPrices);
@@ -76,32 +76,27 @@ abstract contract Pyth is PythGetters, PythSetters, AbstractPyth {
76
76
return singleUpdateFeeInWei () * updateData.length ;
77
77
}
78
78
79
- function createNewPriceInfo (PythInternalStructs.PriceAttestation memory pa ) private view returns (PythInternalStructs.PriceInfo memory info ) {
80
- info.attestationTime = pa.attestationTime;
81
- info.arrivalTime = block .timestamp ;
82
- info.arrivalBlock = block .number ;
83
- info.priceFeed.id = pa.priceId;
84
-
79
+ function createNewPriceInfo (PythInternalStructs.PriceAttestation memory pa ) private pure returns (PythInternalStructs.PriceInfo memory info ) {
85
80
PythInternalStructs.PriceAttestationStatus status = PythInternalStructs.PriceAttestationStatus (pa.status);
86
81
if (status == PythInternalStructs.PriceAttestationStatus.TRADING) {
87
- info.priceFeed. price.price = pa.price;
88
- info.priceFeed. price.conf = pa.conf;
89
- info.priceFeed. price.publishTime = pa.publishTime;
90
- info.priceFeed. emaPrice.publishTime = pa.publishTime;
82
+ info.price.price = pa.price;
83
+ info.price.conf = pa.conf;
84
+ info.price.publishTime = pa.publishTime;
85
+ info.emaPrice.publishTime = pa.publishTime;
91
86
} else {
92
- info.priceFeed. price.price = pa.prevPrice;
93
- info.priceFeed. price.conf = pa.prevConf;
94
- info.priceFeed. price.publishTime = pa.prevPublishTime;
87
+ info.price.price = pa.prevPrice;
88
+ info.price.conf = pa.prevConf;
89
+ info.price.publishTime = pa.prevPublishTime;
95
90
96
91
// The EMA is last updated when the aggregate had trading status,
97
92
// so, we use prev_publish_time (the time when the aggregate last had trading status).
98
- info.priceFeed. emaPrice.publishTime = pa.prevPublishTime;
93
+ info.emaPrice.publishTime = pa.prevPublishTime;
99
94
}
100
95
101
- info.priceFeed. price.expo = pa.expo;
102
- info.priceFeed. emaPrice.price = pa.emaPrice;
103
- info.priceFeed. emaPrice.conf = pa.emaConf;
104
- info.priceFeed. emaPrice.expo = pa.expo;
96
+ info.price.expo = pa.expo;
97
+ info.emaPrice.price = pa.emaPrice;
98
+ info.emaPrice.conf = pa.emaConf;
99
+ info.emaPrice.expo = pa.expo;
105
100
106
101
return info;
107
102
}
@@ -226,14 +221,23 @@ abstract contract Pyth is PythGetters, PythSetters, AbstractPyth {
226
221
function queryPriceFeed (bytes32 id ) public view override returns (PythStructs.PriceFeed memory priceFeed ){
227
222
// Look up the latest price info for the given ID
228
223
PythInternalStructs.PriceInfo memory info = latestPriceInfo (id);
229
- require (info.priceFeed.id != 0 , "price feed for the given id is not pushed or does not exist " );
230
-
231
- return info.priceFeed;
224
+ require (info.price.publishTime != 0 , "price feed for the given id is not pushed or does not exist " );
225
+
226
+ priceFeed.id = id;
227
+ priceFeed.price.price = info.price.price;
228
+ priceFeed.price.conf = info.price.conf;
229
+ priceFeed.price.expo = info.price.expo;
230
+ priceFeed.price.publishTime = uint (info.price.publishTime);
231
+
232
+ priceFeed.emaPrice.price = info.emaPrice.price;
233
+ priceFeed.emaPrice.conf = info.emaPrice.conf;
234
+ priceFeed.emaPrice.expo = info.emaPrice.expo;
235
+ priceFeed.emaPrice.publishTime = uint (info.emaPrice.publishTime);
232
236
}
233
237
234
238
function priceFeedExists (bytes32 id ) public override view returns (bool ) {
235
239
PythInternalStructs.PriceInfo memory info = latestPriceInfo (id);
236
- return (info.priceFeed.id != 0 );
240
+ return (info.price.publishTime != 0 );
237
241
}
238
242
239
243
function getValidTimePeriod () public override view returns (uint ) {
0 commit comments