Skip to content

Add Quasar port of the vault-strategy example#102

Merged
mikemaccana merged 1 commit into
mainfrom
claude/quasar-vault-strategy
Jul 7, 2026
Merged

Add Quasar port of the vault-strategy example#102
mikemaccana merged 1 commit into
mainfrom
claude/quasar-vault-strategy

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Ports finance/vault-strategy/anchor to Quasar under finance/vault-strategy/quasar and 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

  • The cross-program swap is built by hand. Anchor generates a typed CPI client (mock_swap_router::cpi::*); Quasar has none, so each swap is a CpiDynamic call whose account list and wire-format instruction data (a one-byte discriminator plus two little-endian u64s) the vault constructs directly in deposit and rebalance.
  • The Pyth feed and foreign token/mint accounts are read by raw byte offset through UncheckedAccount views (same layout the Anchor build parses).
  • Pool vaults are program-derived token accounts rather than ATAs; the share mint carries no freeze authority (it is never used).

Tests & docs

  • Router suite (mock-swap-router/src/tests.rs): initialize, set-rate, and a USDC-for-asset swap.
  • Vault suite (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.
  • README covers both programs, the accounts/PDAs, custody, and every adaptation.

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 build and cargo clippy --lib are clean for both programs (only the framework's idl-build cfg warnings), and cargo test --no-run compiles 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

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
@mikemaccana mikemaccana merged commit a074d11 into main Jul 7, 2026
26 checks passed
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.

2 participants