|
34 | 34 | pythnet_sdk::{ |
35 | 35 | accumulators::merkle::MerkleRoot, |
36 | 36 | hashers::keccak256_160::Keccak160, |
37 | | - messages::{Message, PriceFeedMessage}, |
| 37 | + messages::{Message, PriceFeedMessage, PriceStatus}, |
38 | 38 | wire::{ |
39 | 39 | from_slice, |
40 | 40 | v1::{ |
@@ -533,17 +533,34 @@ fn parse_batch_attestation(deps: &Deps, env: &Env, data: &Binary) -> StdResult<V |
533 | 533 | } |
534 | 534 |
|
535 | 535 | fn create_price_feed_from_price_attestation(price_feed_message: &PriceFeedMessage) -> PriceFeed { |
| 536 | + let (publish_time, price, conf, ema_price, ema_conf) = match price_feed_message.status { |
| 537 | + PriceStatus::Trading => ( |
| 538 | + price_feed_message.publish_time, |
| 539 | + price_feed_message.price, |
| 540 | + price_feed_message.conf, |
| 541 | + price_feed_message.ema_price, |
| 542 | + price_feed_message.ema_conf, |
| 543 | + ), |
| 544 | + _ => ( |
| 545 | + price_feed_message.prev_publish_time, |
| 546 | + price_feed_message.prev_publish_time, |
| 547 | + price_feed_message.conf, |
| 548 | + price_feed_message.prev_publish_time, |
| 549 | + price_feed_message.conf, |
| 550 | + ), |
| 551 | + }; |
| 552 | + |
536 | 553 | let current_price = Price { |
537 | | - price: price_feed_message.price, |
538 | | - conf: price_feed_message.conf, |
| 554 | + price, |
| 555 | + conf, |
539 | 556 | expo: price_feed_message.exponent, |
540 | | - publish_time: price_feed_message.publish_time, |
| 557 | + publish_time, |
541 | 558 | }; |
542 | 559 | let ema_price = Price { |
543 | | - price: price_feed_message.ema_price, |
544 | | - conf: price_feed_message.ema_conf, |
| 560 | + price: ema_price, |
| 561 | + conf: ema_conf, |
545 | 562 | expo: price_feed_message.exponent, |
546 | | - publish_time: price_feed_message.publish_time, |
| 563 | + publish_time, |
547 | 564 | }; |
548 | 565 | PriceFeed::new( |
549 | 566 | PriceIdentifier::new(price_feed_message.feed_id), |
|
0 commit comments