You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Pyth Network Aptos contract allows users to submit price updates for verification and store them for later use.
1
+
The Pyth Network Sui contract allows users to submit price updates for verification and store them for later use.
2
2
Please see the documentation section on [Pull Updates](documentation/pythnet-price-feeds/on-demand) if you haven't already;
3
-
this section will explain the differences between Pyth Network and other oracles, and help you understand the expected usage patterns.
3
+
this section will explain the differences between Pyth Network and other oracles, and help you understand the expected usage patterns. Pyth on Sui also automatically pushes prices on-chain for a subset of symbols. More information on this TBA.
4
4
5
5
Users of the Pyth contract will typically need to perform two operations:
6
6
7
7
- Update the on-chain price -- In off-chain code, retrieve a verified price update from the
8
8
[price service](documentation/pythnet-price-feeds/price-service) and submit it to the contract
9
9
for verification. This operation makes the price available for on-chain use.
10
-
You will typically call [update_price_feeds](aptos/update-price-feeds) to do this.
10
+
You will typically call [update_price_feeds](sui/update-price-feeds) to do this.
11
11
- Read the on-chain price -- After updating the price, your on-chain contract can call one of the
12
-
many getter functions on the contract to get the price. See [get_price](aptos/get-price) and its variants
12
+
many getter functions on the contract to get the price. See [get_price](sui/get-price) and its variants
These lines allow you to reference Pyth resources as `pyth` instead of manually writing the contract address.
32
-
The contract addresses provided above are for both Aptos mainnet and testnet -- the Pyth contract has the same address in both cases.
31
+
The contract addresses provided above are for both Sui mainnet -- the Pyth contract has a different address on testnet (contract addresses on Sui are not generated deterministically).
33
32
34
33
You can now import the Pyth interfaces in Move code as follows:
| <Argrequired={true}type="vector<vector<u8>>">update_data</Arg> | <Inputid="update_data"format={InputFormats.ByteArray} /> | The price update data for the contract to verify. |
29
-
| <Argrequired={true}type="Coin<AptosCoin>">fee</Arg> | <Inputid="fee"format={InputFormats.BigInt}/> | The update fee in octa. This fee is transferred to the Pyth contract as an effect of the transaction. |
30
-
28
+
| <Argrequired={true}type="&PythState">pyth_state</Arg> | <Inputid="pyth_state"format={InputFormats.ByteArray} /> | The Pyth state object. |
| <Argrequired={true}type=" &mut PriceInfoObject">price_info_object</Arg> | <Inputid="price_info_object"format={InputFormats.BigInt}/> | PriceInfoObject is a shared Sui object containing the price feed to be updated. |
| <Argrequired={true}type=" &Clock">clock</Arg> | <Inputid="clock"format={InputFormats.BigInt}/> | clock is a Sui shared object used to tell time and record timestamps |
31
33
</div>
32
34
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
+
33
38
<Examples>
34
39
<Example
35
40
keyValues={{
@@ -43,36 +48,10 @@ Reverts if the required fee is not paid, or the `update_data` is incorrectly sig
43
48
)
44
49
),
45
50
fee: async (ctx) => {
46
-
// NOTE: this technically could get the update fee for a different VAA than the one above.
47
-
// This shouldn't affect the update fee as long as the fee is only dependent on the price feed ids
48
-
// and not the specific content of the price update.
49
51
let vaa = (awaitctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa;
0 commit comments