Skip to content

fix(sdk): migrate vault fee to tenths-of-bps (feeTenthsBps); @sipher/sdk 0.2.0#359

Merged
rz1989s merged 11 commits into
mainfrom
fix/vault-fee-tenths-bps
Jul 2, 2026
Merged

fix(sdk): migrate vault fee to tenths-of-bps (feeTenthsBps); @sipher/sdk 0.2.0#359
rz1989s merged 11 commits into
mainfrom
fix/vault-fee-tenths-bps

Conversation

@rz1989s

@rz1989s rz1989s commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

The on-chain sipher_vault program re-precisioned its fee from whole basis points to tenths of a basis point (fee_tenths_bps, u16 at config offset 40, divisor 100_000; e.g. 75 = 7.5 bps). This PR brings the TypeScript side in line and fixes a resulting 10× fee mis-report: three SDK sites decoded the raw tenths value but still divided by 10_000, so against the live config they reported 0.75% instead of 0.075% (and the native-SOL path could trip its rent-exempt guard into false rejections).

Changes

@sipher/sdk → 0.2.0

  • VaultConfig.feeBpsfeeTenthsBps (integer). Constants DEFAULT_FEE_TENTHS_BPS = 100 (0.1%, value-preserving) and MAX_FEE_TENTHS_BPS = 1000 (1%).
  • Vault fee math is now exact integer amount * feeTenthsBps / 100_000n at both withdraw builders (privacy.ts, privacy-sol.ts) and the decode (vault.ts).
  • Vendored IDL synced to fee_tenths_bps; recon + devnet bootstrap/refund scripts migrated.
  • Added regression guards at the real devnet value (75 tenths → fee 1_500 on 2_000_000; the old divisor gave 15_000) for both the SOL and SPL paths — the SPL path previously had no fee assertion.

@sipher/agent — surfaces feeTenthsBps with feePercent = feeTenthsBps / 1000. The static per-chain fee list (routes/chains.ts) is a separate concept and correctly stays whole-bps.

examples/vault-privacy-provider — the reference adapter's fee field and previewWithdraw migrated; generic design note updated.

appDepositTxResponse type aligned with the deposit-tx route it consumes.

Out of scope (intentionally unchanged)

  • sip_privacy is a separate program and stays whole-bps (÷10_000), including its skipped-byte layout comments in privacy.ts / privacy-sol.ts.
  • Dated evidence under docs/sentinel/evidence/ (point-in-time records).

Verification

  • pnpm -r build + pnpm typecheck clean across all packages.
  • Tests green: @sipher/sdk 120, @sipher/agent 1718, examples/vault-privacy-provider 22.
  • Design + implementation plan committed under docs/superpowers/.

Note

Publishing @sipher/sdk@0.2.0 to npm is a separate follow-up, not part of this PR.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
sipher Ready Ready Preview, Comment Jul 2, 2026 4:56am

@rz1989s rz1989s merged commit 16edac2 into main Jul 2, 2026
8 checks passed
@rz1989s rz1989s deleted the fix/vault-fee-tenths-bps branch July 2, 2026 04:59
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