Add Quasar port of the vault-strategy example#102
Merged
Conversation
Port finance/vault-strategy/anchor to finance/vault-strategy/quasar as two Quasar programs sharing the Anchor program IDs, and link it in the root README example index: - vault-strategy: the tokenized multi-asset vault (deposit at NAV, withdraw in kind, rebalance, time-based management fee). - mock-swap-router: a constant-rate swap venue the vault trades through. The valuation, fee, and oracle-anchored swap-floor math are preserved. Quasar-specific adaptations: - The cross-program swap is built by hand with CpiDynamic (Quasar has no generated typed CPI client): the router account list and its wire-format instruction data (1-byte discriminator + two LE u64s) are constructed in deposit and rebalance directly. - The Pyth feed and foreign token/mint accounts are read by raw byte offset through UncheckedAccount views. - Pool vaults are program-derived token accounts rather than ATAs; the share mint carries no freeze authority. Includes QuasarSVM tests: the router suite (initialize, set-rate, swap) and the vault suite (manager setup plus a two-program deposit that deploys USDC into the basket through the router CPI), and a README covering both programs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ATxCcgrZxaL5dMZSyWj1K
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.
Ports
finance/vault-strategy/anchorto Quasar underfinance/vault-strategy/quasarand links it in the root README index. This is a two-program system, each its own Quasar project sharing the Anchor program IDs:vault-strategy/- the tokenized multi-asset vault (VLT5W7…).mock-swap-router/- a constant-rate swap venue the vault trades through (SWPR8R…).What's preserved
The net-asset-value pricing, in-kind proportional withdrawal, time-based management fee, and the oracle-anchored swap-slippage floors are faithful to the Anchor build. All 9 vault instructions and all 4 router instructions are ported.
Quasar-specific adaptations
mock_swap_router::cpi::*); Quasar has none, so each swap is aCpiDynamiccall whose account list and wire-format instruction data (a one-byte discriminator plus two little-endian u64s) the vault constructs directly indepositandrebalance.UncheckedAccountviews (same layout the Anchor build parses).Tests & docs
mock-swap-router/src/tests.rs): initialize, set-rate, and a USDC-for-asset swap.vault-strategy/src/tests.rs): the manager setup path (registry, whitelist, strategy, add asset) with state assertions, and a two-program deposit that loads both.sos, wires up rates and a Pyth-shaped feed, and deposits USDC that is deployed into the basket through the router CPI, asserting share minting, vault balances, and treasury flow.The CI builds both programs (all program dirs are built before any are tested), so the vault deposit test finds the router's compiled
.so.Validation
cargo buildandcargo clippy --libare clean for both programs (only the framework'sidl-buildcfg warnings), andcargo test --no-runcompiles and links both QuasarSVM suites. The SBF build and test run happen in the Quasar CI; they couldn't run in the authoring sandbox because Solana platform-tools weren't reachable there.🤖 Generated with Claude Code
https://claude.ai/code/session_016ATxCcgrZxaL5dMZSyWj1K
Generated by Claude Code