Skip to content

Commit cf74732

Browse files
authored
Update update-single-price-feed.mdx
1 parent 8e9e2d0 commit cf74732

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

pages/sui/update-single-price-feed.mdx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Reverts if the required fee is not paid, or the `update_data` is incorrectly sig
3232
| <Arg required={true} type=" &Clock">clock</Arg> | <Input id="clock" format={InputFormats.BigInt}/> | clock is a Sui shared object used to tell time and record timestamps |
3333
</div>
3434

35+
# Warning: do not hardcode price feed updates in your contract
36+
`update_single_price_feed` is meant to be called in a chain of programmable transactions, rather than hardcoded in a contract. This is because when a Sui contract upgrades, the upgraded version lives at a different address. When this happens the previous callsite gets bricked, or becomes un-callable. It is up to the user to use the correct call-site (we also have a helper function for finding the latest call-site given the Pyth state object ID, which is unchanged between upgrades).
37+
3538
<Examples>
3639
<Example
3740
keyValues={{
@@ -45,36 +48,10 @@ Reverts if the required fee is not paid, or the `update_data` is incorrectly sig
4548
)
4649
),
4750
fee: async (ctx) => {
48-
// NOTE: this technically could get the update fee for a different VAA than the one above.
49-
// This shouldn't affect the update fee as long as the fee is only dependent on the price feed ids
50-
// and not the specific content of the price update.
5151
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa;
5252
return await ctx.getEthUpdateFee([vaa]);
5353
},
5454
}}
55-
value="Latest BTC/USD update data"
55+
Example TBA
5656
/>
5757
</Examples>
58-
59-
## Example Code
60-
61-
<Tabs items={['Move']}>
62-
<Tab>
63-
<DynamicCode targets={{
64-
"1": (ctx) => ctx.get("update_data", "<update_data>"),
65-
"2": (ctx) => ctx.get("fee", "<fee>"),
66-
}}>
67-
```rust copy
68-
use pyth::pyth;
69-
use pyth::price_identifier;
70-
71-
let coins = coin::withdraw<AptosCoin>(payer, 2)
72-
pyth::update_price_feeds(
73-
vec![1],
74-
coins
75-
);
76-
```
77-
</DynamicCode>
78-
</Tab>
79-
80-
</Tabs>

0 commit comments

Comments
 (0)