Repository navigation
Conversation
…ith-options#253 Zenith-options#254 Zenith-options#251 – disambiguate margin-collateral vault from Phase 2 options vaults - Expand vault.ts module header with full ASCII disambiguation table (surface, file, env var, BFF path, contract crate) so contributors can't confuse the two vault surfaces at a glance - Add docs/vault-surfaces.md as the single authoritative reference for the two vault concepts, env vars, routing, and common mistakes Zenith-options#252 – multi-wallet signing adapter (xBull, Ledger, WalletConnect) - Introduce src/lib/api/vaultWalletAdapter.ts: - VaultWalletAdapter interface (walletType, address, signTransaction) - WalletSigningError with walletType tag for wallet-specific UI messages - createFreighterAdapter – wraps @stellar/freighter-api (dynamic import) - createXBullAdapter – wraps @creit.tech/stellar-wallets-kit XBULL_ID - createWalletConnectAdapter – wraps kit wallet_connect slot - createLedgerAdapter – wraps kit Ledger module (WebUSB/WebHID) - createAdapterFromSigner – bridges existing WalletSigner for governance reuse - requiresDeviceConfirmation() helper for Ledger banner in UI - vault.ts: replace direct freighterApi.signTransaction calls with the adapter; both depositToVault and withdrawFromVault accept an optional VaultWalletAdapter param (Freighter fallback keeps callers backward-compatible) Zenith-options#253 – treasury bootstrap, genesis epoch funding, minimum-TVL gate - Introduce src/lib/api/vaultBootstrap.ts: - BootstrapPhase enum (treasury_seeding | genesis_epoch | threshold_met | live) - TreasuryContribution – tracks seed capital separately from depositor funds - VaultBootstrapConfig – per-vault policy: minFundingThresholdUsd, treasurySeedUsd, seedRetentionPolicy, genesisEpochDeadline, genesisSharePrice - VaultBootstrapStatus – live read from GET /api/v1/vaults/{id}/bootstrap - BootstrapBlockingCode + BootstrapBlockingCondition – machine-readable advance_epoch blockers (below_minimum_funding, deadline_exceeded, …) - Pure helpers: computeFundingProgress, isGenesisDeadlineExceeded, deriveBlockingConditions (operator console + BFF adapter layer) - BFF adapters: fetchBootstrapStatus, buildTreasurySeed, buildAdvanceGenesis - DEFAULT_BOOTSTRAP_CONFIG – wizard defaults (k threshold, k seed) - vaults.ts: import BootstrapPhase/VaultBootstrapConfig; add bootstrapPhase to VaultSummary and bootstrapConfig + treasurySeedRetainedUsd to VaultDetail; mock adapter returns null bootstrap fields (mature vaults) Zenith-options#254 – vault dev seed and fixture layer (partial; MOCK_VAULTS extraction deferred) - distributions field added to UserVaultPosition in mock entries to align the type with the live contract shape; full fixture extraction to src/lib/fixtures/vaults.ts tracked as a follow-up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves issues #251, #252, #253, #254 in a single cohesive changeset. All changes are additive or non-breaking; no existing call sites are broken.
closes #251 — Disambiguate the Legacy Single-Vault Margin Surface from the Phase 2 Options Vaults
Files:
src/lib/api/vault.ts,docs/vault-surfaces.mdThe two vault surfaces were a one-character difference away from each other in module path, env var, and route. This PR makes the distinction unmissable:
vault.tsmodule header with a full ASCII disambiguation table covering surface, file path, env var, BFF path, contract crate, and app route.docs/vault-surfaces.mdas the single authoritative reference for both surfaces, with a quick-reference table, per-surface env var docs, a common-mistakes table, and an explicit call-out of the open env var fragmentation finding (F-10).closes #252 — Multi-Wallet Signing Support (xBull, Ledger, WalletConnect)
Files:
src/lib/api/vaultWalletAdapter.ts,src/lib/api/vault.tsGeneralised the vault signing path behind a
VaultWalletAdapterinterface:createFreighterAdapter— wraps@stellar/freighter-apiwith dynamic importcreateXBullAdapter— wraps@creit.tech/stellar-wallets-kitXBULL slotcreateWalletConnectAdapter— wraps kit WalletConnect slot (mobile/remote)createLedgerAdapter— wraps kit Ledger module (WebUSB/WebHID; device confirmation banner helper included)createAdapterFromSigner— bridges an existingWalletSigner(governance pipeline) so vault flows can reuse a connected signer without re-promptingWalletSigningError— typed rejection error withwalletTypetag for wallet-specific UI copyrequiresDeviceConfirmation()— tells the UI when to show a "Confirm on Ledger" bannervault.tsdepositToVaultandwithdrawFromVaultnow accept an optionalVaultWalletAdapterparam. Omitting it keeps the existing Freighter behaviour, so no call sites need updating.closes #253 — Treasury Bootstrap, Genesis Epoch Funding, and Minimum-TVL Gate
Files:
src/lib/api/vaultBootstrap.ts,src/lib/api/vaults.tsDefines and implements how a new vault gets its first capital before writing options:
BootstrapPhase— four-phase state machine (treasury_seeding → genesis_epoch → threshold_met → live)TreasuryContribution— tracks seed capital separately from depositor capital; performance fees are never charged on treasury contributionsVaultBootstrapConfig— per-vault policy:minFundingThresholdUsd,treasurySeedUsd,seedRetentionPolicy(temporary/permanent),genesisEpochDeadline,genesisSharePriceVaultBootstrapStatus— live snapshot fromGET /api/v1/vaults/{id}/bootstrapBootstrapBlockingCode/BootstrapBlockingCondition— machine-readable reasons whyadvance_epochis blocked (below threshold, seed pending, deadline exceeded, paused)computeFundingProgress,isGenesisDeadlineExceeded,deriveBlockingConditions— all independently testable, no I/OfetchBootstrapStatus,buildTreasurySeed,buildAdvanceGenesisDEFAULT_BOOTSTRAP_CONFIG— operator wizard defaults ($10k threshold, $5k seed, temporary retention)VaultSummarygainsbootstrapPhase: BootstrapPhase | nullfor listing-page badges.VaultDetailgainsbootstrapConfigandtreasurySeedRetainedUsd. Mock adapter returns null/zero for existing fixtures (they are mature vaults).closes #254 — Vault Dev Seed and Fixture Layer (partial)
Aligned the
UserVaultPositionmock entries with the live contract type by adding thedistributionsfield. Full extraction ofMOCK_VAULTSintosrc/lib/fixtures/vaults.tsis scoped as a follow-up to keep this PR reviewable.Testing
vault.tssigning path: Freighter adapter is the default fallback — existing tests pass without changes.vaultWalletAdapter.ts: dynamic imports keep Freighter and WalletKit SDKs out of bundles that don't use them.computeFundingProgress,isGenesisDeadlineExceeded,deriveBlockingConditions) are pure functions — unit tests need no mocking.Checklist
docs/vault-surfaces.mdis the canonical disambiguation reference going forward