File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " Example Pyth App"
3
+ version = " 0.0.1"
4
+ upgrade_policy = " compatible"
5
+
6
+ [dependencies ]
7
+ Pyth = { git = " https://github.com/pyth-network/pyth-crosschain.git" , subdir = " aptos/contracts" , rev = " main" }
8
+
9
+ [addresses ]
10
+ example = " 0xac74082dfffb80824955aaefb2b0a98634b1368e37f42cbff14564ea430b97dc"
11
+ # On deployment, these should be overridden with --named-addresses using the addresses
12
+ # documented at https://docs.pyth.network/consume-data/aptos#addresses
13
+ pyth = " _"
14
+ deployer = " _"
15
+ wormhole = " _"
16
+
17
+ [dev-addresses ]
18
+ pyth = " 0xe2f37b8ac45d29d5ea23eb7d16dd3f7a7ab6426f5a998d6c23ecd3ae8d9d29eb"
19
+ deployer = " 0x277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b"
20
+ wormhole = " 0x251011524cd0f76881f16e7c2d822f0c1c9510bfd2430ba24e1b3d52796df204"
Original file line number Diff line number Diff line change
1
+ module example ::example {
2
+ use pyth::pyth;
3
+ use pyth::price::Price ;
4
+ use pyth::price_identifier;
5
+ use aptos_framework::coin;
6
+
7
+ /// Updates the Pyth price feeds using the given pyth_update_data, and then returns
8
+ /// the BTC/USD price.
9
+ public fun get_btc_usd_price (user: &signer , pyth_update_data: vector <vector <u8 >>): Price {
10
+
11
+ // First update the Pyth price feeds
12
+ let coins = coin::withdraw (user, pyth::get_update_fee ());
13
+ pyth::update_price_feeds (pyth_update_data, coins);
14
+
15
+ // Price Feed Identifier of BTC/USD in Testnet
16
+ let btc_price_identifier = x"f9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b ";
17
+
18
+ // Now we can use the prices which we have just updated
19
+ let btc_usd_price_id = price_identifier::from_byte_vec (btc_price_identifier);
20
+ pyth::get_price (btc_usd_price_id)
21
+
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments