Skip to content

feat(suins): migrate to Pyth Pro [SUIP-1111] - #1158

Draft
John-Atha wants to merge 14 commits into
mainfrom
giannisathanasiou/suip-1111-suins-sdk-update-interface-for-pyth-endpoints-v2
Draft

feat(suins): migrate to Pyth Pro [SUIP-1111]#1158
John-Atha wants to merge 14 commits into
mainfrom
giannisathanasiou/suip-1111-suins-sdk-update-interface-for-pyth-endpoints-v2

Conversation

@John-Atha

@John-Atha John-Atha commented Jul 22, 2026

Copy link
Copy Markdown

Description

Pyth is retiring the public Hermes endpoint in favour of a keyed Pyth Pro endpoint and upgrading the on-chain Pyth/Wormhole packages (Core→Pro cutover, see https://docs.pyth.network/price-feeds/core/upgrade/preparing/sui). This migrates the SuiNS SDK's Pyth integration to Pro.

Scoped to testnet for now; mainnet follows once its contracts are upgraded (see Pending).

Price fetching

  • Fetch price updates from the keyed Pyth Pro Hermes endpoint on the v2 API (/v2/updates/price/latest), replacing the deprecated public v1 (/api/latest_vaas) host. A single host serves all networks.
  • Add an optional pythAccessToken to SuinsClient and the suins() extension, sent as an Authorization: Bearer header. It is required for non-base-currency registrations/renewals (the base currency does not use the oracle).

On-chain wiring

  • Point the Pyth and Wormhole state ids at the Pro deployments (both networks); converge the testnet price feeds to the global feed ids.
  • Bump the testnet payments / bbb package ids to their upgraded versions. Add payments.packageIdV1 (the original id) so the PaymentsConfig type identity stays keyed by the original package while calls target the latest one.
  • Regenerate the payments binding and switch the non-base register/renew path to the Pro _pro entrypoints (calculate_price_pro / handle_payment_pro). The old Core entrypoints now abort on-chain (ECoreFeedDeprecated).

Pending (mainnet, follow-up)

  • Mainnet contracts are not yet upgraded (tracked in SUIP-1105). The SDK calls the _pro entrypoints unconditionally, so the mainnet flow works only once mainnet is upgraded and its ids are bumped (mirroring testnet). Kept as a draft until then.

Test plan

  • Real testnet registration executed end-to-end paying in SUI: status: success, SuinsRegistration NFT minted, and pyth + payments events emitted (a live Pyth Pro price update settled on-chain, consumed by handle_payment_pro). Tx FFc4iJqJ67kyCNTgEvH23fkoUwr1GqpJVsSwwYov94k8.
  • live.test.ts testnet dry-run green against the Pro endpoint + Pro contracts (skips when VITE_PYTH_ACCESS_TOKEN is unset). Reproducing requires the testnet PaymentsConfig feed ids aligned to the updated Pyth Pro feed ids (related discussion here); that on-chain admin step is tracked on the contracts side (SUIP-1105) and is temporarily reverted on testnet now to avoid blocking users that are still on the previous package versions.
  • Auth: the keyed endpoint returns 401 without a token and 200 with a valid one.

AI Assistance Notice

Please disclose the usage of AI. This is primarily to help inform reviewers of how careful they need to review PRs, and to keep track of AI usage across our team. Please fill this out accurately, and do not modify the content or heading for this section!

  • This PR was primarily written by AI.
  • I used AI for docs / tests, but manually wrote the source code.
  • I used AI to understand the problem space / repository.
  • I did not use AI for this PR.

John-Atha and others added 3 commits July 22, 2026 14:12
Add an optional `pyth` config (`endpoint`, `accessToken`) to SuinsClient and
forward it to the Pyth price-service connection, sending the token as an
`Authorization: Bearer` header for keyed endpoints. Move the price-update fetch
from the deprecated Hermes v1 (`/api/latest_vaas`) to v2 (`/v2/updates/price/latest`).

Read the Pyth and Wormhole on-chain state via layout-agnostic JSON fields instead
of BCS struct decoding, so a single build works against both the current and
Pro-compatible Pyth package layouts. Verified end-to-end on mainnet against the
keyed Pro endpoint + Pro state objects, and against the current public endpoint.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The upgraded (Core->Pro) Pyth and Wormhole State structs have the same layout as
the current ones, so the existing generated BCS bindings decode them unchanged.
Revert the layout-agnostic JSON state reads added earlier; they are unnecessary.

Verified end-to-end on mainnet: the current BCS bindings plus the upgraded Pyth/
Wormhole state ids verify keyed Pro price updates on-chain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…1111]

Hard-code the single keyed Pyth Pro Hermes endpoint and drop the public host;
the Pyth config collapses to a `pythAccessToken` on both `SuinsClient` and the
`suins()` extension, sent as an `Authorization: Bearer` header.

Point the Pyth/Wormhole state ids at the upgraded (Pro-compatible) deployments
and converge the testnet price feeds to the global feed ids. Wire the live test
to read `VITE_PYTH_ACCESS_TOKEN` from env (skipping when absent) and add a
`.env.example`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@John-Atha
John-Atha requested a review from a team as a code owner July 22, 2026 13:23
@John-Atha
John-Atha temporarily deployed to sui-typescript-aws-kms-test-env July 22, 2026 13:23 — with GitHub Actions Inactive
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
sui-typescript-docs Ignored Ignored Preview Aug 18, 2026 10:18pm

Request Review

@John-Atha
John-Atha marked this pull request as draft July 22, 2026 13:23
- bump testnet payments/bbb package ids to the upgraded published-at
- add payments.packageIdV1 to keep the original id for PaymentsConfig type
  identity, since an in-place upgrade moves only the call target
- regenerate the payments binding with handle_payment_pro/calculate_price_pro
- call the _pro entrypoints in the non-base register/renew path

Testnet e2e reaches calculate_price_pro and aborts only on
EPriceFeedIdMismatch, pending the on-chain feed-id admin update.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
John-Atha and others added 2 commits July 27, 2026 20:49
The two cases only asserted the code calls axios the way it calls axios
(change-detectors against mocks). The real Pyth Pro path is covered by the
live e2e, so this added no behavioral coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep the endpoint where it was on main (a local in getPriceInfoObject)
instead of a module constant, to minimize the diff.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…p-1111-suins-sdk-update-interface-for-pyth-endpoints-v2
@John-Atha
John-Atha temporarily deployed to sui-typescript-aws-kms-test-env July 27, 2026 17:58 — with GitHub Actions Inactive
@John-Atha John-Atha changed the title feat(suins): migrate Pyth integration to Pyth Pro keyed endpoint [SUIP-1111] feat(suins): migrate to Pyth Pro [SUIP-1111] Jul 28, 2026
@natalypeyioti natalypeyioti self-assigned this Jul 28, 2026
Comment thread packages/suins/src/suins-client.ts
Comment thread packages/suins/src/suins-client.ts
Comment thread packages/suins/src/suins-client.ts Outdated
getPriceInfoObject is the only consumer of the token; guard it so a
missing token fails fast with a clear message instead of an opaque 401
from the keyed Pro Hermes endpoint.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@John-Atha
John-Atha temporarily deployed to sui-typescript-aws-kms-test-env July 28, 2026 08:36 — with GitHub Actions Inactive
Comment thread packages/suins/src/pyth/PriceServiceConnection.ts Outdated
It's a credential only read inside the class; readonly prevents reassignment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@John-Atha John-Atha self-assigned this Jul 28, 2026
@John-Atha
John-Atha temporarily deployed to sui-typescript-aws-kms-test-env July 28, 2026 08:48 — with GitHub Actions Inactive
Comment thread packages/suins/src/constants.ts Outdated
Throw a legible error if `binary.data` is missing instead of a bare
"Cannot read properties of undefined" TypeError when the shape drifts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Testnet NS now points at the global NS feed (same as mainnet), so the
"using the HFT feed since NS feed on testnet is not available" note no
longer applies.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@natalypeyioti
natalypeyioti had a problem deploying to sui-typescript-aws-kms-test-env August 18, 2026 21:24 — with GitHub Actions Failure
@natalypeyioti
natalypeyioti marked this pull request as ready for review August 18, 2026 21:43
@natalypeyioti
natalypeyioti had a problem deploying to sui-typescript-aws-kms-test-env August 18, 2026 21:43 — with GitHub Actions Failure
@natalypeyioti
natalypeyioti marked this pull request as draft August 18, 2026 22:09
@natalypeyioti
natalypeyioti had a problem deploying to sui-typescript-aws-kms-test-env August 18, 2026 22:17 — with GitHub Actions Failure
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.

3 participants