Skip to content

Vault suite: simulation/fees, SEP-41 shares, fee crystallization, asset-agnostic collateral - #342

Merged
techisigu merged 9 commits into
Zenith-options:mainfrom
chindosunday:drips/214-215-216-217
Oct 24, 2026
Merged

techisigu merged 9 commits into
Zenith-options:mainfrom
chindosunday:drips/214-215-216-217

Conversation

@chindosunday

Copy link
Copy Markdown
Contributor

Summary

Vault suite: simulation/fees, SEP-41 shares, fee crystallization, asset-agnostic collateral

What was solved

#214 — Implement Stellar Transaction Simulation, Fee Estimation, and Failure Surfacing for Vault Deposits and Withdrawals

Implement a shared prepare→simulate→sign→submit pipeline for Soroban vault deposits and withdrawals: call simulateTransaction to surface resource/inclusion/total fees before signing, show quoted shares/assets with a bounded minimum-received slippage guard and a quote-staleness window, map contract error codes to human-readable messages in messages/, render actionable simulation failures with retry (without leaving the form submitting), reuse the existing Freighter signing path, and log simulation results/failures with vault/operation/error-code/footprint context.

Addressed:

  • Changed: src/lib/api/vaults.ts
  • Invoke simulateTransaction to build the final deposit/withdraw transaction and display returned resource fee, inclusion fee, and total estimated cost before signing
  • Show quoted shares (deposit) or assets (withdraw) with an explicit minimum-received slippage guard settable within a bounded range
  • Refuse to sign when the quote is older than a configured staleness window

#215 — Expose Vault LP Shares as a SEP-41 Compliant Token for Wallet Visibility and Composability

Implement SEP-41 token interface on Phase 2 vault share ledgers as an internal shares module (balance, spendable_balance, authorized, transfer, transfer_from, approve, allowance, decimals, name, symbol, total_supply), with mint/burn restricted to vault deposit/redemption paths, standard token-topic events, and a per-vault transferable policy flag defaulting off and switchable without redeploy. Surface symbol/decimals/transferable in the typed vault payload in src/lib/api/vaults.ts.

Addressed:

  • Changed: src/lib/api/vaults.ts
  • Implement full SEP-41 interface on vault share ledger: balance, spendable_balance, authorized, transfer, transfer_from, approve, allowance, decimals, name, symbol, total_supply
  • Mint and burn only from vault-internal deposit/redemption paths; no external mint entry point
  • Emit mint, burn, and transfer events under the standard token topic for indexers

#216 — Implement the Vault Fee Policy With High-Water-Mark Performance Fees and Treasury Distribution

Add a per-vault fee policy layer (management + high-water-mark performance fees) that crystallizes at epoch close and distributes to a treasury/fee-recipient via real token transfer, with governance-gated config and API/analytics exposure of configured rates and last crystallization.

Addressed:

  • Changed: src/lib/api/vaults.ts
  • Per-vault fee config: management_fee_bps, performance_fee_bps, fee_recipient (Stellar address), with hard max-bps bound enforced at configuration time
  • Persist a per-vault high-water mark across epochs in persistent contract storage with explicit TTL policy (not derived from NAV history); document and test loss-epoch behavior
  • Crystallize fees once per epoch at epoch close, before epoch NAV is finalized, so published NAV already reflects fees

#217 — Implement Multi-Asset Collateral Support and Asset Decimal Handling Across the Vault Suite

Make the Phase 2 vault suite asset-agnostic by declaring a per-vault collateral asset (classic Stellar asset or Soroban token) with correct decimals, validating it against a per-network allowlist at creation, normalizing all share pricing/NAV/capacity/fee math to base units, exposing collateralAsset metadata (code, issuer/contract id, decimals) in REST payloads, and formatting NAV/share price/balances in the frontend using the vault's asset metadata.

Addressed:

  • Changed: src/lib/api/vaults.ts
  • Per-network allowlist of supported collateral assets validated at vault-creation time; collateral asset immutable after creation
  • Internal normalization to the asset's declared decimals for all share pricing, NAV, capacity, and fee math via a single shared helper
  • Deposit/withdraw amounts validated against the asset's decimals with clear over-precision errors

Changes

  • src/lib/api/vaults.ts (modify)

Approach

  1. Implement Stellar Transaction Simulation, Fee Estimation, and Failure Surfacing for Vault Deposits and Withdrawals #214 — Implement Stellar Transaction Simulation, Fee Estimation, and Failure Surfacing for Vault Deposits and Withdrawals (Changed: src/lib/api/vaults.ts)
  2. Expose Vault LP Shares as a SEP-41 Compliant Token for Wallet Visibility and Composability #215 — Expose Vault LP Shares as a SEP-41 Compliant Token for Wallet Visibility and Composability (Changed: src/lib/api/vaults.ts)
  3. Implement the Vault Fee Policy With High-Water-Mark Performance Fees and Treasury Distribution #216 — Implement the Vault Fee Policy With High-Water-Mark Performance Fees and Treasury Distribution (Changed: src/lib/api/vaults.ts)
  4. Implement Multi-Asset Collateral Support and Asset Decimal Handling Across the Vault Suite #217 — Implement Multi-Asset Collateral Support and Asset Decimal Handling Across the Vault Suite (Changed: src/lib/api/vaults.ts)

Issues

Closes #214
Closes #215
Closes #216
Closes #217

@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@chindosunday Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

techisigu and others added 5 commits October 24, 2026 12:53
- src/lib/api/vaults.ts: merged [markers] — model resolved the conflict markers

Co-authored-by: Simple Agent <agent@simple.dev>
- src/lib/api/vaults.ts: merged [markers] — model resolved the conflict markers

Co-authored-by: Simple Agent <agent@simple.dev>
- src/lib/api/vaults.ts: merged [markers] — model resolved the conflict markers

Co-authored-by: Simple Agent <agent@simple.dev>
- src/lib/api/vaults.ts: merged [markers] — model resolved the conflict markers

Co-authored-by: Simple Agent <agent@simple.dev>
- src/lib/api/vaults.ts: merged [markers] — model resolved the conflict markers

Co-authored-by: Simple Agent <agent@simple.dev>
@techisigu
techisigu merged commit aa2ee7b into Zenith-options:main Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment