@@ -44,33 +44,34 @@ abi UpdatePrice {
44
44
fn update_price_feeds(update_fee: u64, update_data: Vec<Bytes>);
45
45
}
46
46
47
- const PYTH_CONTRACT_ID = 0x1ab91bc1402a187055d3e827017ace566a103ce2a4126517da5d656d6a436aea; // Testnet Contract
47
+ const PYTH_MAINNET_CONTRACT_ID = 0x1c86fdd9e0e7bc0d2ae1bf6817ef4834ffa7247655701ee1b031b52a24c523da; // Mainnet Contract
48
+ const PYTH_TESTNET_CONTRACT_ID = 0x25146735b29d4216639f7f8b1d7b921ff87a1d3051de62d6cceaacabeb33b8e7; // Testnet Contract
48
49
const FUEL_ETH_BASE_ASSET_ID = 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07;
49
50
50
51
impl UpdatePrice for Contract {
51
52
fn valid_time_period() -> u64 {
52
- let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID );
53
+ let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID );
53
54
let period = pyth_contract.valid_time_period();
54
55
period
55
56
}
56
57
fn get_price(price_feed_id: PriceFeedId) -> Price {
57
- let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID );
58
+ let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID );
58
59
let price = pyth_contract.price(price_feed_id);
59
60
price
60
61
}
61
62
fn get_price_unsafe(price_feed_id: PriceFeedId) -> Price {
62
- let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID );
63
+ let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID );
63
64
let price = pyth_contract.price_unsafe(price_feed_id);
64
65
price
65
66
}
66
67
fn update_fee(update_data: Vec<Bytes>) -> u64 {
67
- let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID );
68
+ let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID );
68
69
let fee = pyth_contract.update_fee(update_data);
69
70
fee
70
71
}
71
72
#[payable]
72
73
fn update_price_feeds(update_fee: u64, update_data: Vec<Bytes>) {
73
- let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID );
74
+ let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID );
74
75
pyth_contract
75
76
.update_price_feeds {
76
77
asset_id: FUEL_ETH_BASE_ASSET_ID,
@@ -101,7 +102,7 @@ The code snippet above does the following things:
101
102
- ` update_fee(update_data) ` : Calculates the fee required to update the price feeds.
102
103
- ` update_price_feeds(update_fee, update_data) ` : Updates the price feeds with the provided data and fee.
103
104
104
- 3 . Uses the ` PYTH_CONTRACT_ID ` constant to interact with the Pyth contract on testnet.
105
+ 3 . Uses the ` PYTH_MAINNET_CONTRACT_ID ` constant to interact with the Pyth contract on testnet.
105
106
4 . Uses the ` FUEL_ETH_BASE_ASSET_ID ` constant as the asset ID for paying update fees.
106
107
107
108
To use this contract, you would typically:
0 commit comments