Skip to content

Commit 0fb5825

Browse files
authored
fix: fuel example (#509)
1 parent 4b1dd13 commit 0fb5825

File tree

1 file changed

+8
-7
lines changed
  • pages/price-feeds/use-real-time-data

1 file changed

+8
-7
lines changed

pages/price-feeds/use-real-time-data/fuel.mdx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,34 @@ abi UpdatePrice {
4444
fn update_price_feeds(update_fee: u64, update_data: Vec<Bytes>);
4545
}
4646
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
4849
const FUEL_ETH_BASE_ASSET_ID = 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07;
4950
5051
impl UpdatePrice for Contract {
5152
fn valid_time_period() -> u64 {
52-
let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID);
53+
let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID);
5354
let period = pyth_contract.valid_time_period();
5455
period
5556
}
5657
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);
5859
let price = pyth_contract.price(price_feed_id);
5960
price
6061
}
6162
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);
6364
let price = pyth_contract.price_unsafe(price_feed_id);
6465
price
6566
}
6667
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);
6869
let fee = pyth_contract.update_fee(update_data);
6970
fee
7071
}
7172
#[payable]
7273
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);
7475
pyth_contract
7576
.update_price_feeds {
7677
asset_id: FUEL_ETH_BASE_ASSET_ID,
@@ -101,7 +102,7 @@ The code snippet above does the following things:
101102
- `update_fee(update_data)`: Calculates the fee required to update the price feeds.
102103
- `update_price_feeds(update_fee, update_data)`: Updates the price feeds with the provided data and fee.
103104

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.
105106
4. Uses the `FUEL_ETH_BASE_ASSET_ID` constant as the asset ID for paying update fees.
106107

107108
To use this contract, you would typically:

0 commit comments

Comments
 (0)