Skip to content

Commit

Permalink
fix getLatestPriceFeed (#86)
Browse files Browse the repository at this point in the history
* fix getLatestPriceFeed

* fix parse-price-feed-updates-unique
  • Loading branch information
cctdaniel authored Oct 19, 2023
1 parent 1c3006a commit 1f3450c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pages/aptos/get-update-fee.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ By default, the data is returned as a base64-encoded string that you must deseri
JSON.stringify(
Array.from(
Buffer.from(
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "aptos")).vaa,
"base64"
)
)
Expand Down
2 changes: 1 addition & 1 deletion pages/aptos/update-price-feeds-with-funder.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Reverts if the `account` does not have a sufficient balance or `update_data` is
JSON.stringify(
Array.from(
Buffer.from(
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "aptos")).vaa,
"base64"
)
)
Expand Down
5 changes: 3 additions & 2 deletions pages/aptos/update-price-feeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Reverts if the required fee is not paid, or the `update_data` is incorrectly sig
JSON.stringify(
Array.from(
Buffer.from(
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "aptos")).vaa,
"base64"
)
)
Expand All @@ -46,7 +46,8 @@ Reverts if the required fee is not paid, or the `update_data` is incorrectly sig
// NOTE: this technically could get the update fee for a different VAA than the one above.
// This shouldn't affect the update fee as long as the fee is only dependent on the price feed ids
// and not the specific content of the price update.
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa;
// FIXME: this gets the ETH update fee, not the cosmos fee. They're currently the same though.
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa;
return await ctx.getEthUpdateFee([vaa]);
},
}}
Expand Down
2 changes: 1 addition & 1 deletion pages/evm/get-update-fee.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The `updateData` can be retrieved from the [Hermes API](https://hermes.pyth.netw
<Example
keyValues={{
updateData: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa,
}}
value="Latest BTC/USD update data"
/>
Expand Down
10 changes: 6 additions & 4 deletions pages/evm/parse-price-feed-updates-unique.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ contain an update for any of the given `priceIds` within the given time range.
<Example
keyValues={{
updateData: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa,
priceId: (ctx) => ctx.getFeedId0x("Crypto.BTC/USD"),
minPublishTime: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).price.publish_time - 5,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).price
.publish_time - 5,
maxPublishTime: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).price.publish_time + 5,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).price
.publish_time + 5,
fee: async (ctx) => {
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa;
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa;
return await ctx.getEthUpdateFee([vaa]);
},
}}
Expand Down
10 changes: 6 additions & 4 deletions pages/evm/parse-price-feed-updates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ contain an update for any of the given `priceIds` within the given time range.
<Example
keyValues={{
updateData: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa,
priceId: (ctx) => ctx.getFeedId0x("Crypto.BTC/USD"),
minPublishTime: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).price.publish_time - 5,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).price
.publish_time - 5,
maxPublishTime: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).price.publish_time + 5,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).price
.publish_time + 5,
fee: async (ctx) => {
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa;
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa;
return await ctx.getEthUpdateFee([vaa]);
},
}}
Expand Down
7 changes: 4 additions & 3 deletions pages/evm/update-price-feeds-if-necessary.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ Reverts if the required fee is not paid, or the `updateData` is incorrectly sign
<Example
keyValues={{
updateData: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa,
priceId: (ctx) => ctx.getFeedId0x("Crypto.BTC/USD"),
publishTime: async (ctx) =>
(await ctx.getLatestPriceFeed("Crypto.BTC/USD")).price.publish_time,
(await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).price
.publish_time,
fee: async (ctx) => {
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD")).vaa;
let vaa = (await ctx.getLatestPriceFeed("Crypto.BTC/USD", "evm")).vaa;
return await ctx.getEthUpdateFee([vaa]);
},
}}
Expand Down

1 comment on commit 1f3450c

@vercel
Copy link

@vercel vercel bot commented on 1f3450c Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.