Skip to content

feat(sdk): native-SOL transaction builders#346

Merged
rz1989s merged 8 commits into
mainfrom
feat/sdk-native-sol-builders
Jun 24, 2026
Merged

feat(sdk): native-SOL transaction builders#346
rz1989s merged 8 commits into
mainfrom
feat/sdk-native-sol-builders

Conversation

@rz1989s

@rz1989s rz1989s commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

sipher_vault is a universal-asset vault — it custodies classic SPL tokens, Token-2022, and native SOL — but @sipher/sdk only shipped transaction builders for the token path. This PR adds the native-SOL builders, mirroring the existing SPL ones one-for-one. Purely additive: no existing export, signature, or behavior changes.

What's added (@sipher/sdk)

Symbol Instruction / purpose
NATIVE_SOL_MINT, VAULT_SOL_SEED, FEE_SOL_SEED native-SOL sentinel mint + SolVault/SolFee PDA seeds
deriveSolVaultPDA, deriveSolFeePDA SolVault / SolFee PDA derivation
buildDepositSolTx deposit_sol
buildRefundSolTx, buildAuthorityRefundSolTx refund_sol / authority_refund_sol
buildPrivateSendSolTx withdraw_private_sol (stealth payout + Pedersen commitment + announcement CPI)
buildCreateSolVaultTx create_sol_vault (one-time PDA init)
SolDepositResult, SolRefundResult result types (WithdrawResult reused for withdraw)

Native-SOL balance reads reuse the existing getVaultBalance(connection, depositor, NATIVE_SOL_MINT) — no new read function.

Design notes

  • NATIVE_SOL_MINT is the all-zeros sentinel (Pubkey::new_from_array([0u8; 32])), not wrapped SOL — the native path never wraps; kept distinct from WSOL_MINT.
  • Rent-exempt guard: withdraw_private_sol pays a plain SystemAccount, so a small payout to a never-funded stealth address would be rejected by the runtime. buildPrivateSendSolTx pre-flights the recipient's balance against the rent-exempt minimum and throws an actionable error (caller pre-funds) instead of letting the tx fail opaquely.
  • Account orders and instruction-data layouts are byte-exact mirrors of the on-chain contexts; the SolVault/SolFee PDA fixtures are verified against the live devnet deployment.

Testing

  • 14 new vault-sol tests + 5 new privacy-sol tests. Full suite: 118 passing; tsc --noEmit: 0 errors.
  • Tests assert the full account-order + signer/writable arrays, instruction-data byte layout, fee/net computation, and the rent-exempt guard (throw + boundary-pass).

Review

Built test-first via per-task implement→review cycles; a final whole-branch review verified every account flag, instruction-data layout, and struct offset (fee_bps @40, total_transfers @43) against the deployed program.

Design + plan: docs/superpowers/specs/2026-06-24-sipher-sdk-native-sol-builders-design.md, docs/superpowers/plans/2026-06-24-sipher-sdk-native-sol-builders.md.

Deferred (non-blocking) polish: a few additional validation-throw test cases, and sharing the withdraw fixedSize constant with the SPL path.

rz1989s added 8 commits June 24, 2026 08:00
Design for adding native-SOL builders to @sipher/sdk, mirroring the
existing SPL builders. The vault program exposes deposit_sol /
withdraw_private_sol / refund_sol / authority_refund_sol on-chain, but
the SDK only builds the token path. Adds buildDepositSolTx,
buildPrivateSendSolTx, buildRefundSolTx, buildAuthorityRefundSolTx, the
SolVault/SolFee PDA derivations, and the NATIVE_SOL_MINT sentinel.

Decisions: separate *Sol builders (vs unified asset param); withdraw
throws on a below-rent-exempt stealth recipient by default; @sipher/sdk
publish deferred. PDA + sentinel fixtures verified against the live
devnet deployment.
Five-task plan (constants+PDAs, deposit, refund family, withdraw, optional
create+barrel gate) with complete code per step, mirroring the existing SPL
builders. Account orders and instruction-data layouts byte-exact from the
program; real devnet PDA fixtures for the derivation tests.
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
sipher Ready Ready Preview, Comment Jun 24, 2026 2:12am

@rz1989s rz1989s merged commit 5b9efb1 into main Jun 24, 2026
6 checks passed
@rz1989s rz1989s deleted the feat/sdk-native-sol-builders branch June 24, 2026 07:32
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.

1 participant