Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TWAP] Update Hermes binary response format, add TwapMessage parsing to price-service-sdk #2158

Merged
merged 7 commits into from
Dec 3, 2024

Conversation

tejasbadadare
Copy link
Contributor

@tejasbadadare tejasbadadare commented Dec 2, 2024

  • Update the Hermes binary output for the /twap/:window_seconds/latest endpoint for better efficiency and usability.

    • New format:
    binary.data = [start_updatedata, end_updatedata]
    
    • Each updatedata contains a VAA and the merkle proofs for the requested price feeds. This lets us transmit just two VAAs total - one for the start block and one for the end block, regardless of how many price feeds were queried. In the previous format, the VAAs were being duplicated per requested price feed.
  • Add TwapMessage parsing support to the Price Service SDK. This will be used by the Solana Receiver SDK when handling binary TwapMessages from Hermes, similar to how PriceFeedMessages are currently being parsed and used.

Copy link

vercel bot commented Dec 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 6:57pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 6:57pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 3, 2024 6:57pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Dec 3, 2024 6:57pm
insights ⬜️ Ignored (Inspect) Visit Preview Dec 3, 2024 6:57pm


test("Parse TWAP message", () => {
// Sample data from the Hermes latest TWAP endpoint.
const test_accumulator_data_twap =
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use camelcase or caps here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops, too much python & rust

);
expect(twapMessage1.cumulativePrice.toString()).toBe("1760238576144013");
expect(twapMessage1.cumulativeConf.toString()).toBe("5113466755162");
expect(twapMessage1.numDownSlots.toString()).toBe("72037403");
Copy link
Contributor

@guibescos guibescos Dec 3, 2024

Choose a reason for hiding this comment

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

big numDownSlots here since stocks stop trading every night

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

LGTM!

@tejasbadadare tejasbadadare merged commit 65baa14 into main Dec 3, 2024
9 of 10 checks passed
@tejasbadadare tejasbadadare deleted the tb/price-service-sdk/add-twap-parsing branch December 3, 2024 18:57
cprussin pushed a commit to cprussin/pyth-crosschain that referenced this pull request Dec 4, 2024
…to price-service-sdk (pyth-network#2158)

* feat: change hermes twap binary response, add twap data model and parsing to price-service-sdk

* feat: reexport parseTwapMessage

* test: add parse twap msg test

* test: update parse twap test

* refactor: pack both start & end updatedatas into a single binaryupdate

* refactor: snake -> camel case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants