Repository navigation
Jsv analytics dashboard - #271
Merged
Merged
Conversation
…nt + test placement Adopts mijinummi's protocol analytics dashboard (API route + Dashboard component) and the subgraph scaffolding (The Graph protocol indexer). Fixes two CI failures: 1. frontend/__tests__/pool.test.ts imported matchstick-as (a subgraph test framework not in frontend's deps) — moved to subgraph/tests/pool.test.ts where Graph projects expect matchstick tests to live. This also removes it from vitest's test roots (__tests__/). 2. prefer-const (5) and no-explicit-any (1) lint errors in pool.test.ts and route.ts fixed; route.ts error: any replaced with instanceof Error check. 3. Prettier run on route.ts and Dashboard.tsx.
Specifies a vault-agnostic adapter interface, a test mock vault, pool-side shared accounting with a liquidity buffer, and a governance flow that reuses the existing Custom proposal type so no enum or stored-proposal schema changes. Documents custody, share-value, and illiquidity risks.
Introduces the jointsave-yield-vault crate with the VaultAdapter trait (deposit, withdraw, share_price, max_redeemable, total_shares, total_assets), a shared VaultError enum, yield-allocation events, and the SHARE_SCALE / liquidity-buffer constants. The pool will depend only on this interface, so any vault implementation can be plugged in.
Implements MockVault as a self-contained VaultAdapter: 1:1 first deposit, live share price from its token balance, floor-rounded withdrawals, and a set_locked_assets admin control to simulate illiquidity deterministically. Includes unit tests and a CI wasm build step.
Extends the Custom proposal dispatcher: a Custom proposal carrying an 'action' parameter (alloc/dealloc) is forwarded via CPI to the pool's apply_yield_allocation / apply_yield_deallocation entrypoints, using the existing i128 param encoding and a strkey vault parameter. Proposals without an 'action' parameter keep the previous behaviour, so the closed ProposalType enum and stored proposal schema are unchanged. Adds mock-pool tests.
Adds apply_yield_allocation (admin or governance only) which moves idle capital into a vault implementing the adapter, tracks the pool's shares and cost basis, and enforces a configurable liquidity buffer (default 20%) so the pot always keeps enough liquid for withdrawals. Adds set_yield_buffer and read-only views. The yield-vault mock is feature-gated so it is not linked into the pool's wasm.
Adds apply_yield_deallocation (admin, governance, or any member) which redeems shares and degrades gracefully to a partial recovery when the vault is illiquid, removing proportional cost basis. Withdrawals now pull the shortfall back from the vault automatically and only revert with a clear 'vault illiquid' error when the pot is genuinely short, so member funds are never trapped. Adds set_yield_locked emergency mode.
Adds sync_yield (admin, governance, or any member) which values the pool's vault position at the live share price, credits any gain to members pro-rata by principal balance using floor division, and advances the cost basis by exactly what was credited so the rounding remainder stays in the pot as still-unrealised yield. Adds yield_position and unrealised_yield views.
Covers illiquidity (partial de-allocation, locked vaults, withdraw panic path), buffer enforcement (zero buffer), rounding and zero-amount rejections, paused pool behavior, and the governance Custom dispatch paths (double-vote/unauthorized already covered). All existing and new tests pass.
Extends useJointSaveContracts with fetchYieldAllocationState and hooks to apply allocation, deallocate, sync yield, set buffer, and set lock on the flexible pool. Mirrors existing contract interaction patterns with loading state and proper argument encoding.
Adds framework-free helpers (buffer/max-allocatable/share-price/unrealised gain) mirroring the contract invariants with unit tests, plus useYieldAllocation which loads the on-chain position and exposes apply/deallocate/sync/buffer/lock actions that refetch after each mutation.
Extends the create-proposal dialog with an Allocate/De-allocate option for flexible pools that encodes a Custom governance proposal carrying action, vault and amount parameters (16-byte BE i128), matching the contract's dispatch_custom routing. Adds pure param-encoding helpers with unit tests and en/es copy.
Parses proposal parameters out of the on-chain map and renders the decoded action, amount and vault on each yield proposal card so members know what they are voting on. Unifies the duplicate GovernanceProposal types onto lib/governance as a single source of truth and adds decode/format helpers with unit tests.
Adds a vault-allocation section to the flexible-pool yield dashboard showing the position value, unrealised yield, share price, liquidity buffer and available-to-allocate, plus controls to allocate, de-allocate, sync yield and toggle the vault lock. Reuses the useYieldAllocation hook with loading/error/ empty states and adds en/es copy.
Adds an in-UI banner for flexible pools when the yield vault is locked with allocated shares, warns about withdrawal limits, and updates the withdraw hint to reflect automatic on-chain de-allocation from vaults. Fetches yield state to detect illiquidity.
Add manual-mock exports for the yield allocation hooks so the group-actions component test can render the extended withdraw flow, and cover the vault allocation dashboard section plus the yield proposal details in the voting UI.
Add a threat model for the vault-backed yield feature, document the mock vault and its deployment in the smart-contract README, extend deploy.sh to build/upload/deploy/initialize the mock vault and record its wasm hash and contract id, and reference the feature from the root README.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The CI clippy job runs with --all-targets, which lints test code too and rejected two bindings that are only used for their side effects in the yield allocation edge-case tests.
This branch was successfully deployed
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.
Description
This branch delivers two related pieces of work on top of
main:f9ed64b,89c0b1c,cb52797) — a protocol-wide analytics dashboard backed by a new/api/v1/protocol/summaryroute and asubgraph/package.e514451…a85c8db) — an opt-in feature that lets flexible pools move idle capital into an external yield vault, gated by governance and a liquidity buffer.Vault-backed yield allocation
Flexible (
flexible) pools can now allocate idle capital to an external, yield-bearing Soroban vault. The feature is deliberately constrained:VaultAdapterinterface (deposit,withdraw,share_price,max_redeemable). AMockVaultships behind themockcargo feature for tests and testnet demos.Customproposal path and are dispatched to the pool via CPI, so there is noProposalTypeenum change."vault illiquid"error if the vault cannot redeem.apply_yield_deallocationdegrades to a partial withdrawal;YieldLockedstops new allocations while still allowing de-allocation.overflow-checks = true), and events for every fund movement.Smart contracts
yield-vaultcrate:VaultAdapter/VaultClient,VaultError, events, types (SHARE_SCALE,DEFAULT_BUFFER_BPS,BPS_DENOMINATOR), and theMockVault.flexible: allocation/de-allocation entrypoints, buffer configuration, yield accounting (sync_yield), views (yield_vault,yield_shares,yield_cost_basis,yield_buffer_bps,yield_locked,max_allocatable_amount,yield_position,unrealised_yield), and buffer-safe withdrawals.governance:dispatch_customroutesalloc/deallocactions through the pool CPI.Frontend
useYieldAllocationdata hook for yield state and actions (apply, deallocate, sync, set buffer, set lock).Docs & deployment
docs/plans/2026-10-16-yield-allocation.md(design spec) anddocs/security/yield-allocation-threat-model.md(threat model).smartcontract/README.mdupdates.smartcontract/scripts/deploy.shnow builds (mock feature), uploads, deploys, and initializes the mock vault on testnet, and records its wasm hash / contract id indeployments/stellar-testnet.json.Type of Change
How Has This Been Tested?
cargo testpasses (smart contracts) —flexible79,governance42,yield-vault4cargo clippy --workspace --all-targets -- -D warningspassescargo fmt --all --checkpassespnpm lintpasses (frontend)pnpm buildsucceeds (CI "Frontend – Lint & Format Check" + Vercel preview)pnpm test:unit— 443 node unit tests passvote-card-yieldandyield-dashboard-vaultsuites pass (7 tests)Notes:
flexible-form,group-page,transactions,archived-pool,deposit-calendar) were confirmed pre-existing/flaky by reproducing them on the base commit — they are unrelated to this change.Checklist
Screenshots (if applicable)