# Vanna Protocol Source: https://docs.vanna.finance/home Lend, borrow up to 10x into one margin account, and use that credit across DeFi on Stellar and Solana. ![Vanna](https://mintcdn.com/vannafinance/UHj8oBBMt2jwIvZH/logo/vanna-dark.png?fit=max\&auto=format\&n=UHj8oBBMt2jwIvZH\&q=85\&s=8d4a259c94861810159a811d7d5a66bd) Composable Creditinfra for any DeFi. Vanna has two sides. **Lenders** supply assets to lending pools and earn interest. **Traders** open a margin account, deposit collateral, borrow up to 10x, and use the borrowed funds in swaps, farms and other protocols without leaving the account. One health factor covers the whole account. Vanna runs on **Stellar** and **Solana**. Both use the same app at [test.vanna.finance](https://test.vanna.finance): pick your chain in the switcher at the top right. ## Choose a chain > **[Vanna on Stellar](/stellar/home)** > > Stellar testnet. Lend XLM and USDC, borrow with Single or Dual Borrow, swap on Soroswap or Aquarius, and farm on Blend and AMM pools. > **[Vanna on Solana](/solana/home)** > > Solana mainnet fork. Use SOL, LSTs, stables and tokenized stocks as collateral, swap on Jupiter or Titan, trade Phoenix perps, farm vaults, and trade predictions. ## Quick links **Stellar** > **[Getting started](/stellar/guides/getting-started)** > > Connect a wallet and get test funds. > **[Borrow](/stellar/guides/margin/borrow)** > > Deposit collateral and borrow up to 10x. > **[Supply to Earn](/stellar/guides/earn/supply)** > > Lend to a pool and earn interest. > **[Health factor](/stellar/guides/margin/health-factor)** > > How liquidation risk is measured. > **[Deployed contracts](/stellar/developers/deployed-contracts)** > > Testnet contract addresses. > **[FAQ](/stellar/resources/faq)** > > Common questions. **Solana** > **[Getting started](/solana/guides/getting-started)** > > Sign in, add the fork RPC and get test funds. > **[Borrow](/solana/guides/margin/borrow)** > > Deposit collateral and borrow up to 10x. > **[Perps](/solana/guides/perps/overview)** > > Long or short on Phoenix from your margin account. > **[Predict](/solana/guides/predict/overview)** > > Trade predictions that earn while you wait. > **[Deployed programs](/solana/developers/deployed-contracts)** > > Program IDs and accounts. > **[FAQ](/solana/resources/faq)** > > Common questions. ## Features by chain | Feature | Stellar | Solana | | :- | :- | :- | | Lending pools | XLM, BLUSDC, AqUSDC, SoUSDC | SOL, USDC, USDT | | Margin account, up to 10x | Yes, with Single and Dual Borrow | Yes | | Collateral | XLM, USDC, Blend and LP positions | SOL, LSTs, stables, tokenized stocks | | Spot swaps | Soroswap, Aquarius | Jupiter, Titan | | Perpetuals | — | Phoenix | | Farming | Blend, Soroswap and Aquarius LP | Kamino, Perena, delta-neutral vaults | | Prediction markets | — | World.xyz | | Analytics and Copilot | Yes | Yes, plus an MCP connector | | Network | Stellar testnet | Solana mainnet fork | > [!NOTE] > > The app is in private testing, so your first visit to [test.vanna.finance](https://test.vanna.finance) asks for an access code. Ask the Vanna team on [Discord](https://discord.gg/hPeTSwuVH) for one. All funds are test funds with no real value. # Architecture Source: https://docs.vanna.finance/solana/developers/architecture Core program, oracle and validator agents, PDAs, the app, and the remaining-accounts convention. ## Core and agents The core program only accounts. It knows what each margin account holds and owes, and asks two agent programs for the rest. The admin registers the agents. The core calls them read-only, with no writable accounts and no signers, and accepts their answer only as return data from the program it called. The interface lives in `programs/vanna_credit_layer/src/interface.rs`. | Agent | Entry point | Answers | | - | - | - | | Oracle (`vanna_oracle`) | `get_price(queries) -> Vec` | The USD value of each token amount or venue holding, plus the checks the price passed (fresh, TWAP, confidence) | | Validator (`vanna_validator`) | `review_call(context) -> CallPermit` | Whether an external call is allowed, which call accounts must be the margin, which margin vaults it may pay into and out of, and spend caps | Every asset names its oracle (`AssetConfig.oracle`). Every whitelisted program names its validator (`Integration.validator`). ## On-chain accounts ```text theme={null} vanna_credit_layer ProtocolConfig ["protocol"] admin, treasury, mode, margin limits, allowed-token list ├── AssetConfig ["asset", mint] token: risk params, oracle, issuer-controls flag │ └── Reserve ["reserve", mint] lending pool (USDC, USDT, SOL only) │ ├── liquidity vault = ATA(mint, reserve) │ └── share mint ["share_mint", mint] vTokens (classic SPL) ├── AssetConfig ["asset", venue] venue kind (the Phoenix exchange) ├── Integration ["integration", program_id] whitelisted external program + its validator └── MarginAccount ["margin", authority] one per wallet ├── margin vaults = ATA(mint, margin) live balance is the collateral └── DebtPosition ["debt", margin, reserve] borrow shares vanna_oracle PriceBook ["price_book"] every token's OracleConfig, keyed by mint MarketBook ["market_book", venue] listed Phoenix markets, leverage caps, index prices ``` ## Remaining accounts Any instruction that values the account or reviews a call takes, in `remaining_accounts`: 1. For `margin_execute` and `public_liquidate`: the external call's accounts first. 2. One `[asset_config, margin_vault]` group per allowed token, in the allowed list's order. The instruction's own token is left out. A vault that does not exist yet counts as zero. 3. One `[asset_config, margin]` group per venue the margin holds. 4. One `[asset_config, reserve, debt_position]` group per active debt. The instruction's own debt is left out. 5. The agent segments: `[vanna_oracle, price_book, …price accounts]`, and for calls that need it the validator's segment (for Phoenix: `[vanna_validator, market_book, exchange]`). Agents find accounts by key. An account that is needed but missing fails the instruction. The app builds these lists in `lib/solana/margin.ts` (`buildHealthRemainingAccounts`). The scripts build them in `scripts/src/devnet-positions.ts`. > [!WARNING] > > Do not trim the groups to save space. A missing debt or token fails closed, and the margin's health can't be computed from a partial set. ## Application The Solana app (`apps/solana` in the `Vanna_Finance_Backend` monorepo, which also holds the Stellar app; it grew out of `vanna-credit-backend`) is a Next.js app with React Query hooks, Zustand stores, an Anchor client, Wallet Standard wallets (Backpack) and Dynamic embedded wallets for email and social login. | Route | Product | | - | - | | `/earn` | Supply to and redeem from the USDC, USDT and SOL pools | | `/` and `/margin` | Margin account: deposit, borrow, repay, withdraw, flash repay (the app opens here) | | `/trade/spot` | Jupiter or Titan swaps (the user picks the aggregator), from the margin account | | `/trade/perps/[pair]` | Phoenix perps from the margin account | | `/farm` | Kamino Lend, Perena USD\* and basis vaults from the margin account | | `/predict` | World.xyz prediction markets | | `/portfolio` | Combined view | | `/analytics` | Protocol and account analytics | | `/copilot` | AI Copilot (plans transactions through the Vanna MCP engine) | | `/rewards` | Coming soon | | `/api/solana/jupiter/*`, `/api/solana/titan/*` | Quote and swap proxies (hold the API keys server-side) | | `/api/solana/prices`, `/api/solana/prices/refresh` | Prices as the program reads them; fork price keeper | | `/api/solana/faucet`, `/api/solana/predict/faucet` | Fork faucet (registry tokens; CASH for Predict) | The browser uses `NEXT_PUBLIC_SOLANA_RPC_URL` (hosted: `https://rpc-devnet.solana.vanna.finance`). Server routes may use a loopback `FORK_RPC_URL` when the app and Surfpool share a machine. Despite the `devnet` hostname, this is a Surfpool **mainnet fork**, not the public Solana Devnet cluster. ## Boundaries * Earn vTokens are not margin collateral. * Perps run on Phoenix through `margin_execute`. There is no perps engine inside Vanna. * Fork cheatcodes (faucet, price keeper, pool healing) are demo infrastructure, not mainnet behaviour. * Source support is not the same as a verified public-mainnet deployment. # Account Layout Source: https://docs.vanna.finance/solana/developers/contracts/accounts ProtocolConfig, AssetConfig, Reserve, MarginAccount, DebtPosition, Integration, and the oracle's books. Source: `programs/vanna_credit_layer/src/state/` and `programs/vanna_oracle/src/{price_book,market_book}.rs`. ## ProtocolConfig `["protocol"]` `admin`, `pending_admin`, `treasury`, `operating_mode`, `max_assets_per_margin`, `next_asset_index`, `allowed_tokens[24]`, `max_debts_per_margin`, `max_venues_per_margin`. `allowed_tokens` is the protocol-wide list of asset indexes that count as collateral. Every margin's health scan walks this list. ## AssetConfig `["asset", mint]` or `["asset", venue]` `mint`, `token_program`, `reserve` (default if there is no pool), `max_collateral_per_margin`, `ltv_bps`, `liquidation_threshold_bps`, `liquidation_bonus_bps`, `asset_index`, `decimals`, `collateral_enabled`, `borrow_enabled`, `kind` (`Token` or `Venue`), `oracle`, `issuer_controls_accepted`. `max_collateral_per_margin` caps how much of a token counts toward health. `u64::MAX` means uncapped, and `0` means it counts for nothing (a liquidator can still seize it). ## Reserve `["reserve", mint]` `asset_config`, `underlying_mint`, `liquidity_vault`, `share_mint`, `supply_cap`, `borrow_cap`, `accounted_liquidity_assets`, `total_borrow_assets`, `total_borrow_shares`, `borrow_index_wad`, `accrued_protocol_fees`, `last_update_timestamp`, `rate_curve`, `reserve_factor_bps`, `status`, `total_supply_shares`, `interest_remainder_wad`, `fee_remainder`. The liquidity vault is the ATA of the reserve PDA. The share mint is `["share_mint", mint]` under classic SPL Token, even when the underlying is Token-2022. ## MarginAccount `["margin", authority]` `authority`, `status`, `venue_count`, `debt_count`, `venue_asset_indexes[24]`, `debt_asset_indexes[24]`, `event_sequence`. There is no collateral ledger. A margin's collateral is the live balance of its vaults (`ATA(mint, margin)`) for every allowed token. The account itself tracks only its venues and debts. ## DebtPosition `["debt", margin, reserve]` `margin_account`, `reserve`, `borrow_shares`. Token debt is derived from shares. ## Integration `["integration", program_id]` `program_id`, `validator`, `enabled`. ## Oracle: PriceBook `["price_book"]` Owned by `vanna_oracle`. Up to 32 `PriceSource { mint, decimals, config: OracleConfig }` entries. `OracleConfig`: `scope_prices`, `scope_chain[4]`, `scope_twap_chain[4]`, `pyth_price`, `pyth_factor`, `receipt_account`, `receipt_program`, `max_age_secs`, `max_twap_divergence_bps`, `max_confidence_bps`. ## Oracle: MarketBook `["market_book", venue]` Owned by `vanna_oracle`. `venue`, `program`, `collateral_mint`, `collateral_decimals`, `collateral_price` (an `OracleConfig`), and up to 32 `MarketEntry { market, asset_id, max_leverage_bps, trading_enabled, index_price }`. # Admin Instructions Source: https://docs.vanna.finance/solana/developers/contracts/admin Protocol init, two-step admin, modes, margin limits, assets, venues, reserves, integrations, fees. Source: `instructions/admin/{protocol,assets,reserves,integrations}.rs`. ## Protocol | Instruction | Purpose | | - | - | | `initialize_protocol(treasury, max_assets_per_margin, max_debts_per_margin, max_venues_per_margin)` | Once. Must be signed by the program's upgrade authority (checked against its program data account) | | `admin_set_margin_limits(max_assets, max_debts, max_venues)` | Change the per-margin limits | | `admin_propose_authority(new_admin)` / `authority_accept_admin` | Two-step admin handover | | `admin_set_operating_mode(mode)` | `Normal`, `BorrowPaused`, `WithdrawOnly`, or `Halted` | The allowed-token list may hold at most `max_assets_per_margin` minus the debt and venue limits. That way, allowing a token never stops borrowing, and a liquidation always fits in one transaction. ## Operating modes | Mode | Allowed | | - | - | | `Normal` (0) | Everything | | `BorrowPaused` (1) | Everything except borrow | | `WithdrawOnly` (2) | Repay, redeem, collateral deposit and withdraw, `margin_execute`, liquidate, write-off | | `Halted` (3) | Repay and collateral deposit only | ## Assets and venues | Instruction | Purpose | | - | - | | `admin_register_asset(max_collateral_per_margin, ltv_bps, liquidation_threshold_bps, liquidation_bonus_bps, collateral_enabled, borrow_enabled, accept_issuer_controls)` | Create `AssetConfig ["asset", mint]`. Names the oracle, has it price the token once, screens the mint. A collateral-enabled token joins the allowed list | | `admin_update_asset_config(…)` | Same risk fields after listing | | `admin_set_asset_oracle` | Re-point the asset at its oracle | | `admin_set_token_allowed(allowed)` | Add or remove a token from the allowed list. Removing zeroes its value immediately | | `admin_register_venue(venue)` | Create a venue-kind `AssetConfig ["asset", venue]` (for Phoenix, the exchange account). Venues can't be borrowed or transferred | Risk parameters are validated: `ltv < liquidation_threshold ≤ 100%`, bonus at most 5%, and `threshold × (1 + bonus) ≤ 100%`. **Issuer controls.** A mint whose issuer keeps power over balances or value needs `accept_issuer_controls = true`. That covers a freeze authority, a close authority, a transfer-fee, interest-rate or scaled-UI authority, a permanent delegate, pausing, or a settable transfer hook. Fixed transfer fees, metadata, groups and confidential transfers need nothing. A live transfer hook, non-transferable mints, accounts created frozen and unknown extensions are refused. A token allowed again is screened again, and must keep its token program and decimals. ## Reserves | Instruction | Purpose | | - | - | | `admin_initialize_reserve(rate_curve, reserve_factor_bps, supply_cap, borrow_cap, status)` | Create `Reserve`, its liquidity vault (idempotent ATA) and share mint | | `admin_update_reserve_config(…)` | Same fields | | `admin_collect_protocol_fees(amount)` | Sweep up to `accrued_protocol_fees` to the treasury | Reserve status: `Active` (0), `SupplyOnly` (1), `RepayOnly` (2), `Frozen` (3). Borrowing needs `Active`. Supply needs `Active` or `SupplyOnly`. Redeem is blocked only when `Frozen`. Repay is always allowed. The configured pools are USDC, USDT and SOL. The bootstrap scripts refuse to initialize a reserve for any other asset. ## Integrations | Instruction | Purpose | | - | - | | `admin_register_integration` | Create `Integration ["integration", program_id]` binding an external program to its validator. The target can't be the core or the validator itself | | `admin_set_integration_validator` | Re-point an integration at a new validator | | `admin_set_integration_enabled(enabled)` | Switch an integration on or off | ## Oracle admin The oracle's price book and market book are configured through `vanna_oracle` instructions, gated by the core protocol admin. See [Oracle Program](/solana/developers/contracts/oracle). # Borrow and Repay Source: https://docs.vanna.finance/solana/developers/contracts/borrowing user_borrow opens the debt position itself; user_repay_from_margin is the only owner repay path. Source: `instructions/account_manager/borrow.rs`. ## `user_borrow(assets, max_debt_shares)` 1. Gate on operating mode, reserve status (`Active`) and `borrow_enabled`. 2. `init_if_needed` the `DebtPosition ["debt", margin, reserve]` and the margin vault. The margin must have room under `max_debts_per_margin` for a new debt. 3. Accrue. Require `total_borrow + assets ≤ borrow_cap` and `assets ≤ available_cash`. 4. Mint debt shares (rounded up), at most `max_debt_shares`. 5. Transfer the tokens from the reserve to the margin vault. 6. Value every holding through the oracle. The full-set health factor must exceed 1.10. Borrowed tokens land in the margin vault, so a borrow raises both collateral and debt. A Token-2022 borrow is health-checked on what actually arrives, net of transfer fees. Only the pool assets (USDC, USDT, SOL) are `borrow_enabled`. ## `user_repay_from_margin(max_assets, repay_all)` Repay from the margin vault's own balance. `repay_all` repays the exact accrued debt. The amount is capped at what the vault holds. When shares reach zero, the debt leaves the margin's active list. Close the `DebtPosition` with `user_reclaim_rent`. > [!NOTE] > > There is no wallet-side repay instruction for owners. To repay with wallet funds, deposit them into the margin first, then repay from margin. Liquidators repay from their own wallet inside `public_liquidate`. # Lending Instructions Source: https://docs.vanna.finance/solana/developers/contracts/lending lender_supply, lender_redeem, public_refresh_reserve. Source: `instructions/lending_pool.rs`. ## `lender_supply(assets, min_shares_out)` Accrue. Measure what actually arrived in the liquidity vault (Token-2022 fees included). Mint vTokens at the current rate, at least `min_shares_out`. Respects `supply_cap`, the operating mode and the reserve status. The first deposit locks `MIN_INITIAL_SHARES` that nobody can redeem. ## `lender_redeem(shares, min_assets_out)` Accrue. Burn vTokens. Pay out at most `available_cash` (cash minus protocol fees). Require assets ≥ `min_assets_out`. Allowed in every reserve status except `Frozen`. ## `public_refresh_reserve` Permissionless accrual. Anyone can update a pool so its index isn't stale before a quote. ## Notes * SOL is wrapped by the client before supply. The program sees wSOL. * Unsolicited transfers into the liquidity vault do not change `accounted_liquidity_assets`, so they can't inflate the vToken rate. * The reserve counts its own lender shares (`total_supply_shares`). vTokens burned outside Vanna don't change anyone else's claim. # Liquidation Instructions Source: https://docs.vanna.finance/solana/developers/contracts/liquidation public_liquidate (permissionless, partial, with optional venue calls) and admin_write_off. Source: `instructions/account_manager/liquidate.rs`. ## `public_liquidate(calls, repay, min_seized)` ```text theme={null} calls: Vec // optional Phoenix unwind calls repay: u64 // debt to repay, in the debt token min_seized: u64 // liquidator's slippage bound ``` Anyone can call it on a margin with debt and HF ≤ 1.10. It does not need the owner. 1. Run the venue calls (if any) through the validator in liquidation mode. For Phoenix, that means reduce-only closes inside a price band and a withdrawal of the trader's collateral. 2. Revalue every holding. Require HF ≤ 1.10. 3. If `repay > 0`, settle one pair: repay part of one debt from the liquidator's wallet, and take one allowed token from the margin. **Settling one pair.** The repay is capped at 50% of that debt, or the full debt when HF ≤ 1 + the token's bonus or the debt is worth \$100 or less. The token taken is worth at most the repaid value × (1 + `liquidation_bonus_bps`, at most 5%). While the margin is solvent but below that line, the multiplier is the health factor instead, so a liquidation never takes more than the margin's equity. When the margin holds less of the token, the repay shrinks to match. A token past its cap, or capped to zero, can still be seized. The debt and collateral prices used for settlement must be fresh and within confidence, but not within the TWAP band, so a crash never blocks liquidation. ### Accounts | Account | Notes | | - | - | | `liquidator` | Signer, pays the debt token | | `protocol_config`, `margin_account` | | | `venue_asset`, `integration`, `target_program`, `validator` | Optional; only with venue calls | `remaining_accounts`, in order: 1. The venue calls' accounts. 2. The groups (allowed tokens, venues, debts). The repaid debt's reserve and debt position, and the seized token's vault, are writable. 3. When `repay > 0`: `[debt_mint, reserve_vault, source, debt_token_program, collateral_mint, destination, collateral_token_program]`. 4. The agent segments. ## `admin_write_off` Admin only, refused while `Halted`. Clears every debt of a margin whose collateral is \$1 or less and below its debt, with no venue position open. * Collateral is every allowed token at its raw balance (frozen or past its cap included). * Every price must pass every check. * Each reserve's `accrued_protocol_fees` absorb the written-off amount first, then lenders' assets fall by the rest. > [!WARNING] > > Write-off sees only allowed tokens. Don't remove a token from the allowed list while a margin about to be written off still holds it. See [Math](/solana/developers/math-reference#liquidation) and [Liquidation Bots](/solana/developers/guides/liquidation-bots). # Margin Instructions Source: https://docs.vanna.finance/solana/developers/contracts/margin Create, deposit, withdraw, reclaim rent, and close the margin account. Source: `instructions/account_manager/{account,collateral}.rs`. ## `user_create_margin` Initialize `["margin", authority]`. One per wallet. Authority = signer. ## `user_deposit_collateral(amount)` `init_if_needed` the margin vault (`ATA(mint, margin)`), then a measured transfer in. The asset must be a collateral-enabled token, not a venue. Any allowed token that reaches the vault counts, however it got there: deposit, borrow, swap, or a plain transfer. ## `user_withdraw_collateral(amount, min_health_factor_wad)` Transfer from the margin vault to the wallet. If the margin has debt, the full-set health factor after the withdrawal must exceed 1.10 and `min_health_factor_wad`. A debt-free withdrawal reads no prices at all. ## `user_reclaim_rent` Close an empty margin vault, a fully repaid `DebtPosition`, or both, and return the rent to the authority. ## `user_close_margin` Requires no debts and no venues. Closes the margin PDA and returns its rent. ## Limits Each margin holds at most `max_debts_per_margin` debts and `max_venues_per_margin` venues. Collateral tokens are bounded by the protocol's allowed-token list, so every health scan has a fixed upper cost. # External Calls (margin_execute) Source: https://docs.vanna.finance/solana/developers/contracts/margin-execute How a margin account calls Jupiter, Titan, Kamino, Phoenix, Perena and the basis vaults, reviewed by the validator and health-checked after. Source: `instructions/account_manager/exec.rs`, `interface.rs`. ```text theme={null} margin_execute(data: Vec, call_account_count: u16) ``` A margin account is a PDA, so it can't sign for itself from outside. Every interaction with an external protocol goes through this one instruction. The core program knows nothing about the target. The rules live in the validator. ## Flow ```text theme={null} wallet ──signs──▶ margin_execute(data, call_account_count) │ ├─▶ vanna_validator::review_call(context) → CallPermit ├─▶ CPI into the target, signed by the margin PDA ├─▶ check the margin's vaults against the permit └─▶ vanna_oracle::get_price for every holding → health check ``` ## Accounts | Account | Notes | | - | - | | `authority` | Signer; the margin's owner | | `protocol_config` | `["protocol"]` | | `margin_account` | `["margin", authority]` | | `integration` | `["integration", target_program]`; must be enabled | | `target_program` | The external program | | `validator` | Must equal `integration.validator` | | `venue_asset` | Optional: the venue's `AssetConfig` for a Phoenix call | `remaining_accounts`, in order: 1. The external instruction's accounts (`call_account_count` of them). None is a signer: Vanna signs as the margin. 2. The allowed-token groups, venue groups and debt groups (see [Architecture](/solana/developers/architecture#remaining-accounts)). 3. The oracle segment, including the price accounts of every holding and every token the call will receive. 4. The validator segment, only when the validator needs accounts. For Phoenix it is `[vanna_validator, market_book, exchange]`. ## The permit `review_call` receives a `CallContext { mode, target_program, data, call_account_count, margin, authority, venue }` and returns: | Field | Meaning | | - | - | | `margin_indexes` | Which call accounts must be the margin (it signs there) | | `tokens_in` | Call accounts that are margin vaults the call may pay into | | `tokens_out` | Call accounts that are margin vaults the call may spend from | | `max_spent` | Spend cap for each `tokens_out` vault | | `opens_venue` | The call opens exposure at a venue (for example a Phoenix order) | The core then enforces the permit: * Every token in `tokens_in` and `tokens_out` must be an allowed token. * Each spent vault may drop by at most its cap. A receiving vault must not shrink. * The margin may appear only where the permit says. The core program, the authority's wallet and the margin's other token accounts may not appear anywhere in the call. * A vault left with a delegate or close authority is refused. * If the call opens a venue, the venue's `collateral_enabled` must be on, and the margin must have room under `max_venues_per_margin`. ## Health After the call, every holding is revalued. The account must be debt-free or above HF 1.10. A collateral whose price fails a check counts as zero. A debt that is fresh and within confidence but off its TWAP counts at the higher of price and TWAP rather than blocking. There is no minimum output check in the core. Slippage protection is the external program's own bound (for example Jupiter's or Titan's minimum out). ## Client notes * The receiving margin vault must exist before the call. The margin account can't pay rent, so the client creates the ATA idempotently from the wallet in the same transaction. * Large calls (Phoenix, the basis vaults) need a v0 transaction with an address lookup table and a raised compute-unit limit. * The app's builder is `marginExecuteIx` in `lib/solana/exec.ts`. ## Validator rules by venue See [Validator Program](/solana/developers/contracts/validator), and [Swaps](/solana/developers/contracts/swap), [Phoenix Perps](/solana/developers/contracts/perps) and [Yield Vaults](/solana/developers/contracts/vaults) for each integration. # Oracle Program Source: https://docs.vanna.finance/solana/developers/contracts/oracle vanna_oracle: the price book, the market book, source selection, and the checks every price carries. `vanna_oracle` — `FXY5DRfekMUTbUp4uyCFpCZmCccrp6kPq3hTM4GRihnc` The core never reads a price account itself. It sends the oracle a list of queries and accepts the answer only as return data from the program it called. ## Instructions | Instruction | Who | Purpose | | - | - | - | | `get_price(queries) -> Vec` | Core (CPI, read-only) | Value token amounts and venue holdings | | `open_price_book` | Protocol admin | Create `PriceBook ["price_book"]` | | `set_price_source(config)` | Protocol admin | Insert or update a mint's `OracleConfig`. Checks every pinned account and prices the token once | | `open_market_book(venue, program, collateral_price)` | Protocol admin | Create `MarketBook ["market_book", venue]` for a venue (Phoenix) | | `list_market(index_price, max_leverage_bps, trading_enabled)` | Protocol admin | Add or update one market. The leverage cap is between 1x and 100x | Admin checks read the core's `ProtocolConfig`, so the oracle has no admin of its own. ## Queries and results ```text theme={null} PriceQuery { asset, amount, liability, margin } // margin set ⇒ a venue holding PriceResult { value, borrow_value, checks, open } ``` `value` is in nano-USD. Liabilities round up, collateral rounds down. `borrow_value` is the value used for borrowing decisions (for a debt off its TWAP, the higher of price and TWAP). `checks` is a bitmask of `FRESH`, `TWAP_OK`, `CONFIDENCE_OK`, `TWAP_FRESH`. `open` says whether a venue still holds exposure. ## Source selection For each token, `get_price` reads its `OracleConfig` from the price book: 1. **Kamino Scope** (`scope_prices` + `scope_chain`): a price is the product of up to four `OraclePrices` entries (for example JitoSOL = stake rate × SOL/USD), stamped with its oldest entry. Used while fresh. A zero entry counts as unavailable. 2. **Pyth** (`pyth_price`, × `pyth_factor` when set): the fallback when Scope is stale, used if it is newer. It is the only source when no Scope chain is set (JupUSD). 3. **Receipts** (`receipt_account` owned by `receipt_program`): a Kamino reserve gives an exchange rate into the underlying; a Perena vault or tranche gives a USD share price; a basis vault gives a NAV per share the oracle computes itself. The xStock Scope entries already apply the mint's scaled-UI multiplier, so they price one raw token. ## Checks | Check | Rule | | - | - | | Fresh | Age ≤ `max_age_secs`. A timestamp too far in the future is not fresh either | | TWAP | Within `max_twap_divergence_bps` of Scope's TWAP chain, or Pyth's EMA | | Confidence | Pyth confidence within `max_confidence_bps` | What each instruction requires: | Instruction | Debts | Collateral | | - | - | - | | Borrow, withdraw with debt | Every check | A failed check counts the token as zero | | `margin_execute` | Fresh and confident. Off-TWAP counts at max(price, TWAP) | A failed check counts the token as zero | | `public_liquidate` | Fresh. The two settled prices must be fresh and confident | Counted at reported value, so stale dust can't block | | `admin_write_off` | Every check | Every check | | Debt-free withdraw | No prices read | No prices read | ## Market book (Phoenix) The market book lists the Phoenix markets Vanna accepts. Each entry holds the market (orderbook account), its Phoenix asset id, the leverage cap, a trading switch, and the index-price `OracleConfig`. The book's `collateral_price` prices Phoenix collateral (phUSD at the USDC price). The validator reads the same book to enforce leverage caps and liquidation bands. See [Phoenix Perps](/solana/developers/contracts/perps). ## Accounts The oracle segment in `remaining_accounts` is `[vanna_oracle, price_book, …]` followed by the price accounts of every token with a balance (a cToken's klend reserve included), and for a held venue its market book, exchange, trader and the price accounts of each open market. Accounts are found by key, in any order. # Phoenix Perps Source: https://docs.vanna.finance/solana/developers/contracts/perps How a margin account trades Phoenix perpetuals through margin_execute, how the oracle values the position, and how it is liquidated. Perps run on **Phoenix** (Ellipsis Labs' perpetuals exchange). Vanna has no perps engine of its own. The margin account is its own Phoenix trader, and every step is a [`margin_execute`](/solana/developers/contracts/margin-execute) call, health-checked after it. Sources: `programs/vanna_validator/src/phoenix.rs`, `programs/vanna_oracle/src/phoenix.rs`, `vanna-credit-backend/lib/solana/{phoenix,perps}.ts`. ## Programs and accounts | Role | Address / seed | | - | - | | Phoenix Eternal program | `EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih` | | Phoenix exchange (global config, the venue key) | `2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ` | | Ember (USDC ⇄ phUSD) | `EMBERpYNE6ehWmXymZZS2skiFmCa9V5dp14e1iduM5qy` | | phUSD mint | `PhUsd11YkbjSaWjFncfAAmatntsjx3MgDR9B6g1ks3A` | | Trader account | Phoenix PDA `["trader", margin, 0u16]`, with the margin as authority | | Venue asset | `AssetConfig ["asset", exchange]`, kind `Venue` | | Market book | `vanna_oracle` PDA `["market_book", exchange]` | The whole Phoenix trader account counts as one collateral line on the margin. ## Lifecycle ```text theme={null} open = Ember deposit (USDC → phUSD) → Phoenix deposit_funds → place_market_order (one tx) close = place_market_order, reduce-only (one tx) then withdraw_funds → Ember withdraw (phUSD → USDC) (one tx) ``` Phoenix market orders are immediate-or-cancel and fill against the book inside the transaction. There is no keeper and no pending order. ## Validator rules | Call | Rule | | - | - | | Ember deposit / withdraw | Owner mode only; 8 accounts; spends from the USDC vault into the phUSD vault, or back | | `deposit_funds` | Owner mode only; phUSD from the margin's phUSD vault to its trader account; opens the venue | | `withdraw_funds` | Only what Phoenix's withdraw budget pays now. Refused while any withdrawal is queued | | `place_market_order`, increase | Owner mode only; the market must be listed and its trading switch on; a limit price is required. Exposure at the limit price, plus every other open position at the index price, must stay within the market's leverage cap × the trader's collateral. At most 4 open positions | | `place_market_order`, reduce-only | Always allowed for the owner. In liquidation mode, the limit price must sit within a band of the index price | The leverage cap is set per market in the market book (`list_market`). On the hosted fork, SOL, ETH and BTC are listed at 5x, and TSLA and META at 3x. ## Valuation The oracle values the trader account as: ```text theme={null} equity = collateral + Σ positions (base × index price − entry notional + funding − taker fee to close) value = max(0, equity) ``` Index and USDC prices carry the same freshness and TWAP checks as every other price. For borrowing, the oracle counts collateral and the losses of open positions, but not unrealized gains. The venue leaves the margin's active list once nothing is open. ## Liquidation A Phoenix position can't change hands, so `public_liquidate` takes venue calls first (`calls: Vec`), run in liquidation mode: * Reduce-only closes priced within a band of the fresh index: 5% divided by the market's leverage cap, at most 3%. * A withdrawal of the trader's collateral up to what Phoenix's withdraw budget pays now. It lands in the margin's phUSD vault. phUSD is a registered collateral-only asset priced at USDC, so the liquidator can then seize it in the same instruction. While anyone's Phoenix withdrawal is queued, the withdrawal is refused, but the closes and the margin's other tokens can still be liquidated. With at most 4 open positions, closing all of them, withdrawing and settling fits one transaction with a lookup table. ## Known limits * A stock perp's index (TSLA, META) goes stale while its market is closed, and liquidation closes need a fresh index. Those markets have lower leverage caps for that reason. * After a deposit into Phoenix, Phoenix refuses withdrawals for a short period. An unhealthy owner can't deposit again, so the delay can't be repeated. * On mainnet, Phoenix grants deposit, withdraw and order capabilities to onboarded traders itself. On the fork, the app's `/api/perps/phoenix-access` route stands in for that onboarding. # Program Entrypoint Source: https://docs.vanna.finance/solana/developers/contracts/program vanna_credit_layer instruction list, module map, and the two agent programs. `programs/vanna_credit_layer/src/lib.rs` ```text theme={null} H37YVBG3eGtz89ofd7iDLc2PJgn12778392XeU2QJcGC ``` ## Modules | Module | Job | | - | - | | `state/` | `ProtocolConfig`, `AssetConfig`, `Reserve`, `MarginAccount`, `DebtPosition`, `Integration` | | `math/` | Fixed point, shares, interest-rate model, health factor | | `risk_engine.rs` | Finds and validates every holding of a margin, has the oracle value it, checks health | | `interface.rs` | Core ↔ agent interface: price queries and results, call context and permits | | `validation/` | Operating-mode and reserve-status gates, account and token-transfer checks | | `instructions/admin/` | `protocol.rs`, `assets.rs`, `reserves.rs`, `integrations.rs` | | `instructions/lending_pool.rs` | Supply, redeem, refresh | | `instructions/account_manager/` | `account.rs`, `collateral.rs`, `borrow.rs`, `exec.rs`, `liquidate.rs` | ## Instructions | Group | Instructions | | - | - | | [Admin](/solana/developers/contracts/admin) | `initialize_protocol`, `admin_set_margin_limits`, `admin_propose_authority`, `authority_accept_admin`, `admin_set_operating_mode`, `admin_register_asset`, `admin_set_token_allowed`, `admin_register_venue`, `admin_update_asset_config`, `admin_set_asset_oracle`, `admin_initialize_reserve`, `admin_update_reserve_config`, `admin_collect_protocol_fees`, `admin_register_integration`, `admin_set_integration_validator`, `admin_set_integration_enabled` | | [Lending](/solana/developers/contracts/lending) | `lender_supply`, `lender_redeem`, `public_refresh_reserve` | | [Margin](/solana/developers/contracts/margin) | `user_create_margin`, `user_close_margin`, `user_reclaim_rent`, `user_deposit_collateral`, `user_withdraw_collateral` | | [Borrowing](/solana/developers/contracts/borrowing) | `user_borrow`, `user_repay_from_margin` | | [External calls](/solana/developers/contracts/margin-execute) | `margin_execute` | | [Liquidation](/solana/developers/contracts/liquidation) | `public_liquidate`, `admin_write_off` | ## Agent programs | Program | ID | Instructions | | - | - | - | | [`vanna_oracle`](/solana/developers/contracts/oracle) | `FXY5DRfekMUTbUp4uyCFpCZmCccrp6kPq3hTM4GRihnc` | `get_price`, `open_price_book`, `set_price_source`, `open_market_book`, `list_market` | | [`vanna_validator`](/solana/developers/contracts/validator) | `6fND3vhtstp486iE6rsSNVUox3kcjNNRsSLAN7ZPs7th` | `review_call` | ## Events Liquidation, write-off and `margin_execute` events are emitted through a self-CPI (`emit_cpi!`), so they survive long external-program logs such as Phoenix's. Read them from the inner instructions. Other events (`Borrowed`, `DebtRepaid`, `CollateralDeposited`, `LiquiditySupplied`, and so on) are in `events.rs`. # Margin Swaps Source: https://docs.vanna.finance/solana/developers/contracts/swap Jupiter v6 and Titan swaps from the margin account through margin_execute, reviewed by the validator and health-checked after. There is no dedicated swap instruction. A margin swap is a [`margin_execute`](/solana/developers/contracts/margin-execute) call whose target is Jupiter or Titan. The validator reads the route, and the core enforces the permit and checks health on the post-swap balances. ## Jupiter v6 Validator file: `programs/vanna_validator/src/jupiter.rs`. Program `JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4`. * Only `route` and `shared_accounts_route`, exact-input, in owner mode. * No platform fee. * The margin is the user / transfer authority. Source and destination must be the margin's own vaults. * The spend cap is the route's `in_amount`. Jupiter's own minimum out is the slippage bound. ## Titan Validator file: `programs/vanna_validator/src/titan.rs`. Program `T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT`. * Only `swap_route_v3`, with the margin as both payer and user. * Only config 3: keep the input token account open, keep wSOL output as wSOL. * No provider fee, token ledger or positive-slippage receiver. * The spend is capped at the routed amount. Titan's own minimum out is the slippage bound. Titan quotes come from Titan's API, which needs a server-side key. The margin account can't pay rent, so the client first creates, from the wallet, any of Titan's token accounts the route needs. ## Best-of routing in the app `lib/solana/aggregator.ts` can quote Jupiter and Titan side by side and pick the larger output, or quote only the provider the caller names. The Spot page passes the aggregator the user picked in the swap card (Jupiter by default, or Titan), so only that one is quoted, and it swaps from the margin account. If Titan has no server key or no route, the card shows that error instead of falling back silently. ## Notes * Token-2022 transfer fees are measured, not assumed. The spend cap and the health check use real balance deltas. * A swap that leaves the account at or below HF 1.10 (with debt) fails the whole transaction. * On the fork, cloned concentrated-liquidity pools can go stale. The app re-clones them from mainnet (`surfnet_resetAccount`) and retries the simulation. This is fork-only. # Validator Program Source: https://docs.vanna.finance/solana/developers/contracts/validator vanna_validator: review_call, call modes, and the per-protocol rules for every margin_execute target. `vanna_validator` — `6fND3vhtstp486iE6rsSNVUox3kcjNNRsSLAN7ZPs7th` ## `review_call(context) -> CallPermit` The core calls this read-only before every external call, from both `margin_execute` and `public_liquidate`. The validator picks its rules by the target program and returns a permit, or fails. ```text theme={null} CallContext { mode, target_program, data, call_account_count, margin, authority, venue } CallPermit { margin_indexes, tokens_in, tokens_out, max_spent, opens_venue, data } ``` `mode` is `Owner` (from `margin_execute`) or `Liquidation` (from `public_liquidate`). In liquidation mode the validator may also rewrite the call's data (`data`), for example to size a Phoenix withdrawal to what is available. ## Rules by target | Target | File | Owner mode | Liquidation mode | | - | - | - | - | | Kamino Lend | `kamino.rs` | `deposit_reserve_liquidity`, `redeem_reserve_collateral` | Refused | | Jupiter v6 | `jupiter.rs` | `route`, `shared_accounts_route`; no platform fee | Refused | | Titan | `titan.rs` | `swap_route_v3`, config 3 only; no provider fee | Refused | | Ember | `phoenix.rs` | USDC ⇄ phUSD deposit / withdraw | Refused | | Phoenix | `phoenix.rs` | `deposit_funds`, `withdraw_funds`, `place_market_order` within leverage caps | Reduce-only closes inside a price band; withdrawal up to the available budget | | Perena | `perena.rs` | USD\* deposit / withdraw; Junior tranche deposit / withdraw | Refused | | Basis vaults | `basis.rs` | Vault `deposit`, `withdraw` | Refused | Any other program, or any other instruction of these programs, is refused with `UnknownProgram` or `CallNotAllowed`. Details per integration: [Swaps](/solana/developers/contracts/swap), [Phoenix Perps](/solana/developers/contracts/perps), [Yield Vaults](/solana/developers/contracts/vaults). ## Adding a protocol 1. Add its rules as a file in the validator (and, if its positions aren't plain tokens, a reader in the oracle). 2. Upgrade that agent program. 3. `admin_register_integration` for the target program. Then `admin_register_asset` for any receipt token, or `admin_register_venue` for a venue. The core is not changed or redeployed. # Yield Vaults Source: https://docs.vanna.finance/solana/developers/contracts/vaults Kamino Lend, Perena USD* and the delta-neutral basis vaults from the margin account: validator rules and how the oracle values each receipt. Each of these integrations turns a margin token into a receipt token that stays in the margin account. The receipt is registered as a collateral-only asset, priced by the oracle from the issuing protocol's own accounts, and counts toward the health factor like any other allowed token. Every deposit and withdrawal is a [`margin_execute`](/solana/developers/contracts/margin-execute) call in owner mode. Liquidation-mode calls are refused, because a liquidator takes the receipt tokens themselves. ## Kamino Lend Validator: `programs/vanna_validator/src/kamino.rs`. Program `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD`. * Only `deposit_reserve_liquidity` and `redeem_reserve_collateral`, with exactly 12 accounts and a non-zero amount. * The margin signs as the owner. The call spends from one margin vault (up to the amount) and pays into another. * The app supplies to Kamino's **main market** reserves (`lib/solana/kamino.ts`). **Valuation.** A cToken's price source names its klend reserve (`receipt_account`). The oracle reads the reserve's exchange rate into the underlying, then prices the underlying from its own Scope / Pyth source. The underlying must already be in the price book with matching decimals. > [!NOTE] > > Kamino Liquidity (multi-asset LP strategies) is not supported. That program rejects CPI, so a margin account can never hold its shares. ## Perena USD\* and USD\* Junior Validator: `programs/vanna_validator/src/perena.rs`. Program `save8RQVPMWNTzU18t3GBvBkN9hT7jsGjiCQ28FpD9H`. * USD\* vault deposit / withdraw, and the **Junior** tranche's deposit / withdraw. The senior tranche is refused. * Each call has a fixed account count, spends from one margin vault and pays into the other (USDC ⇄ share). * Queued withdrawals are refused. **Valuation.** The oracle reads Perena's own USD share price: the vault's share price for USD\*, the tranche state's junior share price for Junior. The NAV's last update is the price's timestamp. USDC is not priced twice, since Perena already values its USDC holdings. A stale NAV counts as zero for the owner, but at its last value for liquidation. ## Basis vaults Validator: `programs/vanna_validator/src/basis.rs`. Oracle: `programs/vanna_oracle/src/basis.rs`. Program `GtuQoYxzytGKtLqQGkYrVbsaPHTZN5jboP25DrSmKvGr` (`vanna_phoenix_vault`, fork only). Each vault takes USDC, buys its asset through Jupiter, and holds it against a short of the same size on Phoenix. There is one vault per asset (SOL, ETH, BTC, TSLA, META), each with its own 6-decimal share token. * Only the vault's `deposit` and `withdraw`, in owner mode. * The margin is the vault's `user` (account 0) and must not appear anywhere else in the call. The vault forwards its signers to the Jupiter route, so the margin's signature must not reach it. * A deposit spends at most its USDC amount from the margin's USDC vault and must not shrink its share vault. A withdrawal spends at most its share amount and must not shrink the USDC vault. * The account count must be exactly the vault's 32 named accounts plus Phoenix's index accounts plus the route's. * The keeper's `rebalance`, `set_deposits_open` and the admin instructions are refused. **Valuation.** The oracle computes the vault's NAV itself, at Vanna's prices rather than Phoenix's mark: the asset held at its Phoenix market's index price (from Vanna's market book), plus the Phoenix trader's equity (collateral, plus each position at the index with unsettled funding, less the taker fee to close). A share is worth the lower of `NAV / supply` and the vault's own `(NAV + $1) / (supply + 1)`. Because the spot asset and the short use the same index, a price move barely changes the share's value. **Fork constraint.** A margin account can't deposit into the SOL vault, because Phoenix's trader realloc needs a system transfer from the vault's `user`, which a program-owned account can't make. A margin can still hold SOL-vault shares bought from a wallet, borrow against them, and redeem them. ## Client notes * The margin's receipt ATA must exist before a deposit. The margin can't pay rent, so the wallet creates it in the same transaction. * Basis-vault calls are one v0 transaction with a lookup table. The app keeps one lookup table per vault (`lib/solana/vault-catalogue.ts`). * Vault and share addresses are listed in [Configured Accounts](/solana/developers/deployed-contracts#yield-vaults). # Configured Accounts Source: https://docs.vanna.finance/solana/developers/deployed-contracts Program IDs, mints, and external protocol addresses used by the hosted mainnet fork. Values come from `vanna-credit-layer` (`Anchor.toml`, `deployments/hosted-fork.json`, the agents' constants) and `vanna-credit-backend/lib/solana`. They describe the hosted **Surfpool mainnet fork**, which clones mainnet accounts on first use. ## Endpoints | Setting | Value | | - | - | | App | `https://test.vanna.finance` (Solana in the chain switcher), behind an access code | | Fork RPC | `https://rpc-devnet.solana.vanna.finance` | | Fork WebSocket | `wss://rpc-devnet.solana.vanna.finance` | | Local RPC | `http://127.0.0.1:8899` | ## Vanna programs | Program | ID | | - | - | | `vanna_credit_layer` | `H37YVBG3eGtz89ofd7iDLc2PJgn12778392XeU2QJcGC` | | `vanna_oracle` | `FXY5DRfekMUTbUp4uyCFpCZmCccrp6kPq3hTM4GRihnc` | | `vanna_validator` | `6fND3vhtstp486iE6rsSNVUox3kcjNNRsSLAN7ZPs7th` | Margin limits on the hosted fork (`deployments/hosted-fork.json`): at most 3 debts and 2 venues per margin account. ## Mints | Symbol | Mint | Token program | Role | | - | - | - | - | | SOL (wSOL) | `So11111111111111111111111111111111111111112` | SPL Token | Pool + collateral | | USDC | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | SPL Token | Pool + collateral | | USDT | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` | SPL Token | Pool + collateral | | JitoSOL | `J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn` | SPL Token | Collateral only | | JupSOL | `jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v` | SPL Token | Collateral only | | JupUSD | `JuprjznTrTSp2UFa3ZBUFgwdAmtZCq4MQCwysN55USD` | SPL Token | Collateral only | | NVDAx | `Xsc9qvGR1efVDFGLrVsmkzv3qi45LTBjeUKSPmx9qEh` | Token-2022 | Collateral only | | GOOGLx | `XsCPL9dNWBMvFtTmwcCA5v3xWPSMEBCszbQdiLLq6aN` | Token-2022 | Collateral only | | AAPLx | `XsbEhLAtcf6HdfpFZ5xEMdqW8nfAvcsP5bdudRLJzJp` | Token-2022 | Collateral only | | TSLAx | `XsDoVfqeBukxuZHWhdvWHBhgEHjGNst4MLodqsJHzoB` | Token-2022 | Collateral only | PDAs for the protocol, assets, reserves, share mints, margin accounts, debts, integrations and the oracle's books are derived. See [PDAs](/solana/developers/sdk/pdas). ## Oracle sources | Role | Address | | - | - | | Kamino Scope program | `HFn8GnPADiny6XqUoWE8uRPPxb29ikn4yTuPa9MF2fWJ` | | Kamino Scope `OraclePrices` | `3t4JZcueEzTbVP6kLxXrL3VpWx45jDer4eqysweBchNH` | | Pyth Receiver | `rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ` | | Pyth push oracle | `pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT` | ## Integrations (`margin_execute` targets) | Program | Address | Used for | | - | - | - | | Kamino Lend (klend) | `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD` | Supply / redeem in the main market | | Jupiter v6 | `JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4` | Swaps | | Titan router | `T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT` | Swaps (`swap_route_v3`) | | Phoenix Eternal | `EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih` | Perps | | Ember | `EMBERpYNE6ehWmXymZZS2skiFmCa9V5dp14e1iduM5qy` | USDC ⇄ phUSD | | Perena | `save8RQVPMWNTzU18t3GBvBkN9hT7jsGjiCQ28FpD9H` | USD\* and USD\* Junior vaults | | Basis vaults (`vanna_phoenix_vault`) | `GtuQoYxzytGKtLqQGkYrVbsaPHTZN5jboP25DrSmKvGr` | Delta-neutral basis vaults | ## Kamino main market | Role | Address | | - | - | | Market | `7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF` | | SOL reserve | `d4A2prbA2whesmvHaL88BH6Ewn5N4bTSU2Ze8P6Bc4Q` | | USDC reserve | `D6q6wuQSrifJKZYpR1M8R4YawnLDtDsMmWM1NbBmgJ59` | | USDT reserve | `H3t6qZ1JkguCNTi9uzVKqQ7dvt2cum4XiXWom6Gn5e5S` | The cToken each reserve mints is registered as a collateral-only asset. Its address is in `lib/solana/kamino.ts`. ## Phoenix | Role | Address | | - | - | | Exchange (global config, the venue key) | `2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ` | | phUSD mint | `PhUsd11YkbjSaWjFncfAAmatntsjx3MgDR9B6g1ks3A` | Markets listed in the fork's market book: SOL, ETH and BTC at 5x; TSLA and META at 3x. ## Yield vaults | Vault | Vault account | Share mint | | - | - | - | | SOL basis | `BLeEcGjJnbGQyDBeTgckreKnKD87xFDDBFTfQYEyZ1j7` | `zMv5AVEURXUVBNmTqvV7ecgXun4uRAq8m3JM13iW71B` | | ETH basis | `7PwzomohGgy1WQeDRaJQs31UQqhapJk67gCg4zoL7znv` | `6Xin8G4Lq9RPxEDc1NnZ4JAkqwLstnosbnu3AeQavVuZ` | | BTC basis | `6qFcw8qCq2oxh1iqpYAKLw3Z7tUMj6APP4tNuHyosveZ` | `7LgRZNY3XTLx95LL1YYz4q7cFLAwupwtEjYepBPvSJ1R` | | TSLA basis | `J23xTNSTgiWdVMgcDbQgJMRc5MWhQ4Q2TrcnbDwG8ejw` | `AzYyMurfA6r5hhBT2R294Zx6pMdeZfCYJ48AkcEnc43T` | | META basis | `3P5p9a4pr6NqRtZpbpPMhC2Kgg5AFjCHishuxP6FW1pJ` | `3EfoqbFDf7FSgtifJsyFiG1QFFStf72tm2n8iqyBh5pa` | | Perena USD\* | `ECJGrTZ6QYMEwiEAnL4oReWF126uc22e9Lojy9qyCjHT` | `star9agSpjiFe3M49B3RniVU4CMBBEK3Qnaqn3RGiFM` | | Perena USD\* Junior | `FbsiAonbNrC3EKWMrZxx9iSc5Q7e7zSAkro4tD8dQQJS` | `3AJYCjrhKitmBd8tRUurPA5dGHCAQh6A8L9DkuSC37Rm` | > [!NOTE] > > The basis-vault program is deployed on the fork only. It is not on public mainnet yet. ## Predict | Role | Address | | - | - | | World.xyz market program | `prediCtPZCttYMvm2W3PtxmMxLmT1dtN7riU6Cxh6tM` | | CASH mint | `CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH` | | `outcome_yield_pool` | `4kFzca1u9TUAVK7BjJZ5vVtfJ2QRATs38vN8Bq6qZwG3` | ## Verify Read `ProtocolConfig`, each `AssetConfig` and `Reserve`, the oracle's `PriceBook`, and a known margin PDA. Compare the deployed program data against the SHA-256 hashes in `deployments/hosted-fork.json`. A reset fork is a new world: user margin addresses derive from the wallet, not from a constant table. # Integrate Lending Source: https://docs.vanna.finance/solana/developers/guides/integrate-lending Supply to and redeem from a Vanna pool from another client. **1. Derive accounts** `asset_config`, `reserve`, `share_mint`, the reserve's liquidity vault, the user's underlying ATA, and the user's share ATA (classic SPL Token). **2. Wrap SOL** If the mint is wSOL, wrap native SOL first. The program only sees wSOL. **3. Refresh and quote** Read the `Reserve`. If `last_update_timestamp` is old, include `public_refresh_reserve` or project accrual off-chain so the quote matches. **4. Supply** Call `lender_supply(assets, min_shares_out)` with `min_shares_out` from the quoted rate minus slippage. **5. Redeem** Call `lender_redeem(shares, min_assets_out)`. Payouts are limited to `accounted_liquidity_assets − accrued_protocol_fees`, so check available cash first. Pools exist for USDC, USDT and SOL. Supply is subject to `supply_cap`, the operating mode, and the reserve status. vTokens are **not** margin collateral. To use supplied funds as collateral, redeem first and deposit the underlying. App reference: `lib/solana/lend.ts` (`supply`, `redeem`, `previewSupplyShares`). # Integrate Margin Source: https://docs.vanna.finance/solana/developers/guides/integrate-margin Create an account, deposit, borrow, call integrations, and pass a complete remaining-accounts set. **1. Create the margin account** `user_create_margin` if `["margin", authority]` has no data. **2. Deposit collateral** `user_deposit_collateral` for each mint. The token must be collateral-enabled and on the allowed list. **3. Borrow** `user_borrow(assets, max_debt_shares)`. It opens the `DebtPosition` itself. Only USDC, USDT and SOL are borrowable. **4. Deploy** `margin_execute` into Jupiter, Titan, Kamino, Phoenix (via Ember), Perena or a basis vault. Create the receiving margin vault from the wallet first. **5. Unwind** `user_repay_from_margin` (with `repay_all` for the exact debt), `user_withdraw_collateral`, `user_reclaim_rent`, then `user_close_margin` when empty. ## Remaining accounts Borrow, withdraw-with-debt, `margin_execute` and liquidation need **every** allowed-token group, every venue group, and every debt group (except the instruction's own), followed by the oracle segment. See [Architecture](/solana/developers/architecture#remaining-accounts). The app helper is `buildHealthRemainingAccounts` in `lib/solana/margin.ts`. If you omit a holding or a debt, the program rejects the transaction. Do not "optimize" the list. ## Health preview Preview health on the client (`lib/account-model.ts`) using the same price sources as the oracle (`lib/solana/oracle.ts`). The chain is the source of truth. The app's own limits target HF ≥ 1.15 so price drift between quote and execution doesn't trip the on-chain `HF > 1.10` check. # Liquidation Bots Source: https://docs.vanna.finance/solana/developers/guides/liquidation-bots Watch health factors, unwind venues, repay one debt, seize one token. Permissionless. Loop: 1. **Enumerate margin accounts.** Index `MarginCreated` events, or scan program accounts on a cluster that supports it. 2. **Value each account** the way the oracle does: every allowed token in its vaults (up to each cap), its Phoenix trader equity, and every debt at accrued value. `lib/account-model.ts` and `lib/solana/oracle.ts` mirror the program. 3. **Pick candidates** with HF ≤ 1.10. 4. **Choose a pair**: one debt to repay and one allowed token to seize. Prefer the largest debt and the most liquid collateral. 5. **Unwind venues if needed.** If the account has open Phoenix positions, pass reduce-only closes (and a collateral withdrawal) as `calls` in the same `public_liquidate`. 6. **Liquidate** with `public_liquidate(calls, repay, min_seized)` and a conservative `min_seized`. ## Economics You receive up to the repaid value × (1 + the token's liquidation bonus, at most 5%). Near HF 1 the multiplier shrinks to the health factor, so a solvent margin is never pushed into bad debt. Repay is capped at 50% of the debt unless HF ≤ 1 + bonus or the debt is worth \$100 or less. Seized receipt tokens (Kamino cTokens, Perena shares, basis-vault shares) are yours to redeem from the issuing protocol. ## Sanity checks * Debts need fresh prices. Collateral is counted at its reported value, so stale dust can't block you. * The two settled prices must be fresh and within confidence. * A healthy account must fail with `PositionHealthy`. If your bot thinks it can liquidate HF 2.0, the account set is wrong. * Liquidation events are emitted through self-CPI. Read them from inner instructions. # Math Reference Source: https://docs.vanna.finance/solana/developers/math-reference WAD, shares, the polynomial rate model, health, and liquidation formulas from the core program. Source: `programs/vanna_credit_layer/src/math/` and `constants.rs`. ## Scales ```text theme={null} WAD = 10^18 USD_VALUE_DECIMALS = 9 // USD values are nano-USD BASIS_POINTS = 10_000 SECONDS_PER_YEAR = 31_556_952 BALANCE_TO_BORROW_THRESHOLD = 1.1 × WAD MIN_INITIAL_SHARES = 1_000 CLOSE_FACTOR_BPS = 5_000 MAX_LIQUIDATION_BONUS_BPS = 500 FULL_LIQUIDATION_DEBT_VALUE = $100 // in nano-USD WRITE_OFF_COLLATERAL_VALUE = $1 // in nano-USD ``` ## Utilization and borrow rate Each reserve stores a `RateCurve { linear_coeff_wad, jump_coeff_wad, rate_multiplier_wad }`. Every coefficient must be greater than zero and at most `10 × WAD`. ```text theme={null} u = total_borrow / (accounted_liquidity + total_borrow) // WAD, 0 if empty polynomial = linear·u + linear·u^32 + jump·u^64 rate_per_sec = rate_multiplier × polynomial / SECONDS_PER_YEAR ``` The rate is gentle at low utilization, then steepens sharply as `u` approaches 1 (the `u^32` and `u^64` terms). ## Accrual ```text theme={null} growth = rate_per_sec × elapsed interest = floor((total_borrow × growth + interest_remainder) / WAD) fee = floor((interest × reserve_factor_bps + fee_remainder) / 10_000) total_borrow' = total_borrow + interest fees' = fees + fee index' = index × total_borrow' / total_borrow ``` The remainders (`interest_remainder_wad`, `fee_remainder`) carry forward, so frequent accruals neither overcharge borrowers nor shortchange the treasury. `now < last_update` is rejected (`TimestampRegression`). ## Lender shares ```text theme={null} lender_assets = accounted_liquidity + total_borrow − protocol_fees available_cash = accounted_liquidity − protocol_fees supply_shares = floor(assets × total_supply_shares / lender_assets) // 1:1 if empty redeem_assets = floor(shares × lender_assets / total_supply_shares) ``` The reserve counts its own shares (`total_supply_shares`), so share tokens burned outside Vanna don't change anyone's claim. The first deposit locks `MIN_INITIAL_SHARES` that nobody can redeem. ## Debt shares ```text theme={null} new_shares = ceil(assets × total_borrow_shares / total_borrow) // 1:1 if empty user_debt = ceil(user_shares × total_borrow / total_borrow_shares) repay_share = floor(paid × total_borrow_shares / total_borrow) // all shares if paid ≥ debt ``` Borrow shares and debt round **up**. Lender shares and redeem assets round **down**. ## USD value and health ```text theme={null} value = amount × price, rescaled by the price exponent and mint decimals to 9 decimals HF = Σ collateral_usd / Σ debt_usd // unweighted borrow / withdraw / margin_execute allowed ⇔ debt = 0 or HF > 1.10 liquidatable ⇔ debt > 0 and HF ≤ 1.10 ``` The oracle rounds collateral down and liabilities up. LTV and liquidation threshold are stored and validated on each asset, but the health factor itself is unweighted. ## Liquidation ```text theme={null} max_bonus = 1 + liquidation_bonus_bps / 10_000 // bonus ≤ 5% bonus = max_bonus if HF < 1 = min(HF, max_bonus) otherwise full = HF ≤ max_bonus or debt_usd ≤ $100 max_repay = debt if full = 50% of debt otherwise repaid = min(repay, max_repay) seize_value = repaid_value × bonus seized = seize_value × held / held_value // capped at held, repaid shrinks to match ``` Require `seized ≥ min_seized`. While the margin is solvent, the bonus never exceeds its equity, so a liquidation never turns a solvent margin into bad debt. ## Write-off `admin_write_off` clears every debt of a margin whose collateral is at most \$1 and below its debt, with no venue position open. Each reserve's `accrued_protocol_fees` absorb the loss first. Lender assets fall by the rest. # Developer Overview Source: https://docs.vanna.finance/solana/developers/overview Integrate with the Vanna credit layer on Solana: one core program, an oracle agent, a validator agent, and the Next.js app. This reference describes `vanna-credit-layer` (three Anchor programs) and `vanna-credit-backend` (the Next.js app) as they run on the hosted Surfpool **mainnet fork**. | Program | ID | Role | | - | - | - | | `vanna_credit_layer` (core) | `H37YVBG3eGtz89ofd7iDLc2PJgn12778392XeU2QJcGC` | Lending pools, margin accounts, health, liquidation, `margin_execute` | | `vanna_oracle` | `FXY5DRfekMUTbUp4uyCFpCZmCccrp6kPq3hTM4GRihnc` | Values every holding: tokens from its price book, the Phoenix venue from its market book | | `vanna_validator` | `6fND3vhtstp486iE6rsSNVUox3kcjNNRsSLAN7ZPs7th` | Decides which external calls a margin account may make | The core knows no price source and no external protocol. Adding a protocol or a price source means a new file in the oracle or the validator, then an admin registration. The core is not redeployed. Start with [Architecture](/solana/developers/architecture), [Configured Accounts](/solana/developers/deployed-contracts), and [Math Reference](/solana/developers/math-reference). ## Repository map | Path | Responsibility | | - | - | | `vanna-credit-layer/programs/vanna_credit_layer` | Core program: `instructions/`, `state/`, `math/`, `risk_engine.rs`, `interface.rs` | | `vanna-credit-layer/programs/vanna_oracle` | Oracle agent: `price_book.rs`, `market_book.rs`, `sources.rs` (Scope, Pyth, Kamino), `phoenix.rs`, `perena.rs`, `basis.rs` | | `vanna-credit-layer/programs/vanna_validator` | Validator agent: `kamino.rs`, `jupiter.rs`, `titan.rs`, `phoenix.rs` (Phoenix + Ember), `perena.rs`, `basis.rs` | | `vanna-credit-layer/programs/vanna_credit_layer/src/tests` | LiteSVM unit and integration tests, many against real mainnet program binaries | | `vanna-credit-layer/scripts` | `devnet.ts` (one command per core instruction), `integrations-fork.ts` (fork setup and integrations), `bootstrap-fork.sh` | | `vanna-credit-backend/app` | Next.js routes: Earn, Margin, Trade (Spot, Perps), Farm, Predict, Portfolio, Analytics | | `vanna-credit-backend/lib/solana` | Client model: PDAs, oracle mirror, margin, `margin_execute`, Phoenix, Kamino, Jupiter, Titan, vaults | | `vanna-credit-backend/lib/account-model.ts` | Health factor, leverage and liquidation-price math used by every page | | `vanna-credit-backend/idl/vanna_credit_layer.json` | Core IDL consumed by the app | ## Current scope * **Lending pools** for USDC, USDT and SOL. Lenders receive vTokens. * **One cross-margin account per wallet.** Every allowed token in it counts toward one health factor. * **Collateral** includes SOL, USDC, USDT, JitoSOL, JupSOL, JupUSD, the xStocks (NVDAx, GOOGLx, AAPLx, TSLAx), and receipt tokens from Kamino, Perena and the basis vaults. * **External calls through `margin_execute`**: Jupiter and Titan swaps, Kamino Lend supply / redeem, Phoenix perps (via Ember USDC ⇄ phUSD), Perena USD\* vaults, and Vanna's delta-neutral basis vaults. * **Liquidation** that is permissionless and partial, plus an admin write-off for dust bad debt. > [!NOTE] > > There is no published SDK package. Copy the PDA helpers and instruction builders from `vanna-credit-backend/lib/solana` or `vanna-credit-layer/scripts/src`. # TypeScript Getting Started Source: https://docs.vanna.finance/solana/developers/sdk/getting-started Use the application-local Anchor client. There is no published package yet. The app's client lives in `vanna-credit-backend/lib/solana`. Copy what you need. ```ts theme={null} import { getProgram } from "@/lib/solana/program"; import { marginPda, reservePda, protocolConfigPda } from "@/lib/solana/pdas"; import { VANNA_PROGRAM_ID, ORACLE_PROGRAM_ID, VALIDATOR_PROGRAM_ID } from "@/lib/solana/config"; import { getToken } from "@/lib/solana/tokens"; const program = getProgram(); // read-only provider; the wallet signs in tx.ts const usdc = getToken("USDC"); const margin = marginPda(owner); const reserve = reservePda(usdc.mint); ``` | Module | Use | | - | - | | `config.ts` | Program IDs, RPC URLs, HF thresholds (`LIQUIDATION_HEALTH_FACTOR = 1.1`, UI buffer `SAFE_HEALTH_FACTOR = 1.15`) | | `tokens.ts` | The token registry: mints, decimals, token programs, which tokens are lendable / depositable | | `pdas.ts` | Every PDA and ATA helper | | `lend.ts` | Supply and redeem | | `margin.ts` | Create, deposit, borrow, repay, withdraw, reclaim rent; `buildHealthRemainingAccounts` | | `exec.ts` | `marginExecuteIx`, margin swaps, Kamino farm deposit / withdraw | | `aggregator.ts`, `swap.ts`, `titan.ts` | Jupiter / Titan quotes and swaps (one named provider, or best-of both) | | `perps.ts`, `phoenix.ts` | Phoenix perps: open, close, withdraw, valuation mirror | | `vault-actions.ts`, `perena.ts`, `vault-state.ts` | Basis and Perena vaults | | `oracle.ts`, `prices.ts` | Client mirror of the oracle's source selection | | `../account-model.ts` | Health factor, leverage and liquidation-price math | The core IDL is `idl/vanna_credit_layer.json`. After a program change, rebuild with `anchor build` and copy `target/idl/vanna_credit_layer.json` into the app. Read [Transaction Flow](/solana/developers/sdk/transaction-flow) before sending. Always simulate. # PDA Helpers Source: https://docs.vanna.finance/solana/developers/sdk/pdas Seeds used by the core and oracle programs, mirrored in vanna-credit-backend/lib/solana/pdas.ts. Core program (`VANNA_PROGRAM_ID`): ```ts theme={null} protocolConfigPda() // ["protocol"] assetConfigPda(mint) // ["asset", mint] (also ["asset", venue] for a venue) reservePda(mint) // ["reserve", mint] shareMintPda(mint) // ["share_mint", mint] marginPda(authority) // ["margin", authority] debtPositionPda(margin, reserve) // ["debt", margin, reserve] integrationPda(programId) // ["integration", program_id] ``` Oracle program (`ORACLE_PROGRAM_ID`): ```ts theme={null} priceBookPda() // ["price_book"] marketBookPda(venue) // ["market_book", venue] ``` Token accounts: ```ts theme={null} reserveVault(mint, tokenProgram) // ATA(mint, reserve PDA) marginVault(margin, mint, tokenProgram) // ATA(mint, margin PDA) — its live balance is the collateral lenderShareAccount(lender, mint) // ATA(share mint, lender), classic SPL Token ``` External: ```ts theme={null} // Phoenix trader owned by the margin account (Phoenix program) ["trader", margin, u16 0] // Pyth push-oracle feed account (push-oracle program) [u16 shard 0 LE, feed_id_bytes] ``` All are `findProgramAddressSync`. Each mint's token program matters for ATAs: the xStocks are Token-2022, everything else is classic SPL Token. # Transaction Flow Source: https://docs.vanna.finance/solana/developers/sdk/transaction-flow Price refresh, remaining accounts, lookup tables, simulate, then send. Typical risk-checked transaction: 1. **Refresh prices (fork only).** The fork has no live price pushers. The app calls `POST /api/prices/refresh`, which rewrites the oracle accounts with live prices before a borrow, withdraw or `margin_execute`. 2. **Build named accounts** from PDAs. 3. **Build `remaining_accounts`** with `buildHealthRemainingAccounts`: allowed-token groups, venue groups, debt groups, then the oracle segment (and the validator segment for Phoenix). 4. **Compute budget and lookup tables.** `margin_execute` into Phoenix or a basis vault needs a v0 transaction with an address lookup table and a high compute-unit limit. 5. **Simulate, then send.** If simulation fails, do not broadcast. Several core instructions can be batched in one transaction. `MarginIndexModel` in `lib/solana/margin.ts` replays each instruction's effect on the margin's active lists, so each one gets the right groups. ## Example: perps open ```ts theme={null} // conceptual — lib/solana/perps.ts openPerp() const ixs = [ emberDepositViaMarginExecute, // margin USDC → phUSD phoenixDepositFundsViaExecute, // phUSD → trader account placeMarketOrderViaExecute, // immediate-or-cancel, filled in the same tx ]; await sendInstructions(ixs, opts); // lib/solana/tx.ts: lookup tables, simulate first, then send ``` ## Multi-step flows The program has no atomic "close everything" instruction. The app's **flash repay** (`lib/solana/flash-repay.ts`) is a sequence of ordinary transactions: close Phoenix positions, redeem Kamino cTokens, swap holdings into each debt token, `repay_all` each loan, then optionally withdraw everything. Each step re-reads the chain, so a run that stopped half-way resumes cleanly. ## Common errors * **Blockhash not found**: the wallet is not pointed at the fork RPC. * **Stale price**: refresh prices and retry. * **Stale pool on the fork**: Jupiter's route used a cloned pool that drifted. The app re-clones it from mainnet and retries. # Developer Setup Source: https://docs.vanna.finance/solana/developers/setup Toolchain, build, tests, the local fork, the app, and hosted fork notes. ## Toolchain | Tool | Version | Needed for | | - | - | - | | Rust | `1.89.0` (from `rust-toolchain.toml`) | Build, tests | | Solana CLI | 3.x | `cargo build-sbf`, refreshing fixtures | | Anchor CLI | `1.1.2` | Build | | Node.js | 20+ for `scripts/`, 22 for the app image | Scripts, app | | Surfpool | latest | Local mainnet fork | | Python | 3.9+ | Refreshing mainnet fixtures only | ## Programs ```bash theme={null} cd vanna-credit-layer anchor build # three programs -> target/deploy/*.so, IDLs in target/idl/ ``` If a local `target/deploy/-keypair.json` belongs to a different address, build with `anchor build --ignore-keys`. Don't run `anchor keys sync` unless you mean to change the program IDs. ## Tests The tests run in LiteSVM (no validator) and load all three programs from `target/deploy/`, so build first and rebuild after any program change. ```bash theme={null} M=programs/vanna_credit_layer/Cargo.toml cargo test --manifest-path $M # everything cargo test --manifest-path $M --test phoenix # one binary ``` | Binary | Covers | | - | - | | `test_full_flow` | Lend → deposit → borrow → repay → withdraw | | `test_liquidation` | Partial liquidation, close factor, bonus, write-off, price checks | | `test_hardening` | Share accounting, issuer controls, transfer fees, frozen accounts | | `test_allowed_tokens` | The allowed-token list, caps, per-margin limits | | `test_security`, `test_admin_and_lifecycle` | Access control, admin instructions, open / close | | `test_interest_rate`, `test_math`, `test_state` | Rate model, fixed-point and health math, registries | | `test_oracle` | Scope chains, Pyth fallback, TWAP / staleness / confidence, price-book rules | | `test_oracle_live` | Ignored by default; reads live mainnet oracle accounts | | `kamino`, `jupiter`, `titan`, `perena`, `phoenix` | Each integration against the real mainnet program binaries | The basis-vault tests live in their own crate (`tests/basis`) because Phoenix's Hawkeye program needs a newer LiteSVM: ```bash theme={null} anchor build cd tests/basis && cargo test -- --nocapture ``` ## Local mainnet fork ```bash theme={null} anchor build mkdir -p /tmp/vanna-fork && cd /tmp/vanna-fork surfpool start --network mainnet --no-tui --no-deploy # second terminal cd vanna-credit-layer/scripts && npm install bash bootstrap-fork.sh # deploys the three programs and registers assets, reserves, integrations ``` The wallet that runs `bootstrap-fork.sh` becomes the protocol admin. `npm run devnet -- ` has one command per core instruction. `npm run integrations-fork -- ` covers funding, Kamino, Jupiter, Titan, Phoenix, Perena and the basis vaults. Run either with no command to print its list. ## App ```bash theme={null} cd vanna-credit-backend npm ci cp .env.example .env.local npm test npm run dev ``` Key settings in `.env.example`: `NEXT_PUBLIC_SOLANA_RPC_URL`, `NEXT_PUBLIC_SOLANA_WS_URL`, `FORK_RPC_URL`, `NEXT_PUBLIC_VANNA_PROGRAM_ID`, `ACCESS_CODE` (the code the site asks for once; required, the site stays locked without it), and server-only API keys for Jupiter and Titan. Titan quotes are skipped when the server has no Titan key. Point your wallet's custom RPC at `http://127.0.0.1:8899` and open `http://localhost:3000`. > [!WARNING] > > Hosted builds bake `NEXT_PUBLIC_*` values in at image build time. Changing runtime environment does not rewrite client RPC URLs. Never put API keys in `NEXT_PUBLIC_*` variables. ## Hosted layout ```text theme={null} https://test.vanna.finance → Vanna app (Solana and Stellar, chain switcher) https://rpc-devnet.solana.vanna.finance → Surfpool RPC (mainnet fork) ``` Check the hosted node: ```bash theme={null} curl -sS https://rpc-devnet.solana.vanna.finance \ -H 'Content-Type: application/json' \ --data '{"jsonrpc":"2.0","id":1,"method":"getVersion"}' ``` A healthy node returns its `surfnet-version` and `solana-core` version. ## Common problems | Symptom | Fix | | - | - | | Wallet shows real balances, previews fail | The wallet isn't on the fork RPC | | "Blockhash not found" | The wallet and the app use different RPCs | | Empty balances | Mint from **Deposit → Test funds** on **this** fork | | Every page asks for an access code | Set `ACCESS_CODE` in `.env.local` and enter it once | The app's end-to-end scripts (`npm run e2e`, `scripts/e2e-*.ts`) run against the fork through the app's own services. Avoid scripts that overwrite shared fixtures on the hosted node. # Analytics Source: https://docs.vanna.finance/solana/guides/analytics Protocol-wide risk, positions, liquidations, lending pools, prediction vaults, collateral and prices: live and read-only. **Analytics** is a live, public view of the whole protocol. It reads every margin account and pool directly from the chain. Nothing here sends a transaction. ![Protocol Analytics overview with Bad Debt, Can Be Liquidated, Liquidatable Debt, Accounts at Risk, Average Health, Collateral at Risk, Average Leverage and Total Debt cards](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/analytics/overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=6f2856aacdb8d405e8019b66e854e368) Analytics overview: bad debt, liquidatable accounts, accounts at risk and the accounts table. The status bar at the top shows that the data is live, how many accounts were found, since when activity is counted, the last update time and a **Refresh** button. ## Sections | Group | Page | What it answers | | - | - | - | | **Risk** | **Overview** | Is anything wrong? Bad debt, liquidatable accounts and debt, accounts at risk, average health and leverage, total debt | | | **Positions** | Look up any wallet or margin account; how accounts spread across health, leverage and collateral | | | **Liquidations** | Past liquidations | | | **Top accounts** | The largest accounts | | | **Alerts** | Accounts and pools that need attention | | **Markets** | **Lending Pools** | Supplied, borrowed, available, utilization and rates per pool | | | **Collateral** | What collateral is made of | | | **Prices** | Oracle prices in use | | **Prediction** | **Prediction Vaults** | Every Predict pool: YES / NO it holds and how much went into Vanna's USDC pool | | **Tools** | **What-if Calculator** | How a price move would change accounts' health | ## Overview The cards answer the key questions at a glance: | Card | Meaning | | - | - | | **Bad debt (estimated)** | Debt not covered by collateral. \$0 means no account owes more than it holds | | **Can be liquidated** | Accounts at a health factor of 1.10 or below, and their debt | | **Liquidatable debt** | That debt, and the collateral backing it | | **Accounts at risk / active** | Accounts close to the line, out of all active accounts | | **Average health / leverage** | Across accounts with debt | | **Collateral at risk** | Collateral in accounts with health under 1.50 | | **Total debt** | Everything owed, against all collateral | Below, the **Accounts** table lists every account **By health** or **By leverage**, filterable by Liquidatable, At risk, Safe, No debt and Not valued, with search by wallet or margin address. If you're connected, your own account is shown first. Further down, **Accounts by health** charts debt at each health level (click a bar to filter the table), **What collateral is made of** splits all collateral into tokens held, Kamino deposits and Phoenix perps, and four cards sum up lending. **Test a price drop** opens the What-if Calculator. ![Accounts by health bar chart with the 1.10 liquidation line, a collateral donut split into tokens held, Kamino deposits and Phoenix perps, and Supplied by lenders, Borrowed, Available to withdraw and Borrowed share cards](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/analytics/overview-charts.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=f335732b88c1b0d6c3b21e1618aa179c) Overview, further down: accounts by health, what collateral is made of, and the lending summary. ## Positions Paste any wallet or margin-account address into **Look up a wallet** and press **Look up** to open that account's own page (read-only). Below it: * **Accounts by health**: how many accounts sit at each health level. * **Debt by leverage**: how leveraged the borrowing accounts are. * **Collateral by asset** and **Debt by asset**: what accounts hold and what they owe, per token. ![Accounts by health bars, a debt by leverage chart, Collateral by asset list (USDC, SOL, JitoSOL, USDT, TSLAx, AAPLx, GOOGLx) and Debt by asset (USDC, SOL, USDT)](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/analytics/positions.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=bda15deeb0ab5d3b8119e72aa8e1ca23) Positions: accounts by health, debt by leverage, and collateral and debt by asset. ## Lending Pools The table lists each pool's supplied, borrowed and available amounts, utilization, borrow and supply APR and status. Select a pool to inspect it: a utilization gauge and **How the borrow rate changes**, the pool's rate curve with a marker at today's utilization. ![Lending Pools table for SOL, USDC and USDT with supplied, borrowed, available, utilization, borrow APR and Active status, and a SOL pool panel with a 1.48% utilization gauge and a borrow-rate curve](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/analytics/lending-pools.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=5439b0ece46595567ee3044c009f3feb) Lending Pools: each pool's numbers, and the selected pool's utilization and borrow-rate curve. ## Prediction Vaults ![Prediction Vaults page with In Vanna's USDC pool, Waiting to merge, YES and NO shares in pools and Pools cards, a Where prediction money sits bar and a pools table with Earning statuses](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/analytics-prediction-vaults.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=0d5906a436ecab6472937a1aa73a57a2) Prediction Vaults: how much Predict money is in Vanna's USDC pool, what is waiting, and one row per pool. Every Predict market has a pool that holds users' YES and NO shares. Matched pairs are merged and supplied to Vanna's USDC pool (see [Earn While You Wait](/solana/guides/predict/earn-while-you-wait)). This page shows where that money is: | Card | Meaning | | - | - | | **In Vanna's USDC pool** | USDC the Predict pools have supplied, and its share of the USDC pool | | **Waiting to merge** | Matched YES + NO pairs not merged yet (\$1 each) | | **YES / NO shares in pools** | All shares held, and how many have nothing to pair with yet | | **Pools** | Pools created, and how many hold funds | The **Pools** table lists each market with YES and NO in its pool, matched pairs, USDC in Vanna's pool and a status: | Status | Meaning | | - | - | | **Earning** | Its pairs are in Vanna's USDC pool | | **Merge pending** | Pairs are waiting for the next merge | | **Waiting for other side** | Only YES or only NO so far: nothing to pair | | **Event ended** | World closed the event before its pairs were merged | | **Empty** | Nothing deposited yet | Use the filters (With funds, Earning, Merge pending, Event ended, All pools) to narrow the table, and click a market to open it on Predict. > [!TIP] > > Use Analytics to sanity-check the protocol before you supply: how much is borrowed, how healthy borrowers are, and whether any bad debt exists. ## Next steps > **[Health factor](/solana/guides/margin/health-factor)** > > What the health numbers mean for your own account. > **[Earn while you wait](/solana/guides/predict/earn-while-you-wait)** > > How Predict pools feed Vanna's USDC pool. # Connect Your Wallet Source: https://docs.vanna.finance/solana/guides/connect-wallet Sign in with email or a social account, or connect Backpack and point it at the Vanna fork RPC. Click **Connect wallet** at the top right of the app to open **Sign in to Vanna**. One sign-in works for both Solana and Stellar. ![Sign in to Vanna dialog with an email field and Continue button, Google, X and GitHub buttons, Stellar wallets Freighter, OneKey and LOBSTR (Soon), and Solana wallets Backpack, Solflare (Soon) and Phantom (Soon), powered by Dynamic](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/sign-in.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=3c58240c85000b7f6839079705212a53) Sign in to Vanna: email, Google, X or GitHub, or a wallet. On Solana, Backpack is live; Solflare and Phantom are marked Soon. ## Choose how to sign in **Email or social** **1. Enter your email** Type your email and click **Continue**, or pick **Google**, **X** or **GitHub**. **2. Confirm** For email, enter the 6-digit code sent to your inbox and click **Sign in**. Social logins send you to the provider and back. **3. Done** Vanna (through [Dynamic](https://www.dynamic.xyz)) creates an embedded wallet for you: one Solana wallet and one Stellar wallet per login. There's nothing to install and no RPC to change, because the app signs and sends through the fork for you. **Backpack** **1. Install Backpack** Install the [Backpack](https://backpack.app/download) browser extension and create (or import) a wallet. Use a **test** wallet: nothing on the fork is real money, but there's no reason to expose a wallet that holds real funds. **2. Add the fork RPC** Point Backpack at the Vanna fork. Follow [the steps below](#add-the-vanna-rpc-to-your-wallet). **3. Connect** In **Sign in to Vanna**, click **Backpack** under **Solana** and approve the connection. Your wallet name appears in the header. | Wallet | Status on Solana | | - | - | | **Backpack** | Live. Supports a custom RPC, so it can sign on Vanna's fork | | **Solflare** | Soon. It checks every transaction against Solana mainnet and has no custom-RPC option, so it can't sign fork transactions. Arrives with mainnet launch | | **Phantom** | Soon | | **Email, Google, X, GitHub** | Live, through Dynamic embedded wallets | > [!NOTE] > > If the dialog shows a Stellar wallet with a **Switch** tag (or Backpack while you're on Stellar), clicking it switches the app to that chain first. ## Add the Vanna RPC to your wallet This section is for **Backpack** users; email and social logins skip it. Vanna runs on a Solana **mainnet fork**. The app already reads and sends every transaction through the fork RPC, but Backpack also needs it: otherwise the wallet shows your real Mainnet balances and simulates transactions against Mainnet, so previews look wrong or fail. ```text theme={null} https://rpc-devnet.solana.vanna.finance ``` The purple strip at the top of every page shows this URL with a **Copy** button. ![Purple banner reading: Vanna runs on a Solana mainnet fork: add RPC https://rpc-devnet.solana.vanna.finance to your wallet. Setup guide](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/rpc-banner.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=e22c3fd576708c2786b8116ba4da2ee5) The RPC strip at the top of the app: click Copy to copy the URL. **1. Open Backpack** Open the Backpack extension. With its default RPC it shows your public Mainnet balances, not the fork. ![Backpack wallet home screen showing a 0 SOL balance on the default RPC](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/1-open-wallet.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=1d20169705732ef3fa36ac379459ba58) Backpack on its default RPC. **2. Open Settings** Click the **account icon** (top left), then **Settings**. ![Backpack account menu open with the Settings option highlighted](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/2-open-settings.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=edb8c9d556d597aad7b94221e39f48b5) Account menu with Settings. **3. Select Solana** Click **Solana** (not Solana Devnet). ![Backpack settings list with Solana and Solana Devnet entries](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/3-select-solana.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=6edeefd731a987a24fd3913808defe2a) Settings: pick the Solana network. **4. Open RPC Connection** Click **RPC Connection**. It shows **Backpack Default RPC** until you change it. ![Backpack Solana settings showing RPC Connection set to Backpack Default RPC](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/4-rpc-connection.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=10e3b169c5d9fc949e693a64c6d64ecc) Solana settings: RPC Connection. **5. Choose Custom** Click **Custom**. ![Backpack RPC Connection screen with Backpack Default RPC and Custom options](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/5-custom.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=0d6bc76f76f553acc609aa7ace93c702) RPC Connection: choose Custom. **6. Paste the Vanna RPC and click Update** Paste `https://rpc-devnet.solana.vanna.finance` into the **RPC** field and click **Update**. ![Backpack Change RPC Connection screen with the Vanna fork RPC URL entered and an Update button](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/wallet/6-paste-rpc.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=68615b8c6845ca78231836bd965dc5fb) Change RPC Connection with the Vanna fork URL. Backpack now shows **Custom Rpc: [https://rpc-devnet.solana.vanna.finance](https://rpc-devnet.solana.vanna.finance)** at the top of the wallet panel, and your balances match the app. Reload the app if it was already open. > [!WARNING] > > Running the stack on your own machine? Use your local node `http://127.0.0.1:8899` instead (see [Developer Setup](/solana/developers/setup)). ## Access code The test app at [test.vanna.finance](https://test.vanna.finance) (Solana in the chain switcher) is private. The first time you open it, it asks for an **access code** before anything loads. Enter the code the Vanna team gave you; your browser remembers it for about 30 days. If the code is changed, you'll be asked again. ## Same login, same account Your margin account is derived from your wallet address. Sign in the same way (same email, same social account or same Backpack wallet) to return to the same collateral, debt, Farm and Predict positions. A different login is a different wallet, so it has a different account. ## Next steps > **[Get test funds](/solana/guides/faucet)** > > Mint every supported token from the Deposit window. > **[Open a margin account](/solana/guides/margin/open-account)** > > Create your account and deposit collateral. # Copilot Source: https://docs.vanna.finance/solana/guides/copilot Ask about your account or describe a change in plain English. The Copilot plans it with live numbers; your wallet signs every transaction. **Copilot** is an AI assistant built into the app that knows your Vanna account. Ask it a question ("What is my health factor?", "What am I earning on Farm?") or describe what you want done ("Borrow 500 USDC", "Put 100 USDC and 1 SOL into Earn, then show my APY"), and it answers with live figures or prepares the transactions for your wallet to sign. It does the same things as the rest of the app (Earn, Margin, Trade, Farm, Predict) with the same rules and the same numbers. You just say what you want instead of filling in each page. ![Copilot page answering What's my health factor with a Margin Account card showing health factor 9.50, collateral, debt, liquidation at 1.10 and safety floor 1.15, and a sidebar with sign-in status, health factor, position lists and recent chats](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/copilot/Copilot_HF.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=7667ec264f1e3248a4a39e36e79ed525) Copilot answering a health-factor question, with the sidebar on the left. ## Getting Started **1. Open Copilot** Click **Copilot** in the header with your wallet connected. If your wallet is still reconnecting, the page waits a moment instead of asking you to connect again. **2. Sign in** Sign a short login message in your wallet. This is not a transaction and costs no fee. It proves you own this wallet, so the Copilot only ever reads and acts for your own account. **3. Ask** Type in the box at the bottom (*Ask about a position, or describe a change*) and press Enter. A sign-in lasts **24 hours** from when you signed, whether you use it or not. After that, the Copilot asks you to sign the login message again. ## The Sidebar ![Copilot sidebar showing Signed in status, health factor 9.50 Healthy, Margin Positions with SOL, USDC, USDT and kSOL collateral and SOL and USDC borrowed, and Earn Positions with SOL and USDC supplied](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/copilot/Copilot_Slidebar.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=b5af4cf043ed2877365bb887e0bff951) The sidebar with Margin Positions and Earn Positions open. | Part | What it shows | | - | - | | **Sign-in status** | "Signed in" with your wallet, or a prompt to sign in. If you switch to another wallet in your extension, it tells you the wallet differs from the sign-in | | **Health factor** | Your margin account's current health factor | | **Margin Positions** | Each asset in your margin account: **Collateral** (what you deposited or swapped into) and **Borrowed** (your debt) | | **Earn Positions** | What you supplied to the Earn pools, at the amount you could redeem now | | **Perps Positions** | Your open Phoenix perps (shown only when you have some) | | **Predict Positions** | Your Yes / No shares, in your wallet or in Vanna's pool (shown only when you have some) | | **Recents** | Your earlier chats. Rename or delete one from its menu; **New chat** starts a fresh one | Position lists start closed: click a heading to open one. Each row shows the same logo as the rest of the app (tokens, vault shares, perps markets, and team or event art for Predict). ## What It Can Do | You want to | Try | | - | - | | **Read your account** | "What's my health factor?", "Show my positions", "How much do I owe?", "What's in my wallet?" | | **Know your limits** | "How much more USDC can I borrow safely?", "How much SOL can I withdraw?", "What's the highest leverage I can take on SOL?" | | **Ask what-if** | "What happens if SOL drops 20%?", "What would my health be if I borrow 300 USDC?" | | **Compare yield** | "Where can I earn the most on USDC?", "What does the BTC Basis vault pay?" | | **Lend** | "Supply 100 USDC to Earn", "Withdraw all my SOL from Earn" | | **Use margin** | "Open a margin account and deposit 2 SOL", "Borrow 1,000 USDC", "Repay all my USDT", "Withdraw as much SOL as is safe" | | **Lever up** | "Lever my SOL 2x", "Deposit 100 USDC and borrow SOL 3x against it", "Borrow USDC until my health is 1.5" | | **Swap** | "Swap 5 SOL to USDC", "Swap 1 SOL to USDC in my wallet", "Swap SOL to get exactly 100 USDC" | | **Farm** | "Put 50 USDC into Kamino", "Deposit 200 USDC into BTC Basis", "Withdraw half my USD\*" | | **Perps** | "Which perps markets are open?", "Open a 2x SOL long with 20 USDC", "Close my ETH short" | | **Predict** | "Show me prediction markets", "Buy 10 CASH of Yes on Barcelona", "Sell all my positions", "Sell half my 49ers shares", "Get me test CASH" | | **Exit** | "Close everything": leaves Farm, repays debt and withdraws, in an order where your health only improves | You can chain several actions in one message, up to 8 transactions ("Deposit 100 USDC, borrow 50 USDT, then show my health factor"). Amounts can be exact ("5 SOL"), in dollars ("\$200 of SOL"), a share ("half", "25%"), everything ("all"), or as much as is safe ("max"). ## How It Works With the App The Copilot is not a separate product with its own numbers. It works through the same pieces the app uses: | On the website | In the Copilot | | - | - | | [Portfolio](/solana/guides/portfolio) and [Margin](/solana/guides/margin/overview) cards | Answers about health, collateral, debt and positions, with the same values | | Max buttons on Margin (keep health at 1.15) | "As much as is safe" uses the same 1.15 floor and formula | | [Earn](/solana/guides/earn/overview) supply / withdraw | The same Earn transactions | | [Spot](/solana/guides/trade/spot-swap) swap (Jupiter or Titan route) | Swaps happen in your margin account by default, like the Spot page; in your wallet only if you ask | | [Perps](/solana/guides/perps/overview) on Phoenix | The same markets and order rules, with your margin account's USDC as collateral | | [Farm](/solana/guides/farm/overview): Kamino, Basis, Perena | The same vaults; shares stay in your margin account as collateral | | [Predict](/solana/guides/predict/overview) | The same event list and prices (it uses the Predict page's own data, so you see every event and outcome), the same buy and sell transactions, CASH only, shares go into Vanna's pool | | [Test funds](/solana/guides/faucet) | Only test CASH for Predict can be requested here; mint other tokens from **Deposit → Test funds** | Every transaction is built and simulated by the [Vanna MCP](/solana/guides/mcp), the same engine that lets other AI apps use Vanna. Under the chat box the app reminds you: *every write asks your wallet for a signature; nothing is sent without it.* ## Approving a Plan When you ask for a change, the Copilot shows a card before anything happens. ![Copilot answering Deposit 10 SOL in my margin account with a card showing Projected Impact: health factor 12.63 to 13.62 on a bar marking 1.10 liquidation and the 1.15 copilot floor, collateral and debt before and after, Approve and run and Cancel buttons and Expires in 4:42, beside the sidebar with Margin, Earn and Predict positions](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/copilot/approve-and-run.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=5e8a512e227711bcf170d896d2e6d788) A single action: Projected Impact shows your health factor, collateral and debt before → after, with Approve and run, Cancel and the countdown. 1. **Review.** A single action shows its **Projected Impact**: your health factor on a bar with the 1.10 liquidation line and the 1.15 Copilot floor, plus collateral and debt before → after. A multi-step plan lists each step with its exact amount, how many wallet signatures it needs, any warnings, and your health factor after the plan. 2. **Approve within 5 minutes.** Click **Approve and run** (**Approve & run** on a multi-step plan). A countdown from 4:59 shows how long it's valid. After that it expires, and you ask again so it uses fresh prices. 3. **Sign each step.** For each step the Copilot checks live data again, builds the transaction, and your wallet asks you to sign it. A step that only shows you something (like your health factor) needs no signature. A Predict trade with several transactions is signed in **one** wallet approval. 4. **Done.** A step shows as confirmed only when the chain has confirmed it. ![Approve Plan card expiring in 4:38 with three steps: deposit 10 SOL as margin collateral, borrow 2,149.484995 USDC, and a report step showing the health factor with no signature, plus an execution preview and a 3x leverage note](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/copilot/Copilot_Multi-Plan.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=5d604f9bf8dd7f3e80c45a26f0c0b0a4) A three-step plan waiting for approval: deposit, a borrow sized to 3x, and a health-factor report, with the countdown at the top right. ![Executing step 2 of 3: deposit 10 SOL confirmed with its signature, borrow USDC checking before it is sent, show health factor next, and a Cancel remaining steps button](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/copilot/Copilot_Plan_Execution.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=b5bdeab5a43415dddd12d565f3ec1fd4) The same plan running: the deposit is confirmed and the borrow is being checked before it is sent. You can stop a running plan at any time with **Cancel remaining steps**. Steps already confirmed stay done. If prices move and a step would take your health below 1.15, the plan pauses instead of sending it. ## Safety * **Nothing moves without your signature.** The Copilot never holds a key and never signs. If you don't sign, nothing happens. * **The AI never picks a number.** It understands what you want; the app computes every amount from live on-chain data and checks it before you see it. * **Same limits as the app.** Actions that can lower your health keep it at **1.15 or above**; liquidation is at 1.10. Adding collateral and repaying are always allowed. * **Your account only.** It can't read for or act on another wallet, send funds to an address, run arbitrary programs, change protocol settings or liquidate anyone. * **Only what's on Vanna.** Tokens outside the app, options, spot shorts and multi-asset LP positions are refused (shorts are available as Phoenix perps). * **No orders for later.** It can't watch prices or act later (stop-loss, limit, DCA, "when SOL hits 200"). It tells you which part it won't do and does the rest now. * **No predictions.** On Predict it shows the market's prices; it never tells you which outcome will win. > [!NOTE] > > The Copilot can misread a request. Always check the plan card (asset, amount, direction and health factor after) before you approve and sign. ## Next steps > **[Vanna MCP](/solana/guides/mcp)** > > Use the same capabilities from Claude, Cursor or any MCP client. > **[Health factor](/solana/guides/margin/health-factor)** > > The floor every Copilot plan respects. # Earn Overview Source: https://docs.vanna.finance/solana/guides/earn/overview Vanna's lending pools: supply SOL, USDC or USDT and earn borrow interest. **Earn** lists Vanna's lending pools. Supplying to a pool lends your tokens to margin accounts; their interest is what you earn. ![Earn page with a Multi-Collateral Vaults banner, Overall Deposit and Net Earnings charts with 1 Week, 1 Month, 3 Months and All Time ranges, and Vaults / Positions tabs with pool filters](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/earn/overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=a78cf3fc005bc4c300b5c3cffa1f3598) Earn: your Overall Deposit and Net Earnings charts, then the pool list. ## Pools | Pool | Receipt | Notes | | - | - | - | | SOL | vSOL | Borrowed for SOL longs and SOL-denominated strategies | | USDC | vUSDC | Usually the busiest pool: most leverage, perps collateral and vaults run on USDC | | USDT | vUSDT | Stablecoin pool | ## Columns | Column | Meaning | | - | - | | **Assets Supplied** | Total supplied to the pool, in tokens and USD | | **Supply APY** | What lenders currently earn | | **Assets Borrowed** | What margin accounts currently owe the pool | | **Borrow APY** | What borrowers currently pay | | **Utilization Rate** | Borrowed ÷ supplied. Rates rise with utilization | | **Your Supply** | Your share of the pool, in tokens and USD | ![Earn pool table listing SOL, USDC and USDT pools, each Active, with Assets Supplied, Supply APY, Assets Borrowed, Borrow APY, Utilization Rate and Your Supply](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/earn/pools.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=6391a5d1f4bfa9c130727e5481648883) The pool table: SOL, USDC and USDT with supply, borrow, rates, utilization and your supply. Use **Vaults / Positions** to switch between all pools and just yours, and **All Pools**, search, **Deposit** and **Supply APY is** to filter. The charts above the table show your **Overall Deposit** and **Net Earnings** over 1 week, 1 month, 3 months or all time. ## Pool page Click a pool for its detail page: Total Supply, Available Liquidity, Utilization Rate and Supply APY on top, the **Supply Liquidity / Withdraw Liquidity** panel on the right, and these tabs: | Tab | What it shows | | - | - | | **Your Positions** | Your supply in this pool over time (**My Supply** chart) | | **Details** | Statistics: total supplied and borrowed, available liquidity, supply and borrow APY, utilization, liquidation bonus, oracle price and source, share-token exchange rate, reserve factor, supply and borrow caps, status and rate curve | | **Activity** | The pool's split between idle and borrowed funds, and your own supplies and withdrawals in this pool | | **Collateral and Limits** | The account-wide liquidation rule, each asset's collateral parameters and how much of each cap is used | | **Analytics** | The rate curve; on the USDC pool, also how much USDC came from each [Predict market](/solana/guides/predict/earn-while-you-wait#where-to-see-it) | ![SOL pool Details tab with Total Supplied and Total Borrowed rings, Available Liquidity, Supply APY, Borrow APY, Utilization Rate, Liquidation Bonus 5% liquidatable at HF 1.10 or below, Oracle Price from Kamino Scope with Pyth fallback, Share Token Exchange Rate, Reserve Factor 10%, Supply Cap and Borrow Cap Uncapped, and the Supply Liquidity panel](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/earn/pool-details.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=e7864f85940117ae0497138e17088d50) SOL pool → Details: statistics, oracle price (Kamino Scope, Pyth fallback) and the 1.10 liquidation line. ## Your receipt: vTokens Supplying mints vTokens to your wallet. The number of vTokens you hold stays the same; what each one is worth in the underlying asset (the exchange rate, e.g. "SOL per vSOL") rises as interest accrues. See [vTokens](/solana/learn/vtokens). ## Next steps > **[Supply](/solana/guides/earn/supply)** > > Lend SOL, USDC or USDT and receive vTokens. > **[Withdraw](/solana/guides/earn/withdraw)** > > Redeem vTokens for the asset plus interest. # Supply Source: https://docs.vanna.finance/solana/guides/earn/supply Supply SOL, USDC or USDT to a Vanna lending pool. ![SOL pool page showing Total Supply, Available Liquidity, Utilization Rate and Supply APY, a My Supply chart, and a Supply Liquidity form for 10 SOL with You Get vSOL, SOL per vSOL, Current Supply APY and estimated monthly earnings](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/earn/pool-supply.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=15732fcc5324e305a648207524ed69c5) SOL pool page with the Supply Liquidity panel and More Details expanded. **1. Open the pool** On [Earn](/solana/guides/earn/overview), click the pool you want (SOL, USDC or USDT). **2. Choose Supply Liquidity** In the right-hand panel keep **Supply Liquidity** selected and check the token. **3. Enter an amount** Type an amount or use **10% / 25% / 50% / 100%** of your wallet balance (shown as **Bal**). For SOL a small amount is kept back for fees. **4. Check More Details** Expand **More Details** to see what you'll receive (**You Get vSOL**), the current exchange rate (**SOL per vSOL**), the current Supply APY, estimated monthly and yearly earnings at that APY, and the **Remaining Supply Cap**. **5. Supply and sign** Click **Supply Liquidity** and approve in your wallet. When the transaction confirms, your vTokens appear and the pool's **Your Supply** updates. ## Good to know * Supply APY changes with utilization; the estimate uses today's rate, not a guarantee. * You can supply more at any time; every deposit mints vTokens at the current exchange rate. * Your earnings show on [Portfolio → Lender](/solana/guides/portfolio) as **Interest earned** and in the 30-day Lending P\&L chart. ## Next steps > **[Withdraw](/solana/guides/earn/withdraw)** > > Take your supply and interest back out. > **[Track it on Portfolio](/solana/guides/portfolio)** > > Interest earned and your 30-day Lending P\&L. # Withdraw Source: https://docs.vanna.finance/solana/guides/earn/withdraw Redeem vTokens for the underlying asset plus the interest it earned. **1. Open the pool** On [Earn](/solana/guides/earn/overview), open the pool you supplied to. **2. Choose Withdraw Liquidity** Switch the right-hand panel to **Withdraw Liquidity**. **3. Enter an amount** Enter how much of the underlying asset to withdraw, or use the % chips. **100%** redeems all your vTokens. **4. Confirm** Check the preview, click **Withdraw Liquidity** (**Withdraw All** at 100%) and approve in your wallet. The vTokens are burned and the underlying (with its accrued interest) arrives in your wallet. ## If the pool is busy You can only withdraw cash the pool is holding right now, shown as **Available Liquidity** (supplied minus borrowed). In a pool with very high utilization, a large withdrawal may have to wait until borrowers repay or are liquidated. High utilization also pushes rates up, which encourages repayment and new supply. ## Interest Interest accrues continuously. The amount you receive is your vTokens × the current exchange rate, so it already includes everything earned since you supplied. > [!TIP] > > You can also withdraw from [Portfolio → Lender](/solana/guides/portfolio): each supplied pool has **Withdraw** and **Supply more** buttons. ## Next steps > **[Earn overview](/solana/guides/earn/overview)** > > Compare pools, rates and utilization. > **[vTokens](/solana/learn/vtokens)** > > How your receipt grows in value. # Delta-Neutral Basis Vaults Source: https://docs.vanna.finance/solana/guides/farm/delta-neutral Earn Phoenix perp funding without price exposure: spot long plus an equal short. Vanna's **basis vaults** hold an asset and an **equal 1× short** of the same asset on Phoenix. The two legs cancel each other's price moves, so the vault is *delta-neutral*: what it earns is the **funding** that longs pay shorts on Phoenix. ![SOL Basis vault page with Jupiter and Phoenix badges, Vault APY 7D, Funding Now, Open Interest and Total Value Locked, a position with vbSOL receipt balance and earned yield, and a Deposit panel for 10 USDC showing estimated vbSOL, share price, APY and projected monthly earnings](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/farm/sol-basis-vault.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=50d3206b6e1d994cf3e286fe73716b4e) SOL Basis vault page: Vault APY (7D), Funding Now, Open Interest, TVL, your position and the Deposit panel. ## The vaults | Vault | Share | Legs | | - | - | - | | **SOL Basis** | vbSOL | SOL held at Phoenix, with an equal SOL-PERP short | | **ETH Basis** | vbETH | Spot ETH via Jupiter, with an equal ETH-PERP short on Phoenix | | **BTC Basis** | vbBTC | Spot BTC via Jupiter, with an equal BTC-PERP short on Phoenix | | **TSLA Basis** | vbTSLA | Spot TSLA exposure via Jupiter, with an equal TSLA-PERP short on Phoenix | | **META Basis** | vbMETA | Spot META exposure via Jupiter, with an equal META-PERP short on Phoenix | Each vault has a **capacity** (the most it accepts in total) and a per-deposit maximum. ## Deposit **1. Open the vault** On **Farm → Delta-Neutral**, click a vault. **2. Enter USDC** Deposits are **USDC** from your margin account. **Margin** shows the balance. **3. Read the details** Network, deposit, **Est. receipt received** (vbSOL…), **Share price**, **APY** and projected monthly earnings. **4. Deposit** Click **Deposit** and approve once. The shares go to your margin account and count toward its health factor. > [!NOTE] > > **SOL Basis** routes the USDC through your wallet: it leaves the margin account, is deposited into the vault and the vbSOL comes straight back to the margin account, all in **one approval**. The program checks the account's health at the moment the USDC is out, so a very large SOL Basis deposit against a lot of debt can be refused. The panel warns you if so. Any vbSOL left in your wallet can be moved into the margin account with the recovery button. ## Withdraw Switch to **Withdraw** and enter the shares to redeem. The vault unwinds your share of both legs and returns USDC to your margin account. ## The numbers | Field | Meaning | | - | - | | **Vault APY (7D)** | The vault's realized share-price return over the last 7 days, annualized. Until a vault has 7 days of history, it shows an estimate from Phoenix's last 7 days of funding on the vault's short | | **Funding Now** | Phoenix's current hourly funding on that market, annualized. Positive = shorts are paid | | **Open Interest** | Total open positions on that Phoenix market (one side), in USD and in the asset | | **Total Value Locked** | The vault's net asset value | | **Capacity** | The vault's cap and how much of it is used | ## What can go wrong * **Negative funding.** When more traders are short than long, funding turns negative and the short **pays**. If that lasts, the vault's APY falls and can go below zero. * **Costs.** Entering and rebalancing pay Jupiter swap and Phoenix fees. On a small vault, one rebalance can move the share price more than days of funding. * **Venue risk.** The vault relies on Jupiter, Phoenix and its own program working as intended. Compare vaults on the Delta-Neutral list: Funding Now and Vault APY tell you which market currently pays best. ## Next steps > **[Farm positions](/solana/guides/farm/positions)** > > Track earnings and exit. > **[Perps on Phoenix](/solana/learn/perps-on-phoenix)** > > How funding works on Phoenix. # Kamino Lending Source: https://docs.vanna.finance/solana/guides/farm/kamino Supply SOL, USDC or USDT from your margin account to Kamino and earn its supply APY. Kamino is Solana's largest lending market. From Farm you supply margin-account tokens to Kamino's main market and receive Kamino **receipt tokens** (kSOL, kUSDC, kUSDT) that grow as Kamino borrowers pay interest. ![Kamino SOL vault page with Supply APY, Borrow APY, Utilization Rate and Total Pool Supply, Position value and Receipt balance, and a Supply panel previewing 10 SOL](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/farm/kamino-sol.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=21c7127d7967b0c526cb8ca4f3332475) Kamino SOL vault page: Supply APY, Borrow APY, utilization and pool size, your position and the Supply panel. ## Supply **1. Open the vault** On **Farm → Lending / Single Assets**, click SOL, USDC or USDT with the **Kamino** badge. **2. Enter the amount** In **Supply**, type an amount or use the % chips. **Margin** shows what your margin account holds of that token. Need more? Deposit or borrow on [Margin](/solana/guides/margin/overview) first. **3. Read the details** The details box shows the network, your deposit before → after, the **Est. receipt received** (kSOL…), the APY and projected monthly earnings. **4. Supply** Click **Supply SOL to Kamino** and approve. The receipt lands in your margin account. ## Withdraw Switch to **Withdraw**, choose a percentage of your position and confirm. The receipt is redeemed and the underlying token returns to your margin account. [Flash repay](/solana/guides/margin/repay#flash-repay) also redeems every Kamino receipt automatically. ## The numbers | Field | Meaning | | - | - | | **Supply APY / Borrow APY** | Kamino's live rates for that reserve | | **Utilization Rate** | How much of Kamino's reserve is borrowed | | **Total Pool Supply** | Size of Kamino's reserve | | **Receipt balance** | Your kSOL / kUSDC / kUSDT. It's a share of the reserve, so the number is much larger than the underlying it's worth | | **Earned yield** | What your position has earned since your first deposit | ## Leveraged Kamino Borrow on Margin, then supply here: you earn Kamino's supply APY on the borrowed amount and pay Vanna's borrow APY on it. It's profitable while Kamino's supply rate is above Vanna's borrow rate for that asset. Watch both, since both move with utilization. ## Next steps > **[Farm positions](/solana/guides/farm/positions)** > > Track earnings and exit. > **[Kamino integration](/solana/learn/kamino-integration)** > > How Vanna supplies to Kamino under the hood. # Farm Overview Source: https://docs.vanna.finance/solana/guides/farm/overview Put your margin account's balances to work in Kamino, Perena and delta-neutral basis vaults. **Farm** deploys tokens from your margin account into yield venues. You can farm with your own collateral or with borrowed funds (leveraged yield). Whatever you receive back, a Kamino receipt or vault shares, **stays in your margin account and counts as collateral**, so farming barely moves your health factor. ![Farm page with a Farm DeFi Yields banner, Net Health Factor, Your Deposit TVL, Your Earnings, Net Farm APY and Pending Rewards, and a Kamino table for SOL and USDC under Lending/Single Assets](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/farm/overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4b98753ed9c2d0b567f10e585b2eaca6) Farm: your farm stats, then Vaults / Positions and the Lending/Single Assets and Delta-Neutral categories. ## Stats | Stat | Meaning | | - | - | | **Your Deposit TVL** | What you currently have deployed in Farm | | **Your Earnings** | Yield earned across your Farm positions | | **Net Farm APY** | Your blended APY across positions | | **Pending Rewards** | Rewards not yet claimed | | **Net Health Factor** | Your margin account's health factor (same number as on Margin) | ## Categories | Category | Venues | Guide | | - | - | - | | **Lending / Single Assets** | **Kamino** lending (SOL, USDC, USDT) and **Perena** USD\* vaults | [Kamino](/solana/guides/farm/kamino) · [Perena](/solana/guides/farm/perena) | | **Delta-Neutral** | Vanna's **basis vaults**: SOL, ETH, BTC, TSLA and META Basis, earning Phoenix funding | [Delta-Neutral](/solana/guides/farm/delta-neutral) | **Vaults** lists everything you can farm; **Positions** lists what you hold. Use **All Pools**, search and the column filters to narrow the list. **Lending / Single Assets** Kamino reserves (SOL, USDC, USDT) with total deposits and borrows, supply and borrow APY, utilization and your holding, then the **Perena vaults** (USD\* and USD\* Junior) with TVL, share price, APY (7D), holders and your holding. ![Kamino rows for SOL, USDC and USDT with total deposits, total borrow, supply APY, borrow APY, utilization and holding, and a Perena vaults table with USD\* and USD\* Junior showing TVL, share price, APY 7D and holders](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/farm/lending-vaults.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=d91db17ee05fe5da1912e30aa6dc6ca2) Lending/Single Assets: Kamino reserves and Perena vaults. **Delta-Neutral** Vanna's basis vaults (SOL, ETH, BTC, TSLA and META Basis) with total deposits, capacity used, Vault APY, **Funding Now**, open interest and your holding. ![Delta-Neutral table listing SOL, ETH, BTC, TSLA and META Basis vaults on Jupiter and Phoenix with total deposits, capacity, vault APY, funding now, open interest and holding](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/farm/delta-neutral-vaults.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4020f09db53d59518fa5d51abafe85a4) Delta-Neutral: five basis vaults, each a spot leg plus a 1× Phoenix short. ## Every vault page looks the same Click a row to open its page: * **Stats bar** on top (APY, rates, TVL…) * **All Transactions**: your position value, receipt balance and earned yield, with Current Position and Position History tables * **Analytics**: charts and details for that venue * **Deposit / Withdraw panel** on the right. After you enter an amount, a details box shows the network, the amount, the **estimated receipt** you'll get, the share price, the APY and **projected monthly earnings** ## Why the health factor barely moves A farm deposit swaps one thing in your margin account (USDC, SOL…) for another of about the same value (kUSDC, USD\*, vbSOL…), so total collateral stays the same. What can move it later is the receipt's own value: a vault's share price can rise or fall. > [!WARNING] > > Leverage can get your account liquidated. Prices, borrow interest, swap slippage, perp funding and vault share prices all move your health factor, which must stay **above 1.10**. Only use what you can afford to lose. ## Next steps > **[Kamino](/solana/guides/farm/kamino)** > > Supply SOL, USDC or USDT to Kamino. > **[Perena](/solana/guides/farm/perena)** > > USD\* and USD\* Junior stablecoin vaults. > **[Delta-neutral](/solana/guides/farm/delta-neutral)** > > Earn Phoenix funding without price exposure. # Perena Vaults Source: https://docs.vanna.finance/solana/guides/farm/perena Deposit margin-account USDC into Perena's USD* and USD* Junior vaults. [Perena](https://perena.org) runs USD\*, a yield-bearing stablecoin vault. Vanna lets you deposit USDC from your margin account and hold the vault shares as collateral. ![Perena USD\* vault page with APY 7D, Share Price, Holders and Total Value Locked, an Analytics tab with Share price (Perena), Share price (Vanna), Exit fee, Recorded APY 30D, ROI and Max drawdown, and a Deposit panel for 10 USDC](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/farm/perena-usd-star.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=2a8a4adf53646711371dc0378b28b9ef) USD\* vault page, Analytics tab: APY (7D), share price on Perena and on Vanna, exit fee, recorded APY, and the Deposit panel. ## The two vaults | Vault | Share | What it is | | - | - | - | | **USD\*** | USD\* | Perena's main (senior) vault | | **USD\* Junior** | USD\* Junior | Higher-yield junior tranche: it takes losses before the senior vault does, in return for more yield. **Instant withdrawals pay a 1% exit fee** | ## Deposit **1. Open the vault** On **Farm → Lending / Single Assets**, click **USD\*** or **USD\* Junior** (Perena badge). **2. Enter USDC** Deposits are in **USDC** from your margin account (**Margin** shows the balance). **3. Read the details** Network, deposit amount, **Est. receipt received** (USDC ÷ share price), **Share price**, **APY** and projected monthly earnings. **4. Deposit** Click **Deposit** and approve. The shares arrive in your margin account. ## Withdraw Switch to **Withdraw** and enter how many shares to redeem. The details show the **Est. USDC received**; for USD\* Junior that already includes the 1% instant-exit fee. ## The numbers | Field | Meaning | | - | - | | **APY (7D)** | Perena's published APY | | **Share price** | USDC value of one share. It rises as the vault earns | | **Holders / Total Value Locked** | Perena's vault-wide figures | | **Share price (Perena) / Share price (Vanna)** | Perena's published mainnet price, and the price Vanna values your receipt at | | **Exit fee** | 0% on USD\*; 1% on USD\* Junior's instant withdrawals | | **Recorded APY 30D / ROI / Max drawdown** | Vanna's own record of the share price since it began recording | | **Earned yield** | Your share-price gain since your first deposit | Shares are valued at their share price in your health factor. ## Next steps > **[Farm positions](/solana/guides/farm/positions)** > > Track earnings and exit. > **[Yield vaults](/solana/learn/yield-vaults)** > > How Perena and basis vaults work. # Farm Positions Source: https://docs.vanna.finance/solana/guides/farm/positions Track what you've farmed, what it's earned, and exit. There are three places to see your Farm positions. ## Farm → Positions On the Farm page, switch from **Vaults** to **Positions** to list only the vaults you hold, across Kamino, Perena and the basis vaults, with your holding in each. ## The vault page Each vault page's **All Transactions** tab shows: | Field | Meaning | | - | - | | **Position value** | What your holding is worth now, in USD | | **Receipt balance** | Your kSOL / USD\* / vbBTC… | | **Earned yield** | Your gain since your first deposit (the date is shown below it) | | **Current Position** | Asset, protocol, supplied amount or value, receipt balance and APY | | **Position History** | Every deposit and withdrawal with date, amount, status and transaction hash | Use **Customize** to choose the columns and the filter to narrow the history. ## Margin → Positions Farm receipts are collateral, so they also appear on the left of the Margin page's positions map. The **Farm** chip under **Borrowed money is in** shows how much is deployed in Farm and jumps there. Portfolio → Trader → **Farm** lists the same positions. ## Exiting | Venue | How to exit | | - | - | | Kamino | **Withdraw** a percentage on the vault page; the token returns to your margin account | | Perena | **Withdraw** shares; USDC returns to your margin account (USD\* Junior: 1% instant-exit fee) | | Basis vaults | **Withdraw** shares; the vault unwinds both legs and returns USDC | To close everything at once, including repaying your loans, use [Flash repay](/solana/guides/margin/repay#flash-repay). It redeems Kamino receipts automatically; vault shares can be withdrawn on their pages. ## Next steps > **[Flash repay](/solana/guides/margin/repay#flash-repay)** > > Unwind and repay in guided steps. > **[Farm overview](/solana/guides/farm/overview)** > > Compare every vault. # Faucet Source: https://docs.vanna.finance/solana/guides/faucet Mint free test tokens on the Vanna mainnet fork from the Deposit window. Test funds live in the **Deposit** window. Click **Deposit** in the header (next to your account) to open **Portfolio account**, then use **Test funds** on the **Deposit** tab. You can also open it from the **Deposit** button on [Portfolio](/solana/guides/portfolio). ![Portfolio account window with Deposit and Transfer tabs, a Test funds grid with Mint buttons for SOL, USDC, USDT, JitoSOL, JupSOL, JupUSD, NVDAx, GOOGLx, AAPLx, TSLAx and CASH, a Mint all button, and a Receive panel with a QR code and Copy address](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/faucet/test-funds.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=bfdb474f26f1c518f221559f31d54531) Deposit → Test funds: Mint one token or Mint all. The Receive panel shows your address and a QR code. **1. Sign in** [Connect](/solana/guides/connect-wallet) with email, a social login or Backpack. **2. Open Deposit** Click **Deposit** in the header. The window shows your wallet and the **Testnet** tag. **3. Mint** Click **Mint** on a token, or **Mint all** for every token at once. Each tile shows what was added and your new balance. | Token | Per mint | | - | - | | SOL, USDC, USDT | +1,000 | | JitoSOL, JupSOL, JupUSD | +1,000 | | NVDAx, GOOGLx, AAPLx, TSLAx | +10 | | CASH (Predict) | +1,000 | Minting is **unlimited on the fork**: mint again whenever you run low. ## How it works Test funds use Surfpool **fork cheatcodes**: the server writes the new balance straight into fork state. There is no transaction to sign and no wallet approval. Nothing real moves; these tokens exist only on the fork. ## The rest of the Deposit window | Part | What it's for | | - | - | | **Receive** | Your wallet address with a QR code and **Copy address**, to receive fork tokens from another Vanna tester. Only Vanna testnet tokens show up here; devnet or mainnet tokens won't | | **Transfer** tab | Move tokens between your wallet (**Portfolio account**) and your **Margin account**, the same form as [Transfer Collateral](/solana/guides/margin/transfer-collateral) | > [!TIP] > > * Keep some SOL in your wallet for transaction fees. > * CASH is the token World.xyz markets settle in. You only need it for [Predict](/solana/guides/predict/overview). > * Using Backpack and a balance doesn't appear there? Check Backpack is pointed at the [fork RPC](/solana/guides/connect-wallet#add-the-vanna-rpc-to-your-wallet). The app itself always reads the fork. ## Next steps > **[Supply on Earn](/solana/guides/earn/overview)** > > Lend your test tokens and earn interest. > **[Open a margin account](/solana/guides/margin/open-account)** > > Deposit collateral and borrow. # For Liquidity Providers Source: https://docs.vanna.finance/solana/guides/for-liquidity-providers Supply SOL, USDC or USDT and earn the interest margin accounts pay. ## What you earn You supply an asset to its lending pool and receive **vTokens** (vSOL, vUSDC, vUSDT). Borrowers pay interest into the pool, so each vToken is redeemable for more of the underlying over time. Your **Supply APY** depends on how much of the pool is borrowed (its utilization): the busier the pool, the higher the rate. See [Interest Rate Model](/solana/learn/interest-rate-model). ## What you risk * **Liquidity:** you can withdraw only what isn't currently lent out. In a very busy pool (high utilization) you may have to wait for repayments or liquidations to free cash. * **Bad debt:** if a borrower's collateral falls faster than it can be liquidated, the pool can take a loss. Vanna liquidates at a health factor of 1.10, while every borrower still has more collateral than debt, to keep this rare. The [Analytics](/solana/guides/analytics) page shows estimated bad debt and accounts at risk live. * **Test network:** today's app runs on a mainnet fork; balances are test balances. ## Other ways to earn * **Predict:** hold matched Yes and No shares and they earn in Vanna's USDC pool until the event resolves ([Predict](/solana/guides/predict/earn-while-you-wait)). * **Farm:** through a margin account you can supply to Kamino or deposit into Perena and basis vaults ([Farm](/solana/guides/farm/overview)). ## How to start **1. Sign in and get test funds** [Connect your wallet](/solana/guides/connect-wallet) and mint test funds from **Deposit** ([Faucet](/solana/guides/faucet)). **2. Supply** Open [Earn](/solana/guides/earn/overview), pick a pool and [supply](/solana/guides/earn/supply). **3. Track it** Watch interest on [Portfolio → Lender](/solana/guides/portfolio). ## Next steps > **[Supply on Earn](/solana/guides/earn/supply)** > > Lend SOL, USDC or USDT. > **[Interest rate model](/solana/learn/interest-rate-model)** > > How utilization sets your APY. # For Traders Source: https://docs.vanna.finance/solana/guides/for-traders Borrow against many collaterals and use the loan for swaps, perps and yield. ## What you can do | Goal | How | | - | - | | Borrow without selling | Deposit SOL, LSTs, stables or xStocks and borrow SOL, USDC or USDT ([Borrow](/solana/guides/margin/borrow)) | | Leverage up to 10× | Use the leverage slider on Margin; borrow one asset or two at once with Dual Borrow | | Swap with leverage | Swap inside the margin account on Jupiter or Titan ([Spot](/solana/guides/trade/spot-swap)) | | Long or short | Phoenix perps on SOL, ETH, BTC, TSLA and META, up to 5× per order ([Perps](/solana/guides/perps/overview)) | | Leveraged yield | Supply to Kamino, or deposit into Perena or delta-neutral basis vaults ([Farm](/solana/guides/farm/overview)) | | Close everything | Flash repay closes positions and repays every loan in one guided flow ([Repay](/solana/guides/margin/repay)) | ## Your numbers * **Health factor**: collateral ÷ debt. Liquidation at 1.10 or below. See [Health Factor](/solana/guides/margin/health-factor). * **Leverage**: everything the account holds (borrowed funds included, open perps at full size) ÷ your equity. 1.00x means no borrowing. * **Collateral left before liquidation**: how much value your collateral can lose before the account reaches 1.10. Every page that can change your account shows a before → after preview of these numbers before you sign. > [!WARNING] > > Leverage can get your account liquidated. Prices, borrow interest, swap slippage, perp funding and vault share prices all move your health factor, which must stay **above 1.10**. Only use what you can afford to lose. ## How to start **1. Sign in and get test funds** [Connect](/solana/guides/connect-wallet) and mint test funds from **Deposit** ([Faucet](/solana/guides/faucet)). **2. Open your account** [Open a margin account](/solana/guides/margin/open-account) and [deposit collateral](/solana/guides/margin/deposit-collateral). **3. Borrow and use it** [Borrow](/solana/guides/margin/borrow), then swap, trade perps or farm. ## Next steps > **[Margin overview](/solana/guides/margin/overview)** > > Collateral, loans and leverage in one place. > **[Perps](/solana/guides/perps/overview)** > > Long or short on Phoenix. # Getting Started Source: https://docs.vanna.finance/solana/guides/getting-started Open Vanna, sign in, mint test funds and pick what you want to do. Vanna is a credit layer on Solana. You lend into Vanna's pools, or open one **margin account** that holds many collaterals, borrow against it, and use that loan across Solana: spot swaps (Jupiter or Titan), perps (Phoenix), Kamino lending, Perena and delta-neutral vaults, and World.xyz prediction markets. **Live app:** [test.vanna.finance](https://test.vanna.finance) (choose **Solana** in the chain switcher at the top right). > [!NOTE] > > Vanna runs on a **Solana mainnet fork** (Surfpool), not public Devnet or Mainnet. Balances are test balances on the fork. If you use Backpack, add the fork RPC `https://rpc-devnet.solana.vanna.finance` to it ([how](/solana/guides/connect-wallet#add-the-vanna-rpc-to-your-wallet)). Then mint test funds from **Deposit → Test funds** ([Faucet](/solana/guides/faucet)) before any Earn, Margin, Trade, Farm or Predict action. ## Four steps to start **1. Enter the access code** The test app is private. On your first visit it asks for an **access code**; enter the one the Vanna team gave you. Your browser remembers it for about 30 days. **2. Sign in** Click **Connect wallet** at the top right. Sign in with **email** (a one-time code), **Google**, **X** or **GitHub**, or connect **Backpack**. See [Connect Your Wallet](/solana/guides/connect-wallet). **3. Backpack only: add the fork RPC** If you use Backpack, add the custom RPC `https://rpc-devnet.solana.vanna.finance` so it shows fork balances and previews transactions correctly. The purple strip at the top of the app has a **Copy** button and a **Setup guide** link. Email and social logins don't need this. **4. Mint test funds** Click **Deposit** in the header, then **Mint all** under **Test funds**: 1,000 of each token (10 of each xStock) plus 1,000 CASH for Predict, with no wallet approval. See [Faucet](/solana/guides/faucet). ![Vanna Portfolio page showing net worth split into wallet, lending and margin equity, net earnings, and a health factor card with the chameleon mascot](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/portfolio/overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=0db0e79c5575d7268b77c68afbebc693) Portfolio after signing in and minting test funds: net worth, net earnings and health factor at the top. ## The app at a glance The header groups the pages the way money flows. On Solana, the app opens on **Margin**. | Group | Page | What you do there | | - | - | - | | | [Portfolio](/solana/guides/portfolio) | Everything you hold, earn and owe in one place | | **Lend** | [Earn](/solana/guides/earn/overview) | Supply SOL, USDC or USDT to Vanna's pools and earn borrow interest | | **Lend** | [Predict](/solana/guides/predict/overview) | Buy Yes / No on real World.xyz events; your shares earn in Vanna's USDC pool while you wait | | **Borrow & Trade** | [Margin](/solana/guides/margin/overview) | Deposit collateral, borrow up to 10×, repay, move collateral | | **Borrow & Trade** | [Trade → Spot](/solana/guides/trade/spot-swap) | Swap inside your margin account through Jupiter or Titan | | **Borrow & Trade** | [Trade → Perps](/solana/guides/perps/overview) | Long or short SOL, ETH, BTC, TSLA, META on Phoenix | | **Borrow & Trade** | [Farm](/solana/guides/farm/overview) | Put margin balances into Kamino, Perena or delta-neutral basis vaults | | | [Analytics](/solana/guides/analytics) | Protocol-wide risk, pools, collateral and prices | | | [Copilot](/solana/guides/copilot) | Ask about your account or describe a change in plain English | | | Rewards (**Soon**) | Points, referrals and a leaderboard are coming. See the [FAQ](/solana/resources/faq) | On the right of the header: the **chain switcher** (Solana / Stellar), the **Deposit** button (test funds, receive address and wallet ↔ margin transfers) and your account menu. Outside the app, [Vanna MCP](/solana/guides/mcp) lets Claude, Cursor or any MCP-compatible assistant use Vanna for you. ## Supported assets | Asset | What it is | Lend (Earn) | Borrow | Margin collateral | | - | - | :-: | :-: | :-: | | SOL | Native SOL (wrapped to wSOL in vaults) | ✓ | ✓ | ✓ | | USDC | Circle USDC | ✓ | ✓ | ✓ | | USDT | Tether USD | ✓ | ✓ | Held, not offered as a deposit | | JitoSOL, JupSOL | Liquid-staked SOL | | | ✓ | | JupUSD | Jupiter USD | | | ✓ | | NVDAx, GOOGLx, AAPLx, TSLAx | Backed Finance xStocks (tokenized equities, Token-2022) | | | ✓ | | CASH | World.xyz's settlement token, used on Predict | | | | Vault receipts you receive from Farm (kSOL, kUSDC, USD\*, vbSOL…) stay in your margin account and count as collateral too. > [!TIP] > > A wallet signature is not the final result. Wait for the confirmation toast and refreshed balances before the next step that depends on it. ## Next steps > **[Connect your wallet](/solana/guides/connect-wallet)** > > Sign-in options and the Backpack RPC setup. > **[Get test funds](/solana/guides/faucet)** > > Mint every supported token on the fork. > **[Supply on Earn](/solana/guides/earn/supply)** > > Lend SOL, USDC or USDT and earn interest. > **[Open a margin account](/solana/guides/margin/open-account)** > > Deposit collateral and borrow against it. # How Vanna Works Source: https://docs.vanna.finance/solana/guides/how-vanna-works Lenders, margin accounts, venues and the health check that ties them together. Vanna has two sides: **lenders** who supply assets to pools, and **margin accounts** that borrow from those pools and put the loan to work on other Solana protocols. ## The pieces | Piece | What it is | | - | - | | **Lending pools** | One pool per lendable asset (SOL, USDC, USDT). Lenders deposit and receive vTokens (vSOL, vUSDC, vUSDT) that grow as interest accrues. | | **Margin account** | A program-owned account per wallet. It holds your collateral, the tokens you borrowed and every receipt or position you open. | | **Venues** | The protocols a margin account can act on: Jupiter and Titan (swaps), Phoenix (perps), Kamino (lending), Perena and Vanna's basis vaults (yield). | | **Oracle** | Prices for every asset, from Kamino Scope first and Pyth as fallback. The app shows each source and its freshness on the Margin page. | | **Health check** | Run on-chain after any action that could reduce health. The account must stay above a health factor of 1.10. | ## Follow the money **1. Lenders supply** A lender supplies USDC on Earn and receives vUSDC. The USDC sits in the pool, ready to be borrowed. **2. A trader deposits collateral** A trader opens a margin account and deposits collateral, for example SOL, USDC or TSLAx. **3. The trader borrows** The trader borrows USDC from the pool. The USDC moves into the trader's margin account, not their wallet, and the account records the debt. **4. The loan goes to work** From the margin account the trader swaps, opens a perp, or moves into a Farm vault. Each result (tokens, kSOL, vbSOL, a Phoenix position) stays in the account and counts as collateral. **5. Interest flows back** Borrowers pay interest that accrues to the pool. Lenders' vTokens are worth more underlying over time. **6. Unwind** The trader closes positions and repays (or uses Flash repay to do it all in one flow), then withdraws what's left. ## Account health ```text theme={null} Health factor = total collateral value (USD) ÷ total debt value (USD) ``` Every asset counts at its full oracle value, with no per-asset weighting. At **1.10 or below** the account can be liquidated. The app blocks withdrawals and new borrows that would take you under a **1.15** safety floor, so you always keep a buffer. More in [Health Factor](/solana/guides/margin/health-factor). ## Predict Predict is a separate flow on World.xyz markets. When you hold matching **Yes and No** shares of the same market, Vanna pairs them, merges them back into USDC and lends that USDC in its pool, so the pair earns interest until the event resolves. See [Earn While You Wait](/solana/guides/predict/earn-while-you-wait). ## Next steps > **[Getting Started](/solana/guides/getting-started)** > > Sign in and mint test funds. > **[Architecture](/solana/developers/architecture)** > > The programs behind it, for developers. # Borrow Source: https://docs.vanna.finance/solana/guides/margin/borrow Borrow SOL, USDC or USDT against your collateral, up to 10× leverage. Borrowing happens in the **Leverage your Assets** tab, together with (or without) a deposit. ![Leverage panel with SOL deposit, USDC borrow of 1089.45, Single Borrow / Dual Borrow toggle and a 1x to 10x leverage slider](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/margin/borrow-leverage.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4325f47a6ffca2c70d16d9bd94c8d7e5) Deposit 10 SOL and borrow USDC at 2×: Max Value, the leverage slider and the total. **1. Set up the deposit** Choose collateral under **Deposit**. **WB** deposits from your wallet; **MB** borrows against collateral already in your margin account. **2. Choose Single or Dual Borrow** **Single Borrow** borrows one asset. **Dual Borrow** splits the loan 50/50 across two assets, sized from the leverage slider. **3. Pick the asset** Choose SOL, USDC or USDT under **Borrow**. **4. Set the size** Drag the leverage slider (**1× to 10×**), use **−/+**, type an amount, or click **Max Value**. **Total** and **Max** show the loan in USD. **5. Review and sign** Check **Transaction Details**: the account's health factor, leverage and collateral before → after. Click **Deposit & Borrow** and approve. ## Where the loan goes Borrowed tokens land in your **margin account**, not your wallet. From there you can swap, trade perps or farm. To take them to your wallet, use [Transfer Collateral](/solana/guides/margin/transfer-collateral) (Margin account → Portfolio account); that withdrawal is health-checked. ## Limits * The program rejects any borrow that would leave the account at a health factor of **1.10 or below**. * The app's Max keeps a **1.15** safety floor so a small price move right after borrowing doesn't put you at the line. * You can't borrow more than the pool has available (see the pool's Available Liquidity on [Earn](/solana/guides/earn/overview)). ## Interest Debt grows at the pool's **Borrow APY**, which rises with the pool's utilization. **Net Borrow Rate** on the Margin page is your account's blended rate; accrued interest shows in the Positions table and on Portfolio. > [!WARNING] > > Leverage can get your account liquidated. Prices, borrow interest, swap slippage, perp funding and vault share prices all move your health factor, which must stay **above 1.10**. Only use what you can afford to lose. ## Next steps > **[Swap](/solana/guides/trade/spot-swap)** > > Turn the loan into another token. > **[Trade perps](/solana/guides/perps/overview)** > > Long or short on Phoenix. > **[Repay](/solana/guides/margin/repay)** > > Pay back part or all of a loan. # Deposit Collateral Source: https://docs.vanna.finance/solana/guides/margin/deposit-collateral Add SOL, USDC, LSTs, JupUSD or xStocks to your margin account. There are two ways to deposit: | Where | Use it when | | - | - | | **Leverage your Assets** tab | You want to deposit and borrow in one transaction | | **Transfer Collateral** (Portfolio account → Margin account) | You only want to move tokens into the margin account | ## Deposit (and borrow) in one go **1. Open Leverage your Assets** On **Margin**, keep the first tab selected. **2. Pick the token and source** Under **Deposit**, choose the token. **WB** deposits from your wallet balance; **MB** borrows against collateral already in your margin account (one token, borrow only). **3. Enter the amount** Type it or use **10% / 25% / 50% / 100%**. The USD value and current price are shown under the field. **4. Add more collateral (optional)** **+ Add Collateral** adds another token to the same transaction, so you can deposit several assets at once. **5. Borrow, or not** Set the borrow amount or leverage (see [Borrow](/solana/guides/margin/borrow)). To deposit only, leave the borrow at zero. **6. Review and sign** Check **Transaction Details** and the before → after account preview, then click **Deposit & Borrow** (or deposit) and approve. ## Accepted collateral SOL, USDC, JitoSOL, JupSOL, JupUSD, NVDAx, GOOGLx, AAPLx and TSLAx can be deposited. USDT can be held, borrowed, repaid and withdrawn, but isn't offered as a deposit. Each asset counts at its full oracle value: health factor is total collateral ÷ total debt with no per-asset haircut. > [!NOTE] > > When you deposit SOL from your wallet, the app keeps a small SOL reserve (0.05 SOL) back so you can still pay transaction fees. ## Next steps > **[Borrow](/solana/guides/margin/borrow)** > > Borrow SOL, USDC or USDT up to 10×. > **[Health factor](/solana/guides/margin/health-factor)** > > How your collateral keeps you safe. # Health Factor Source: https://docs.vanna.finance/solana/guides/margin/health-factor The one number that decides whether your margin account is safe. ```text theme={null} Health factor = total collateral value (USD) ÷ total debt value (USD) ``` * **Collateral** is everything in your margin account at its oracle price: tokens, borrowed tokens still in the account, Kamino receipts, vault shares and your Phoenix perps collateral (with open P\&L). * **Debt** is every loan, with interest accrued to now. * Every asset counts at **full value**: there are no per-asset collateral weights. With no debt the health factor is shown as **No debt**. Very large values show as **>100**. ## Zones | Health factor | Label | What it means | | - | - | - | | 1.50 or more | **Safe** | Comfortable buffer | | 1.25 – 1.50 | **Healthy** | Fine, but a sharp move would bring you closer | | Above 1.10, below 1.25 | **At risk** | Orders that would take you between 1.15 and 1.25 show a warning; below 1.15 they're blocked | | **1.10 or below** | **Liquidation** | Anyone can liquidate the account | The app keeps a **1.15 safety floor**: it won't build a borrow, withdrawal or trade that would leave you below it. The program's hard rule is 1.10: it rejects any action that would leave the account at or below that. ## Example You deposit $10,000 of SOL and borrow $5,000 USDC, which stays in the account. * Collateral = $10,000 SOL + $5,000 USDC = $15,000; debt = $5,000 → **HF 3.00** * You swap the $5,000 USDC into SOL: collateral is still $15,000 (now all SOL) → **HF 3.00** * SOL falls 60%: collateral = \$6,000 → **HF 1.20**, close to the line * SOL falls 64%: collateral ≈ \$5,400 → **HF 1.08**, liquidatable Moving value between assets inside the account (a swap, a Kamino supply, a vault deposit) barely changes the health factor, because what goes out comes back at about the same value. What moves it is **prices** and **debt**. ## Where you see it Portfolio, Margin (stats, Account Info and the Liquidation bar), Spot, Perps and Farm all show your health factor, and every action shows it **before → after** before you sign. ## Raising it * Deposit more collateral * Repay some debt * Close or reduce risky positions ## Next steps > **[Liquidation](/solana/guides/margin/liquidation)** > > What happens at 1.10 and how to avoid it. > **[Health factor (concept)](/solana/learn/health-factor)** > > The math in more depth. # Liquidation Source: https://docs.vanna.finance/solana/guides/margin/liquidation What happens when a margin account's health factor reaches 1.10, and how to avoid it. When a margin account's health factor is **1.10 or below**, anyone can liquidate it. Liquidation exists to make sure lenders are repaid while the account still has more collateral than debt. ## How it works 1. A liquidator calls the program's public liquidation instruction on your account. 2. They **repay some of your debt** with their own tokens. 3. In return they **seize collateral** worth the repaid debt **plus a liquidation bonus** (set per asset, capped at 5%; each Earn pool page shows its bonus). 4. If needed, the liquidation can first unwind positions the account holds on other venues (for example a Kamino supply or a Phoenix position) so there's collateral to seize. The program checks the account was liquidatable before, and that the liquidator received at least the minimum they asked for. ## What it costs you You lose the seized collateral, including the bonus paid to the liquidator. The debt that was repaid is gone too, so your equity drops by roughly the bonus on each liquidation. The rest of the account stays yours. ## How to avoid it * Watch the health factor and the **Collateral Left Before Liquidation** figure on Margin. * Keep well above the 1.15 safety floor when markets are volatile. * Repay debt or add collateral when the health factor drifts down. * Remember what moves it: collateral prices, borrow interest, perp P\&L and funding, and vault share prices. * Use [Flash repay](/solana/guides/margin/repay#flash-repay) to unwind quickly. ## Watching the whole protocol [Analytics](/solana/guides/analytics) lists every account's health, the accounts that can be liquidated right now and the debt at risk. > [!WARNING] > > Leverage can get your account liquidated. Prices, borrow interest, swap slippage, perp funding and vault share prices all move your health factor, which must stay **above 1.10**. Only use what you can afford to lose. ## Next steps > **[Repay](/solana/guides/margin/repay)** > > Pay down debt or use Flash repay. > **[Analytics](/solana/guides/analytics)** > > Accounts at risk across the protocol. # Open a Margin Account Source: https://docs.vanna.finance/solana/guides/margin/open-account Create your margin account: one signature, once per wallet. Your margin account is a program-owned account derived from your wallet address. You create it once; after that it's always the same account for that wallet. **1. Connect** [Connect your wallet](/solana/guides/connect-wallet) and mint test funds from **Deposit** ([Faucet](/solana/guides/faucet)). **2. Open Margin** Go to **Margin** (the page the app opens on). If you don't have an account yet, the page offers to create one. **3. Create and sign** Click create and approve in your wallet. A small amount of SOL pays the account's rent. > [!TIP] > > You can also skip this step: your first deposit (in **Leverage your Assets** or **Transfer Collateral** into the margin account) creates the account in the same transaction if it doesn't exist yet. ## What the account holds * Collateral you deposit * Tokens you borrow (they stay in the account; they don't go to your wallet) * Swap results, Kamino receipts (kSOL, kUSDC, kUSDT), vault shares (USD\*, USD\* Junior, vbSOL, vbBTC…) and your Phoenix perps collateral All of it counts toward one health factor. ## Next steps > **[Deposit collateral](/solana/guides/margin/deposit-collateral)** > > Add SOL, USDC, LSTs, JupUSD or xStocks. > **[Margin accounts (concept)](/solana/learn/margin-accounts)** > > How the account works on-chain. # Margin Overview Source: https://docs.vanna.finance/solana/guides/margin/overview One margin account: many collaterals, borrow up to 10×, and use the loan across Solana. The **Margin** page (also the page the app opens on) is where you manage your margin account: deposit collateral, borrow, repay and move collateral in or out. ![Margin page with a Multicollateral Loans banner, Net Health Factor with the chameleon mascot, Collateral Left Before Liquidation, Net Available Collateral, Net amount Borrowed, Net Leverage Taken, the Leverage your Assets / Repay Loan / Transfer Collateral tabs and Margin Account Info](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/margin/overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=e3be5dbd7dbb98d39d437aa65af285b0) Margin: account stats on top, the action panel on the left and Margin Account Info on the right. ## Account stats | Stat | Meaning | | - | - | | **Net Health Factor** | Collateral ÷ debt. Liquidatable at 1.10 or below. **No debt** when you owe nothing | | **Collateral Left Before Liquidation** | How much value your collateral can lose before the account hits 1.10 | | **Net Available Collateral** | Collateral minus debt: your equity | | **Net amount Borrowed** | Total debt in USD, including accrued interest | | **Net Leverage Taken** | Everything the account holds (borrowed funds included, open perps at full size) ÷ your equity. 1.00x = no borrowing | ## The three tabs | Tab | What it does | Guide | | - | - | - | | **Leverage your Assets** | Deposit collateral and borrow in one transaction, with a 1×–10× leverage slider | [Deposit](/solana/guides/margin/deposit-collateral) · [Borrow](/solana/guides/margin/borrow) | | **Repay Loan** | Repay from the tokens in your margin account; Flash repay closes everything | [Repay](/solana/guides/margin/repay) | | **Transfer Collateral** | Move tokens between your wallet (Portfolio account) and your margin account | [Transfer Collateral](/solana/guides/margin/transfer-collateral) | ## Margin Account Info The right column shows Total Borrowed value, Net Available Collateral, Total Value, Net Health Factor and Net Borrow Rate, then: * **Liquidation**: your health factor on a bar, the 1.10 liquidation line and the dollar buffer left before it. * **Oracles and LTs**: the oracle program, the 1.10× liquidation threshold, the Vanna program address, and every token's live price with its source (Kamino Scope or Pyth) and freshness. ![Leverage your Assets panel depositing 10 SOL and borrowing USDC at 2x, with the Liquidation card and Oracles and LTs list](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/margin/borrow-leverage.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4325f47a6ffca2c70d16d9bd94c8d7e5) Borrowing with the leverage slider, and the Liquidation and Oracles panels. ## Positions ![Account map with five collaterals (SOL, AAPLx, GOOGLx, USDC and more behind Show all) linked to an Account value node with interest accrued and borrow rate, two loans (SOL 90% of debt, USDC 10% of debt) with Repay buttons, Flash repay and share buttons, and Borrowed money is in chips for Spot, Farm and Idle](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/margin/positions.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=aa0d7e1657ea9d05c39c6e431e6e4159) Current Positions: collateral on the left, the account value in the middle, each loan on the right, and where the borrowed money is. **Current Positions** draws the whole account as one map: * **Collateral** on the left: every token the account holds, including Farm receipts such as kSOL, kUSDC, USD\* and vbSOL. **Show all** expands a long list. * **Account value** in the middle, with **Interest accrued** and the **Borrow rate**. * **Borrowed** on the right: each loan with its share of total debt and a **Repay** button. * **Borrowed money is in**: chips showing how much of the loan sits in **Spot**, **Perps** or **Farm** positions and how much is **Idle** in the account. Click a chip to jump to that page. * **Flash repay** unwinds the account; the share button makes a shareable card. **Positions History** lists past actions. > [!WARNING] > > An account with debt is healthy only while `collateral USD ÷ debt USD` stays **above 1.10**. At 1.10 or below anyone can liquidate it. The app keeps a 1.15 safety floor on withdrawals and new borrows so you have room before that line. ## Next steps > **[Open a margin account](/solana/guides/margin/open-account)** > > One signature, once per wallet. > **[Deposit collateral](/solana/guides/margin/deposit-collateral)** > > SOL, USDC, LSTs, JupUSD or xStocks. > **[Borrow](/solana/guides/margin/borrow)** > > Up to 10× with the leverage slider. > **[Health factor](/solana/guides/margin/health-factor)** > > The one number that keeps you safe. # Repay Source: https://docs.vanna.finance/solana/guides/margin/repay Repay a loan from your margin account or wallet, or unwind everything with Flash repay. ## Repay a loan Repays come from the **borrowed asset held in your margin account** (the tab shows **Repay From: Margin Account**). If the account doesn't hold enough of that token, move more in first with [Transfer Collateral](/solana/guides/margin/transfer-collateral), or let [Flash repay](#flash-repay) swap other holdings for you. **1. Open Repay Loan** On **Margin**, open the **Repay Loan** tab, or click **Repay** next to a loan in the positions map on Margin or Portfolio (it opens this tab with that asset selected). **2. Choose the asset** The tab shows your exact on-chain debt for that asset, interest included, next to what your margin account holds of it. **3. Enter the amount** Type an amount or use the % chips. **100%** repays as much as the margin account can: the whole loan when it holds enough, otherwise everything it holds of that token (a partial repay). **4. Pay** Check the before → after preview (Outstanding Debt, Margin Collateral, Health Factor) and click **Pay Now**. > [!NOTE] > > **A full repay needs a small buffer.** Interest keeps accruing while the transaction lands, so closing a loan entirely needs the debt plus a small (0.2%) buffer in the margin account. If the account is short, the button reads **Insufficient Balance** and the tab offers **Flash repay** instead. ## Flash repay **Flash repay** (on the Margin positions map, in the Repay tab and on Portfolio → Trader) unwinds the whole account for you, in steps: | Step | What it does | | - | - | | 1. Perps | Closes every Phoenix position (reduce-only market orders) and brings the USDC back to the margin account | | 2. Farm | Redeems every Kamino receipt back to its underlying token | | 3. Swap | For each loan the account can't cover in that same token, swaps other holdings into it (stables first, then the largest holding) through the best route | | 4. Repay | Repays every loan in full and closes its debt position | | 5. Transfer (optional) | **Flash transfer all to wallet** (on the Transfer tab) also withdraws everything left to your wallet | Each step is its own transaction and wallet approval, with progress shown as it goes. You don't have to watch it: close the window (×, Escape or a click outside) and it keeps running as a small card at the bottom right with the current step and a progress bar. **View** opens the full window again; once it finishes, the card shows Done or the error and can be closed. It is **not** one atomic transaction. Every step re-reads the chain first, so if a run stops half-way you simply run it again and it continues with whatever is left. It never repays more than you owe; if the account can't cover its debt, the swap step stops and shows the shortfall. ## After repaying When all debt is repaid the health factor reads **No debt**. Your collateral stays in the margin account; withdraw it with [Transfer Collateral](/solana/guides/margin/transfer-collateral) (Margin account → Portfolio account). ## Next steps > **[Transfer collateral](/solana/guides/margin/transfer-collateral)** > > Move tokens back to your wallet. > **[Health factor](/solana/guides/margin/health-factor)** > > How repaying improves your account. # Transfer Collateral Source: https://docs.vanna.finance/solana/guides/margin/transfer-collateral Move tokens between your wallet and your margin account. The **Transfer Collateral** tab moves a token between your wallet (**Portfolio account**) and your **Margin account**. The same form is on the **Transfer** tab of the header's [Deposit window](/solana/guides/faucet#the-rest-of-the-deposit-window). | Direction | What happens | | - | - | | **Portfolio account → Margin account** | Deposits into the margin account (creating it in the same transaction if needed) | | **Margin account → Portfolio account** | Withdraws to your wallet. Health-checked on-chain | **1. Open Transfer Collateral** On **Margin**, open the third tab (or **Deposit → Transfer** in the header). **2. Set the direction** The form shows **From** and **To**. Click the swap button between them to flip the direction. **3. Pick the token and amount** Choose the token and type an amount or use the % chips. **Available** (into margin) or **Max** (out of margin) shows the most you can move. **4. Confirm** Check the preview (collateral, health factor and liquidation buffer before → after), click **Transfer** and approve in your wallet. ## The safe limit With debt, you can withdraw only what keeps the account's health factor at **1.15 or above** (the app's safety floor). The program itself rejects anything that would leave the account at 1.10 or below. With no debt, **100%** withdraws everything, down to the last unit. ## Limits on the wallet side When you deposit SOL from the wallet, 0.05 SOL stays behind for transaction fees. Only collateral tokens can go into the margin account (USDT can come out but isn't offered as a deposit). ## Move everything out **Flash transfer all to wallet** at the bottom of the form repays every loan (closing positions as needed) and then withdraws everything left to your wallet, in guided steps. See [Flash repay](/solana/guides/margin/repay#flash-repay). ## Next steps > **[Deposit collateral](/solana/guides/margin/deposit-collateral)** > > Deposit and borrow in one transaction. > **[Repay](/solana/guides/margin/repay)** > > Clear debt before withdrawing everything. # Vanna MCP Source: https://docs.vanna.finance/solana/guides/mcp Use Vanna from Claude, Cursor or any MCP-compatible AI assistant. Log in with your wallet; every transaction is still signed by you. The **Vanna MCP** is a server that gives any AI assistant (Claude, Cursor, Windsurf, or anything that speaks the [Model Context Protocol](https://modelcontextprotocol.io)) the same abilities as the [Copilot](/solana/guides/copilot): read your account, answer with live figures, and prepare Earn, Margin, Trade, Farm and Predict transactions for your wallet to sign. It is also the engine behind the Copilot itself. Every transaction the Copilot shows you is built and simulated by this server. > [!NOTE] > > The server **never holds a key and never signs**. Your AI assistant gets a link, you open it, review the plan and sign in your own wallet. ## Connect The hosted server is live on the Vanna test network: ```text theme={null} https://vanna-mcp-solana-public-398807408840.us-central1.run.app/mcp ``` **1. Add the server to your assistant** **Claude Code:** ```bash theme={null} claude mcp add --transport http vanna-solana https://vanna-mcp-solana-public-398807408840.us-central1.run.app/mcp ``` **Claude (desktop or web):** add a custom connector with the URL above. **Cursor, Windsurf and others:** add a remote MCP server with the URL above in the app's MCP settings, for example: ```json theme={null} { "mcpServers": { "vanna-solana": { "url": "https://vanna-mcp-solana-public-398807408840.us-central1.run.app/mcp" } } } ``` **2. Log in with your wallet** The first time, your browser opens Vanna's **Connect your wallet** page. It shows which app is asking and where it will return, and what it will be able to do: **Read your balances, positions and market data**, and **Prepare transactions for you to review and sign**. Untick the second to give read-only access. Click **Connect wallet and approve**, and your wallet asks you to sign a login message. No transaction, no fee. There is no separate account: your wallet is the login. ![Connect your wallet page for Claude Code (vanna-solana-live) listing read and prepare-transactions permissions, with Connect wallet and approve and Decline buttons, and a Backpack window asking to approve the sign-in message](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/mcp/MCP_Authentication.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=0acf3e833b1ea74ed1f7d1e0966b35d1) The Connect page, with the wallet asking to sign the login message. **3. Ask** Your assistant now lists the Vanna server as connected, with its 20 tools. Talk to it as you would to the Copilot: "Show my Vanna portfolio", "Supply 100 USDC to Earn". ![Claude Code Manage MCP servers list showing vanna-solana-live connected with 20 tools](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/mcp/MCP_Connected.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=389e7b28ca5828a9cd5a373222186d75) Claude Code's MCP list with the Vanna server connected. After you log in, every call acts as your wallet. The server refuses any write for another wallet. ## Signing a Transaction When you ask for a change, the assistant gets a **link** to a signing page served by Vanna. Nothing has been sent at this point. ![Claude Code answering supply 10 USDC to earn: the supply is prepared and simulated, nothing sent yet, with a link to approve it within 5 minutes](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/mcp/MCP_Approve_transaction.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=05b3d6d7812513f5946d4076f9f49e88) Claude prepares an Earn supply and gives the signing link. 1. **Review.** The page shows the plan the server drew: each step, amounts, warnings, and your worst-case health factor. 2. **Approve.** Click **Approve plan with wallet** and sign the approval message, which names exactly that plan. A plan must be approved within 5 minutes. **Cancel plan** stops it without any signature. 3. **Sign each step.** For each step the server checks live data again, builds and simulates the transaction, and your wallet shows it to you to sign. A Predict trade with several transactions is signed in one approval. 4. **Confirmed.** The server checks that what you signed is exactly what it built, sends it and waits for the chain. Your assistant can then report the result. ![Review and sign page with an awaiting approval plan to supply 10 USDC to the Vanna Earn pool, Approve plan with wallet and Cancel plan buttons, and a Backpack window showing the approval message with wallet, plan, digest and health factor floor](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/mcp/MCP_Plan_Approved.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4f3aa662fed36062e28fc52725b8bc55) The signing page awaiting approval, with the wallet showing the plan approval message. A copied link only lets someone see the plan. It can't run it: running needs the approval made in your browser. > [!TIP] > > Use the same wallet in your browser extension as the one you logged in with. The signing page checks it. ## What You Can Ask | Area | Examples | | - | - | | **Account** | "What's my health factor?", "Show my portfolio", "What's my history?" | | **Risk** | "How much can I borrow safely?", "What if I withdraw 1 SOL?", "How far is liquidation?" | | **Earn** | "Supply 100 USDC to Earn", "What do the pools pay?" | | **Margin** | "Open a margin account and deposit 5 SOL", "Borrow 500 USDC", "Repay my USDT" | | **Leverage** | "Lever my SOL 2x", "Close everything" | | **Swap** | "Swap 5 SOL to USDC", "Swap SOL to get 100 USDC" | | **Farm** | "Put 50 USDC into Kamino", "Deposit 20 USDC into ETH Basis" | | **Perps** | "Open a 2x SOL long with 20 USDC", "Close my ETH short" | | **Predict** | "What prediction markets are there?", "Bet 5 CASH on Barcelona", "Get me test CASH" | | **Test funds** | "Fund my wallet": test tokens on the fork (a few times a day per wallet) | Some assistants also show ready-made commands from the server: **lever**, **unwind**, **health check**, **earn overview** and the full **Vanna assistant** rules. ## Tools The server exposes 20 tools. Your assistant chooses them; you don't call them yourself. | Tool | What it does | | - | - | | `vanna_portfolio` | Everything you hold, earn and owe, like the Portfolio page | | `vanna_account` | Margin account: health, positions; open or close the account | | `vanna_margin_status` | Collateral, debt and health details | | `vanna_margin_trade` | Deposit, withdraw, borrow, repay | | `vanna_risk` | Safe borrow / withdraw capacity, what-if, leverage limits, liquidation distance, the live policy | | `vanna_plan` | Multi-step plans: lever, unwind, exact-output swap, custom chains; plan status | | `vanna_earn_market`, `vanna_earn_position`, `vanna_earn_write` | Earn pools, your deposits, supply and withdraw | | `vanna_swap` | Quotes and swaps (Jupiter or Titan route) | | `vanna_farm_overview`, `vanna_farm_kamino` | Kamino markets, your receipts, deposit and redeem | | `vanna_vaults` | Basis and Perena vaults: yields, your shares, deposit and withdraw | | `vanna_perps` | Phoenix perps: markets, positions, preview, open and close | | `vanna_predict` | Predict: events, positions, quotes, buy, sell, test CASH | | `vanna_oracle` | The prices the protocol uses | | `vanna_protocol_info` | Protocol settings, assets and programs | | `vanna_history` | Your past transactions | | `vanna_wallet` | Wallet balances and test tokens | | `vanna_sign` | Status of a transaction you signed | ## Safety These are enforced by the server, so no wording can talk the AI past them: * **Health floor.** Anything that can lower your health (borrow, withdraw, margin swap) must keep it at **1.15 or above**. Liquidation is at 1.10. Adding collateral and repaying are never blocked. * **Limits per wallet.** $5,000 per action and $25,000 per day, 6 transaction builds a minute, 8 steps per plan. * **Exact amounts.** Zero, negative or unclear amounts, or more decimals than the token has, are refused, never rounded. * **What you approved is what runs.** The plan is frozen with exact amounts; your approval signs it; the transaction you sign must match the server's own build byte for byte. * **Exactly once.** Each step is sent one time. An unclear result is never retried automatically. * **Your wallet only.** No transfers to other addresses, no arbitrary programs, no admin actions, no liquidating others. The assistant is also told the Copilot's rules: stay on Vanna, never invent a number, refuse orders for later (stop-loss, limit, DCA), never say a Predict outcome will win, and never say something happened before the chain confirms it. > [!NOTE] > > An AI assistant can misread a request. Always check the signing page (asset, amount, direction and health factor after) before you approve. ## Read-Only Access Untick **Prepare transactions for you to review and sign** on the Connect page if you only want your assistant to see your account. It can answer questions about positions, prices and risk, but can't prepare any transaction. ## Next steps > **[Copilot](/solana/guides/copilot)** > > The same engine, built into the app. > **[Getting Started](/solana/guides/getting-started)** > > Sign in and mint test funds first. # Open a Long Source: https://docs.vanna.finance/solana/guides/perps/long Bet on a price going up with a Phoenix perp from your margin account. A **long** profits when the price rises and loses when it falls. **1. Pick the market** On **Trade → Perps**, choose the market from the selector at the top left (SOL, ETH, BTC, TSLA or META). Check **Market status** is Open. **2. Select Long** In the order panel, keep **Long** selected and **Market**. **3. Set collateral** Enter the USDC **Collateral** for this order, use **MAX** or the 0–100% slider. **Available** is the USDC in your margin account. **4. Set leverage** Choose **Order leverage** (1× up to the market's maximum). **Position size** shows the size in the asset or in USD. **5. Check the order** **Order on Phoenix** shows the estimated entry price, the **max entry price** your slippage allows, and the account's health factor after the order. **6. Place it** Click **Long** and approve. The USDC moves to Phoenix and the order fills in the same transaction. ## Managing the position Your position appears in the positions table below the chart with market, side, size, collateral, leverage, entry and mark price, liquidation price and PnL. Click **Close** to close all or a percentage of it (a reduce-only market order); **Close All** closes every position. A **History** tab lists past orders. When nothing is left open in that account, the USDC returns to your margin account in a follow-up transaction. ## What moves your P\&L * The perp's price relative to your entry price * Hourly funding: when it's positive, longs pay shorts * Fees and slippage on open and close All of it shows up in your margin account's health factor. ## Next steps > **[Open a short](/solana/guides/perps/short)** > > The other side of the trade. > **[Delta-neutral vaults](/solana/guides/farm/delta-neutral)** > > Earn funding without price exposure. # Perps Overview Source: https://docs.vanna.finance/solana/guides/perps/overview Long or short SOL, ETH, BTC, TSLA and META on Phoenix, straight from your margin account. **Trade → Perps** opens perpetual futures on **Phoenix** from your margin account. Your margin account is its own Phoenix trader: Vanna's program signs every order for it and checks the account's health after each one. ![ETHUSDC perps page on Phoenix with index price, 24h volume, open interest, funding, market status, margin account strip, price chart, order book and a Long order panel at 3x](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/perps/phoenix-perps.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=08ce598308ca9d67af20b0913ac53b4a) Perps: your margin and Phoenix strip, market header, chart, order book and the order panel. ## Markets | Market | Underlying | | - | - | | SOL-PERP | Solana | | ETH-PERP | Ether | | BTC-PERP | Bitcoin | | TSLA-PERP | Tesla stock | | META-PERP | Meta stock | Each market has its own maximum leverage set by Phoenix (shown as **Max 5×** under the market name). Stock markets follow their market hours; **Market status** shows whether the market is open and its price feed is fresh. ## The page | Area | What it shows | | - | - | | **Market header** | Mark price and 24h change, index price, 24h volume, open interest, **Funding / 1h** with the countdown to the next funding, market status and the **Venue** (Phoenix) | | **Margin account strip** | Health factor, account leverage, room before liquidation and USDC available, then your Phoenix perps value and open P\&L | | **Chart** | Price chart with 1m to 1D timeframes | | **Order book / Trades** | Phoenix's live book and recent trades | | **Order panel** | Long / Short, collateral, size, leverage, slippage and the order preview | | **Positions / History** | Open positions (size, collateral, leverage, entry, mark, liq. price, PnL) with **Close** and **Close All**, and past orders | ## How collateral works Perps collateral is **USDC from your margin account**. When you open a position, that USDC is moved into your margin account's Phoenix trader account and the market order is placed, all in one transaction. When you close and no position is left, the USDC comes back to the margin account. Need more USDC? **+ Borrow** next to the collateral field takes you to borrowing. Your Phoenix collateral and open P\&L count toward your margin account's health factor. ## Orders **Market** orders only for now (**Limit** is marked **Soon**). A market order fills immediately against Phoenix's order book inside the transaction, or not at all: there's no pending order and no keeper. **Slippage** (1% by default) sets the worst price you accept. ## Funding Perps pay or charge funding every hour. When funding is positive, longs pay shorts; when negative, shorts pay longs. The rate is shown in the header. > [!WARNING] > > Leverage can get your account liquidated. Prices, borrow interest, swap slippage, perp funding and vault share prices all move your health factor, which must stay **above 1.10**. Only use what you can afford to lose. ## Next steps > **[Open a long](/solana/guides/perps/long)** > > Profit when the price rises. > **[Open a short](/solana/guides/perps/short)** > > Profit when the price falls. # Open a Short Source: https://docs.vanna.finance/solana/guides/perps/short Bet on a price going down with a Phoenix perp from your margin account. A **short** profits when the price falls and loses when it rises. Losses on a short have no fixed ceiling, because a price can keep rising: watch your health factor. **1. Pick the market** On **Trade → Perps**, choose SOL, ETH, BTC, TSLA or META and check the market is Open. **2. Select Short** In the order panel click **Short**, with **Market** selected. **3. Set collateral and leverage** Enter the USDC **Collateral** (or use MAX / the slider) and choose **Order leverage**. **Position size** updates. **4. Check the order** **Order on Phoenix** shows the estimated entry price and the **min entry price** your slippage allows, plus the account's health factor after the order. **5. Place it** Click **Short** and approve. Collateral moves to Phoenix and the order fills in the same transaction. ## Funding on shorts When funding is **positive** (most of the time in a rising market) shorts are paid every hour. When it turns **negative**, shorts pay. This is the same funding Vanna's [delta-neutral vaults](/solana/guides/farm/delta-neutral) earn by holding spot and an equal short. ## Closing Click **Close** on the position (all or a percentage, as a reduce-only market order) or **Close All**. When nothing is left open, the USDC goes back to your margin account. [Flash repay](/solana/guides/margin/repay#flash-repay) also closes every perp position as its first step. ## Next steps > **[Open a long](/solana/guides/perps/long)** > > The other side of the trade. > **[Liquidation](/solana/guides/margin/liquidation)** > > What happens if your health factor hits 1.10. # Portfolio Source: https://docs.vanna.finance/solana/guides/portfolio Everything you hold, earn and owe across Vanna, in one page. **Portfolio** combines your wallet, your Earn supply, your Predict positions and your margin account. **Deposit** and **Transfer** at the top right open the [Deposit window](/solana/guides/faucet) for test funds and wallet ↔ margin transfers. ![Portfolio page with Net worth split into Wallet, Lending and Margin equity, Net earnings with Lending and Trading chips, a Health factor card with borrowed, leverage and interest accrued, and the Lender tab showing Lender Stats and a Lending P\&L chart](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/portfolio/overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=0db0e79c5575d7268b77c68afbebc693) Portfolio: Net worth, Net earnings and Health factor, then the Lender, Trader and Balances tabs. ## Top cards | Card | What it shows | | - | - | | **Net worth** | Wallet + Lending + Margin equity (collateral minus debt), with a bar showing the split | | **Net earnings** | Lending interest earned plus trading P\&L, each shown as its own chip | | **Health factor** | Your margin account's health factor with its zone (for example **Safe**) and the chameleon mascot, what you've borrowed, your leverage and the interest accrued so far. Shows **No debt** when you owe nothing. The share button makes a shareable card | ## The tabs **Lender** Two sub-tabs: * **Lending pools**: Lender Stats (total holdings, supplied assets, average supply APY, interest earned), a 30-day Lending P\&L chart and a positions table of every pool you supply, with **Supply more** and **Withdraw** on each row. **Position History** lists past supplies and withdrawals. * **Predict**: your prediction-market positions and what they earn while you wait. ![Positions table listing SOL, USDC and USDT supplied, with Amount Supplied, Supply APY, Earned and Value columns and Supply more and Withdraw buttons](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/portfolio/lender-positions.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=551c37d899de5eb0014d518d16b0ea66) Lender → Lending pools: your supplied positions with Supply more and Withdraw. **Trader** Four sub-tabs: **Margin**, **Spot**, **Perps** and **Farm**. **Margin** shows Total Margin Balance, Total Collateral Deposited, Total Loan Taken, Cross Account Leverage, Health Factor, Cross Margin Ratio (debt ÷ holdings), Collateral Left Before Liquidation and Net Borrowed Interest Accrued, a health-factor bar with the 1.10 liquidation mark, and the same account map as the [Margin page](/solana/guides/margin/overview#positions). **Spot**, **Perps** and **Farm** list your positions on each venue. **Flash repay** beside the sub-tabs closes positions and repays every loan (it shows how many positions it closes and how much it repays). See [Flash repay](/solana/guides/margin/repay#flash-repay). ![Trader tab with Margin, Spot, Perps and Farm sub-tabs, Flash repay button, margin totals including Cross Margin Ratio and Net Borrowed Interest Accrued, and a health factor bar at 12.63 with liquidation at 1.10](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/portfolio/trader-margin.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=2f6024823673b3d802b9eeb704580a90) Trader → Margin: account totals, health-factor bar and Flash repay. **Balances** Every token you hold, split between your **wallet** and your **margin account**, with amounts and USD values. Margin holdings include Farm receipts (kSOL, USD\*, vbSOL…) and, when it holds anything, your Phoenix perps account as one line. ## Where the numbers come from All figures are read live from the fork: on-chain accounts priced with the same oracle prices the program uses (Kamino Scope first, Pyth as fallback). Nothing is cached in your browser, so clearing site data never changes what you see. ## Next steps > **[Earn](/solana/guides/earn/overview)** > > Supply to Vanna's lending pools. > **[Margin](/solana/guides/margin/overview)** > > Manage collateral, loans and leverage. # Earn While You Wait Source: https://docs.vanna.finance/solana/guides/predict/earn-while-you-wait How matched Yes and No shares earn interest in Vanna's USDC pool until the event resolves. Prediction shares usually sit idle for days or weeks until the event resolves. On Vanna they earn. ## Pairing For any one market, **1 Yes share + 1 No share** always pays exactly \*\*$1** at resolution, whatever happens. So a Yes/No pair is as good as $1 of USDC. Vanna uses that: **1. Your shares go into Vanna's pool** When you buy on Predict, your shares are deposited into Vanna's outcome pool for that market in the same approval. **2. Yes and No are paired** The pool matches Yes shares against No shares held in it (from you and from other users). **3. Pairs are merged into USDC and lent** Each pair is merged back into \$1 of USDC and that USDC is supplied to Vanna's USDC lending pool, where it earns the pool's supply rate. **4. Yield comes back as extra shares** The interest is paid to you as extra shares of the side you hold. Because it's extra Yes (or No) shares, the yield pays out only if your side wins. Shares that can't be paired yet (more Yes than No in the pool, or the reverse) are **waiting**: they're held safely but don't earn until the other side arrives. ## Reading the numbers | Where | Field | Meaning | | - | - | - | | Event card | **Earn up to X%** | The best rate any side of this event can earn right now | | Trade panel | **Paired** | How much of the shares you're buying will be paired | | Trade panel | **Your paired Yes** | Your paired shares before → after this trade | | Trade panel | **Est. yield** | Estimated earnings per month at the current rate | | Earning tab | **Pairs / Yes earns / No earns** | Pool balance per market and what each side earns | | Summary strip | **Earning in USDC pool / Passive yield / Earned** | Your totals across all markets | The side that's scarcer in the pool earns more, because each of its shares backs more of the pool's pairs. ## Where to see it The same numbers show up in two places: * **Earn → USDC → Analytics** lists how much USDC each Predict market has supplied to the pool. * **Analytics → Prediction Vaults** shows every Predict pool: shares held, pairs waiting and USDC supplied. See [Analytics](/solana/guides/analytics#prediction-vaults). ![From Predict markets card listing Democrats, LA Rams, Galatasaray and Republicans with the USDC each supplied and its share of the pool](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/earn-usdc-from-predict.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4b642efdc74d0c93e4b4c8982e2e1ce8) Earn → USDC → Analytics: USDC supplied by each Predict market. ## Risks * The yield is paid in shares of your side, so if your side loses, the yield is worth \$0 along with it. * The pool's USDC is lent through Vanna's USDC pool and carries that pool's risks (see [For Liquidity Providers](/solana/guides/for-liquidity-providers)). * Rates move with the USDC pool's supply APY and with how balanced Yes and No are. ## Next steps > **[Trade on Predict](/solana/guides/predict/trade)** > > Buy Yes or No on an event. > **[Prediction Vaults analytics](/solana/guides/analytics#prediction-vaults)** > > Every Predict pool at a glance. # Predict Overview Source: https://docs.vanna.finance/solana/guides/predict/overview Trade Yes / No on real World.xyz events, and earn in Vanna's USDC pool while you wait. **Predict** brings World.xyz prediction markets into Vanna. Every market is a question with a **Yes** and a **No** share. A winning share pays **\$1** when the event resolves; a losing share pays nothing. The price of a share (in cents) is roughly the market's probability for that outcome. What Vanna adds: your shares don't just sit. Matched Yes and No shares are lent into Vanna's USDC pool, so your position **earns while you wait** for the result. ![Predict page with a Trade the world's outcomes banner, Predictions value, Earning in USDC pool, Passive yield APY, Earned and Pays if right cards, a Linked wallets row with Add wallet coming soon, Trending, Crypto, Sports, Politics, Economics and All filters, search, My positions, and Trending event cards](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/predict/markets.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=8bd0e171ca29b9629f9088eb5d1c6ff3) Predict: summary strip, linked wallets, category filters and Trending events. ## The page | Section | What it shows | | - | - | | **Summary strip** | Predictions value, how much is Earning in the USDC pool, your Passive yield APY, what you've Earned, and what your positions **Pay if right** | | **Linked wallets** | The wallets whose World positions Vanna tracks (your connected wallet; **Add wallet** is coming soon), and whether any World positions are waiting to earn | | **Filters** | Trending, Crypto, Sports, Politics, Economics, All, plus search and **My positions** | | **Event cards** | Each event's outcomes with live probabilities, the last trade, volume and the **Earn up to** rate for that event | Trending follows World.xyz's own trending list. ## Prices Prices come live from World's maker quotes, with recent trades as a fallback. Each outcome shows a Yes price and a No price; together they add up to a little over \$1 (the maker's spread). An outcome with no quote and no recent trade isn't tradable until one appears. ## What you pay with Predict trades settle in **CASH**, World's USD token. Mint test CASH from **Deposit → Test funds** ([Faucet](/solana/guides/faucet)). ## Next steps > **[Trade on Predict](/solana/guides/predict/trade)** > > Buying, selling and the bet slip. > **[Earn while you wait](/solana/guides/predict/earn-while-you-wait)** > > How pairing and pool yield work. # Trade on Predict Source: https://docs.vanna.finance/solana/guides/predict/trade Buy and sell Yes / No shares on a World.xyz event. ![Who will win the 2026 NFL championship event page with leader, volume, open interest and Earn while you wait up to 1.8%, an Outcomes list with Buy Yes and Buy No prices per team, and a Buy panel with One outcome and Bet slip tabs paying 10 CASH for SF 49ers Yes at 16.6 cents](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/predict/event.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=d23fb80f8efd4032fc9a51465f1a1f9b) An event page: each outcome is its own Yes / No market, with the trade panel on the right. ## Buy **1. Open an event** Click an event card on [Predict](/solana/guides/predict/overview). The page shows each outcome's probability, your holdings ("You hold 315.71 Yes…") and a **Buy Yes / Buy No** button per outcome. **2. Pick the outcome and side** Click **Buy Yes** or **Buy No** on an outcome, or choose the **Market** and **YES / NO** in the trade panel. **3. Enter the amount** Enter how much CASH to spend, or use the % chips. Your CASH balance is shown under the field. **4. Check More details** **Avg price** (cents per share), **Shares** you'll get, **Pays if right** (shares × \$1) and **Profit if right**. The **Earns while you wait** box shows how much of this position will be paired and its estimated yield. **5. Buy and sign** Click **Buy Yes** / **Buy No** and approve. Your shares go straight into Vanna's pool in the same approval. ## Bet slip On events with more than one tradable outcome, switch the panel from **One outcome** to **Bet slip** to buy several outcomes at once. Add legs with **Add an outcome**; the slip shows each leg, the total cost and what you get if each pick is right. The bet slip is for buying only. ## Sell Switch the panel to **Sell**, pick the outcome and side you hold, and enter how many shares to sell. You can also use **Sell** on a position row under the event. Shares in your wallet are sold first; if you hold fewer than you're selling, the rest are redeemed from your pool shares in the same transaction. Shares sell at the current bid. ## Your positions on the event ![Earning tab with Earning, Prices, Rules and Activity tabs, a market table with pool balance, pairs, Yes earns and No earns, and an Earns while you wait box showing paired share, your paired Yes and estimated monthly yield above a Buy Yes button](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/predict/earning-tab.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=ac2f588d0ca37fcf3123aa7a90e7d925) The Earning tab (pairs and what each side earns per market) and the Earns while you wait box in the trade panel. Each position shows **Avg / now** price, what's **Earning in pool**, and what it **Pays if right**, with **Buy more** and **Sell**. Below, the tabs are: | Tab | Shows | | - | - | | **Earning** | Pairs earning in Vanna's USDC pool, how much of each side is paired or waiting, and what Yes and No earn | | **Prices** | Price history once it's recorded | | **Rules** | How the market resolves and its data source | | **Activity** | Recent trades | ## When the event resolves Winning shares pay $1 each, losing shares $0. Anything earned in the pool while you waited is already part of your position (see [Earn While You Wait](/solana/guides/predict/earn-while-you-wait)). ## Next steps > **[Earn while you wait](/solana/guides/predict/earn-while-you-wait)** > > How your shares earn until resolution. > **[Predict (concept)](/solana/learn/predict)** > > How Vanna's Predict pools work. # Spot Swap Source: https://docs.vanna.finance/solana/guides/trade/spot-swap Swap tokens inside your margin account through Jupiter or Titan. **Trade → Spot** swaps tokens **inside your margin account**. It's how you turn borrowed USDC into SOL (a leveraged long), SOL into USDC (de-risking), or move between any supported tokens without the funds ever leaving the account. ![Spot swap card via Jupiter paying 100 SOL to receive 33.83 GOOGLx, health factor 12.63 to 13.61, a one-hop Meteora DLMM route, and a Margin account panel with health factor, account leverage, borrowed and swappable SOL before and after](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/trade/spot-swap.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=fcb53460af6dc312f8b328dca3050f65) Spot: the swap card (via Jupiter) with its route, and the Margin account block beside it. **1. Pick the aggregator** The card header reads **Swap via Jupiter**. Open the dropdown to switch to **Titan**. Jupiter is the default. **2. Choose what you pay** Under **You Pay**, pick the token and amount, or use **25% / 50% / 75% / Max**. **Swappable** is what your margin account holds of that token. **3. Choose what you receive** Under **You Receive**, pick the token. The quote fills in the amount you get. **4. Check the details** The rate line shows the price and your health factor before → after. Expand it for **Price Impact**, **Slippage Tolerance** and **Min. Received**. Slippage is **Auto (0.5%)** by default; change it with the gear icon. **5. Check the route** The **Route** card shows the hops and pools (for example *1 hop · Meteora DLMM*) and a badge for the aggregator that built it. **6. Swap** Click **Swap** and approve. The swap runs on-chain from your margin account and is health-checked in the same transaction. ## Jupiter or Titan You choose the aggregator; only that one is quoted, and the swap runs through it. | Aggregator | What it does | | - | - | | **Jupiter** (default) | Jupiter's best route across Solana AMMs | | **Titan** | Titan's meta-aggregated route. If Titan isn't available on the server or finds no route, the card says so; switch back to Jupiter | Either way the swap executes from your margin account through Vanna's program, which only allows the routes and settings its validator approves and checks the account's health afterwards. ## The Margin account block Beside the swap card: your health factor before → after with its bar, **Account leverage** before → after, **Borrowed**, and the **Swappable** balance of the token you're paying before → after. **Position History** below lists your past swaps. ## Things to know * Swapping doesn't change your debt. It changes what your collateral is made of, so your health factor barely moves unless prices move afterwards. * A swap that would leave the account below the safety floor is blocked before you sign. * Without a wallet connected, only the swap card is shown. ## Next steps > **[Trade perps](/solana/guides/perps/overview)** > > Long or short with leverage on Phoenix. > **[Farm](/solana/guides/farm/overview)** > > Put swapped tokens to work in a vault. # Why Vanna Source: https://docs.vanna.finance/solana/guides/why-vanna One margin account, many collaterals, and a loan you can use anywhere on Solana. On most of Solana a loan stays inside the protocol that issued it: borrow on a money market and you can only hold the borrowed tokens there. Vanna is a **credit layer**: the loan lives in your own margin account, and that account can act across Solana while the protocol keeps checking that it stays solvent. ## What Vanna adds ### 1. One account, many collaterals Deposit SOL, USDC, liquid-staked SOL (JitoSOL, JupSOL), JupUSD and tokenized stocks (NVDAx, GOOGLx, AAPLx, TSLAx) into a single margin account. Every asset counts toward one health factor, so you don't manage a separate loan per collateral. ### 2. Borrow up to 10× and keep using the loan Borrow SOL, USDC or USDT from Vanna's pools (one asset, or two at once with **Dual Borrow**) and the borrowed tokens stay in your margin account. From there you can: * **Swap** on Jupiter or Titan ([Spot](/solana/guides/trade/spot-swap)) * **Long or short** SOL, ETH, BTC, TSLA, META on Phoenix ([Perps](/solana/guides/perps/overview)) * **Earn** on Kamino, Perena or delta-neutral basis vaults ([Farm](/solana/guides/farm/overview)) Receipts and positions you open stay in the margin account and keep counting as collateral. ### 3. Lenders earn real borrow interest Lenders supply SOL, USDC or USDT on [Earn](/solana/guides/earn/overview) and receive vTokens that grow as borrowers pay interest. ### 4. Prediction shares that earn while you wait On [Predict](/solana/guides/predict/overview) you buy Yes / No on World.xyz events. Matching Yes and No shares are paired and lent into Vanna's USDC pool, so your position earns interest until the event resolves. ## Safety built into every action Every action that could reduce your account's health (withdraw, borrow, swap, open a perp, move into a vault) runs a health check **on-chain** in the same transaction. If the account would end at or below a health factor of 1.10 the transaction fails, so it can't leave you liquidatable. See [Health Factor](/solana/guides/margin/health-factor). ## What this is not * **Not real money.** Vanna's current app runs on a Solana mainnet fork for testing. Test funds and balances exist only on the fork. * **Not risk-free.** Leverage, perp funding and vault share prices can move against you. Read [Liquidation](/solana/guides/margin/liquidation) before borrowing. ## Next steps > **[How Vanna works](/solana/guides/how-vanna-works)** > > Follow the money from lender to trader. > **[Getting Started](/solana/guides/getting-started)** > > Sign in and mint test funds. # Vanna on Solana Source: https://docs.vanna.finance/solana/home ![Vanna](https://mintcdn.com/vannafinance/UHj8oBBMt2jwIvZH/logo/vanna-dark.png?fit=max\&auto=format\&n=UHj8oBBMt2jwIvZH\&q=85\&s=8d4a259c94861810159a811d7d5a66bd) One account. Credit everywhere.Earn. Borrow. Trade. Farm. Predict. START Get started in three stepsSign in with email or Backpack, add the fork RPC to Backpack, and mint free test funds from **Deposit**. Then lend, borrow up to 10×, swap on Jupiter or Titan, trade Phoenix perps, farm on Kamino, Perena and delta-neutral vaults, or trade World.xyz predictions that earn while you wait. ❯ [Open](/solana/guides/getting-started) [LendersSupply SOL, USDC or USDT and earn the interest margin accounts pay. Or hold Predict shares that earn in Vanna's USDC pool until the event resolves.❯](/solana/guides/for-liquidity-providers) [TradersDeposit SOL, LSTs, stables or xStocks, borrow up to 10×, then swap on Jupiter or Titan, long or short on Phoenix, or farm, all from one health factor.❯](/solana/guides/for-traders) [DevelopersAnchor programs (core, oracle, validator), PDAs, venue integrations through a validator, the math reference and a one-command local fork.❯](/solana/developers/overview) > [!NOTE] > > **App:** [test.vanna.finance](https://test.vanna.finance) (pick **Solana** in the chain switcher). It asks for an **access code** on your first visit. **Fork RPC (add it to Backpack):** `https://rpc-devnet.solana.vanna.finance` · [Wallet setup](/solana/guides/connect-wallet#add-the-vanna-rpc-to-your-wallet) ## Jump in > **[Getting Started](/solana/guides/getting-started)** > > Access code, sign in, test funds and a tour of the app. > **[Connect your wallet](/solana/guides/connect-wallet)** > > Email or social login, or Backpack with the fork RPC. > **[Get test funds](/solana/guides/faucet)** > > Mint SOL, USDC, LSTs, xStocks and CASH in one click. > **[Earn](/solana/guides/earn/overview)** > > Supply SOL, USDC or USDT and earn borrow interest. > **[Margin](/solana/guides/margin/overview)** > > One account, many collaterals, borrow up to 10×. > **[Spot swap](/solana/guides/trade/spot-swap)** > > Swap inside your margin account on Jupiter or Titan. > **[Perps](/solana/guides/perps/overview)** > > Long or short SOL, ETH, BTC, TSLA and META on Phoenix. > **[Farm](/solana/guides/farm/overview)** > > Kamino lending, Perena USD\* and delta-neutral basis vaults. > **[Predict](/solana/guides/predict/overview)** > > Trade World.xyz events; shares earn while you wait. > **[Copilot](/solana/guides/copilot)** > > Ask about your account or describe a change in plain English. > **[Analytics](/solana/guides/analytics)** > > Live protocol risk, pools, collateral and prices. > **[FAQ](/solana/resources/faq)** > > Access code, fork RPC, faucet, perps, Predict and more. # Composable Leverage Source: https://docs.vanna.finance/solana/learn/composable-leverage Borrowed tokens stay in the margin account and move into whitelisted protocols through margin_execute. Vanna leverage is **borrowed tokens** that the margin account can spend in approved protocols. Every such call goes through one instruction, `margin_execute`. The validator checks the call, Vanna signs as the margin account, and the whole account is health-checked afterwards. ## What borrowed funds can do | Use | Protocol | What the margin holds afterwards | | - | - | - | | Swap | Jupiter or Titan (you pick the aggregator) | The output token | | Lend | Kamino main market | Kamino cTokens | | Trade perps | Phoenix (via Ember USDC ⇄ phUSD) | A Phoenix trader account with positions | | Stable yield | Perena USD\* or USD\* Junior | Perena shares | | Delta-neutral yield | Vanna basis vaults (SOL, ETH, BTC, TSLA, META) | Basis-vault shares | All of these count toward **one health factor**. A profitable farm and a losing perp offset each other. ## Atomic vs multi-step | Action | Atomic? | | - | - | | One `margin_execute` call | Yes | | Perps open (Ember deposit + Phoenix deposit + market order) | Yes — one transaction | | Perps close (reduce-only order), then withdraw | Two transactions | | Flash repay (close perps, redeem farms, swap, repay, withdraw) | No — a sequence of transactions; each step resumes cleanly | "One-click" is a UX promise. On-chain atomicity is per transaction. # Health Factor Source: https://docs.vanna.finance/solana/learn/health-factor Unweighted collateral-to-debt ratio, liquidatable at 1.10, with conservative rounding. ```text theme={null} HF = Σ collateral_usd / Σ debt_usd healthy ⇔ no debt, or HF > 1.10 liquidatable ⇔ HF ≤ 1.10 ``` The ratio is **unweighted**: every allowed token counts at its full USD value (up to its per-margin cap). The same 1.10 threshold gates new borrows, withdrawals with debt, and every `margin_execute` call. ## What counts * Every allowed token in the margin's vaults, including borrowed tokens and receipts (Kamino cTokens, Perena shares, basis-vault shares). * The Phoenix trader account, as one line: collateral plus position equity, floored at zero. * Every debt, at its accrued value. Borrowed tokens land in the margin vault, so a borrow raises both sides of the ratio. ## Rounding | Side | Rounding | | - | - | | Collateral | Down | | Debt | Up | The protocol would rather reject a tight borrow than mark an account safer than it is. ## Prices that fail a check For the owner's own actions, a collateral token whose price is stale or off its TWAP counts as **zero**, so a stale-priced token can't be used to borrow more. A debt must have a good price, or the action is blocked. For liquidation, collateral counts at its reported value and only the debts need fresh prices. ## In the app The app uses the same formula (`lib/account-model.ts`) and the same price sources as the oracle. Its own limits target HF ≥ 1.15, so price drift between quote and execution doesn't trip the on-chain check. # Interest Rate Model Source: https://docs.vanna.finance/solana/learn/interest-rate-model A polynomial utilization curve. Borrow interest funds lender yield. Each pool's borrow rate depends on its utilization `u = borrows / (cash + borrows)`. The curve has three coefficients set by the admin: ```text theme={null} annual_rate = rate_multiplier × (linear·u + linear·u^32 + jump·u^64) ``` * At low utilization the linear term dominates, so borrowing is cheap. * As utilization approaches 100%, the `u^32` and `u^64` terms take over and the rate climbs steeply. That pulls in new lenders and pushes borrowers to repay before the pool runs dry. * An empty pool (`u = 0`) charges nothing. The rate is applied per second (`SECONDS_PER_YEAR = 31,556,952`). ## Where interest goes Interest accrues on every pool touch (and on `public_refresh_reserve`). A reserve-factor slice goes to `accrued_protocol_fees`. The rest increases `total_borrow_assets`, which raises the value of every vToken. ```text theme={null} lender APY ≈ borrow APR × utilization × (1 − reserve_factor) ``` Rounding remainders carry over between accruals, so frequent updates neither overcharge borrowers nor shortchange the treasury. Exact coefficients live on each `Reserve` account. Read them on-chain rather than assuming defaults. # Kamino Integration Source: https://docs.vanna.finance/solana/learn/kamino-integration Supply margin funds to Kamino's main market. The cTokens stay in the margin account as collateral. A margin account can supply tokens, its own or borrowed, to a Kamino Lend reserve in Kamino's **main market**. The call goes through `margin_execute`. The Kamino receipt (cToken) lands back in the margin account and counts toward the health factor. ```text theme={null} Program KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD Market 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF ``` ## What the validator allows Only Kamino's `deposit_reserve_liquidity` (supply) and `redeem_reserve_collateral` (redeem), in owner mode, with the margin as owner and the margin's own vaults on both sides. The spend is capped at the call's amount. ## How cTokens are valued Each cToken is registered as a collateral-only asset. Its price source names its Kamino reserve. The oracle reads the reserve's exchange rate and multiplies by the underlying token's own price. As Kamino interest accrues, the exchange rate rises, and so does the cToken's value in the health factor. ## The leveraged farm 1. Deposit collateral into the margin account. 2. Borrow USDC, USDT or SOL from Vanna. 3. Supply the borrowed tokens to Kamino. The account earns Kamino's supply rate on the whole position and pays Vanna's borrow rate on the borrowed part. The spread, times the leverage, is the carry. If Vanna's borrow rate rises above Kamino's supply rate, the carry turns negative. ## Unwind Redeem the cTokens through `margin_execute`, then repay from margin. A liquidator can seize cTokens directly and redeem them from Kamino. > [!NOTE] > > Kamino Liquidity (multi-asset LP strategies) isn't supported. That program rejects CPI, so a margin account can never hold its shares. # Lending Pools Source: https://docs.vanna.finance/solana/learn/lending-pools Per-mint reserves for USDC, USDT and SOL: cash ledger, borrow totals, rate curve, caps. Each pool has one `Reserve` at `["reserve", mint]` and one share mint (vTokens) at `["share_mint", mint]`. Pools exist for **USDC, USDT and SOL**. Every other asset is collateral only. ## Balances that matter | Field | Meaning | | - | - | | `accounted_liquidity_assets` | Cash credited by measured transfers | | `total_borrow_assets` | Outstanding principal plus accrued interest | | `total_borrow_shares` | Sum of borrower shares | | `total_supply_shares` | Sum of lender shares, counted by the reserve itself | | `accrued_protocol_fees` | Reserve-factor slice, not lender equity | | `borrow_index_wad` | Cumulative borrow growth | ```text theme={null} lender_total_assets = accounted_liquidity + total_borrow − protocol_fees available_cash = accounted_liquidity − protocol_fees utilization = borrows / (cash + borrows) ``` Unsolicited transfers into the liquidity vault do **not** increase `accounted_liquidity_assets`, so they can't inflate the vToken rate. Because the reserve counts its own shares, vTokens burned outside Vanna don't change anyone's claim either. ## Caps `supply_cap` limits total lender assets. `borrow_cap` limits total borrows. ## Status and modes Each reserve has a status: | Status | Supply | Redeem | Borrow | Repay | | - | - | - | - | - | | Active | Yes | Yes | Yes | Yes | | SupplyOnly | Yes | Yes | No | Yes | | RepayOnly | No | Yes | No | Yes | | Frozen | No | No | No | Yes | The protocol also has an operating mode (`Normal`, `BorrowPaused`, `WithdrawOnly`, `Halted`). An action must pass both. Repay is always available. See [Interest Rate Model](/solana/learn/interest-rate-model). # Liquidation Source: https://docs.vanna.finance/solana/learn/liquidation Permissionless, partial, bonus-paid close of accounts at HF ≤ 1.10, plus admin write-off of dust bad debt. Anyone can liquidate a margin account once its health factor is at or below 1.10. One liquidation repays part of **one debt** and takes **one token**. ## How much * **Repay**: up to 50% of the chosen debt. The full debt can be repaid when HF ≤ 1 + the token's bonus, or when the debt is worth \$100 or less. * **Seize**: tokens worth at most the repaid value × (1 + the token's liquidation bonus). The bonus is at most 5%. * **Solvency guard**: while the margin is still solvent, the multiplier is capped at the health factor. A liquidation never takes more than the margin's equity, so it never turns a solvent account into bad debt. The liquidator sets `min_seized` as a slippage bound. ## Phoenix positions A Phoenix position can't change hands. The liquidator closes it inside the same `public_liquidate`: reduce-only market orders priced within a band of the index price, then a withdrawal of the trader's collateral back to the margin. The band is tighter for higher-leverage markets. ## Prices Debts need fresh prices. Collateral counts at its reported value, so stale dust can't block a liquidation. The two prices actually settled must be fresh and within confidence, but they don't need to sit inside the TWAP band, so a crash never blocks liquidation. ## Write-off When a margin is left with \$1 or less of collateral and still owes more, the admin can write off its debts. The pool's accrued protocol fees absorb the loss first, then lenders. ## Known limits * Eligibility uses the spot price, so a short wick can trigger a liquidation. The close factor and the bonus cap bound the cost. * A debt whose price nobody can refresh would block liquidation, so only assets with crankable prices (Scope, Pyth) are borrowable. * A stock perp's index goes stale while its market is closed. Those markets carry lower leverage caps. # Margin Accounts Source: https://docs.vanna.finance/solana/learn/margin-accounts One PDA per wallet. Live vault balances of allowed tokens are the collateral. Debt is shares. `MarginAccount` is seeded `["margin", authority]`. It records only its active **debts** and **venues** (for example Phoenix). It has no collateral ledger. ## Collateral Each margin vault is the associated token account of the margin PDA for one mint. Its live balance is the collateral. Every token on the protocol's **allowed-token list** counts, however it reached the vault: deposit, borrow, swap, a Kamino or vault receipt, or a plain transfer. * Tokens off the list count for nothing. * Each token can be capped per margin (`max_collateral_per_margin`). Anything above the cap doesn't count. * A frozen vault counts for nothing. * A token with `collateral_enabled` off stops backing new debt, but liquidation still values and seizes it. A donation into one margin's vault can't change anyone else's position. Shared reserve vaults are the opposite: they keep `accounted_liquidity_assets` and ignore surprise transfers. ## Debt `DebtPosition` stores **shares**, not a token amount. Interest grows `Reserve.total_borrow_assets`, so one reserve update reprices every borrower. ```text theme={null} user_debt_tokens = ceil(user_shares × total_borrow_assets / total_borrow_shares) ``` ## Venues A venue is a protocol where the margin holds positions that aren't tokens. Phoenix is the venue today: the margin account is its own Phoenix trader, and the whole trader account counts as one collateral line, valued by the oracle. See [Perps on Phoenix](/solana/learn/perps-on-phoenix). ## Limits Each margin holds at most a fixed number of debts and venues (3 and 2 on the hosted fork). The allowed-token list is bounded too, so every health scan has a fixed cost and a liquidation always fits in one transaction. ## Lifecycle ```text theme={null} create → deposit → borrow → margin_execute (swap / farm / perps / vaults) ↘ repay → withdraw → reclaim rent → close ↘ liquidate (HF ≤ 1.10) ``` # Oracle System Source: https://docs.vanna.finance/solana/learn/oracle-system The oracle program: Kamino Scope first, Pyth as fallback, receipt tokens through their issuer, with freshness, TWAP and confidence checks. Vanna's core program never reads a price feed. A separate program, `vanna_oracle`, values every holding and reports which checks each price passed. ## Sources | Order | Source | Used for | | - | - | - | | 1 | **Kamino Scope** — Chainlink and Pyth Lazer, cross-checked by Scope's keepers | Every token except JupUSD. A price can be the product of up to four entries (for example JitoSOL = stake rate × SOL) | | 2 | **Pyth** push-oracle feeds | Fallback when the Scope price is stale and Pyth is newer; the only source for JupUSD | | — | **Issuer accounts** | Kamino cTokens (reserve exchange rate × underlying price), Perena shares (Perena's share price), basis-vault shares (NAV computed by the oracle) | Each token's sources live in the oracle's **price book**, one `OracleConfig` per mint. Every account it reads is pinned in that config. ## Checks | Check | Rule | | - | - | | Fresh | No older than `max_age_secs`, and not dated in the future | | TWAP | Within `max_twap_divergence_bps` of Scope's TWAP, or Pyth's EMA | | Confidence | Pyth confidence within `max_confidence_bps` | How a failed check is treated depends on the action. For the owner, a failed collateral price counts as zero and a failed debt price blocks. For liquidation, collateral counts at its reported value, and only fresh, confident prices are settled. A withdrawal with no debt reads no price at all. ## Perps prices Phoenix positions are valued at an **index price** for each listed market, held in the oracle's **market book** alongside each market's leverage cap. ## On the fork The fork has no live price pushers. The app's price keeper copies Scope prices from mainnet and rewrites Pyth accounts with live prices before risk-checked transactions. That is demo infrastructure, not a mainnet oracle design. Stale or wide-confidence prices are never "used anyway". The program does not fall back to a last good price. # Core Concepts Source: https://docs.vanna.finance/solana/learn/overview Lending pools, cross-margin accounts, vTokens, health, oracles, and the integrations on Solana. Vanna on Solana is a lending and margin protocol. Lenders supply USDC, USDT or SOL to pools. Traders borrow from those pools through one cross-margin account per wallet, and put the borrowed funds to work in whitelisted protocols: Jupiter and Titan swaps, Kamino lending, Phoenix perps, Perena's USD\* vaults, and Vanna's delta-neutral basis vaults. Every position counts toward one health factor. The protocol is three programs: a **core** that only does accounting, an **oracle** that values every holding, and a **validator** that decides which external calls a margin account may make. * [Protocol Architecture](/solana/learn/protocol-architecture): the core and its two agents * [Tokenized Stocks](/solana/learn/tokenized-stocks): xStocks as collateral * [Margin Accounts](/solana/learn/margin-accounts): PDA custody and debt shares * [Lending Pools](/solana/learn/lending-pools) and [vTokens](/solana/learn/vtokens): supply, borrowing, receipt value * [Health Factor](/solana/learn/health-factor) and [Liquidation](/solana/learn/liquidation) * [Interest Rate Model](/solana/learn/interest-rate-model) and [Oracle System](/solana/learn/oracle-system) * [Composable Leverage](/solana/learn/composable-leverage): what borrowed funds can do * [Kamino Integration](/solana/learn/kamino-integration), [Perps on Phoenix](/solana/learn/perps-on-phoenix), [Yield Vaults](/solana/learn/yield-vaults), [Predict](/solana/learn/predict) These pages describe `vanna-credit-layer` and `vanna-credit-backend` as deployed on the hosted Surfpool **mainnet fork** behind [test.vanna.finance](https://test.vanna.finance) (Solana in the chain switcher). They do not certify a public-mainnet launch. # Perps on Phoenix Source: https://docs.vanna.finance/solana/learn/perps-on-phoenix Long or short SOL, ETH, BTC, TSLA and META perpetuals on Phoenix from the margin account, valued in the same health factor. Vanna's perps run on **Phoenix**, Ellipsis Labs' perpetuals exchange. Vanna doesn't run its own perps engine. Instead, each margin account is its own Phoenix trader, and USDC from the margin, borrowed or not, funds its positions. ## How a trade works **1. Wrap USDC** Ember converts the margin's USDC to phUSD, Phoenix's collateral token, 1:1. **2. Deposit to Phoenix** The phUSD moves into the margin's Phoenix trader account (cross-margined across all its Phoenix positions). **3. Place a market order** An immediate-or-cancel order fills against Phoenix's book in the same transaction. There is no keeper and no pending order. **4. Close** A reduce-only market order closes the position. Then Phoenix collateral is withdrawn and Ember converts phUSD back to USDC in the margin account. Opening is one transaction. Closing and withdrawing are two. ## Markets and leverage Vanna only allows markets listed in its oracle's market book. Each market has a leverage cap: the order's exposure, plus every other open position, must stay within the cap × the trader's Phoenix collateral. On the hosted fork: | Market | Max leverage | | - | - | | SOL | 5x | | ETH | 5x | | BTC | 5x | | TSLA | 3x | | META | 3x | A margin can hold at most 4 open Phoenix positions. ## Risk The whole Phoenix account counts as one collateral line in the margin's health factor: collateral plus each position's equity at the oracle's index price, net of funding and the fee to close, floored at zero. Borrowing power counts losses but not unrealized gains. If the margin becomes liquidatable, a liquidator closes the Phoenix positions with reduce-only orders priced close to the index, withdraws the collateral back to the margin as phUSD, then repays part of a debt and takes phUSD (or another allowed token) in return, all in one transaction. > [!NOTE] > > Stock perps (TSLA, META) use an index that goes stale while the stock market is closed. Those markets carry lower leverage caps for that reason. # Predict Source: https://docs.vanna.finance/solana/learn/predict World.xyz prediction markets in the Vanna app, with an outcome yield pool that lends matched pairs into Vanna's USDC pool. The Predict page lists **World.xyz** prediction markets and trades them from the wallet on the hosted fork. It is a wallet product, not a margin-account integration: positions don't count toward the margin health factor. ## World.xyz markets World's market program holds each market's collateral in **CASH**, a Token-2022 stablecoin, and mints a YES and a NO outcome token (6 decimals each). Splitting and merging are permissionless: N CASH ⇄ N YES + N NO. A winning outcome token redeems 1 CASH. | Role | Address | | - | - | | World market program | `prediCtPZCttYMvm2W3PtxmMxLmT1dtN7riU6Cxh6tM` | | CASH mint | `CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH` | Market discovery and prices come from mainnet (the latest maker fills), since the fork clones accounts only as they are touched. ## Outcome yield pool Vanna's `outcome_yield_pool` program (`4kFzca1u9TUAVK7BjJZ5vVtfJ2QRATs38vN8Bq6qZwG3`) lets outcome tokens earn while they wait for resolution: 1. Outcome tokens bought on an allowlisted market can go into the pool in the same wallet approval. The holder receives pool shares (9 decimals). 2. A keeper merges matched YES + NO pairs back into CASH, swaps it to USDC, and supplies it to Vanna's USDC lending pool (`lender_supply` on the core program). 3. On redeem, the pool pays from its unmatched outcome tokens first and covers any shortfall from its USDC position. The allowlist is read on-chain, never hardcoded. Only markets the pool has allowlisted can be deposited. > [!NOTE] > > Predict runs on the hosted mainnet fork with a fork maker standing in for World's mainnet market makers. It is demo infrastructure, not a live mainnet integration. # Protocol Architecture Source: https://docs.vanna.finance/solana/learn/protocol-architecture A core program that only accounts, an oracle agent that values, and a validator agent that permits. Solana splits code and state. Vanna's programs are executable at fixed IDs, and every pool, config and user account is a separate PDA they own. ## Three programs | Program | Job | | - | - | | `vanna_credit_layer` (core) | Lending pools, margin accounts, borrowing, health checks, liquidation, and `margin_execute` | | `vanna_oracle` | Values every holding: tokens from its **price book** (Kamino Scope first, Pyth as fallback, receipt tokens through their issuer's accounts), Phoenix positions from its **market book** | | `vanna_validator` | Reviews every external call: which instruction, which accounts, which vaults it may spend from and pay into, and how much | The core knows no price source and no external protocol. It asks the agents and accepts only their return data. Adding a protocol means adding rules to the validator (and, if needed, a reader to the oracle), then one admin registration. The core is not redeployed. ## Core accounts | Component | Role | | - | - | | `ProtocolConfig` | Admin, treasury, operating mode, margin limits, the allowed-token list | | `AssetConfig` | Per token: risk parameters, caps, its oracle. Also one per venue (Phoenix) | | `Reserve` | Per pool: cash, borrows, rate curve, share mint | | `MarginAccount` | One per wallet: its active debts and venues | | `DebtPosition` | Borrow shares for one (margin, reserve) | | `Integration` | One per whitelisted external program, naming its validator | ```mermaid theme={null} flowchart TD Wallet[Wallet] --> Earn[lender_supply] Earn --> Reserve[Reserve + vToken] Wallet --> Margin[user_create_margin] Margin --> Vault[Margin vault ATAs] Reserve --> Borrow[user_borrow] Borrow --> Vault Vault --> Exec[margin_execute] Exec --> Validator[vanna_validator: review_call] Exec --> Venues[Jupiter / Titan / Kamino / Phoenix / Perena / Basis] Venues --> Vault Exec --> Oracle[vanna_oracle: get_price] Borrow --> Oracle Oracle --> Health[Health check] Health --> Liq[public_liquidate] ``` Earn never touches a margin account. A margin account never uses Earn vTokens as collateral unless the user redeems first and deposits the underlying. See [Developer Architecture](/solana/developers/architecture) for the account graph and the remaining-accounts convention. # Tokenized Stocks Source: https://docs.vanna.finance/solana/learn/tokenized-stocks xStocks on Solana as margin collateral, priced by Kamino Scope, and stock perps on Phoenix. ## The tokens | Token | Issuer | Program | Decimals | Role in Vanna | | - | - | - | - | - | | NVDAx | xStocks (Backed) | Token-2022 | 8 | Collateral only | | GOOGLx | xStocks (Backed) | Token-2022 | 8 | Collateral only | | AAPLx | xStocks (Backed) | Token-2022 | 8 | Collateral only | | TSLAx | xStocks (Backed) | Token-2022 | 8 | Collateral only | xStocks are not lending pools in Vanna. You can't supply or borrow them. You can hold them in a margin account, borrow USDC, USDT or SOL against them, and swap into or out of them through Jupiter or Titan. ## Pricing Each xStock is priced from Kamino's Scope aggregator (Chainlink xStocks and Pyth Lazer, cross-checked by Scope), with the same freshness and TWAP limits Kamino's own reserves use. The xStock price already applies the mint's scaled-UI multiplier, so it prices one raw token. Amounts in the app are raw token amounts, which can differ slightly from wallets that apply the multiplier. ## Issuer controls The xStocks' issuer keeps powers such as a freeze authority. Vanna registers such mints only with an explicit `accept_issuer_controls`, and a frozen vault counts for nothing in the health factor. ## Stock exposure without the token * **Long with leverage**: borrow USDC and swap it into an xStock inside the margin account. * **Stock perps**: Phoenix lists TSLA and META perps. See [Perps on Phoenix](/solana/learn/perps-on-phoenix). * **Delta-neutral**: the TSLA and META basis vaults hold spot exposure to the stock against a Phoenix short. See [Yield Vaults](/solana/learn/yield-vaults). Transfer fees, if a Token-2022 mint ever has one, are measured on every move. Quotes and health use the amount that actually arrived. # vTokens Source: https://docs.vanna.finance/solana/learn/vtokens Share receipts for a Vanna pool. The exchange rate rises with interest. A vToken is the pool's share mint (classic SPL Token). Supplying 100 USDC mints vUSDC. Redeeming burns vUSDC for USDC at the current rate. ```text theme={null} shares_out = floor(assets × total_supply_shares / lender_assets) // supply assets_out = floor(shares × lender_assets / total_supply_shares) // redeem ``` Empty pool: 1:1. The first deposit locks 1,000 shares that nobody can redeem, which protects the rate from being manipulated while the pool is tiny. Interest does not mint extra vTokens. The same shares become worth more underlying. vTokens live in the **wallet**. They are Earn receipts, not margin collateral. To use supplied funds as collateral, redeem first, then deposit the underlying. Redeems are paid from available cash. When utilization is very high, a large redeem may have to wait for repayments or new supply. # Yield Vaults Source: https://docs.vanna.finance/solana/learn/yield-vaults Perena USD* and Vanna's delta-neutral basis vaults, held in the margin account as collateral. Besides Kamino, a margin account can put USDC into two kinds of yield vaults. The vault's share token stays in the margin account, counts toward the health factor, and can be borrowed against. ## Perena USD\* and USD\* Junior Perena's USD\* vault takes USDC and issues USD\* shares. The Junior tranche takes more risk for more yield. Vanna's oracle reads Perena's own share price for each. * A stale Perena NAV counts as zero for the owner's actions, but at its last value for liquidation. * A Junior exit that would push the account below HF 1.10 is refused. * The senior tranche and queued withdrawals aren't supported. ## Delta-neutral basis vaults Vanna's basis vaults take USDC, buy an asset through Jupiter, and hold it against a short of the same size on Phoenix. The vault's dollar value stays roughly flat while it collects funding. | Vault | Holds | | - | - | | SOL | Native SOL as Phoenix collateral | | ETH | Wormhole ETH (half the deposit; the rest is USDC margin) | | BTC | cbBTC (half) | | TSLA | TSLAx (half) | | META | METAx (half) | The oracle computes each vault's NAV itself, pricing both the spot asset and the short at the same Phoenix index. Because the two legs offset, a move in the asset's price barely changes the share's value, and the margin's health factor stays where it was. A share is never valued above the vault's own share price. > [!NOTE] > > The basis-vault program is deployed on the hosted fork only. A margin account can't deposit into the SOL vault directly (a Phoenix constraint), but it can hold, borrow against and redeem SOL-vault shares bought from a wallet. ## Liquidation Vault shares are ordinary collateral tokens to a liquidator. A liquidator repays part of a debt, receives shares worth up to the repaid value plus the bonus, and redeems them from the vault. Exit costs beyond the fee to close (Phoenix spread, Jupiter price impact) are covered by the 1.10 threshold, not modelled separately. # FAQ Source: https://docs.vanna.finance/solana/resources/faq Quick answers about the Vanna app on Solana. ## Access and setup > **Where is the app?** > > Open [test.vanna.finance](https://test.vanna.finance) and choose **Solana** in the chain switcher at the top right. The same site also runs Vanna on Stellar. > **Why is it asking for an access code?** > > The test app is private. Enter the access code the Vanna team gave you; your browser remembers it for about 30 days. If the code is changed, you're asked again. Don't have one? Ask the Vanna team. > **Is this Solana Devnet?** > > No. Vanna runs on a **Solana mainnet fork** (Surfpool): real mainnet programs and accounts, cloned onto a test node. The RPC hostname contains `devnet`, but it isn't public Devnet. > **Which wallets and logins work?** > > Sign in with **email**, **Google**, **X** or **GitHub** (an embedded wallet is created for you), or connect **Backpack**. Solflare and Phantom show as **Soon**: Solflare checks every transaction against Solana mainnet and has no custom-RPC option, so it can't sign on the fork yet. See [Connect Your Wallet](/solana/guides/connect-wallet). > **Do I need to change my wallet's RPC?** > > Only with **Backpack**. Add `https://rpc-devnet.solana.vanna.finance` as a custom RPC so it shows fork balances and previews transactions correctly. See [Add the Vanna RPC](/solana/guides/connect-wallet#add-the-vanna-rpc-to-your-wallet). Email and social logins don't need it. > **Where is the faucet?** > > Click **Deposit** in the header and use **Test funds**: **Mint** one token or **Mint all**. You get 1,000 of each token, 10 of each xStock and 1,000 CASH, as often as you like. See [Faucet](/solana/guides/faucet). > **Are test funds real?** > > No. Minting writes test balances directly into the fork. They have no value on Mainnet, and devnet or mainnet tokens sent to your address won't show up in the app. ## Borrowing and risk > **What can I use as collateral?** > > SOL, USDC, JitoSOL, JupSOL, JupUSD and the xStocks NVDAx, GOOGLx, AAPLx and TSLAx. Farm receipts (kSOL, kUSDC, USD\*, vbSOL…) count too. > **What can I borrow?** > > SOL, USDC and USDT. > **What's the maximum leverage?** > > Up to **10×** on the Margin page's slider, as long as your health factor stays above the 1.15 safety floor. Perps orders go up to each Phoenix market's own limit, shown under the market name on the Perps page (for example **Max 5×** on ETH-PERP). > **When can my account be liquidated?** > > When its health factor (collateral ÷ debt) is **1.10 or below**. See [Liquidation](/solana/guides/margin/liquidation). > **Why can't I repay from my wallet?** > > Repays come from the borrowed token held in your margin account. Move more in with [Transfer Collateral](/solana/guides/margin/transfer-collateral), or use [Flash repay](/solana/guides/margin/repay#flash-repay), which swaps other holdings to cover the loan. > **Can I withdraw from Earn at any time?** > > Yes, up to the pool's available liquidity (what isn't currently borrowed). ## Trading, Farm and Predict > **Which swap aggregator is used?** > > You choose: **Jupiter** (the default) or **Titan**, from the dropdown in the swap card's header. Either way the swap runs from your margin account and is health-checked. See [Spot Swap](/solana/guides/trade/spot-swap). > **Which perps markets are there?** > > SOL, ETH, BTC, TSLA and META perps on **Phoenix**, with USDC from your margin account as collateral. Market orders only; limit orders are marked Soon. Stock markets follow their market hours. See [Perps](/solana/guides/perps/overview). > **Why doesn't depositing into a Farm vault lower my health factor?** > > You swap one asset in your margin account for a receipt of about the same value, and the receipt counts as collateral. See [Farm](/solana/guides/farm/overview). > **Why is a basis vault's APY low or negative?** > > Basis vaults earn Phoenix perp funding. When funding turns negative, the vault's short pays instead of earning. See [Delta-Neutral](/solana/guides/farm/delta-neutral#what-can-go-wrong). > **What is Predict and what do I pay with?** > > Predict lists real World.xyz events. Each outcome has a Yes and a No share; a winning share pays \$1. You pay in **CASH**, World's USD token; mint test CASH from **Deposit → Test funds**. See [Predict](/solana/guides/predict/overview). > **How does Predict earn while I wait?** > > Matched Yes and No shares are merged into USDC and lent in Vanna's USDC pool; the interest comes back as extra shares of your side. See [Earn While You Wait](/solana/guides/predict/earn-while-you-wait). ## Everything else > **Is there a rewards program?** > > Not yet. **Rewards** in the header is marked **Soon**: points for lending, trading and predicting, referrals and a leaderboard are on the way, across Solana and Stellar. > > ![Rewards page with a Coming soon badge: points for lending, trading and predicting, referrals and a leaderboard are on the way](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/solana/rewards/coming-soon.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=239d8d49566cad69eb575eac30a55b41) > > The Rewards page today: coming soon. > **Can an AI assistant use Vanna for me?** > > Yes. Use the built-in [Copilot](/solana/guides/copilot), or connect Claude, Cursor or another MCP client through [Vanna MCP](/solana/guides/mcp). Either way, your wallet signs every transaction. > **Where are the programs?** > > The core program is `H37YVBG3eGtz89ofd7iDLc2PJgn12778392XeU2QJcGC`. See [Deployed Contracts](/solana/developers/deployed-contracts). # Architecture Source: https://docs.vanna.finance/stellar/developers/architecture Contracts, controllers, frontend, API routes, and data sources. ## Contract architecture ```mermaid theme={null} flowchart TD Wallet[Wallet] --> Pool[Lending Pool] Pool --> Receipt[vToken] Wallet --> Manager[AccountManager] Manager --> Account[SmartAccount] Manager --> Risk[RiskEngine] Manager --> Registry[Registry execution gate] Registry --> Controller[Blend / Soroswap / Aquarius controller] Manager --> Controller Controller --> Account Account --> External[External pool or router] Controller --> Tracking[TrackingToken and position membership] Risk --> Account Risk --> Pool Risk --> Oracle[Oracle service] Oracle --> Reflector[Reflector-compatible feed] ``` Earn users supply directly to a lending pool. Margin owners call AccountManager, which coordinates account custody, borrowing, repayment, and external strategies. SmartAccounts hold the actual tokens; Registry maps tokens, pools, accounts, controllers, and tracking metadata. ControllerFacade is available for capability checks, but the optimized `exec` path reads Registry's batched execution gate and calls the controller directly. Live post-exec and post-borrow health validation is admin configurable. Borrow and withdrawal checks, controller allowlists, ledger accounting, and liquidation valuation are distinct checks. ## Application architecture `Vanna_Finance_Backend/apps/stellar` is a **Next.js application with both frontend screens and server API routes** (under `/api/stellar/*`), in a monorepo whose `packages/shared` holds the header, sign-in dialog and funds modal. It uses React, TanStack Query, Zustand and Stellar SDK transaction builders. Users sign with Freighter or OneKey, or with an email/social wallet through Dynamic when the build enables it. The main screens are Portfolio, Earn, Margin, Spot, Farm, Analytics, and Copilot. Rewards is a placeholder. Perps and options routes redirect to Spot. Read services combine Soroban simulation, Horizon, cached pool/account APIs, and Mercury history with RPC fallback. Hubble/BigQuery powers a separate server-gated stats surface. Copilot adds planning, execution approval, and optional external MCP/signing services; it is not an on-chain contract. ## Boundaries that matter * XLM and three separate USDC test assets have four independent lending markets. * Wallet Earn receipts are separate from SmartAccount collateral. * External position value can differ from withdrawable or spendable balance. * A multi-step frontend strategy is atomic only when it uses one successful atomic contract invocation. * Source support, configured addresses, and a working live deployment are different facts. ## Source reference * `Protocol_V1_Soroban_testnet/contracts/AccountManagerContract/src/account_manager.rs` * `Vanna_Finance_Backend/apps/stellar/app` * `Vanna_Finance_Backend/apps/stellar/lib` # AccountManager Source: https://docs.vanna.finance/stellar/developers/contracts/account-manager Current testnet implementation, behavior, authorization, and Rust signatures. AccountManager authenticates margin owners, manages account lifecycle, coordinates lending and risk checks, and routes external actions through registered controllers. Earn deposits call lending pools directly. ## Account lifecycle `create_account` deploys or reactivates a SmartAccount for the trader and updates Registry ownership records. `close_account` requires owner authorization, no outstanding debt, and a ledger later than activation. It unwinds external positions, sweeps direct tokens to the owner, deactivates the account, and records it for reuse. ## Collateral and borrowing Deposits, withdrawals, and borrows use WAD amounts. Token transfers use each token's native decimals. Deposits credit the amount actually transferred after conversion. Borrow proceeds remain in the SmartAccount; gross debt includes any origination fee, while credited collateral is the net receipt. `deposit_and_borrow` combines same-asset operations. `deposit_and_borrow_cross` supports distinct collateral and debt assets. `deposit_borrow_and_deploy_blend` accepts the legacy encoded Blend Deposit action and executes the combined operation atomically. The frontend may instead use multiple transactions. The asset cap defaults to **5**, and can be changed by the admin. Token eligibility and pool resolution use Registry configuration. Borrow and withdrawal checks require health strictly above 1.1. ## Repayment, settlement, and liquidation `repay` takes arguments in the order **amount, symbol, SmartAccount**. It clamps repayment to debt, updates pool shares, and transfers repayment tokens from the SmartAccount through `remove_borrowed_token_balance`. It does not automatically fund repayment from the owner's wallet. `settle_account` unwinds external positions into the account, attempts repayment of recognized debt legs, and returns whether debt is cleared. It neither sweeps remaining collateral to the wallet nor deactivates the account. Use withdrawal or `close_account` afterward. `liquidate` requires the liquidator's authorization and allowances for each underlying debt token to AccountManager. It takes a liquidation snapshot, rejects healthy accounts and unpriceable plain collateral, repays full recognized debt from the liquidator, exits Blend directly to the liquidator, transfers held AMM LP tokens, and sweeps remaining direct collateral to the liquidator. There is no partial-repayment input or enforced debt-plus-bonus seizure cap. The 10% bonus reported by `get_liquidation_config` is not a separate payment calculation in this path. Liquidation does not deactivate the account. ## External execution `exec` uses the typed `ExternalAction` interface. It calls Registry's batched `get_exec_gate`, checks the controller's `can_call`, executes through the SmartAccount, applies signed WAD token deltas, and enforces asset and controller TVL caps. The current path checks Registry directly; it does not require a facade round-trip. Live post-execution and post-borrow health validation is controlled by `get_exec_live_gate` (default **true**, admin configurable). Borrowing uses SmartAccount prechecks, then conditionally calls RiskEngine on the resulting state; the combined deposit/borrow path uses the same flag. Do not promise that every external action always runs a live health check. `execute` is the legacy XDR adapter; `exec_fn` is the function-name adapter. Use the typed path for new integrations. ## Administration Admin methods cover two-step admin transfer, WASM upgrades, SmartAccount upgrades, pause state, asset cap, collateral eligibility, tracking minter authorization, valuation-cache refreshes, and the live execution gate. Manager pause blocks borrowing, combined deposit/borrow, collateral withdrawal, external execution, and liquidation. Standalone collateral deposit, repayment, settlement, and explicit close do not check this pause flag; their other authorization/configuration checks still apply. These controls are separate from pool and RiskEngine pause flags. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: &Env, admin: Address, registry_contract: Address) ``` ### get\_liquidation\_config ```rust theme={null} pub fn get_liquidation_config(_env: &Env) -> (u128, u128, bool, bool) ``` ### get\_admin ```rust theme={null} pub fn get_admin(env: &Env) -> Address ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### upgrade\_smart\_account ```rust theme={null} pub fn upgrade_smart_account(env: &Env, smart_account: Address, new_wasm_hash: BytesN<32>) ``` ### refresh\_blend\_underlying\_cache ```rust theme={null} pub fn refresh_blend_underlying_cache(env: &Env, smart_account: Address) ``` ### refresh\_lp\_usd\_cache ```rust theme={null} pub fn refresh_lp_usd_cache(env: &Env, smart_account: Address) ``` ### refresh\_usd\_valuation\_cache ```rust theme={null} pub fn refresh_usd_valuation_cache(env: &Env, smart_account: Address) ``` ### create\_account ```rust theme={null} pub fn create_account( env: &Env, trader_address: Address, ) -> Result ``` ### close\_account ```rust theme={null} pub fn close_account( env: &Env, smart_account_address: Address, ) -> Result ``` ### deposit\_collateral\_tokens ```rust theme={null} pub fn deposit_collateral_tokens( env: Env, smart_account: Address, token_symbol: Symbol, token_amount_wad: U256, ) -> Result<(), AccountManagerError> ``` ### withdraw\_collateral\_balance ```rust theme={null} pub fn withdraw_collateral_balance( env: Env, smart_account: Address, token_symbol: Symbol, token_amount_wad: U256, ) -> Result<(), AccountManagerError> ``` ### borrow ```rust theme={null} pub fn borrow( env: &Env, smart_account: Address, borrow_amount_wad: U256, token_symbol: Symbol, ) -> Result<(), AccountManagerError> ``` ### deposit\_and\_borrow ```rust theme={null} pub fn deposit_and_borrow( env: Env, smart_account: Address, deposit_amount_wad: U256, borrow_amount_wad: U256, token_symbol: Symbol, ) -> Result<(), AccountManagerError> ``` ### deposit\_and\_borrow\_cross ```rust theme={null} pub fn deposit_and_borrow_cross( env: Env, smart_account: Address, deposit_amount_wad: U256, deposit_token_symbol: Symbol, borrow_amount_wad: U256, borrow_token_symbol: Symbol, ) -> Result<(), AccountManagerError> ``` ### deposit\_borrow\_and\_deploy\_blend ```rust theme={null} pub fn deposit_borrow_and_deploy_blend( env: Env, smart_account: Address, deposit_amount_wad: U256, borrow_amount_wad: U256, token_symbol: Symbol, blend_call_bytes: Bytes, ) -> Result<(), AccountManagerError> ``` ### repay ```rust theme={null} pub fn repay( env: Env, repay_amount_wad: U256, token_symbol: Symbol, smart_account: Address, ) -> Result<(), AccountManagerError> ``` ### liquidate ```rust theme={null} pub fn liquidate( env: Env, liquidator: Address, smart_account: Address, ) -> Result<(), AccountManagerError> ``` ### settle\_account ```rust theme={null} pub fn settle_account(env: Env, smart_account: Address) -> Result ``` ### propose\_admin ```rust theme={null} pub fn propose_admin(env: &Env, proposed: Address) ``` ### accept\_admin ```rust theme={null} pub fn accept_admin(env: &Env) ``` ### set\_paused ```rust theme={null} pub fn set_paused(env: &Env, paused: bool) ``` ### is\_paused ```rust theme={null} pub fn is_paused(env: &Env) -> bool ``` ### set\_max\_asset\_cap ```rust theme={null} pub fn set_max_asset_cap(env: &Env, cap: U256) ``` ### get\_max\_asset\_cap ```rust theme={null} pub fn get_max_asset_cap(env: &Env) -> U256 ``` ### get\_iscollateral\_allowed ```rust theme={null} pub fn get_iscollateral_allowed(env: &Env, token_symbol: Symbol) -> bool ``` ### set\_iscollateral\_allowed ```rust theme={null} pub fn set_iscollateral_allowed(env: &Env, token_symbol: Symbol, allowed: bool) ``` ### generate\_salt ```rust theme={null} pub fn generate_salt( env: &Env, trader_address: Address, account_manager: Address, smart_account_num: u32, ) -> BytesN<32> ``` ### get\_inactive\_accounts ```rust theme={null} pub fn get_inactive_accounts(env: &Env, trader_address: Address) -> Vec
``` ### exec ```rust theme={null} pub fn exec( env: &Env, smart_account: Address, target: Address, action: ExternalAction, tokens: Vec
, amounts_wad: Vec, min_out: u128, ) ``` ### set\_exec\_live\_gate ```rust theme={null} pub fn set_exec_live_gate(env: &Env, enabled: bool) ``` ### get\_exec\_live\_gate ```rust theme={null} pub fn get_exec_live_gate(env: &Env) -> bool ``` ### authorize\_tracking\_minter ```rust theme={null} pub fn authorize_tracking_minter(env: &Env, minter: Address, authorized: bool) ``` ### execute ```rust theme={null} pub fn execute(env_x: &Env, smart_account: Address, extern_proto_call_bytes: Bytes) ``` ### exec\_fn ```rust theme={null} pub fn exec_fn( env: &Env, smart_account: Address, target: Address, func: Symbol, args: Vec, auth_entries: Vec, tokens: Vec
, ) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/AccountManagerContract/src/account_manager.rs` # Aquarius Controller Source: https://docs.vanna.finance/stellar/developers/contracts/aquarius-controller Current testnet implementation, behavior, authorization, and Rust signatures. AquariusController supports `Swap`, `AddLiquidity`, and `RemoveLiquidity` through the configured Aquarius router. Tokens are sorted for pool discovery, and a pool index selects the underlying pool. Swap/add input amounts use WAD before native conversion. Remove-liquidity input is **LP WAD**, unlike Soroswap's raw LP amount. Swap `min_out` and the add-liquidity minimum LP amount are native units passed to Aquarius. Removal splits `min_out / 2` into each native leg minimum. Inspect the action branch and frontend builder before encoding minima. The controller authorizes router/pool/token subcalls through SmartAccount, synchronizes actual LP position membership, and returns signed WAD collateral deltas. Swap credits are capped by oracle input value. The configured XLM pair uses **AqUSDC**, a separate test token. The frontend configuration records a gauge/trustline limitation for smart-contract deposits into the referenced gauge-enabled pool. Controller support is present, but that comment is not evidence that the external pool now accepts deposits. Simulate the selected pool before relying on this flow; live availability was not checked in this documentation review. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, registry: Address, admin: Address) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### register\_pool ```rust theme={null} pub fn register_pool( env: &Env, token_a: Address, token_b: Address, pool_index: BytesN<32>, pool_address: Address, ) ``` ### can\_call ```rust theme={null} pub fn can_call( env: &Env, target: Address, action: ExternalAction, tokens: Vec
, ) -> (bool, Vec
, Vec
) ``` ### execute ```rust theme={null} pub fn execute( env: &Env, account: Address, action: ExternalAction, tokens: Vec
, amounts: Vec, min_out: u128, ) -> TokenDeltas ``` ### get\_registry ```rust theme={null} pub fn get_registry(env: &Env) -> Address ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/AquariusControllerContract/src/controller.rs` # Blend Controller Source: https://docs.vanna.finance/stellar/developers/contracts/blend-controller Current testnet implementation, behavior, authorization, and Rust signatures. BlendController supports `Supply` and `Withdraw` against the configured Blend pool and registered reserve tokens. It authenticates AccountManager, resolves token tracking metadata, and calls Blend through SmartAccount-authorized callbacks. Supply uses Blend request type 0; withdraw uses type 1. Input amounts use WAD and are converted to reserve-native units. Receipt changes are derived from Blend positions and synchronized through authorized tracking-token operations and underlying caches. `withdraw_all_to` batches reserve exits and sends underlying to the supplied recipient. Liquidation uses this path to pay Blend collateral directly to the liquidator. It verifies that requested supply positions have fully exited and burns remaining tracking receipts. The contract exposes capability, execution, Registry, and admin-upgrade methods. The constructor argument order differs from ControllerFacade: verify the signatures below. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, registry: Address, admin: Address) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### can\_call ```rust theme={null} pub fn can_call( env: &Env, target: Address, action: ExternalAction, tokens: Vec
, ) -> (bool, Vec
, Vec
) ``` ### execute ```rust theme={null} pub fn execute( env: &Env, account: Address, action: ExternalAction, tokens: Vec
, amounts: Vec, _min_out: u128, ) -> TokenDeltas ``` ### withdraw\_all\_to ```rust theme={null} pub fn withdraw_all_to( env: &Env, account: Address, recipient: Address, target: Address, tokens: Vec
, ) ``` ### get\_registry ```rust theme={null} pub fn get_registry(env: &Env) -> Address ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/BlendControllerContract/src/controller.rs` # Controller Facade Source: https://docs.vanna.finance/stellar/developers/contracts/controller-facade Current testnet implementation, behavior, authorization, and Rust signatures. ControllerFacade resolves a controller for an external target, calls its capability check, and verifies permitted input tokens. Unknown targets return a denied result with empty token lists. `can_call` uses a typed action; `can_call_fn` uses a function symbol. Each returns `(allowed, tokens_in, tokens_out)`. `validate_tokens_in` checks a supplied list against Registry. Admin can change Registry and upgrade WASM. The facade remains available as a policy interface. AccountManager's current `exec` implementation optimizes the transaction budget by reading `Registry.get_exec_gate` and calling the controller directly, so an architecture diagram must not require the facade in every execution. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, admin: Address, registry: Address) ``` ### can\_call ```rust theme={null} pub fn can_call( env: &Env, target: Address, action: ExternalAction, tokens: Vec
, ) -> (bool, Vec
, Vec
) ``` ### can\_call\_fn ```rust theme={null} pub fn can_call_fn( env: &Env, target: Address, func: soroban_sdk::Symbol, tokens: Vec
, ) -> (bool, Vec
, Vec
) ``` ### validate\_tokens\_in ```rust theme={null} pub fn validate_tokens_in(env: &Env, tokens_in: Vec
) -> bool ``` ### get\_registry ```rust theme={null} pub fn get_registry(env: &Env) -> Address ``` ### set\_registry ```rust theme={null} pub fn set_registry(env: &Env, new_registry: Address) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/ControllerFacadeContract/src/facade.rs` # Deployment Contracts Source: https://docs.vanna.finance/stellar/developers/contracts/deployers Current testnet implementation, behavior, authorization, and Rust signatures. The core Deployer and lending-pool Deployer are separate admin-controlled contracts. ## Core deployment `deploy_all` deploys Registry, RateModel, RiskEngine, Oracle, and AccountManager; sets the SmartAccount WASM hash; and wires core addresses. It accepts the Reflector address explicitly. A one-time deployed guard prevents repeating the core deployment. The return order is **Registry, RateModel, RiskEngine, Oracle, AccountManager**. ## Lending deployment `DeployerLPoolContract` provides a legacy XLM/USDC pair deployment and `deploy_single_pool` for additional markets. It deploys a pool and receipt, initializes metadata, and initializes the pool. A single-pool deployment still needs appropriate Registry asset/alias/permission configuration; it does not onboard every dependency automatically. The legacy two-pool helper initializes vXLM with 7 decimals and vUSDC with 6; this is not a universal claim about the four configured receipt deployments or underlying SAC decimals. Read deployed metadata. The Rust workspace uses Soroban SDK **25.3.1**, Blend SDK **2.25.0**, and contract imports from `target/wasm32v1-none/release`. Build prerequisite WASMs before consumers. Review the repository's deployment scripts before using them; addresses listed here are configuration snapshots, not a new deployment. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### DeployerContract ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, admin: Address) ``` ### deploy\_all ```rust theme={null} pub fn deploy_all( env: Env, registry_contract_wasm_hash: BytesN<32>, risk_engine_wasm_hash: BytesN<32>, rate_model_wasm_hash: BytesN<32>, oracle_wasm_hash: BytesN<32>, account_manager_wasm_hash: BytesN<32>, smart_account_hash: BytesN<32>, reflector_address: Address, ) -> (Address, Address, Address, Address, Address) ``` ### propose\_admin ```rust theme={null} pub fn propose_admin(env: Env, new_admin: Address) ``` ### accept\_admin ```rust theme={null} pub fn accept_admin(env: Env) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: Env, new_wasm_hash: BytesN<32>) ``` ### DeployerLPoolContract ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, admin: Address) ``` ### deploy\_lps\_and\_token\_contracts ```rust theme={null} pub fn deploy_lps_and_token_contracts( env: Env, registry_address: Address, account_manager: Address, rate_model: Address, token_issuer: Address, lending_pool_hash: BytesN<32>, vtoken_hash: BytesN<32>, origination_fee_u128: u128, ) -> (Address, Address, Address, Address) ``` ### deploy\_single\_pool ```rust theme={null} pub fn deploy_single_pool( env: Env, registry_address: Address, account_manager: Address, rate_model: Address, token_issuer: Address, lending_pool_hash: BytesN<32>, vtoken_hash: BytesN<32>, origination_fee_u128: u128, asset_symbol: Symbol, asset_address: Address, vtoken_symbol: Symbol, vtoken_decimals: u32, vtoken_name: String, vtoken_ticker: String, nonce: u32, ) -> (Address, Address) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/DeployerContract/src/deployer.rs` * `Protocol_V1_Soroban_testnet/contracts/DeployerLPoolContract/src/pool_deployer.rs` # Lending Pools Source: https://docs.vanna.finance/stellar/developers/contracts/lending-pools Current testnet implementation, behavior, authorization, and Rust signatures. One lending-pool implementation serves four configured frontend markets: XLM, Blend USDC, Aquarius USDC, and Soroswap USDC. Each deployment has its own underlying asset, liquidity, debt shares, and vToken. ## Supply and redeem `deposit(lender, amount_wad)` authenticates the lender, accrues interest, transfers native underlying, and mints vTokens. The first deposit uses 1:1 WAD accounting and reserves 1,000 WAD share units for minimum liquidity before native vToken conversion. Later deposits use a virtual offset of **1 WAD integer unit** in both supply and assets. A zero-share accounting result is rejected. `redeem_vtokens(lender, tokens_to_redeem_wad)` accepts **vToken quantity in WAD**, not underlying quantity or raw native receipt units. Payout is clamped to the minimum of requested value, **50% of total assets**, and available liquidity. A partial redemption burns the recomputed share amount; zero available payout fails. Read the event's `asset_amount` and remaining balance to determine what actually redeemed. ## Borrow and repay accounting Only AccountManager may call `lend_to` and `collect_from`. `lend_to` returns `(is_first_borrow, net_amount_wad)` on success, records gross debt with upward-rounded shares, and distributes the fee to treasury and net proceeds to the SmartAccount. New borrowing cannot exceed **95% pool utilization**. `collect_from` updates debt accounting; it does not itself pull tokens. AccountManager's regular repay path separately transfers account-held underlying, while liquidation transfers from the liquidator using an allowance. Do not call the pool accounting function as a standalone repayment flow. `get_borrows` includes pending interest with floor rounding. `update_state` persists interest with ceiling rounding. Account debt getters use these live preview borrows, not just stored principal. See [Math Reference](/stellar/developers/math-reference). ## Pool administration Pool pause blocks supply, redeem, and borrow, but not `collect_from`. Admin transfer is two-step. Origination fee and rate-model address are configurable. Read `get_origination_fee` rather than assuming a fixed deployment fee. The frontend's 0.9999 spend buffer is a rounding allowance, not the on-chain fee. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor( env: Env, admin: Address, asset_config: AssetConfig, registry_contract: Address, account_manager: Address, rate_model: Address, token_issuer: Address, treasury: Address, origination_fee: U256, ) ``` ### propose\_admin ```rust theme={null} pub fn propose_admin(env: Env, proposed: Address) -> Result<(), LendingError> ``` ### accept\_admin ```rust theme={null} pub fn accept_admin(env: Env) -> Result ``` ### get\_admin ```rust theme={null} pub fn get_admin(env: &Env) -> Result ``` ### initialize\_pool ```rust theme={null} pub fn initialize_pool( env: Env, vtoken_contract_address: Address, ) -> Result ``` ### deposit ```rust theme={null} pub fn deposit(env: Env, lender: Address, amount_wad: U256) ``` ### redeem\_vtokens ```rust theme={null} pub fn redeem_vtokens(env: &Env, lender: Address, tokens_to_redeem_wad: U256) ``` ### lend\_to ```rust theme={null} pub fn lend_to( env: &Env, smart_account: Address, amount_wad: U256, ) -> Result<(bool, U256), LendingError> ``` ### collect\_from ```rust theme={null} pub fn collect_from( env: &Env, amount_wad: U256, trader_smart_account: Address, ) -> Result ``` ### convert\_asset\_borrow\_shares ```rust theme={null} pub fn convert_asset_borrow_shares(env: &Env, amount_wad: U256, round_up: bool) -> U256 ``` ### convert\_borrow\_shares\_asset ```rust theme={null} pub fn convert_borrow_shares_asset(env: &Env, debt_wad: U256) -> U256 ``` ### update\_state ```rust theme={null} pub fn update_state(env: &Env) ``` ### set\_paused ```rust theme={null} pub fn set_paused(env: Env, paused: bool) ``` ### is\_paused ```rust theme={null} pub fn is_paused(env: &Env) -> bool ``` ### before\_deposit ```rust theme={null} pub fn before_deposit(env: &Env) ``` ### before\_withdraw ```rust theme={null} pub fn before_withdraw(env: &Env) ``` ### get\_user\_borrow\_shares ```rust theme={null} pub fn get_user_borrow_shares(env: &Env, trader: Address) -> U256 ``` ### get\_borrow\_balance ```rust theme={null} pub fn get_borrow_balance(env: &Env, trader: Address) -> U256 ``` ### get\_total\_borrow\_shares ```rust theme={null} pub fn get_total_borrow_shares(env: &Env) -> U256 ``` ### total\_assets ```rust theme={null} pub fn total_assets(env: &Env) -> U256 ``` ### get\_borrows ```rust theme={null} pub fn get_borrows(env: &Env) -> U256 ``` ### get\_rate\_factor ```rust theme={null} pub fn get_rate_factor(env: &Env) -> Result ``` ### get\_total\_liquidity\_in\_pool ```rust theme={null} pub fn get_total_liquidity_in_pool(env: &Env) -> U256 ``` ### get\_last\_updated\_time ```rust theme={null} pub fn get_last_updated_time(env: &Env) -> u64 ``` ### get\_current\_total\_vtoken\_balance ```rust theme={null} pub fn get_current_total_vtoken_balance(env: &Env) -> U256 ``` ### get\_total\_vtokens\_minted ```rust theme={null} pub fn get_total_vtokens_minted(env: &Env) -> U256 ``` ### get\_total\_vtokens\_burnt ```rust theme={null} pub fn get_total_vtokens_burnt(env: &Env) -> U256 ``` ### get\_lenders ```rust theme={null} pub fn get_lenders(env: Env) -> Vec
``` ### is\_pool\_initialised ```rust theme={null} pub fn is_pool_initialised(env: &Env) -> bool ``` ### get\_native\_asset\_address ```rust theme={null} pub fn get_native_asset_address(env: &Env) -> Address ``` ### get\_asset\_config ```rust theme={null} pub fn get_asset_config(env: &Env) -> AssetConfig ``` ### convert\_asset\_to\_vtoken ```rust theme={null} pub fn convert_asset_to_vtoken(env: &Env, amount_wad: U256) -> U256 ``` ### convert\_vtoken\_to\_asset ```rust theme={null} pub fn convert_vtoken_to_asset(env: &Env, vtokens_to_be_burnt_wad: U256) -> U256 ``` ### update\_origination\_fee ```rust theme={null} pub fn update_origination_fee(env: &Env, origination_fee: U256) ``` ### update\_rate\_model ```rust theme={null} pub fn update_rate_model(env: &Env, new_rate_model: Address) ``` ### get\_origination\_fee ```rust theme={null} pub fn get_origination_fee(env: &Env) -> U256 ``` ### get\_treasury ```rust theme={null} pub fn get_treasury(env: &Env) -> Address ``` ### get\_max\_utilization\_wad ```rust theme={null} pub fn get_max_utilization_wad(_env: &Env) -> u128 ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/lending-pool/src/pool.rs` # Oracle Service Source: https://docs.vanna.finance/stellar/developers/contracts/oracle Reflector pricing, memoization, freshness, and emergency fallback. OracleContract returns `(price, decimals)` for a feed symbol. RiskEngine converts the result to USD WAD. ## Resolution order The production path can reuse a **30-second memo**. Otherwise it checks a Reflector-compatible feed's latest timestamp, uses a supported positive **five-record TWAP** when fresh, then a positive fresh spot price, then an admin-set fallback. Fresh upstream data must be no older than **600 seconds**; fallback prices expire after **86,400 seconds**. A missing `twap` method is tolerated. The testutils path uses a mock oracle without the TWAP call. A fallback is a configurable emergency price, not guaranteed live market data. If no usable price exists the call fails. RiskEngine handles failures differently for new risk and liquidation; plain collateral that cannot be priced blocks AccountManager liquidation. ## Administration The admin can set fallback prices, replace the Reflector address, and upgrade WASM. Configuration getters expose upstream address, staleness windows, and per-symbol fallback metadata. Stored metadata and memoization reduce cross-contract costs; read the implementation before assuming every call contacts Reflector. ## Function signatures ### \_\_constructor ```rust theme={null} pub fn __constructor(env: &Env, admin: Address, reflector_address: Address) ``` ### get\_price\_latest ```rust theme={null} pub fn get_price_latest(env: &Env, symbol: Symbol) -> (u128, u32) ``` ### get\_oracle\_config ```rust theme={null} pub fn get_oracle_config(env: &Env) -> (Address, u64, u64) ``` ### get\_asset\_config ```rust theme={null} pub fn get_asset_config( env: &Env, symbol: Symbol, ) -> (Address, u64, u64, Option<(u128, u32, u64)>) ``` ### get\_admin ```rust theme={null} pub fn get_admin(env: &Env) -> Address ``` ### set\_fallback\_price ```rust theme={null} pub fn set_fallback_price(env: &Env, symbol: Symbol, price: u128, decimals: u32) ``` ### set\_reflector\_contract ```rust theme={null} pub fn set_reflector_contract(env: &Env, new_address: Address) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/OracleContract/src/oracle_service.rs` # Rate Model Source: https://docs.vanna.finance/stellar/developers/contracts/rate-model Current testnet implementation, behavior, authorization, and Rust signatures. The rate model uses a smooth utilization polynomial. It is not a two-slope kinked model. ```text theme={null} u = borrows / (liquidity + borrows) annual_rate = c3 × (c1×u + c1×u^32 + c2×u^64) rate_per_second = annual_rate / 31,556,952 ``` All contract values are WAD-scaled. Defaults are `c1 = 0.1`, `c2 = 0.3`, `c3 = 3.5`; these are configurable, not immutable market rates. `get_coefficients` returns current values. The admin setter rejects coefficients whose implied 100%-utilization APR exceeds **1000%**. Utilization is clamped to 100%, and inputs to the borrow-rate calculation are capped at 10^36. The constructor accepts a Registry argument for deployment compatibility but does not persist or use it. The model's admin may change coefficients and upgrade WASM. See [Math Reference](/stellar/developers/math-reference) for integer scaling and interest rounding. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: &Env, admin: Address, _registry_contract: Address) ``` ### set\_coefficients ```rust theme={null} pub fn set_coefficients(env: &Env, c1: u128, c2: u128, c3: u128) ``` ### get\_coefficients ```rust theme={null} pub fn get_coefficients(env: &Env) -> (u128, u128, u128) ``` ### get\_admin ```rust theme={null} pub fn get_admin(env: &Env) -> Address ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### get\_borrow\_rate\_per\_sec ```rust theme={null} pub fn get_borrow_rate_per_sec( env: &Env, liquidity_wad: U256, borrows_wad: U256, ) -> Result ``` ### get\_utilisation\_ratio ```rust theme={null} pub fn get_utilisation_ratio( env: &Env, liquidity_wad: U256, borrows_wad: U256, ) -> Result ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/RateModelContract/src/rate_model.rs` # Registry Source: https://docs.vanna.finance/stellar/developers/contracts/registry Current testnet implementation, behavior, authorization, and Rust signatures. Registry stores core addresses, trader-to-account membership, token aliases, asset metadata, token permissions, controller routes, controller TVL caps, and tracking metadata. ## Discovery Use `get_protocol_config` for batched core/token/protocol configuration; `get_registered_assets`, `get_token_address_for`, and `get_lending_pool_for_symbol` for market resolution; and `get_tracking_meta` for external-position valuation/unwind configuration. USDC price-feed aliases do not make distinct token contracts interchangeable. Account membership is written through AccountManager-authorized `add_account`, `close_account`, and `update_account`. There is no invented `get_user_smart_account` ABI: the frontend discovers account records using Registry storage and other supported fallbacks in `MarginAccountService`. ## Governance After `finalize_registry_config`, controller registration has a **48-hour** queue delay. Token allowlist, asset metadata, and tracking metadata changes have a **24-hour** queue delay. Before finalization, these queue methods apply configuration immediately as a bootstrap path. The queue methods accept proposed data; the corresponding apply methods consume the queued change after its deadline. Cancellation and immediate deregistration methods are available. Finalizing Registry configuration restricts subsequent changes to sensitive configuration. Admin succession uses proposal and acceptance. `AssetMeta` includes LTV and liquidation fields, but the current RiskEngine's operative health threshold is a global 1.1. Do not infer per-asset weighted risk calculations solely from metadata fields. `get_exec_gate` batches target-to-controller lookup, probation TVL cap, and token permission checks. AccountManager's current typed execution uses it directly. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, admin: Address) ``` ### set\_lendingpool\_xlm ```rust theme={null} pub fn set_lendingpool_xlm( env: &Env, lendingpool_xlm: Address, ) -> Result<(), RegistryContractError> ``` ### set\_smart\_account\_hash ```rust theme={null} pub fn set_smart_account_hash( env: &Env, smart_account_hash: BytesN<32>, ) -> Result<(), RegistryContractError> ``` ### set\_accountmanager\_contract ```rust theme={null} pub fn set_accountmanager_contract( env: &Env, account_manager_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_lendingpool\_usdc ```rust theme={null} pub fn set_lendingpool_usdc( env: &Env, lendingpool_usdc_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_risk\_engine\_address ```rust theme={null} pub fn set_risk_engine_address( env: &Env, risk_engine_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_rate\_model\_address ```rust theme={null} pub fn set_rate_model_address( env: &Env, rate_model_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_oracle\_contract\_address ```rust theme={null} pub fn set_oracle_contract_address( env: &Env, oracle_contract_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_native\_xlm\_contract\_address ```rust theme={null} pub fn set_native_xlm_contract_address( env: &Env, xlm_contract_adddress: Address, ) -> Result<(), RegistryContractError> ``` ### set\_native\_usdc\_contract\_address ```rust theme={null} pub fn set_native_usdc_contract_address( env: &Env, usdc_contract_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_blend\_pool\_address ```rust theme={null} pub fn set_blend_pool_address( env: &Env, blend_pool_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_tracking\_token\_contract\_addr ```rust theme={null} pub fn set_tracking_token_contract_addr( env: &Env, tracking_token_contract_addr: Address, ) -> Result<(), RegistryContractError> ``` ### set\_aquarius\_router\_address ```rust theme={null} pub fn set_aquarius_router_address( env: &Env, aquarius_router_address: Address, ) -> Result<(), RegistryContractError> ``` ### set\_aquarius\_pool\_index ```rust theme={null} pub fn set_aquarius_pool_index( env: &Env, pool_index: BytesN<32>, ) -> Result<(), RegistryContractError> ``` ### get\_lendingpool\_xlm ```rust theme={null} pub fn get_lendingpool_xlm(env: &Env) -> Result ``` ### get\_smart\_account\_hash ```rust theme={null} pub fn get_smart_account_hash(env: &Env) -> Result, RegistryContractError> ``` ### get\_accountmanager\_contract ```rust theme={null} pub fn get_accountmanager_contract(env: &Env) -> Result ``` ### get\_lendingpool\_usdc ```rust theme={null} pub fn get_lendingpool_usdc(env: &Env) -> Result ``` ### get\_risk\_engine\_address ```rust theme={null} pub fn get_risk_engine_address(env: &Env) -> Result ``` ### get\_rate\_model\_address ```rust theme={null} pub fn get_rate_model_address(env: &Env) -> Result ``` ### get\_oracle\_contract\_address ```rust theme={null} pub fn get_oracle_contract_address(env: &Env) -> Result ``` ### get\_xlm\_contract\_address ```rust theme={null} pub fn get_xlm_contract_address(env: &Env) -> Result ``` ### get\_usdc\_contract\_address ```rust theme={null} pub fn get_usdc_contract_address(env: &Env) -> Result ``` ### get\_blend\_pool\_address ```rust theme={null} pub fn get_blend_pool_address(env: &Env) -> Result ``` ### get\_aquarius\_router\_address ```rust theme={null} pub fn get_aquarius_router_address(env: &Env) -> Result ``` ### set\_soroswap\_router\_address ```rust theme={null} pub fn set_soroswap_router_address( env: &Env, soroswap_router_address: Address, ) -> Result<(), RegistryContractError> ``` ### get\_soroswap\_router\_address ```rust theme={null} pub fn get_soroswap_router_address(env: &Env) -> Result ``` ### get\_aquarius\_pool\_index ```rust theme={null} pub fn get_aquarius_pool_index(env: &Env) -> Result, RegistryContractError> ``` ### has\_tracking\_token\_contract\_addr ```rust theme={null} pub fn has_tracking_token_contract_addr(env: &Env) -> bool ``` ### get\_tracking\_token\_contract\_addr ```rust theme={null} pub fn get_tracking_token_contract_addr(env: &Env) -> Result ``` ### get\_admin ```rust theme={null} pub fn get_admin(env: &Env) -> Result ``` ### propose\_admin ```rust theme={null} pub fn propose_admin(env: &Env, proposed: Address) -> Result<(), RegistryContractError> ``` ### accept\_admin ```rust theme={null} pub fn accept_admin(env: &Env) -> Result<(), RegistryContractError> ``` ### get\_proposed\_admin ```rust theme={null} pub fn get_proposed_admin(env: &Env) -> Option
``` ### get\_timelock\_durations ```rust theme={null} pub fn get_timelock_durations(_env: &Env) -> (u64, u64) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### add\_account ```rust theme={null} pub fn add_account( env: &Env, trader: Address, smart_account: Address, ) -> Result ``` ### close\_account ```rust theme={null} pub fn close_account( env: &Env, trader: Address, smart_account: Address, ) -> Result ``` ### update\_account ```rust theme={null} pub fn update_account( env: &Env, trader: Address, smart_account: Address, ) -> Result ``` ### set\_iscollateral\_allowed ```rust theme={null} pub fn set_iscollateral_allowed(env: &Env, token_symbol: Symbol, allowed: bool) ``` ### get\_iscollateral\_allowed ```rust theme={null} pub fn get_iscollateral_allowed(env: &Env, token_symbol: Symbol) -> bool ``` ### is\_collateral\_explicitly\_revoked ```rust theme={null} pub fn is_collateral_explicitly_revoked(env: &Env, token_symbol: Symbol) -> bool ``` ### set\_controller\_facade ```rust theme={null} pub fn set_controller_facade(env: &Env, facade: Address) ``` ### get\_controller\_facade ```rust theme={null} pub fn get_controller_facade(env: &Env) -> Address ``` ### has\_controller\_facade ```rust theme={null} pub fn has_controller_facade(env: &Env) -> bool ``` ### is\_registry\_config\_finalized ```rust theme={null} pub fn is_registry_config_finalized(env: &Env) -> bool ``` ### finalize\_registry\_config ```rust theme={null} pub fn finalize_registry_config(env: &Env) ``` ### queue\_register\_controller ```rust theme={null} pub fn queue_register_controller( env: &Env, target: Address, controller: Address, tvl_cap_usd_wad: u128, ) ``` ### register\_controller ```rust theme={null} pub fn register_controller(env: &Env, target: Address) ``` ### cancel\_register\_controller ```rust theme={null} pub fn cancel_register_controller(env: &Env, target: Address) ``` ### deregister\_controller ```rust theme={null} pub fn deregister_controller(env: &Env, target: Address) ``` ### get\_controller\_for ```rust theme={null} pub fn get_controller_for(env: &Env, target: Address) -> Option
``` ### get\_controller\_tvl\_cap ```rust theme={null} pub fn get_controller_tvl_cap(env: &Env, controller: Address) -> Option ``` ### get\_protocol\_config ```rust theme={null} pub fn get_protocol_config(env: &Env) -> vanna_common::types::ProtocolConfig ``` ### get\_revoked\_flags ```rust theme={null} pub fn get_revoked_flags(env: &Env, symbols: Vec) -> Vec ``` ### get\_exec\_gate ```rust theme={null} pub fn get_exec_gate( env: &Env, target: Address, tokens: Vec
, ) -> vanna_common::types::ExecGate ``` ### queue\_set\_token\_allowed ```rust theme={null} pub fn queue_set_token_allowed(env: &Env, token_addr: Address, allowed: bool) ``` ### set\_token\_allowed ```rust theme={null} pub fn set_token_allowed(env: &Env, token_addr: Address) ``` ### cancel\_set\_token\_allowed ```rust theme={null} pub fn cancel_set_token_allowed(env: &Env, token_addr: Address) ``` ### deregister\_token ```rust theme={null} pub fn deregister_token(env: &Env, token_addr: Address) ``` ### is\_token\_allowed ```rust theme={null} pub fn is_token_allowed(env: &Env, token_addr: Address) -> bool ``` ### queue\_set\_asset\_meta ```rust theme={null} pub fn queue_set_asset_meta(env: &Env, token_addr: Address, meta: AssetMeta) ``` ### set\_asset\_meta ```rust theme={null} pub fn set_asset_meta(env: &Env, token_addr: Address) ``` ### cancel\_set\_asset\_meta ```rust theme={null} pub fn cancel_set_asset_meta(env: &Env, token_addr: Address) ``` ### get\_asset\_meta ```rust theme={null} pub fn get_asset_meta(env: &Env, token_addr: Address) -> Option ``` ### get\_registered\_assets ```rust theme={null} pub fn get_registered_assets(env: &Env) -> Vec ``` ### backfill\_asset\_list ```rust theme={null} pub fn backfill_asset_list(env: &Env, tokens: Vec
) ``` ### get\_token\_address\_for ```rust theme={null} pub fn get_token_address_for(env: &Env, symbol: Symbol) -> Option
``` ### get\_price\_feed\_for ```rust theme={null} pub fn get_price_feed_for(env: &Env, symbol: Symbol) -> Option ``` ### register\_token\_alias ```rust theme={null} pub fn register_token_alias(env: &Env, symbol: Symbol, address: Address) ``` ### get\_lending\_pool\_for ```rust theme={null} pub fn get_lending_pool_for(env: &Env, token_addr: Address) -> Option
``` ### get\_lending\_pool\_for\_symbol ```rust theme={null} pub fn get_lending_pool_for_symbol(env: &Env, symbol: Symbol) -> Option
``` ### queue\_set\_tracking\_meta ```rust theme={null} pub fn queue_set_tracking_meta(env: &Env, symbol: Symbol, meta: TrackingMeta) ``` ### set\_tracking\_meta ```rust theme={null} pub fn set_tracking_meta(env: &Env, symbol: Symbol) ``` ### cancel\_set\_tracking\_meta ```rust theme={null} pub fn cancel_set_tracking_meta(env: &Env, symbol: Symbol) ``` ### deregister\_tracking\_meta ```rust theme={null} pub fn deregister_tracking_meta(env: &Env, symbol: Symbol) ``` ### get\_tracking\_meta ```rust theme={null} pub fn get_tracking_meta(env: &Env, symbol: Symbol) -> Option ``` ### get\_blend\_tracking\_symbol\_for ```rust theme={null} pub fn get_blend_tracking_symbol_for(env: &Env, token_addr: Address) -> Option ``` ### is\_tracking\_symbol ```rust theme={null} pub fn is_tracking_symbol(env: &Env, symbol: Symbol) -> bool ``` ### get\_all\_tracking\_symbols ```rust theme={null} pub fn get_all_tracking_symbols(env: &Env) -> Vec ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/RegistryContract/src/registry.rs` # Risk Engine Source: https://docs.vanna.finance/stellar/developers/contracts/risk-engine Current testnet implementation, behavior, authorization, and Rust signatures. RiskEngine values collateral and debt in USD WAD and exposes borrow, withdrawal, execution, and liquidation checks. ## Health factor `HF = collateral_usd / debt_usd`. Healthy means **strictly greater than 1.1**; a priced account with debt at or below 1.1 is liquidation eligible, subject to execution checks. `get_health_factor` returns a WAD `u128`, or `u128::MAX` for zero debt. For a new gross borrow B, the standalone guard evaluates `(C + B) / (D + B)`. Existing borrowed proceeds already included in C are not added a second time. AccountManager/SmartAccount fast paths and net borrow credits must also be respected; this formula is not a transaction quote. ## Collateral valuation Plain tokens use registered metadata, native decimal conversion, and canonical oracle feeds. Explicitly revoked collateral is excluded. Tracking positions use Registry `TrackingMeta`: | Kind | Valuation | | - | - | | `BlendUnderlying` | Receipt balance × Blend reserve b\_rate, converted to underlying USD | | `LpSoroswap` | User share of conservatively valued committed pair reserves | | `LpAquarius` | User share of conservatively valued committed pool reserves | | `Unpriced` | Zero | LP pool USD value is **2 × min(USD value of each reserve side)**, not the unrestricted sum of both sides. Freeze/revocation and missing data can remove collateral value. Borrow/withdraw snapshots may use cached Blend/LP values; liquidation reads its own snapshot and external positions. LP collateral is not categorically zero. ## Liquidation-safe reads `liquidation_snapshot` returns `(collateral_usd_wad, debt_usd_wad, unpriceable_plain)`. AccountManager refuses liquidation when `unpriceable_plain` is true. Missing debt resolution or debt prices receive conservative maximum-value treatment. Some unavailable external collateral contributes zero. A displayed HF is therefore insufficient to guarantee liquidation execution. AccountManager may use SmartAccount prechecks instead of calling these standalone guards. Its admin-configurable live gate also controls post-borrow RiskEngine checks. Admin can pause guarded operations, change Registry, transfer administration in two steps, and upgrade WASM. Read deployment and liquidation configuration getters to inspect the selected contracts. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: &Env, admin: Address, registry_contract: Address) ``` ### get\_liquidation\_config ```rust theme={null} pub fn get_liquidation_config(_env: &Env) -> (u128, u128, bool) ``` ### get\_deployment\_config ```rust theme={null} pub fn get_deployment_config(env: &Env) -> (Address, Address) ``` ### is\_borrow\_allowed ```rust theme={null} pub fn is_borrow_allowed( env: &Env, symbol: Symbol, borrow_amount_wad: U256, margin_account: Address, ) -> Result ``` ### lp\_position\_usd\_wad ```rust theme={null} pub fn lp_position_usd_wad( env: &Env, margin_account: Address, lp_symbol: Symbol, ) -> U256 ``` ### account\_usd\_totals ```rust theme={null} pub fn account_usd_totals( env: &Env, margin_account: Address, ) -> Result<(U256, U256), RiskEngineError> ``` ### account\_usd\_totals\_liq\_safe ```rust theme={null} pub fn account_usd_totals_liq_safe( env: &Env, margin_account: Address, ) -> Result<(U256, U256), RiskEngineError> ``` ### has\_unpriceable\_plain\_collateral ```rust theme={null} pub fn has_unpriceable_plain_collateral(env: &Env, margin_account: Address) -> bool ``` ### is\_deposit\_borrow\_allowed ```rust theme={null} pub fn is_deposit_borrow_allowed( env: &Env, deposit_symbol: Symbol, deposit_amount_wad: U256, borrow_symbol: Symbol, borrow_amount_wad: U256, margin_account: Address, ) -> Result ``` ### is\_withdraw\_allowed ```rust theme={null} pub fn is_withdraw_allowed( env: &Env, symbol: Symbol, withdraw_amount_wad: U256, margin_account: Address, ) -> Result ``` ### is\_account\_healthy ```rust theme={null} pub fn is_account_healthy( env: &Env, total_account_balance_wad: U256, total_account_debt_wad: U256, ) -> Result ``` ### get\_health\_factor ```rust theme={null} pub fn get_health_factor(env: &Env, margin_account: Address) -> u128 ``` ### get\_health\_factor\_threshold ```rust theme={null} pub fn get_health_factor_threshold(_env: &Env) -> u128 ``` ### get\_current\_total\_balance ```rust theme={null} pub fn get_current_total_balance( env: &Env, margin_account: Address, ) -> Result ``` ### get\_total\_balance\_liq\_safe ```rust theme={null} pub fn get_total_balance_liq_safe( env: &Env, margin_account: Address, ) -> Result ``` ### get\_current\_total\_borrows ```rust theme={null} pub fn get_current_total_borrows( env: &Env, margin_account: Address, ) -> Result ``` ### get\_total\_borrows\_liq\_safe ```rust theme={null} pub fn get_total_borrows_liq_safe( env: &Env, margin_account: Address, ) -> Result ``` ### debt\_usd\_wad ```rust theme={null} pub fn debt_usd_wad(env: &Env, margin_account: Address) -> Result ``` ### is\_still\_healthy\_after\_execute ```rust theme={null} pub fn is_still_healthy_after_execute( env: &Env, margin_account: Address, known_debt_usd: U256, ) -> Result ``` ### is\_currently\_healthy ```rust theme={null} pub fn is_currently_healthy(env: &Env, margin_account: Address) -> Result ``` ### liquidation\_snapshot ```rust theme={null} pub fn liquidation_snapshot(env: &Env, margin_account: Address) -> (U256, U256, bool) ``` ### is\_account\_healthy\_liq\_safe ```rust theme={null} pub fn is_account_healthy_liq_safe(env: &Env, margin_account: Address) -> Result ``` ### mul\_wad\_down ```rust theme={null} pub fn mul_wad_down(env: &Env, a: U256, b: U256) -> U256 ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### set\_registry ```rust theme={null} pub fn set_registry(env: &Env, new_registry: Address) ``` ### propose\_admin ```rust theme={null} pub fn propose_admin(env: &Env, proposed: Address) ``` ### accept\_admin ```rust theme={null} pub fn accept_admin(env: &Env) ``` ### set\_paused ```rust theme={null} pub fn set_paused(env: &Env, paused: bool) ``` ### is\_paused ```rust theme={null} pub fn is_paused(env: &Env) -> bool ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/RiskEngineContract/src/risk_engine.rs` # Shared Types and Units Source: https://docs.vanna.finance/stellar/developers/contracts/shared-types Controller actions, configuration, tracking metadata, and fixed-point units. `vanna-common` is a shared Rust library, not a separately deployed contract. It defines controller interfaces, arithmetic helpers, TTL constants, and the types below. `ExternalAction::PlaceOrder` is a type variant; none of the three current controllers implements a perpetual-order integration. An enum variant is not product availability. `TokenDeltas` contains signed WAD collateral changes. Controller execution can constrain credits by ledger and oracle value; consumers must not equate every delta with a raw wallet balance change. ```rust theme={null} use soroban_sdk::{contracttype, Address, BytesN, Symbol, Vec}; #[contracttype] #[derive(Clone)] pub struct AssetConfig { pub native_asset_address: Address, pub asset_symbol: Symbol, pub vtoken_symbol: Symbol, } // ───────────────────────────────────────────────────────────────────────────── // Controller-facade port, Phase 4 — the shared controller interface types. // ───────────────────────────────────────────────────────────────────────────── #[contracttype] #[derive(Clone, Debug, Eq, PartialEq)] pub enum ExternalAction { Supply, Withdraw, Swap, AddLiquidity, RemoveLiquidity, PlaceOrder, } #[contracttype] #[derive(Clone, Debug, Eq, PartialEq)] pub struct TokenDeltas { pub tokens: Vec
, pub deltas: Vec, } // ───────────────────────────────────────────────────────────────────────────── // Budget optimization — batched Registry reads. // // Every cross-contract invocation instantiates a wasm VM and is charged to the // per-tx budget; the exec pipeline (AM → controller → vault → external // protocol) previously performed 12-14 SEPARATE single-value Registry reads, // which alone exhausted the transaction memory budget on the real network. // These structs let each participant fetch everything it needs from the // Registry in ONE call. // ───────────────────────────────────────────────────────────────────────────── #[contracttype] #[derive(Clone, Debug, Eq, PartialEq)] pub struct ProtocolConfig { pub account_manager: Address, pub oracle: Address, pub tracking_token: Address, pub xlm: Address, pub usdc: Address, pub aquarius_usdc: Option
, pub soroswap_usdc: Option
, pub blend_pool: Option
, pub aquarius_router: Option
, pub soroswap_router: Option
, pub aquarius_pool_index: Option>, } #[contracttype] #[derive(Clone, Debug, Eq, PartialEq)] pub struct ExecGate { pub controller: Option
, pub tvl_cap: u128, pub tokens_allowed: bool, } // ───────────────────────────────────────────────────────────────────────────── // Tracking-token registry (generic external-protocol position receipts). // ───────────────────────────────────────────────────────────────────────────── #[contracttype] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum TrackingValuationKind { BlendUnderlying = 0, LpSoroswap = 1, LpAquarius = 2, Unpriced = 3, } #[contracttype] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum TrackingUnwindKind { BlendWithdraw = 0, LpRemoveWad = 1, LpRemoveRaw = 2, } #[contracttype] #[derive(Clone, Debug, Eq, PartialEq)] pub struct TrackingMeta { pub symbol: Symbol, pub target: Address, pub valuation_kind: TrackingValuationKind, pub unwind_kind: TrackingUnwindKind, pub price_feed: Symbol, pub token_legs: Vec
, } ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/vanna-common/src/types.rs` * `Protocol_V1_Soroban_testnet/contracts/vanna-common/src/controller.rs` * `Protocol_V1_Soroban_testnet/contracts/vanna-common/src/math.rs` * `Protocol_V1_Soroban_testnet/contracts/vanna-common/src/ttl.rs` # SmartAccount Source: https://docs.vanna.finance/stellar/developers/contracts/smart-account Current testnet implementation, behavior, authorization, and Rust signatures. Each margin account is a separate contract holding real tokens and accounting state for its trader. It is controlled through AccountManager and registered controller callbacks; the owner does not have unrestricted arbitrary-call access. ## Ledger and snapshots The V2 ledger uses token contract addresses for plain assets and tracking symbols for external positions. This prevents similarly named test tokens from sharing a balance. Debt is represented by lending-pool shares; `get_borrowed_token_debt` resolves the pool and reads its debt value. Batched getters expose collateral lists, debt lists, ledger balances, and valuation snapshots. Blend underlying and LP USD caches reduce cross-contract calls on constrained execution paths. A cached valuation is not proof of a current market quote. Manager refresh methods update these caches; liquidation uses a separate valuation path. ## Custody and callbacks `authorize_and_call` permits registered controller execution. `manager_authorize_and_call` is the manager-controlled counterpart. `update_tokens_in` and `update_tokens_out` apply controller deltas to the collateral ledger. Swap credits may be capped at oracle input value, so a raw token balance and accounted collateral need not match. `sync_tracking_for_target` maintains external-position membership; Blend callbacks refresh underlying estimates. `repay_borrowed_token_to_pool` transfers account-held tokens and decrements collateral by the native amount actually paid, with a minimum native unit for positive dust repayment. ## Closing and sweeping `sweep_to` moves held direct collateral. `transfer_held_token_to` permits LP seizure during liquidation. `sweep_to_split` exists, but the current AccountManager liquidation path calls `sweep_to`, not the split helper. `close_account` on AccountManager performs external unwind and deactivation; repayment and liquidation alone do not close the account. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor( env: Env, account_manager: Address, registry_contract: Address, user_address: Address, ) ``` ### deactivate\_account ```rust theme={null} pub fn deactivate_account(env: &Env) -> Result<(), SmartAccountError> ``` ### activate\_account ```rust theme={null} pub fn activate_account(env: &Env) -> Result<(), SmartAccountError> ``` ### remove\_borrowed\_token\_balance ```rust theme={null} pub fn remove_borrowed_token_balance( env: Env, token_symbol: Symbol, amount_wad: u128, ) -> Result<(), SmartAccountError> ``` ### remove\_collateral\_token\_balance ```rust theme={null} pub fn remove_collateral_token_balance( env: &Env, user_address: Address, token_symbol: Symbol, amount_wad: u128, ) -> Result<(), SmartAccountError> ``` ### sweep\_to ```rust theme={null} pub fn sweep_to(env: &Env, to_address: Address) -> Result<(), SmartAccountError> ``` ### transfer\_held\_token\_to ```rust theme={null} pub fn transfer_held_token_to( env: &Env, to_address: Address, token_address: Address, amount: i128, ) -> Result<(), SmartAccountError> ``` ### sweep\_to\_split ```rust theme={null} pub fn sweep_to_split( env: &Env, to_first: Address, to_second: Address, to_first_bps: u32, ) -> Result<(), SmartAccountError> ``` ### has\_debt ```rust theme={null} pub fn has_debt(env: &Env) -> bool ``` ### set\_has\_debt ```rust theme={null} pub fn set_has_debt(env: &Env, has_debt: bool) ``` ### get\_all\_borrowed\_tokens ```rust theme={null} pub fn get_all_borrowed_tokens(env: &Env) -> Vec ``` ### get\_asset\_lists ```rust theme={null} pub fn get_asset_lists(env: &Env) -> (Vec, Vec) ``` ### get\_collateral\_ledger\_snapshot ```rust theme={null} pub fn get_collateral_ledger_snapshot(env: &Env) -> (Vec, Vec) ``` ### get\_debt\_snapshot ```rust theme={null} pub fn get_debt_snapshot(env: &Env) -> (Vec, Vec) ``` ### get\_health\_snapshot ```rust theme={null} pub fn get_health_snapshot( env: &Env, ) -> (Vec, Vec, Vec, Vec) ``` ### get\_valuation\_snapshot ```rust theme={null} pub fn get_valuation_snapshot( env: &Env, ) -> ( Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec, ) ``` ### set\_lp\_usd\_wad\_cache ```rust theme={null} pub fn set_lp_usd_wad_cache(env: &Env, lp_symbol: Symbol, usd_wad: U256) ``` ### refresh\_lp\_cache\_all ```rust theme={null} pub fn refresh_lp_cache_all(env: &Env, lp_symbols: Vec, lp_usd_wads: Vec) ``` ### debt\_usd\_wad\_cache ```rust theme={null} pub fn debt_usd_wad_cache(env: &Env) -> U256 ``` ### refresh\_usd\_valuation\_cache ```rust theme={null} pub fn refresh_usd_valuation_cache(env: &Env) ``` ### refresh\_blend\_underlying\_wad ```rust theme={null} pub fn refresh_blend_underlying_wad(env: &Env, tracking_symbol: Symbol) ``` ### refresh\_blend\_cache\_all ```rust theme={null} pub fn refresh_blend_cache_all(env: &Env) ``` ### is\_deposit\_borrow\_precheck ```rust theme={null} pub fn is_deposit_borrow_precheck( env: &Env, deposit_symbol: Symbol, deposit_amount_wad: U256, borrow_symbol: Symbol, borrow_amount_wad: U256, live_debt: bool, ) -> bool ``` ### is\_borrow\_precheck ```rust theme={null} pub fn is_borrow_precheck(env: &Env, borrow_symbol: Symbol, borrow_amount_wad: U256) -> bool ``` ### refresh\_token\_directory ```rust theme={null} pub fn refresh_token_directory(env: &Env) ``` ### get\_assets ```rust theme={null} pub fn get_assets(env: &Env) -> Vec ``` ### get\_collateral\_token\_addrs ```rust theme={null} pub fn get_collateral_token_addrs(env: &Env) -> Vec
``` ### get\_borrows ```rust theme={null} pub fn get_borrows(env: &Env) -> Vec
``` ### get\_collateral\_balance ```rust theme={null} pub fn get_collateral_balance(env: &Env, token: Address) -> U256 ``` ### migrate\_ledger\_to\_v2 ```rust theme={null} pub fn migrate_ledger_to_v2(env: &Env) -> Result<(), SmartAccountError> ``` ### authorize\_and\_call ```rust theme={null} pub fn authorize_and_call( env: &Env, target: Address, func: Symbol, args: Vec, auth_entries: Vec, ) -> Val ``` ### manager\_authorize\_and\_call ```rust theme={null} pub fn manager_authorize_and_call( env: &Env, target: Address, func: Symbol, args: Vec, auth_entries: Vec, ) -> Val ``` ### update\_tokens\_in ```rust theme={null} pub fn update_tokens_in( env: &Env, tokens: Vec
, amounts_wad: Vec, max_asset_cap_wad: U256, ) -> bool ``` ### update\_tokens\_out ```rust theme={null} pub fn update_tokens_out(env: &Env, tokens: Vec
, amounts_wad: Vec) ``` ### sync\_tracking\_for\_target ```rust theme={null} pub fn sync_tracking_for_target( env: &Env, target: Address, tracking_symbol: Symbol, keep_tracked: bool, ) ``` ### refresh\_blend\_cache\_for\_target ```rust theme={null} pub fn refresh_blend_cache_for_target(env: &Env, target: Address, tracking_symbol: Symbol) ``` ### add\_borrowed\_token ```rust theme={null} pub fn add_borrowed_token(env: &Env, token_symbol: Symbol) -> Result<(), SmartAccountError> ``` ### record\_new\_borrow ```rust theme={null} pub fn record_new_borrow(env: &Env, borrowed_sym: Symbol, max_asset_cap_wad: U256) -> bool ``` ### remove\_borrowed\_token ```rust theme={null} pub fn remove_borrowed_token(env: &Env, token_symbol: Symbol) -> Result<(), SmartAccountError> ``` ### get\_all\_collateral\_tokens ```rust theme={null} pub fn get_all_collateral_tokens(env: &Env) -> Vec ``` ### add\_collateral\_token ```rust theme={null} pub fn add_collateral_token(env: &Env, token_symbol: Symbol) -> Result<(), SmartAccountError> ``` ### remove\_collateral\_token ```rust theme={null} pub fn remove_collateral_token(env: &Env, token_symbol: Symbol) -> Result<(), SmartAccountError> ``` ### get\_collateral\_token\_balance ```rust theme={null} pub fn get_collateral_token_balance(env: &Env, token_symbol: Symbol) -> U256 ``` ### set\_collateral\_token\_balance ```rust theme={null} pub fn set_collateral_token_balance( env: &Env, token_symbol: Symbol, balance_wad: U256, ) -> Result<(), SmartAccountError> ``` ### credit\_borrow\_collateral ```rust theme={null} pub fn credit_borrow_collateral( env: &Env, token_symbol: Symbol, received_wad: U256, max_asset_cap_wad: U256, ) -> bool ``` ### credit\_deposit\_collateral ```rust theme={null} pub fn credit_deposit_collateral( env: &Env, token_symbol: Symbol, actual_deposited_wad: U256, max_asset_cap_wad: U256, ) -> bool ``` ### record\_borrow\_and\_credit ```rust theme={null} pub fn record_borrow_and_credit( env: &Env, borrowed_sym: Symbol, received_wad: U256, gross_borrow_wad: U256, max_asset_cap_wad: U256, ) -> bool ``` ### apply\_deposit\_borrow\_ledger ```rust theme={null} pub fn apply_deposit_borrow_ledger( env: &Env, deposit_token: Symbol, deposit_wad: U256, borrowed_sym: Symbol, borrow_received_wad: U256, gross_borrow_wad: U256, max_asset_cap_wad: U256, include_deposit: bool, include_borrow: bool, ) -> bool ``` ### sync\_tracking\_collateral ```rust theme={null} pub fn sync_tracking_collateral( env: &Env, tracking_symbol: Symbol, max_asset_cap_wad: U256, keep_tracked: bool, ) -> bool ``` ### get\_borrowed\_token\_debt ```rust theme={null} pub fn get_borrowed_token_debt( env: &Env, token_symbol: Symbol, ) -> Result ``` ### clear\_account\_state ```rust theme={null} pub fn clear_account_state(env: &Env) -> Result<(), SmartAccountError> ``` ### repay\_borrowed\_token\_to\_pool ```rust theme={null} pub fn repay_borrowed_token_to_pool( env: Env, token_symbol: Symbol, amount_wad: u128, ) -> Result<(), SmartAccountError> ``` ### is\_account\_active ```rust theme={null} pub fn is_account_active(env: &Env) -> bool ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/SmartAccountContract/src/smart_account.rs` # Soroswap Controller Source: https://docs.vanna.finance/stellar/developers/contracts/soroswap-controller Current testnet implementation, behavior, authorization, and Rust signatures. SoroswapController supports `Swap`, `AddLiquidity`, and `RemoveLiquidity` through the configured Soroswap router. It validates the action/token combination and uses SmartAccount custody and contract authorization. Swap and add-liquidity input amounts are WAD. The remove-liquidity path accepts **raw native LP units** in its amount vector. Swap `min_out` is native output-token units. Add/remove pass `min_out / 2` as each native leg minimum and use router deadlines; do not apply a single generic WAD interpretation to every argument. The controller sizes liquidity using committed reserve ratios, calls the router, synchronizes LP tracking membership, and returns signed WAD ledger deltas. Swap output credit is limited by accounted input and oracle value, so received token balance can exceed collateral credit. The testnet pair uses **SoUSDC**, not Blend USDC or AqUSDC. Exact addresses and pair configuration come from Registry and frontend configuration. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, registry: Address, admin: Address) ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ### can\_call ```rust theme={null} pub fn can_call( env: &Env, target: Address, action: ExternalAction, tokens: Vec
, ) -> (bool, Vec
, Vec
) ``` ### execute ```rust theme={null} pub fn execute( env: &Env, account: Address, action: ExternalAction, tokens: Vec
, amounts: Vec, min_out: u128, ) -> TokenDeltas ``` ### get\_registry ```rust theme={null} pub fn get_registry(env: &Env) -> Address ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/SoroswapControllerContract/src/controller.rs` # Tracking Tokens Source: https://docs.vanna.finance/stellar/developers/contracts/tracking-tokens Current testnet implementation, behavior, authorization, and Rust signatures. TrackingToken stores per-account, per-symbol external-position receipts. It is an accounting registry, not a freely transferable wallet token or a lending-pool vToken. ## Metadata and balances Initialization is per symbol. The contract has admin and deployer roles, with admin-authorized minters for controller operations. `mint_by` and `burn_by` require the specified authorized minter; `mint` and `burn` use the admin path. Freeze and supply/balance checks apply as implemented by each entrypoint. Registry metadata, not a fixed list in RiskEngine, determines what a symbol represents. Blend receipts track b-token units. AMM position accounting also consults actual LP token balances and synchronizes tracking membership; do not assume every LP operation mints synthetic receipts by the legacy `execute()` return value. | Configured symbol | Position | | - | - | | `BLEND_XLM` | Blend XLM supply | | `BLEND_USDC` | Blend's USDC supply | | `AQ_XLM_USDC` | Aquarius XLM/AqUSDC LP | | `SS_XLM_USDC` | Soroswap XLM/SoUSDC LP | Blend and registered AMM LP positions can contribute collateral value. `Unpriced` metadata and frozen/revoked positions are treated differently. See [Risk Engine](/stellar/developers/contracts/risk-engine). ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, admin: Address, deployer: Address) ``` ### rotate\_deployer ```rust theme={null} pub fn rotate_deployer(env: Env, new_deployer: Address) ``` ### initialize ```rust theme={null} pub fn initialize( env: Env, admin: Address, token_symbol: Symbol, decimal: u32, name: String, ) -> Result<(), TokenError> ``` ### admin ```rust theme={null} pub fn admin(env: Env) -> Address ``` ### set\_admin ```rust theme={null} pub fn set_admin(env: Env, new_admin: Address) -> Result<(), TokenError> ``` ### decimals ```rust theme={null} pub fn decimals(env: Env, token_symbol: Symbol) -> u32 ``` ### name ```rust theme={null} pub fn name(env: Env, token_symbol: Symbol) -> String ``` ### symbol ```rust theme={null} pub fn symbol(env: Env, token_symbol: Symbol) -> Symbol ``` ### balance ```rust theme={null} pub fn balance(env: Env, id: Address, token_symbol: Symbol) -> i128 ``` ### total\_supply ```rust theme={null} pub fn total_supply(env: Env, token_symbol: Symbol) -> i128 ``` ### mint ```rust theme={null} pub fn mint( env: Env, token_symbol: Symbol, to: Address, amount: i128, ) -> Result<(), TokenError> ``` ### set\_authorized\_minter ```rust theme={null} pub fn set_authorized_minter( env: Env, minter: Address, authorized: bool, ) -> Result<(), TokenError> ``` ### is\_authorized\_minter ```rust theme={null} pub fn is_authorized_minter(env: Env, minter: Address) -> bool ``` ### mint\_by ```rust theme={null} pub fn mint_by( env: Env, minter: Address, token_symbol: Symbol, to: Address, amount: i128, ) -> Result<(), TokenError> ``` ### burn\_by ```rust theme={null} pub fn burn_by( env: Env, minter: Address, token_symbol: Symbol, from: Address, amount: i128, ) -> Result<(), TokenError> ``` ### burn ```rust theme={null} pub fn burn( env: Env, token_symbol: Symbol, from: Address, amount: i128, ) -> Result<(), TokenError> ``` ### burn\_from ```rust theme={null} pub fn burn_from( env: Env, token_symbol: Symbol, from: Address, amount: i128, ) -> Result<(), TokenError> ``` ### set\_frozen ```rust theme={null} pub fn set_frozen(env: Env, id: Address, freeze: bool) -> Result<(), TokenError> ``` ### frozen ```rust theme={null} pub fn frozen(env: Env, id: Address) -> bool ``` ### upgrade ```rust theme={null} pub fn upgrade(env: Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/TrackingTokenContract/src/tracking_token.rs` # vTokens Source: https://docs.vanna.finance/stellar/developers/contracts/vtokens Current testnet implementation, behavior, authorization, and Rust signatures. Each lending pool controls a separate receipt-token deployment. The frontend configures four receipts: vXLM, vBLEND\_USDC, vAQUARIUS\_USDC, and vSOROSWAP\_USDC. Use [configured addresses](/stellar/developers/deployed-contracts) and token metadata for exact tickers and decimals. ## Pool shares A receipt represents a claim on pool assets, including outstanding borrow interest. The exact conversion includes a virtual offset and native decimal rounding; use pool conversion getters rather than assuming one receipt always equals one underlying token. Pool methods take WAD quantities; token `balance`, `transfer`, `mint`, and `burn` use native `i128` quantities. Underlying and receipt decimals must each be read independently. ## Authorization and controls Construction sets an admin; initialization supplies metadata and authenticates the configured admin. The lending pool normally controls mint/burn. Holder transfers and allowance-based transfers require their respective authorizations. Admin controls include maximum supply and account authorization/freeze state. Transfers can be blocked by freeze state; unconditional transferability is not guaranteed. Pool-directed burn is permitted for exit even when receipt receiving/transfers are frozen. Holding vTokens does not itself add collateral to a margin account. Earn positions and margin custody are separate. ## Function signatures These signatures are copied from the reviewed Rust implementation. `env` is supplied by Soroban and is not a transaction argument. `Result` errors and panics must be handled by the caller; simulation does not guarantee later execution. Public methods include privileged and internal-contract callbacks, not just user entrypoints. ### \_\_constructor ```rust theme={null} pub fn __constructor(env: Env, admin: Address) ``` ### initialize ```rust theme={null} pub fn initialize( env: Env, admin: Address, decimal: u32, name: String, symbol: String, ) -> Result<(), TokenError> ``` ### admin ```rust theme={null} pub fn admin(env: Env) -> Address ``` ### set\_admin ```rust theme={null} pub fn set_admin(env: Env, new_admin: Address) -> Result<(), TokenError> ``` ### set\_max\_supply ```rust theme={null} pub fn set_max_supply(env: Env, max_supply: i128) -> Result<(), TokenError> ``` ### max\_supply ```rust theme={null} pub fn max_supply(env: Env) -> Option ``` ### decimals ```rust theme={null} pub fn decimals(env: Env) -> u32 ``` ### name ```rust theme={null} pub fn name(env: Env) -> String ``` ### symbol ```rust theme={null} pub fn symbol(env: Env) -> String ``` ### balance ```rust theme={null} pub fn balance(env: Env, id: Address) -> i128 ``` ### total\_supply ```rust theme={null} pub fn total_supply(env: Env) -> i128 ``` ### allowance ```rust theme={null} pub fn allowance(env: Env, from: Address, spender: Address) -> i128 ``` ### approve ```rust theme={null} pub fn approve( env: Env, from: Address, spender: Address, amount: i128, expiration_ledger: u32, ) -> Result<(), TokenError> ``` ### transfer ```rust theme={null} pub fn transfer(env: Env, from: Address, to: Address, amount: i128) -> Result<(), TokenError> ``` ### transfer\_from ```rust theme={null} pub fn transfer_from( env: Env, spender: Address, from: Address, to: Address, amount: i128, ) -> Result<(), TokenError> ``` ### mint ```rust theme={null} pub fn mint(env: Env, to: Address, amount: i128) -> Result<(), TokenError> ``` ### burn ```rust theme={null} pub fn burn(env: Env, from: Address, amount: i128) -> Result<(), TokenError> ``` ### burn\_from ```rust theme={null} pub fn burn_from( env: Env, spender: Address, from: Address, amount: i128, ) -> Result<(), TokenError> ``` ### set\_authorized ```rust theme={null} pub fn set_authorized(env: Env, id: Address, authorize: bool) -> Result<(), TokenError> ``` ### authorized ```rust theme={null} pub fn authorized(env: Env, id: Address) -> bool ``` ### set\_frozen ```rust theme={null} pub fn set_frozen(env: Env, id: Address, freeze: bool) -> Result<(), TokenError> ``` ### frozen ```rust theme={null} pub fn frozen(env: Env, id: Address) -> bool ``` ### upgrade ```rust theme={null} pub fn upgrade(env: &Env, new_wasm_hash: BytesN<32>) ``` ## Source reference * `Protocol_V1_Soroban_testnet/contracts/v-token/src/token.rs` # Deployed Contracts Source: https://docs.vanna.finance/stellar/developers/deployed-contracts Every Vanna contract, lending pool, vToken, asset and external protocol address on Stellar testnet. These are the contracts the app at [test.vanna.finance](https://test.vanna.finance) uses. They match `CONTRACT_ADDRESSES` in `Vanna_Finance_Backend/apps/stellar/lib/stellar-utils.ts`, and every address was verified on-chain on **2026-10-24**. All Vanna contracts were deployed by `vanna_deployer` [`GAUVY7FNDKVWRMW3SYEMX6QMFSWQDKC6XIPJJKAMOEMLZPAI7XZPDV3D`](https://stellar.expert/explorer/testnet/account/GAUVY7FNDKVWRMW3SYEMX6QMFSWQDKC6XIPJJKAMOEMLZPAI7XZPDV3D). | Setting | Value | | - | - | | Network | Stellar testnet | | Network passphrase | `Test SDF Network ; September 2015` | | Soroban RPC | `https://soroban-testnet.stellar.org` | | Horizon | `https://horizon-testnet.stellar.org` | | Explorer | [stellar.expert/explorer/testnet](https://stellar.expert/explorer/testnet) | | Price source | Reflector, through the Vanna Oracle contract | ## Core | Contract | Address | Role | | - | - | - | | Registry | [`CBBQQULN3XZDWDZG7D6VYD4UQKBGYH22DOFQEISKENCMZTYUPQ5LDXUO`](https://stellar.expert/explorer/testnet/contract/CBBQQULN3XZDWDZG7D6VYD4UQKBGYH22DOFQEISKENCMZTYUPQ5LDXUO) | Central address book: assets, pools, controllers, and every margin account with its owner | | Account Manager | [`CAZLR6EHZXQNZJIFNP6F7SIJQC3P64MKHHQNZSSG5BNAEFCYTTGTDZXB`](https://stellar.expert/explorer/testnet/contract/CAZLR6EHZXQNZJIFNP6F7SIJQC3P64MKHHQNZSSG5BNAEFCYTTGTDZXB) | User entry point: create account, deposit, borrow, repay, withdraw, and route `execute()` calls | | Risk Engine | [`CCSCBA4WSUMVGA4CWC7QKBZXXEL4TO2YCCFPGHX5SJCYKHQLQUKAVUAY`](https://stellar.expert/explorer/testnet/contract/CCSCBA4WSUMVGA4CWC7QKBZXXEL4TO2YCCFPGHX5SJCYKHQLQUKAVUAY) | Values collateral, LP and debt positions; enforces the 1.10 health factor | | Oracle | [`CAYHPE4U54GDKULPRHYJZNDMBAJDQ3UNQ446KFYMJ5HABBPORERZCRWB`](https://stellar.expert/explorer/testnet/contract/CAYHPE4U54GDKULPRHYJZNDMBAJDQ3UNQ446KFYMJ5HABBPORERZCRWB) | Reflector-backed price feed for collateral and debt | | Rate Model | [`CBMJ7DD4EUVZWFRPKRPGYK2NADCIGY5OFTPN7PJ7SAOIJI7IQTVHOJT6`](https://stellar.expert/explorer/testnet/contract/CBMJ7DD4EUVZWFRPKRPGYK2NADCIGY5OFTPN7PJ7SAOIJI7IQTVHOJT6) | Utilization-based interest-rate curve for the lending pools | | Tracking Token | [`CC4P2DC4J3DTKNL7CQB42S3JSZNIVVHFJEMHZWTSDR233CT6O2KK7ZK2`](https://stellar.expert/explorer/testnet/contract/CC4P2DC4J3DTKNL7CQB42S3JSZNIVVHFJEMHZWTSDR233CT6O2KK7ZK2) | Per-account receipt for external positions (e.g. Blend supply) so the Risk Engine can value them | | Controller Facade | [`CB2SEZGDRPS4O56UYQAERQGHM7V6ZDMZZE5AYOGERRGWT5CUGRPVDWEH`](https://stellar.expert/explorer/testnet/contract/CB2SEZGDRPS4O56UYQAERQGHM7V6ZDMZZE5AYOGERRGWT5CUGRPVDWEH) | Resolves the protocol controller for each `execute()` target | | Pool Deployer | [`CCURFEEXKVGDAKXAGNG4NHEK2RRSOBOVUZDNHI32DFBAF2HWO57JKLIP`](https://stellar.expert/explorer/testnet/contract/CCURFEEXKVGDAKXAGNG4NHEK2RRSOBOVUZDNHI32DFBAF2HWO57JKLIP) | Factory for lending pools and their vTokens | ## Protocol controllers | Contract | Address | Role | | - | - | - | | Blend Controller | [`CCZVHCPWY47GRWCE2TB7QPX7Y54BMQUYQTTAQ5LJGNJ3GLGO77VVQUS3`](https://stellar.expert/explorer/testnet/contract/CCZVHCPWY47GRWCE2TB7QPX7Y54BMQUYQTTAQ5LJGNJ3GLGO77VVQUS3) | Blend supply / withdraw from a margin account | | Soroswap Controller | [`CBSUSG7PK2QKYBEA2GPNNTV7QVGKV7DSDUFDB44FFRZYR4L4GB7BKD2M`](https://stellar.expert/explorer/testnet/contract/CBSUSG7PK2QKYBEA2GPNNTV7QVGKV7DSDUFDB44FFRZYR4L4GB7BKD2M) | Soroswap swap / add / remove liquidity | | Aquarius Controller | [`CBVRH2DWBMASALAMPZ5JUCKZHWO6SA2MD4MBXMO644XNCERWBMKHL2WT`](https://stellar.expert/explorer/testnet/contract/CBVRH2DWBMASALAMPZ5JUCKZHWO6SA2MD4MBXMO644XNCERWBMKHL2WT) | Aquarius swap / add / remove liquidity (multi-pool) | ## Lending pools | Pool | Address | Underlying | | - | - | - | | XLM Lending Pool | [`CB3LCPDMPRTRXJHO7ZB3OORQDL2AV5FTJPPZOPHTZFOMUPMJY55RHYR3`](https://stellar.expert/explorer/testnet/contract/CB3LCPDMPRTRXJHO7ZB3OORQDL2AV5FTJPPZOPHTZFOMUPMJY55RHYR3) | Native XLM | | BLUSDC Lending Pool | [`CCHSDWJPFMEFNDRSZ55A5MLSTASYHZERLPJIJGTAD7MT24KHVLOU3BTI`](https://stellar.expert/explorer/testnet/contract/CCHSDWJPFMEFNDRSZ55A5MLSTASYHZERLPJIJGTAD7MT24KHVLOU3BTI) | Blend USDC | | AqUSDC Lending Pool | [`CDKMMD63RUZNROFZZD64QZNEQ2FR5X62R4FE6E3USJ5VN5KY7QM6F2FD`](https://stellar.expert/explorer/testnet/contract/CDKMMD63RUZNROFZZD64QZNEQ2FR5X62R4FE6E3USJ5VN5KY7QM6F2FD) | Aquarius USDC | | SoUSDC Lending Pool | [`CCZQUQQVZVNZMTG2P6MVAGA7V2DRTCII6IGVEQ5YUCYP7MXA7SMLHETP`](https://stellar.expert/explorer/testnet/contract/CCZQUQQVZVNZMTG2P6MVAGA7V2DRTCII6IGVEQ5YUCYP7MXA7SMLHETP) | Soroswap USDC | ## vTokens | Receipt | Address | Notes | | - | - | - | | vXLM | [`CDGYZSMWOOKM55WEKEQ2HEMM7RS2KRA7MYI2DDYXWV5YHGUVUGQZSOCB`](https://stellar.expert/explorer/testnet/contract/CDGYZSMWOOKM55WEKEQ2HEMM7RS2KRA7MYI2DDYXWV5YHGUVUGQZSOCB) | XLM Lending Pool receipt | | vBLUSDC | [`CAZWBJQ6V2XASUILI36UVQJ5K2EQXIDVXJZNGZBEONPUVVURKDOP4RX5`](https://stellar.expert/explorer/testnet/contract/CAZWBJQ6V2XASUILI36UVQJ5K2EQXIDVXJZNGZBEONPUVVURKDOP4RX5) | BLUSDC Lending Pool receipt | | vAqUSDC | [`CAU5GVAGCWLOIAGFHQFEVBJLDHVS2KH4YPRQ34CIDG2T7RDAWWWODKRV`](https://stellar.expert/explorer/testnet/contract/CAU5GVAGCWLOIAGFHQFEVBJLDHVS2KH4YPRQ34CIDG2T7RDAWWWODKRV) | AqUSDC Lending Pool receipt | | vSoUSDC | [`CAIMEE4EZ3FUMOBTVV7DKGI2TDACWXUWU6Z2RJ3NMP642TDKQHHOEIWG`](https://stellar.expert/explorer/testnet/contract/CAIMEE4EZ3FUMOBTVV7DKGI2TDACWXUWU6Z2RJ3NMP642TDKQHHOEIWG) | SoUSDC Lending Pool receipt | ## Assets | Asset | Token contract | Source | | - | - | - | | XLM (native SAC) | [`CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC`](https://stellar.expert/explorer/testnet/contract/CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC) | Stellar native, via Friendbot | | BLUSDC (Blend USDC) | [`CAQCFVLOBK5GIULPNZRGATJJMIZL5BSP7X5YJVMGCPTUEPFM4AVSRCJU`](https://stellar.expert/explorer/testnet/contract/CAQCFVLOBK5GIULPNZRGATJJMIZL5BSP7X5YJVMGCPTUEPFM4AVSRCJU) | Blend testnet faucet | | AqUSDC (Aquarius USDC) | [`CAZRY5GSFBFXD7H6GAFBA5YGYQTDXU4QKWKMYFWBAZFUCURN3WKX6LF5`](https://stellar.expert/explorer/testnet/contract/CAZRY5GSFBFXD7H6GAFBA5YGYQTDXU4QKWKMYFWBAZFUCURN3WKX6LF5) | Aquarius testnet faucet; classic issuer `GAHPYWLK6YRN7CVYZOO4H3VDRZ7PVF5UJGLZCSPAEIKJE2XSWF5LAGER` | | SoUSDC (Soroswap USDC) | [`CB3TLW74NBIOT3BUWOZ3TUM6RFDF6A4GVIRUQRQZABG5KPOUL4JJOV2F`](https://stellar.expert/explorer/testnet/contract/CB3TLW74NBIOT3BUWOZ3TUM6RFDF6A4GVIRUQRQZABG5KPOUL4JJOV2F) | Soroswap testnet faucet | > [!WARNING] > > BLUSDC, AqUSDC and SoUSDC are three different token contracts. They share a USDC price feed but are not interchangeable. ## External protocols | Contract | Address | Role | | - | - | - | | Blend Pool (TestnetV2) | [`CCEBVDYM32YNYCVNRXQKDFFPISJJCV557CDZEIRBEE4NCV4KHPQ44HGF`](https://stellar.expert/explorer/testnet/contract/CCEBVDYM32YNYCVNRXQKDFFPISJJCV557CDZEIRBEE4NCV4KHPQ44HGF) | Blend lending pool used by Farm (XLM and USDC reserves) | | Soroswap Router | [`CCJUD55AG6W5HAI5LRVNKAE5WDP5XGZBUDS5WNTIVDU7O264UZZE7BRD`](https://stellar.expert/explorer/testnet/contract/CCJUD55AG6W5HAI5LRVNKAE5WDP5XGZBUDS5WNTIVDU7O264UZZE7BRD) | Soroswap swap and liquidity router | | Soroswap XLM / SoUSDC pair | [`CDVAIOYHCD4RUSLQNVFI7RIZBFT2JZMJWM4RTOLQZQXL4QAVXU5RFKDB`](https://stellar.expert/explorer/testnet/contract/CDVAIOYHCD4RUSLQNVFI7RIZBFT2JZMJWM4RTOLQZQXL4QAVXU5RFKDB) | Pair contract and LP token | | Aquarius Router | [`CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD`](https://stellar.expert/explorer/testnet/contract/CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD) | Aquarius swap and liquidity router | | Aquarius XLM / AqUSDC pool | [`CD3LFMMLBQ6RBJUD3Z2LFDFE6544WDRMWHEZYPI5YDVESYRSO2TT32BX`](https://stellar.expert/explorer/testnet/contract/CD3LFMMLBQ6RBJUD3Z2LFDFE6544WDRMWHEZYPI5YDVESYRSO2TT32BX) | Constant-product pool used by Spot and Farm | ## Faucet accounts | Role | Account | | - | - | | Blend faucet | [`GATALTGTWIOT6BUDBCZM3Q4OQ4BO2COLOAZ7IYSKPLC2PMSOPPGF5V56`](https://stellar.expert/explorer/testnet/account/GATALTGTWIOT6BUDBCZM3Q4OQ4BO2COLOAZ7IYSKPLC2PMSOPPGF5V56) | | Aquarius faucet / AqUSDC issuer | [`GAHPYWLK6YRN7CVYZOO4H3VDRZ7PVF5UJGLZCSPAEIKJE2XSWF5LAGER`](https://stellar.expert/explorer/testnet/account/GAHPYWLK6YRN7CVYZOO4H3VDRZ7PVF5UJGLZCSPAEIKJE2XSWF5LAGER) | | Soroswap faucet | [`GCPJFNZAARY3Z2AM7RVXDZDLPOEBT4QHTQXFOFKMZHLV7PPDKE2M67Q6`](https://stellar.expert/explorer/testnet/account/GCPJFNZAARY3Z2AM7RVXDZDLPOEBT4QHTQXFOFKMZHLV7PPDKE2M67Q6) | A margin account (SmartAccount) address is per trader. Find yours through the app, or read it from the Registry; don't reuse another user's address. ## Frontend constants > **All CONTRACT\_ADDRESSES values (37)** > > `USDC_TOKEN`, `BLEND_USDC` and `BLEND_USDC_TOKEN` all point to Blend USDC. `VUSDC_TOKEN` and `LENDING_PROTOCOL_USDC` are back-compat aliases for the BLUSDC market. `AQUARIUS_XLM_USDT_POOL` is configured but hidden from Farm. > > | Constant | Value | > | - | - | > | `REGISTRY` | `CBBQQULN3XZDWDZG7D6VYD4UQKBGYH22DOFQEISKENCMZTYUPQ5LDXUO` | > | `ORACLE` | `CAYHPE4U54GDKULPRHYJZNDMBAJDQ3UNQ446KFYMJ5HABBPORERZCRWB` | > | `RATE_MODEL` | `CBMJ7DD4EUVZWFRPKRPGYK2NADCIGY5OFTPN7PJ7SAOIJI7IQTVHOJT6` | > | `RISK_ENGINE` | `CCSCBA4WSUMVGA4CWC7QKBZXXEL4TO2YCCFPGHX5SJCYKHQLQUKAVUAY` | > | `ACCOUNT_MANAGER` | `CAZLR6EHZXQNZJIFNP6F7SIJQC3P64MKHHQNZSSG5BNAEFCYTTGTDZXB` | > | `TRACKING_TOKEN` | `CC4P2DC4J3DTKNL7CQB42S3JSZNIVVHFJEMHZWTSDR233CT6O2KK7ZK2` | > | `CONTROLLER_FACADE` | `CB2SEZGDRPS4O56UYQAERQGHM7V6ZDMZZE5AYOGERRGWT5CUGRPVDWEH` | > | `POOL_DEPLOYER` | `CCURFEEXKVGDAKXAGNG4NHEK2RRSOBOVUZDNHI32DFBAF2HWO57JKLIP` | > | `BLEND_CONTROLLER` | `CCZVHCPWY47GRWCE2TB7QPX7Y54BMQUYQTTAQ5LJGNJ3GLGO77VVQUS3` | > | `SOROSWAP_CONTROLLER` | `CBSUSG7PK2QKYBEA2GPNNTV7QVGKV7DSDUFDB44FFRZYR4L4GB7BKD2M` | > | `AQUARIUS_CONTROLLER` | `CBVRH2DWBMASALAMPZ5JUCKZHWO6SA2MD4MBXMO644XNCERWBMKHL2WT` | > | `VXLM_TOKEN` | `CDGYZSMWOOKM55WEKEQ2HEMM7RS2KRA7MYI2DDYXWV5YHGUVUGQZSOCB` | > | `VBLEND_USDC_TOKEN` | `CAZWBJQ6V2XASUILI36UVQJ5K2EQXIDVXJZNGZBEONPUVVURKDOP4RX5` | > | `VAQUARIUS_USDC_TOKEN` | `CAU5GVAGCWLOIAGFHQFEVBJLDHVS2KH4YPRQ34CIDG2T7RDAWWWODKRV` | > | `VSOROSWAP_USDC_TOKEN` | `CAIMEE4EZ3FUMOBTVV7DKGI2TDACWXUWU6Z2RJ3NMP642TDKQHHOEIWG` | > | `VUSDC_TOKEN` | `CAZWBJQ6V2XASUILI36UVQJ5K2EQXIDVXJZNGZBEONPUVVURKDOP4RX5` | > | `LENDING_PROTOCOL_XLM` | `CB3LCPDMPRTRXJHO7ZB3OORQDL2AV5FTJPPZOPHTZFOMUPMJY55RHYR3` | > | `LENDING_PROTOCOL_BLEND_USDC` | `CCHSDWJPFMEFNDRSZ55A5MLSTASYHZERLPJIJGTAD7MT24KHVLOU3BTI` | > | `LENDING_PROTOCOL_AQUARIUS_USDC` | `CDKMMD63RUZNROFZZD64QZNEQ2FR5X62R4FE6E3USJ5VN5KY7QM6F2FD` | > | `LENDING_PROTOCOL_SOROSWAP_USDC` | `CCZQUQQVZVNZMTG2P6MVAGA7V2DRTCII6IGVEQ5YUCYP7MXA7SMLHETP` | > | `LENDING_PROTOCOL_USDC` | `CCHSDWJPFMEFNDRSZ55A5MLSTASYHZERLPJIJGTAD7MT24KHVLOU3BTI` | > | `BLEND_USDC_TOKEN` | `CAQCFVLOBK5GIULPNZRGATJJMIZL5BSP7X5YJVMGCPTUEPFM4AVSRCJU` | > | `AQUARIUS_USDC_TOKEN` | `CAZRY5GSFBFXD7H6GAFBA5YGYQTDXU4QKWKMYFWBAZFUCURN3WKX6LF5` | > | `SOROSWAP_USDC_TOKEN` | `CB3TLW74NBIOT3BUWOZ3TUM6RFDF6A4GVIRUQRQZABG5KPOUL4JJOV2F` | > | `USDC_TOKEN` | `CAQCFVLOBK5GIULPNZRGATJJMIZL5BSP7X5YJVMGCPTUEPFM4AVSRCJU` | > | `BLEND_POOL` | `CCEBVDYM32YNYCVNRXQKDFFPISJJCV557CDZEIRBEE4NCV4KHPQ44HGF` | > | `BLEND_XLM` | `CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC` | > | `BLEND_USDC` | `CAQCFVLOBK5GIULPNZRGATJJMIZL5BSP7X5YJVMGCPTUEPFM4AVSRCJU` | > | `AQUARIUS_ROUTER` | `CBCFTQSPDBAIZ6R6PJQKSQWKNKWH2QIV3I4J72SHWBIK3ADRRAM5A6GD` | > | `AQUARIUS_XLM_USDC_POOL` | `CD3LFMMLBQ6RBJUD3Z2LFDFE6544WDRMWHEZYPI5YDVESYRSO2TT32BX` | > | `AQUARIUS_USDC` | `CAZRY5GSFBFXD7H6GAFBA5YGYQTDXU4QKWKMYFWBAZFUCURN3WKX6LF5` | > | `AQUARIUS_POOL_INDEX_HEX` | `9ac7a9cde23ac2ada11105eeaa42e43c2ea8332ca0aa8f41f58d7160274d718e` | > | `AQUARIUS_XLM_USDT_POOL` | `CA6DAGOMK5D7GKBNWVCIEAYSTPJXLQUFWFKSZOMNEM6BVOTUBDCTIT5I` | > | `SOROSWAP_ROUTER` | `CCJUD55AG6W5HAI5LRVNKAE5WDP5XGZBUDS5WNTIVDU7O264UZZE7BRD` | > | `SOROSWAP_XLM` | `CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC` | > | `SOROSWAP_USDC` | `CB3TLW74NBIOT3BUWOZ3TUM6RFDF6A4GVIRUQRQZABG5KPOUL4JJOV2F` | > | `SOROSWAP_XLM_USDC_POOL` | `CDVAIOYHCD4RUSLQNVFI7RIZBFT2JZMJWM4RTOLQZQXL4QAVXU5RFKDB` | ## Verify a deployment Read the Registry's protocol configuration, asset metadata, controller mappings and tracking metadata. Check each pool's underlying and receipt, origination fee, pause flags and rate coefficients, and AccountManager's live execution gate. Compare the deployed WASM with the Rust source before assuming they match. ## Source reference * `Vanna_Finance_Backend/apps/stellar/lib/stellar-utils.ts` * `Stellar/docs/Vanna Protocol Stellar Contract Doc.md` (on-chain verification, 2026-10-24) * `Protocol_V1_Soroban_testnet/deploy/deploy.sh`, `deploy/verify.sh` # Frontend and Server APIs Source: https://docs.vanna.finance/stellar/developers/frontend Current routes, wallet flows, state, and feature availability. The Stellar app lives in the `Vanna_Finance_Backend` monorepo at `apps/stellar` (package `@vanna/stellar-app`). It is a Next.js application with both the frontend screens and their server API routes. Header, sign-in dialog, funds modal and mascot come from the shared workspace package `packages/shared`, which the Solana app also uses. The live testnet build is at [test.vanna.finance](https://test.vanna.finance). ## Screens | Route | Implemented behavior | | - | - | | `/` | Margin (the header's **Margin** link): Leverage your Assets, Repay Loan, Transfer Collateral, account info, liquidation meter, positions | | `/margin` | Same Margin screen | | `/portfolio` | Net worth, net earnings, health factor; Lender / Trader / Balances tabs | | `/earn`, `/earn/[id]` | Four lending markets (XLM, BLUSDC, AqUSDC, SoUSDC), supply and receipt redemption | | `/trade/spot` | Margin-account swaps through Soroswap or Aquarius, with health-factor preview and route | | `/trade/perps`, `/trade/options` | Redirect to `/trade/spot` | | `/farm`, `/farm/[id]` | Blend single-asset supply (XLM, BLUSDC) and Soroswap / Aquarius LP pools | | `/analytics` | Protocol risk Overview (`/analytics/overview2` maps to the same item) | | `/analytics/positions`, `/analytics/positions/[address]` | Address lookup and distribution by health, leverage and holdings | | `/analytics/accounts/[address]` | One margin account: health, what-if slider, holdings, recent events | | `/analytics/liquidations`, `/analytics/top-accounts`, `/analytics/alerts` | Liquidation candidates and history, largest borrowers and activity feed, derived alerts | | `/analytics/pools`, `/analytics/collateral`, `/analytics/prices` | Lending pools and the on-chain rate curve, collateral assets, Reflector prices | | `/analytics/what-if` | Read-only repricing of the account snapshot (also reached from `/analytics/stress-test`) | | `/analytics/risk-explorer`, `/analytics/risk-explorer/*` | Scenario hub and 12 stress scenarios run on the live account snapshot | | `/analytics/positions-advanced` | Collateral-type, correlated-group and borrow-rate views | | `/copilot` | Conversation, plan approval and execution, with a health / auto-approve / positions / recents sidebar | | `/rewards` | "Coming soon" placeholder | | `/stats` | Separately gated Hubble (mainnet) stats; 404 unless `STATS_ENABLED="true"` | There is no Pro/Lite mode in the current app. A visible pool row is not proof of an enabled controller route: the Aquarius config also has an XLM/USDT pool, which Farm hides (`HIDDEN_POOL_IDS`); the lending markets remain the four documented assets. ## Wallets and state The **Sign in to Vanna** dialog (`packages/shared/v4/connect-modal.tsx`) offers: | Option | Status on Stellar testnet | | - | - | | Freighter | Live | | OneKey | Live | | LOBSTR | Shown as "Soon" (its extension signs for mainnet only) | | Email code, Google, X, GitHub (Dynamic) | Shown only when the build sets a Dynamic environment ID (`dynamicEnabled` in `packages/shared/dynamic/dynamic-session.tsx`) | `lib/wallet-adapter.ts` gives every call site the same `getAddress` / `requestAccess` / `signTransaction` shape for Freighter, OneKey and Dynamic. It still contains a Privy raw-hash signing path, but the current sign-in dialog does not offer Privy. Zustand stores hold wallet, selections, the margin account and transaction progress. TanStack Query and ledger-tick hooks refresh data. App-side safety constants live in `lib/account-model.ts`: `LIQ_HF = 1.1` (the contract line), `SAFE_HF = 1.15` (Spot blocks a swap that lowers health below it) and `WARN_HF = 1.25`. The Margin leverage slider is capped at 10x and by the RiskEngine borrow limit. ## APIs All server routes are under `/api/stellar/`. | Route family | Purpose | | - | - | | `pools` | Cached shared lending-pool reads | | `account/[addr]` | Cached margin-account snapshot | | `mercury`, `mercury/events` | Server-side indexed-history proxies (Mercury credentials stay server-side) | | `faucet/blend` | Blend testnet faucet integration | | `copilot`, `copilot/guardian`, `copilot/log`, `copilot/status`, `copilot/investigate` | Copilot chat turn, guard, logging, status and read-only investigations | | `copilot/session*`, `copilot/wallet-bind`, `copilot/wallet-session`, `copilot/standing-orders` | Copilot sessions, wallet binding and standing orders | | `copilot/workflow/propose`, `copilot/workflow/[id]/*` | Plan proposal, approval, prepare-sign, submit, confirm, recheck, advance, reply | | `auth/*` | Login, callback, session and logout | | `analytics/accounts`, `analytics/events`, `analytics/oracle`, `analytics/pool-stats` | Live testnet reads (Registry account scan, event feed, Reflector, pool stats) | | `analytics/liquidations`, `analytics/top-borrowers`, `analytics/tvl`, `analytics/volume` | Hubble queries, gated by `STATS_ENABLED` | ## Data limitations The Analytics account scan reads up to the 200 most recent margin accounts from the Registry. Risk Explorer scenarios run on that live snapshot; only their stress presets come from `lib/analytics/data/mock.ts`. Scenario outputs are conditional calculations, not forecasts. Derived equity is not realized profit, and history can be missing when Mercury or RPC retention has gaps. ## Copilot integration `lib/copilot` includes intent routing, planning, asset readiness, plan sanitization, approval checks, wallet binding, conditional guards, write deduplication, auto-approve budgets and execution receipts. The agent runs inside the Next.js server and calls a configured MCP service. With Freighter, every transaction still opens the wallet for a signature. Presence of these code paths does not prove the external services are configured or available. ## Source reference * `Vanna_Finance_Backend/apps/stellar/app` * `Vanna_Finance_Backend/apps/stellar/lib/constants.ts` * `Vanna_Finance_Backend/apps/stellar/lib/account-model.ts` * `Vanna_Finance_Backend/apps/stellar/lib/wallet-adapter.ts` * `Vanna_Finance_Backend/apps/stellar/lib/copilot/config.ts` * `Vanna_Finance_Backend/packages/shared/v4/connect-modal.tsx` * `Vanna_Finance_Backend/packages/shared/dynamic/dynamic-session.tsx` # Events and Indexing Source: https://docs.vanna.finance/stellar/developers/guides/events-indexing Decode current manager and pool events with correct units and identities. ## Event identity Decode topics and data as Soroban ScVals. Preserve contract ID, ledger/cursor, transaction hash, and event identity. Deduplicate by event identity, not only transaction hash: one transaction can emit several manager, pool, token, and protocol events. ## Manager events | Topic | Meaning | | - | - | | `Smart_account_creation` | New account creation | | `Smart_Account_Reactivated` | Reuse of a closed account | | `Smart_Account_Closed` | Explicit account close | | `Trader_Deposit` | Collateral deposit | | `Trader_Withdraw` | Collateral withdrawal | | `Trader_Borrow` | Borrow | | `Trader_Repay_Event` | Repayment | | `Trader_Liquidate_Event` | Forced liquidation | | `Trader_SettleAccount_Event` | Voluntary settlement attempt | Decode the structs in `AccountManagerContract/src/types.rs`; topic and struct names are not interchangeable. A liquidation or settle event does not mean the account was closed. ## Lending events | Topic | Relevant payload | | - | - | | `deposit_event` | `lender`, `amount`, `timestamp`, `asset_symbol` | | `borrow_event` | `smart_account`, gross `amount`, `timestamp`, `asset_symbol` | | `repay_event` | `smart_account`, `amount`, `timestamp`, `asset_symbol` | | `withdraw_event` | `lender`, `vtoken_amount`, `asset_amount`, `timestamp`, `asset_symbol` | Pool amounts are WAD; token-contract events use native token units. `withdraw_event.asset_amount` records actual underlying payout, which may be less than requested due to partial redemption. Do not count manager and pool events as two independent borrows or repayments. ## Source and history handling Use Mercury server proxies when configured and protocol-specific RPC history readers for fallback. Pagination and retention can leave incomplete histories. Treat missing history as unknown, not a zero balance or zero cost basis. Reconcile indexed state with current contract reads, and keep scenario and stress outputs separate from ledger events. ## Source reference * `Protocol_V1_Soroban_testnet/contracts/AccountManagerContract/src/types.rs` * `Protocol_V1_Soroban_testnet/contracts/AccountManagerContract/src/account_manager.rs` * `Protocol_V1_Soroban_testnet/contracts/lending-pool/src/events.rs` * `Vanna_Finance_Backend/apps/stellar/lib/mercury-client.ts` # Integrate Lending Source: https://docs.vanna.finance/stellar/developers/guides/integrate-lending Supply and redeem from the four configured testnet lending markets. ## Supply Resolve the exact asset's pool with `lendingPoolAddress(assetType)`. The app-local `ContractService.deposit(walletAddress, amount, assetType)` accepts a human-unit number, constructs WAD arguments, prepares/signs/submits, and returns a success result or error. For precise external integrations, build amounts from strings/bigint directly. At the contract boundary call `deposit(lender, amount_wad)`. The lender authorizes the call and underlying transfer. This is a wallet-to-pool flow; no SmartAccount is required. ## Redeem Read the receipt balance and its own decimals. Convert the desired receipt quantity to WAD and call `redeem_vtokens(lender, tokens_to_redeem_wad)`. The app-local `ContractService.withdraw` passes receipt quantities, despite the generic parameter name `amount`. Redemption can partially fill because the pool limits a single payout to 50% of total assets and available cash. Read `withdraw_event.asset_amount`, `vtoken_amount`, and the refreshed balance. Do not show the requested quantity as the completed payout. ## Pool data Use `get_total_liquidity_in_pool`, `get_borrows`, `total_assets`, and conversion getters to distinguish available cash from outstanding debt and receipt value. Read the current rate model and fee. Borrowers are subject to the pool's 95% utilization cap. See [Lending Pools](/stellar/developers/contracts/lending-pools) for signatures and [Math Reference](/stellar/developers/math-reference) for scaling. ## Source reference * `Vanna_Finance_Backend/apps/stellar/lib/stellar-utils.ts` * `Vanna_Finance_Backend/apps/stellar/hooks/use-earn.ts` * `Protocol_V1_Soroban_testnet/contracts/lending-pool/src/pool.rs` # Integrate Margin Source: https://docs.vanna.finance/stellar/developers/guides/integrate-margin Create accounts, manage collateral and debt, and route external actions. 1. Resolve the trader's existing account using `MarginAccountService.discoverExistingAccount`. Account discovery in this app includes Registry storage and fallback reads; do not invent a Registry getter. 2. If needed, call AccountManager `create_account(trader_address)` with trader authorization. 3. Resolve the exact token and pool. Deposit using `deposit_collateral_tokens(smart_account, symbol, amount)` in the signature order shown in the reference. 4. Borrow only after inspecting account health, spendable balances, pool cash, utilization, permissions, and fee. Use the current builder for atomic same-asset or cross-asset operations. 5. For external strategies, call typed `exec` with the registered target, action, token addresses, protocol-specific amount units, and minima. 6. Repay with `repay(amount_wad, symbol, smart_account)` from SmartAccount-held tokens. Unwind external assets or transfer collateral in first if required. 7. To exit the account, settle recognized debt, verify `has_debt`, and call `close_account` after the activation ledger. Treat each operation as independently fallible. AccountManager applies authorization, per-account reentrancy locks, configuration checks, and risk checks, while controller routing and the live post-exec gate have their own policies. For UI integrations, reuse `lib/margin-utils.ts` and the wallet adapter. Its normalization keeps BLUSDC/USDC aliases within the Blend token identity, separate from AQUSDC and SOUSDC. Read [AccountManager](/stellar/developers/contracts/account-manager) and [Transaction Flow](/stellar/developers/sdk/transaction-flow) before encoding calls. ## Source reference * `Vanna_Finance_Backend/apps/stellar/lib/margin-utils.ts` * `Protocol_V1_Soroban_testnet/contracts/AccountManagerContract/src/account_manager.rs` # Liquidation Bots Source: https://docs.vanna.finance/stellar/developers/guides/liquidation-bots Eligibility, allowances, full-debt funding, external collateral, and reconciliation. ## Candidate discovery Discover SmartAccounts from Registry/account events and indexed or RPC account readers. Read `RiskEngine.liquidation_snapshot` for current valuation and the unpriceable-plain-collateral flag. HF at or below 1.1 is a candidate condition, not guaranteed execution or profit. ## Prepare funding and authorization For each recognized debt leg, resolve the underlying address and current lending-pool debt. Fund the liquidator with the exact test-token variant and enough allowance headroom for interest. Approve **AccountManager as spender**, using native token units and a suitable expiration ledger. The liquidation method calls token `transfer_from` from the liquidator directly to the pool. Approving SmartAccount or sending tokens to it is not the required liquidator funding path. ## Execute Call `AccountManager.liquidate(liquidator, smart_account)` with liquidator authorization. There is no partial debt parameter or borrower-signature requirement. Manager pause, missing configuration, external liquidity, oracle failure, insufficient allowance, and transaction resource limits can all prevent success. The current implementation: 1. Takes one eligibility snapshot and rejects healthy accounts or unpriceable plain collateral. 2. Accrues each recognized pool, transfers debt payment from the liquidator, and clears corresponding debt shares. 3. Batch-withdraws Blend collateral to the liquidator and hands AMM LP tokens to the liquidator without forcing a router exit. 4. Sweeps all remaining direct collateral and emits `Trader_Liquidate_Event`. Unrecognized debt symbols are reported and prevent the blanket debt-cleared flag. Inspect remaining shares/debt after execution. The SmartAccount is not deactivated by this function. ## Proceeds and limits The liquidation configuration getter reports a 10% bonus value, but current execution does not compute a capped debt-plus-bonus payout or return surplus through `sweep_to_split`. Estimate proceeds using actual external exit value and LP liquidity. An LP token handed to the liquidator is not already converted underlying. Simulate the complete account shape and approval state. An indexed liquidation candidate, a quoted bonus, or a successful simple-account test does not establish that a multi-position transaction fits the network budget. ## Source reference * `Protocol_V1_Soroban_testnet/contracts/AccountManagerContract/src/account_manager.rs` * `Protocol_V1_Soroban_testnet/contracts/RiskEngineContract/src/risk_engine.rs` * `Vanna_Finance_Backend/apps/stellar/lib/margin-utils.ts` # Math Reference Source: https://docs.vanna.finance/stellar/developers/math-reference Exact scaling, debt rounding, share conversion, health, and collateral valuation. ## WAD arithmetic `WAD = 10^18`. A WAD integer unit is 10^-18 tokens or ratio units, not one whole token. Plain token and receipt transfers use their own native decimals. ```text theme={null} mul_wad_down(a,b) = floor(a*b/WAD) mul_wad_up(a,b) = ceil(a*b/WAD) native_to_wad(n,d) = floor(n*WAD/10^d) wad_to_native(w,d) = floor(w*10^d/WAD) ``` The frontend's configured SAC amounts commonly use 7 decimals, including USDC test variants. Do not import an EVM USDC 6-decimal assumption. Read each asset and receipt's `decimals()`. ## Interest rate model In real-number notation, with integer operations rescaled to WAD: ```text theme={null} u = min(1, borrows / (liquidity + borrows)) annual_rate = c3 * (u*c1 + u^32*c1 + u^64*c2) rate_per_second = annual_rate / 31,556,952 ``` Empty-pool utilization is zero. Default coefficients are 0.1, 0.3, and 3.5. Admin can change them subject to `c3*(2*c1+c2) <= 10` (1000% APR). Rates shown as APR are annualized rates, not guaranteed realized APY. ## Interest accrual ```text theme={null} factor_wad = elapsed_seconds * rate_per_second_wad preview_borrows = stored_borrows + floor(stored_borrows*factor_wad/WAD) persisted_borrows = stored_borrows + ceil(stored_borrows*factor_wad/WAD) ``` `get_borrows` returns the preview. `update_state` persists accrual and advances time; it does not accrue again if the current timestamp is no later than the last update. `get_borrow_balance` converts shares using preview borrows, so user debt includes pending interest. ## Borrow share accounting ```text theme={null} new_shares = ceil(gross_borrow * total_shares / current_borrows) repay_shares = floor(repay_amount * total_shares / current_borrows) user_debt = floor(user_shares * current_borrows / total_shares) ``` When no total shares exist, conversion is 1:1. Repayment has explicit dust and clamping rules: a nonzero repayment rounding to zero shares becomes one share, and reductions are bounded by user/pool shares and debt. A UI dust threshold is not global on-chain debt forgiveness. ### Origination fee ```text theme={null} fee = floor(gross_borrow * fee_rate_wad / WAD) net_credit = gross_borrow - fee ``` Debt is the gross amount, and native transfers split it between treasury and borrower. The frontend documents a zero-fee configuration and applies a 0.9999 spend buffer, floored to 7 decimals. Verify `get_origination_fee` for the actual deployment. ## vToken exchange rate Let A be liquidity plus preview borrows and S the receipt supply converted to WAD. The virtual offset v is **1**, in WAD integer units. ```text theme={null} minted_shares_wad = floor(deposit_wad * (S+v) / (A+v)) redeemed_assets_wad = floor(receipts_wad * (A+v) / (S+v)) ``` First-deposit execution instead starts 1:1 and subtracts 1,000 WAD share units before minting the user's receipts. Mint/burn then convert to the receipt's native decimals; this small accounting constant must not be described as 1,000 whole tokens. Redemption payout is capped at `min(requested_value, floor(A/2), available_liquidity)`. For partial fills the burn amount is recomputed from the payout. Borrow execution separately enforces post-borrow utilization at or below 95%. ## Health factor ```text theme={null} HF_wad = floor(collateral_usd_wad * WAD / debt_usd_wad) healthy = HF_wad > 1.1 * WAD borrow_guard = (C+B)/(D+B) > 1.1 withdraw_guard = (C-W)/D > 1.1 ``` C includes accounted borrowed proceeds and recognized external positions; do not add existing debt into C again. Zero debt is healthy. Oracle and configuration failures can reject operations independently of the ratio. Post-exec and post-borrow live health checks depend on the manager's admin-configurable execution gate. The frontend derives equity as `max(0, C-D)`, liquidation collateral headroom as `max(0, C-1.1*D)`, and debt limit as `C/1.1`. Equity and displayed debt limit are not spendable-token or new-borrow guarantees. Frontend dust handling may differ from exact contract values. ## Blend b-token valuation ```text theme={null} underlying_native = floor(b_tokens_native * b_rate / 10^12) underlying_wad = native_to_wad(underlying_native, underlying_decimals) USD_wad = floor(underlying_wad * oracle_price_wad / WAD) ``` ## LP valuation For both registered Soroswap and Aquarius LP kinds: ```text theme={null} side_a_usd = floor(reserve_a_wad * price_a_wad / WAD) side_b_usd = floor(reserve_b_wad * price_b_wad / WAD) conservative_pool_usd = 2 * min(side_a_usd, side_b_usd) position_usd = floor(user_lp_native * conservative_pool_usd / total_lp_native) ``` Read committed pool reserves and map token ordering correctly. Do not use raw donated balances, an uncapped reserve sum, or the older 2x-skew piecewise formula. `Unpriced`, revoked, frozen, missing, or stale-cache positions can have lower or zero recognized value. ## Oracle price conversion For supported oracle precision d no greater than 18, `price_wad = price * (10^18 / 10^d)`. The service prefers an available fresh five-record TWAP, then fresh spot, then a bounded admin fallback. Upstream freshness is 600 seconds; fallback lifetime is 86,400 seconds; the production memo window is 30 seconds. ## Storage TTL Shared constants are 6,307,200 and 63,072,000 ledgers for refresh threshold and extension target. These are code-requested TTL values, not guarantees that every entry lives for a calendar year or ten years. Storage class, reads/writes, and network limits determine actual lifetime. ## Source reference * `Protocol_V1_Soroban_testnet/contracts/lending-pool/src/pool.rs` * `Protocol_V1_Soroban_testnet/contracts/RiskEngineContract/src/risk_engine.rs` * `Protocol_V1_Soroban_testnet/contracts/RateModelContract/src/rate_model.rs` * `Protocol_V1_Soroban_testnet/contracts/vanna-common/src/math.rs` * `Vanna_Finance_Backend/apps/stellar/lib/margin-health.ts` # Developer Overview Source: https://docs.vanna.finance/stellar/developers/overview Integrate with the reviewed Stellar testnet contracts and application. This reference describes the local `Protocol_V1_Soroban_testnet` contracts and the Stellar app in `Vanna_Finance_Backend/apps/stellar`, reviewed on **2026-10-29**. Configured contract addresses were verified on-chain on 2026-10-24. It does not describe the Solana, Solidity, or older Soroban directories. Start with [Architecture](/stellar/developers/architecture), [Configured Contracts](/stellar/developers/deployed-contracts), and [Math Reference](/stellar/developers/math-reference). The [contract reference](/stellar/developers/contracts/account-manager) includes the current Rust signatures, including privileged callbacks. Env is implicit at the transaction boundary. ## Repository map | Directory or file | Responsibility | | - | - | | `Protocol_V1_Soroban_testnet/contracts` | Core contracts, controllers, deployers, shared library | | `Protocol_V1_Soroban_testnet/integrated_test` | Lifecycle, controller, risk, registry, and regression tests | | `Protocol_V1_Soroban_testnet/deploy` | Deployment and verification scripts | | `Vanna_Finance_Backend/apps/stellar/app` | Next.js pages and server API routes (`/api/stellar/*`) | | `Vanna_Finance_Backend/apps/stellar/lib/*-utils.ts` | Stellar transaction and read services | | `Vanna_Finance_Backend/apps/stellar/hooks` | Query, mutation, wallet, and snapshot hooks | | `Vanna_Finance_Backend/apps/stellar/lib/copilot` | Copilot planning, authentication, approval, execution | | `Vanna_Finance_Backend/packages/shared` | Header, sign-in dialog, funds modal and mascot shared with the Solana app | ## Current scope Four lending markets, per-trader SmartAccounts, Blend supply, and Soroswap/Aquarius controller integrations are implemented. External availability remains pool/configuration dependent. Perpetuals and options are not enabled in this Stellar application. Read the [frontend reference](/stellar/developers/frontend) for routes and data limitations. The TypeScript integration is application-local service code, not a published `@vanna/sdk` package. Use [Getting Started](/stellar/developers/sdk/getting-started) and [Transaction Flow](/stellar/developers/sdk/transaction-flow). # Documentation Review Scope Source: https://docs.vanna.finance/stellar/developers/review-scope Source versions, coverage, and limits of this documentation refresh. Last reviewed on **2026-10-29** against the local source trees (contract reference first written 2026-09-12): | Source | Git HEAD at review | | - | - | | `Protocol_V1_Soroban_testnet` | `1d333fb816454ea9d0c3614508b53d9bd0bae577` (unchanged since 2026-09-12) | | `Vanna_Finance_Backend` (`apps/stellar`, replaces `mercury-stellar-backend`) | `dcec4589bf776d213d36198e2422393a9816b86f` | The configured contract addresses were verified on-chain on 2026-10-24. The contract working tree also has an uncommitted `Trader_Exec` event in AccountManager; it is not deployed and is not documented here. The checked-out file contents are the basis for behavior descriptions. Commit IDs identify the baseline; local changes, if any, also form part of the reviewed working tree. ## Contract coverage The reference covers AccountManager, SmartAccount, Registry, RiskEngine, Oracle, RateModel, lending-pool, v-token, TrackingToken, ControllerFacade, BlendController, SoroswapController, AquariusController, both deployers, and the shared vanna-common library. Public Rust signatures are copied from the implementation rather than reconstructed from old docs. ## Application coverage The guides cover onboarding (Freighter, OneKey and optional Dynamic email login), the Deposit / test-funds modal, Margin (including Dual Borrow), Earn, Spot, Farm, Portfolio, Analytics, and Copilot. The developer section covers transaction services, account/pool snapshots, `/api/stellar/*` routes, Mercury proxies and RPC history, Hubble gates, and the external Copilot service boundary. ## Main corrections Four distinct lending markets; conservative LP collateral valuation; live debt previews and rounding directions; partial receipt redemption and utilization caps; full-collateral liquidation with external exits and allowances; settlement/close separation; Registry bootstrap/finalization and timelocks; configurable post-exec/post-borrow checks; native/WAD controller differences; and multi-transaction fallbacks in the app's deposit-and-borrow flow. The 2026-10-29 pass removed Lite mode and Privy login (no longer in the app), moved source paths and API routes to `apps/stellar` and `/api/stellar/*`, and updated Analytics to its live Registry-snapshot sections. ## Verification limits This is a source-based documentation update. It does not verify deployed WASM, runtime permissions/fees, external pool availability, or production services. No deployment or financial transaction was performed. Selected historical screenshots are included as visual guides with captions; their rates, addresses, and labels are not proof of current UI behavior. Outdated implementation diagrams are excluded. Earlier review reports are archival, not current implementation references. Address values are labeled configuration snapshots. Existing page routes are retained where practical; new contract and application pages are linked in navigation. # TypeScript Integration Source: https://docs.vanna.finance/stellar/developers/sdk/getting-started Use the application-local Stellar service layer. The Stellar app (`@vanna/stellar-app`) declares Next.js `^16.2.3`, React `19.2.0`, Stellar SDK `^14.4.3`, and Freighter API `^6.0.1`. These are repository declarations, not claims about latest upstream releases. ## Run the application From the `Vanna_Finance_Backend` monorepo root: ```bash theme={null} npm ci npm run dev:stellar # Stellar app only, on port 3002 ``` `npm run dev` starts both chain apps. Environment variables are listed in `apps/stellar/docs/README.md` (copy `.env.example` to `.env.local`). Basic contract reads use the configured testnet RPC. Mercury history (`MERCURY_URL`, `MERCURY_KEY`), email login (a Dynamic environment ID), Copilot (MCP settings) and Hubble (`STATS_ENABLED`, Google credentials) need their own configuration. Keep service credentials server-side. ## Service map | Module | Export | | - | - | | `lib/stellar-utils.ts` | `ContractService`, `WalletService`, `CONTRACT_ADDRESSES`, `ASSET_TYPES` | | `lib/margin-utils.ts` | `MarginAccountService` | | `lib/blend-utils.ts` | `BlendService` | | `lib/soroswap-utils.ts` | `SoroswapService` | | `lib/aquarius-utils.ts` | `AquariusService` | | `lib/wallet-adapter.ts` | Wallet-kind-independent address, access, and signing functions (Freighter, OneKey, Dynamic) | Imports using `@xlm/` (or `@/`) assume the application's TypeScript aliases. There is no generated universal client behind these service methods; read their argument types before reusing them. ## Encode exact amounts For direct contract calls, use decimal strings or bigint, not floating-point multiplication by 10^18: ```typescript theme={null} import { nativeToScVal } from '@stellar/stellar-sdk'; const oneTokenWad = 1_000_000_000_000_000_000n; const amountArg = nativeToScVal(oneTokenWad, { type: 'u256' }); const symbolArg = nativeToScVal('XLM', { type: 'symbol' }); ``` A token balance is native units. Pool deposit and manager repayment amounts are WAD. Pool redemption expects WAD **receipt quantity**. Controller minima and LP-removal units vary by protocol; see the controller references. ## Checks `npm run lint`, `npm test`, and `npm run build` are the application checks. Rust integrated tests depend on the imported prerequisite WASMs. Documentation updates do not establish that a deployment or full integration test passed. ## Source reference * `Vanna_Finance_Backend/package.json` * `Vanna_Finance_Backend/apps/stellar/package.json` * `Vanna_Finance_Backend/apps/stellar/lib/stellar-utils.ts` * `Vanna_Finance_Backend/apps/stellar/docs/README.md` # Mercury and Data Sources Source: https://docs.vanna.finance/stellar/developers/sdk/mercury-indexer Server-side history proxies, RPC fallbacks, and separate Hubble stats. ## Mercury proxy The browser calls same-origin server routes. `POST /api/stellar/mercury` accepts `{ query, variables }` and proxies GraphQL using server-only `MERCURY_URL` and `MERCURY_KEY`. `GET /api/stellar/mercury/events` proxies event history; the client decodes base64 ScVal topics and payloads with Stellar SDK. `isMercuryEnabled()` is a browser-context hint, not a credential/health check. Missing Mercury configuration can return an API error. History consumers have protocol-specific Mercury/RPC paths; check the relevant `mercury-*` and `*-history-rpc.ts` modules rather than treating Mercury as the authoritative source of current balances. ## Current balances and freshness `/api/stellar/pools` returns shared pool statistics. `/api/stellar/account/[addr]` returns a derived account snapshot. Both can serve cached results. `lib/account-snapshot.ts` and `lib/margin-health.ts` centralize displayed margin metrics; the snapshot includes debt/collateral reconciliation and UI dust handling. RPC event history is retention-limited; cached or indexed history can be delayed or incomplete. Confirm transaction success by hash and current state, not by the immediate appearance of a history row. ## Hubble is separate `/stats` and the Hubble routes (`/api/stellar/analytics/liquidations`, `top-borrowers`, `tvl`, `volume`) are gated by server-only `STATS_ENABLED="true"`; otherwise they return 404. Hubble uses a mainnet Stellar BigQuery dataset, not this testnet's authoritative account ledger. Credentials are supplied via `GOOGLE_CREDS_JSON` or Application Default Credentials with `GOOGLE_CLOUD_PROJECT`. Dataset queries run in the US location. The `/analytics/...` UI is a different surface. It reads the testnet directly: up to 200 margin accounts from the Registry, Reflector prices and pool stats (`/api/stellar/analytics/accounts`, `events`, `oracle`, `pool-stats`, which are not gated). Risk Explorer scenarios run on that live snapshot with preset stress assumptions. See [Frontend](/stellar/developers/frontend). ## Source reference * `Vanna_Finance_Backend/apps/stellar/lib/mercury-client.ts` * `Vanna_Finance_Backend/apps/stellar/app/api/stellar/mercury/route.ts` * `Vanna_Finance_Backend/apps/stellar/app/api/stellar/mercury/events/route.ts` * `Vanna_Finance_Backend/apps/stellar/lib/hubble/gate.ts` * `Vanna_Finance_Backend/apps/stellar/lib/hubble/client.ts` # Transaction Flow Source: https://docs.vanna.finance/stellar/developers/sdk/transaction-flow Prepare, sign, submit, confirm, and reconcile Stellar transactions. ## Browser transaction lifecycle 1. Resolve the active wallet through `lib/wallet-adapter.ts` and obtain its source account. 2. Build the operation using the configured testnet passphrase and exact ScVal types. 3. Prepare/simulate the transaction to derive authorization and Soroban resource requirements. 4. Sign the prepared transaction with the active wallet: Freighter, OneKey, or the Dynamic email/social wallet when enabled. 5. Submit to Soroban RPC and poll the transaction hash for a terminal result. 6. Refresh account, pool, and wallet state after confirmation. Dynamic signs whole XDR envelopes, and the adapter checks the returned envelope. (A legacy Privy raw-hash path remains in `lib/wallet-adapter.ts`, but the sign-in dialog no longer offers Privy.) A public read-source address can be used for read simulations without a wallet; it is not a funding or signing credential. ## Status and retry behavior A simulation result or submission response is not final confirmation. The service layer handles sequence/footprint races with bounded rebuild/retry paths. `resubmitOnTryAgainLater` resubmits the same signed envelope when the RPC queue declines an attempt. Inspect failed transaction diagnostics before retrying a business-rule rejection. Transaction progress is shared through `lib/tx-progress.tsx` and stores. Some operations pad simulated resource budgets to account for changes between simulation and execution. A timeout or missing history row does not prove the transaction failed; reconcile its hash and on-chain balances. ## Multi-step strategies The Margin **Leverage your Assets** tab uses the atomic `deposit_and_borrow` / `deposit_and_borrow_cross` call for a single collateral (one signature). Dual Borrow's second asset follows as a separate `borrow`, and multi-collateral deposits or a call that overflows the per-transaction budget fall back to separate deposit and borrow transactions. Spot swaps, Farm supply and LP actions are separate `execute` submissions. Confirmed earlier steps remain if a later step fails; inspect the account before retrying. Copilot writes add their own plan approval, wallet binding, execution policy, and receipt flow. Do not assume every Copilot write uses the same browser signing path or that plan approval means on-chain success. ## Source reference * `Vanna_Finance_Backend/apps/stellar/lib/stellar-utils.ts` * `Vanna_Finance_Backend/apps/stellar/lib/wallet-adapter.ts` * `Vanna_Finance_Backend/apps/stellar/components/margin/mg-leverage.tsx` * `Vanna_Finance_Backend/apps/stellar/lib/copilot/handle.ts` # Liquidation Monitoring Source: https://docs.vanna.finance/stellar/guides/analytics/liquidations See which accounts can be liquidated now, which are closest to the 1.10 line, and what has been liquidated. **Analytics → Liquidations** shows who can be liquidated now, how close everyone else is, and the liquidations already recorded on-chain. ## On the page | Panel | What it shows | | - | - | | **KPI cards** | Can be liquidated now, liquidatable debt, bad debt (estimated), liquidations recorded | | **Accounts that can be liquidated** | Every account with debt at a health factor of **1.10 or below** | | **Closest to being liquidated** | Healthy accounts nearest the line | | **Debt by risk** | How much debt sits in each risk band | | **Past liquidations** | Liquidation events read from the chain | | **Liquidation line** | How the 1.10 rule works | ![Accounts by health column chart with a dashed red liquidation line at 1.10, showing \$326.78 of debt in the 1.0 to 1.1 band and larger amounts in the 1.1 to 1.3 and 1.3 to 1.5 bands](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/analytics/analytics-health-collateral.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=fd9691b6cf4b4f61a8baa672dd411a8f) Accounts by health, from Overview: debt per health band with the 1.10 liquidation line. Click the image to zoom. ## Candidate vs liquidated > **A candidate isn't guaranteed to be liquidated** > > A liquidator still needs funds to repay all the debt, token allowances, fresh oracle prices and a transaction that fits Soroban's limits. If a plain collateral token can't be priced, the contract refuses to liquidate. > **What a liquidator receives** > > The liquidator repays all recognized debt. In return they get Blend positions (withdrawn to them), LP tokens (transferred as-is) and every remaining token in the account. > **After a liquidation** > > The margin account stays open and empty. A recorded liquidation event means the transaction ran; check the account's current state for details. History can lag a few seconds behind the chain. Use the transaction hash on Stellar Expert to confirm. See [Liquidation](/stellar/guides/margin/liquidation) and [Liquidation Bots](/stellar/developers/guides/liquidation-bots). # Risk Monitoring Dashboard Source: https://docs.vanna.finance/stellar/guides/analytics/overview Protocol-wide risk on Stellar testnet, read live from the chain: every margin account, its health, debt and collateral. **Analytics** is a public, protocol-wide risk dashboard. It reads the list of margin accounts straight from the **Registry** contract, then reads each account's collateral and debt and prices them with Vanna's Reflector-backed oracle. There's no private database: anyone can check every account. No wallet is needed to view it. The strip at the top says what you're looking at, for example **Live · Stellar testnet · 200 open margin accounts read from the Registry · 4 lending pools · Reflector prices**, with the update time and a **Refresh** button. The deep scan covers the most recent 200 accounts. ![Analytics Overview with the Live Stellar testnet strip, KPI cards for Bad debt (estimated) \$0.00, Can be liquidated 1, Liquidatable debt \$326.78, Accounts at risk / active 15 / 111, Average health 3.64, Collateral at risk \$114.79K, Average leverage 3.89x and Total debt \$95.79K, and an Accounts table with All, Liquidatable, At risk, Safe and No debt filters and a wallet search](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/analytics/analytics-overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=64d522642d796f6b0e3ff257e314927d) Analytics Overview: the KPI cards and the Accounts table, with the section sidebar on the left. Click the image to zoom. ## Sections **Risk** | Section | What it answers | | - | - | | **Overview** | Is anything wrong? Bad debt, liquidatable accounts and debt, accounts at risk, average health and leverage, total debt and collateral, then the Accounts table and lending summary | | **Positions** | Look up any wallet; accounts by health and leverage; collateral and debt by asset | | **Liquidations** | Who can be liquidated now, who's closest, past liquidations and the 1.10 line | | **Top accounts** | Debt concentration, largest borrowers and recent activity | | **Alerts** | What needs attention now, by priority (Act now, Critical, Warning, For information) | **Markets** | Section | What it answers | | - | - | | **Lending Pools** | Supplied, borrowed and available to withdraw per pool, plus the on-chain borrow-rate curve | | **Collateral** | Which assets accounts hold, how each is priced, and the kind (token, Blend deposit, LP) | | **Prices** | The Reflector price for each asset and whether the latest read was live | **Tools** | Section | What it answers | | - | - | | **What-if Calculator** | Reprice every account with your own price moves and see before / after | | **Risk Explorer** | Stress scenarios run against the live accounts | | **Advanced positions** | Positions grouped by collateral type, correlated-drop groups and borrow-rate impact | All tools are **read-only**: they never send a transaction or ask for a signature. ![Accounts by health column chart of debt per health band with a dashed liquidation line at 1.10, a What collateral is made of donut showing \$350.71K split into Held in account 93.0%, Blend deposits 6.2% and Aquarius / Soroswap LP 0.8%, and cards for Supplied by lenders, Borrowed, Available to withdraw and Borrowed share](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/analytics/analytics-health-collateral.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=fd9691b6cf4b4f61a8baa672dd411a8f) Further down Overview: debt at each health level with the 1.10 liquidation line, what collateral is made of, and the lending summary. Click the image to zoom. ## Reading the numbers * **Accounts table:** your own margin account is listed first, with its real rank. Click a row to open that account's page. * **Health bands** are display buckets. The only contract threshold is **1.10**. * **Bad debt (estimated)** is an account owing more than it holds. It's a derived figure, not a write-off in the pools. * **Empty accounts** (no collateral and no debt) aren't counted as active. > **[Positions](/stellar/guides/analytics/positions)** > > Look up accounts and see the spread. > **[Liquidations](/stellar/guides/analytics/liquidations)** > > Who's at the line. > **[Risk Explorer](/stellar/guides/analytics/risk-explorer)** > > Stress the live accounts. # Positions Source: https://docs.vanna.finance/stellar/guides/analytics/positions Look up any wallet or margin account, and see how accounts spread across health, leverage, collateral and debt. **Analytics → Positions** answers two questions: what does a given account hold, and how are all accounts spread out? ## Look up an account Paste a **wallet** (starts with G) or **margin account** (starts with C) address into **Look up a wallet**. The account page shows its health, a what-if slider on its own balances, how it ranks, what it holds and owes, and its recent on-chain events. An account outside the latest scan is read live from the chain. ## Distributions | Chart | What it shows | | - | - | | **Accounts by health** | How many accounts (and how much debt) sit in each health band | | **Debt by leverage** | Debt per leverage band | | **Collateral by asset** | What accounts hold, including Blend deposits (BLEND\_XLM, BLEND\_USDC) and LP positions (SS\_XLM\_USDC) | | **Debt by asset** | What accounts owe, with each asset's share | | **Positions by bucket** | The detailed monitor: health and leverage buckets, borrow rates, the health heatmap and the positions in each bucket | ![Collateral by asset bars for SOUSDC, XLM, BLEND\_XLM, AQUSDC, BLUSDC, SS\_XLM\_USDC and BLEND\_USDC, Debt by asset bars for SOUSDC 62%, BLUSDC 16%, XLM 14%, AQUSDC 7%, AQUA and WETH, and a Positions by bucket card with Show the detailed bucket monitor](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/analytics/analytics-collateral-debt.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=739bd625a8c5ff48fb58f910f739c30d) Collateral by asset and Debt by asset, then the Positions by bucket monitor. Click the image to zoom. ## Good to know * A wallet (G…) and its margin account (C…) are different addresses. Debt belongs to the margin account. * An account with no debt shows **No debt** instead of a health factor. * Health bands and heatmap colours are display choices. The only contract threshold is **1.10**. * Click **Refresh** at the top before acting on an account close to the line. See [Health Factor](/stellar/guides/margin/health-factor) and [Liquidations](/stellar/guides/analytics/liquidations). # Risk Explorer Source: https://docs.vanna.finance/stellar/guides/analytics/risk-explorer Stress the live Stellar margin accounts with price, depeg, rate and protocol shocks. Read-only. **Analytics → Risk Explorer** runs stress tests against the **live** margin accounts: baseline bad debt, a stress heatmap, presets and manual shocks. Changing a scenario never trades, moves an oracle price or liquidates anyone. Nothing is sent to the chain. ## Scenario library | Category | Scenario | What it tests | | - | - | - | | Market risk | **Single Asset Risk Explorer** | One asset's price drop across every position holding or owing it | | Market risk | **Multi-Asset Correlated Crash** | XLM deep bear, flash crash and USDC contagion presets | | Market risk | **Stablecoin Depeg** | BLUSDC / AQUSDC / SOUSDC depeg: collateral loses value while USDC debt shrinks | | Market risk | **Black Swan Multi-Shock** | Crash, depeg, a venue loss and a rate spike at once | | Leverage risk | **Leveraged LP Impermanent Loss** | Impermanent loss on live Aquarius / Soroswap LP positions vs each account's equity | | Leverage risk | **High-Leverage Concentration** | Accounts per leverage band and what a move does to the most leveraged | | Leverage risk | **Leveraged External-Pool Shock** | A price move flowing through Blend / Aquarius / Soroswap positions | | Systemic risk | **Cascading Liquidation** | The liquidation spiral, with your own market-impact assumption | | Systemic risk | **Whale Withdrawal** | Lenders pull from a pool: utilization and the on-chain rate rise | | Systemic risk | **Interest Rate Spike** | Pools pushed up the rate curve; interest erodes borrower health | | Protocol risk | **Reflector Oracle Failure** | A stale or wrong price: hidden, wrongful or missed liquidations | | Protocol risk | **Integrated Protocol Exploit** | An exploit in Blend, Aquarius or Soroswap impairs positions there | The scenarios use the current account snapshot. Only the stress **presets** (the preset shock sizes) are fixed values. ## Use it **1. Pick a scenario** Open **Risk Explorer** and choose a card from the library. **2. Set the shock** Use a preset or adjust the controls. **3. Read the results** Compare accounts pushed below 1.10, debt at risk and estimated bad debt against the baseline. > [!NOTE] > > Results are what-if calculations on today's accounts, not forecasts. Real outcomes also depend on liquidator behaviour, external liquidity and oracle updates. For your own price assumptions across all accounts, use **What-if Calculator**. See [Risk Monitoring](/stellar/guides/analytics/overview) and [Health Factor](/stellar/guides/margin/health-factor). # Connect Your Wallet Source: https://docs.vanna.finance/stellar/guides/connect-wallet Sign in with Freighter or OneKey on Stellar testnet, then mint free test tokens from the Deposit button. ## Supported sign-in methods Click **Connect wallet** at the top right. The **Sign in to Vanna** dialog lists: | Method | Status on Stellar testnet | | - | - | | **Freighter** | Live. Set Freighter's network to **Testnet**. | | **OneKey** | Live. Unlock OneKey and make sure it has a Stellar account. | | **LOBSTR** | Shown as **Soon**. LOBSTR signs for Stellar mainnet only. | | **Email, Google, X, GitHub** | Shown only when email sign-in is enabled for the build. It is powered by Dynamic and gives you a Stellar wallet without an extension. | > [!NOTE] > > The dialog also lists Solana wallets. Picking one switches you to Vanna on Solana; Stellar positions stay with your Stellar address. ## Connect **1. Prepare the wallet** Install [Freighter](https://www.freighter.app/), create or import an account, and switch its network to **Testnet**. **2. Open the sign-in dialog** Go to [test.vanna.finance](https://test.vanna.finance), enter your access code if asked, choose **Stellar** in the chain switcher at the top right, and click **Connect wallet**. **3. Approve the connection** Pick **Freighter** (or OneKey) and approve in the wallet pop-up. Your wallet name, for example **@Freighter**, replaces the button. **4. Check the address** Open the wallet menu to see your address. If you already have a margin account, Vanna finds it on-chain automatically. ## Get test tokens Click **Deposit** in the header. The **Portfolio account** modal opens on the **Deposit** tab: ![Portfolio account modal showing Freighter GCQP...ZUQ5 on Testnet, Deposit and Transfer tabs, Test funds tiles for XLM, BLUSDC, AqUSDC and SoUSDC with Mint buttons, a Mint all button, and a Receive panel with QR code and Copy address](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/onboarding/deposit-modal-test-funds.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4ef009b18c5ef268cc0db1dde71f4ccd) Test funds with one-click Mint per token and Mint all, plus your receive address and QR code. Click the image to zoom. | Token | Source | How often | | - | - | - | | **XLM** | Stellar Friendbot, 10,000 XLM | Once per account (Friendbot funds an address only once) | | **BLUSDC** | Blend testnet faucet. Sends a basket: USDC, BLND, wETH and wBTC | Once per wallet | | **AqUSDC** | Aquarius testnet faucet, 1,000 per mint | Any time | | **SoUSDC** | Soroswap testnet faucet | Any time, with a short cooldown between mints | **Mint all** mints every token that isn't already funded or cooling down. Some mints open your wallet once to add the token's trustline; approve it. The **Receive** panel shows your address and QR code. Send only Stellar **testnet** assets there; mainnet XLM or USDC will not show up in Vanna. > [!TIP] > > Keep some XLM in your wallet. Every Stellar transaction pays a small XLM fee, and each trustline raises your account's minimum XLM reserve. The app always leaves that reserve untouched when you deposit or supply XLM. ## Move funds to your margin account The modal's **Transfer** tab moves tokens between your wallet and your margin account. It is the same form as **Margin → Transfer Collateral**. See [Transfer Collateral](/stellar/guides/margin/transfer-collateral). ## Reconnect Use the same wallet to return to the same positions. A different address has different balances and a different margin account. Next: [Earn](/stellar/guides/earn/overview) or [Open a Margin Account](/stellar/guides/margin/open-account). # Copilot Source: https://docs.vanna.finance/stellar/guides/copilot Ask about your Stellar account or describe a change in plain English. Copilot plans it with live numbers; your wallet signs each step. **Copilot** is an AI assistant that knows your Vanna account. Ask a question ("What's my health factor?", "Price of XLM") or describe a change ("Deposit 100 XLM and borrow 3x leverage AqUSDC"), and it answers with live figures or prepares the transactions for your wallet to sign. It does what the rest of the app does, with the same rules and numbers. You just say what you want instead of filling in each page. ![Copilot page with the request Deposit 100 XLM and Borrow 3x leverage AQUSDC, the plan Deposit 100 XLM as collateral then Borrow 33.9112961 AQUSDC, a Your signature needed card on step 1 of 2 with an Approve button, and a sidebar showing New chat, Health factor 1.82 Healthy, Auto-approve Off, Margin Positions 6, Earn Positions 1 and Recents](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/copilot/copilot-plan.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=9dfaffee8c4d3d91a5002c00406f7182) A two-step plan: deposit 100 XLM, then borrow AqUSDC at 3x. Step 1 is waiting for your signature. Click the image to zoom. ## Get started **1. Open Copilot** Click **Copilot** in the header with your wallet connected. **2. Prove your wallet** With Freighter, sign a one-time message when asked. It is not a transaction and costs no fee. It lets Copilot read and act only for your own address. **3. Ask** Type in the box at the bottom and press Enter. ## The sidebar | Part | What it shows | | - | - | | **New chat** | Starts a fresh conversation | | **Health factor** | Your margin account's current health factor and its zone | | **Auto-approve** | Off by default. See [below](#auto-approve) | | **Margin Positions** | Each asset your margin account holds or owes | | **Earn Positions** | What you supplied to Vanna's lending pools | | **Recents** | Earlier chats. Rename or delete one from its menu | ## What it can do | You want to | Try | | - | - | | **Read your account** | "What's my health factor?", "Show my positions", "Price of XLM" | | **Lend** | "Supply 500 XLM to Earn", "Withdraw my SoUSDC from Earn" | | **Use margin** | "Open a margin account", "Deposit 1,000 XLM into my margin account", "Repay all my XLM debt" | | **Lever up** | "Deposit 100 XLM and borrow AqUSDC at 3x", "Deposit 3,000 XLM, dual-borrow BLUSDC and AqUSDC" | | **Swap** | "Swap 100 XLM to SoUSDC" (inside your margin account) | | **Farm** | "Supply 100 XLM to Blend", "Add XLM / SoUSDC liquidity on Soroswap", "Withdraw from Blend" | | **Withdraw** | "Move 50 XLM from my margin account to my wallet" | ## Approving a plan **1. Review** Copilot restates your request ("Read as: ...") and lists each step with its exact amount. **2. Approve in time** A plan is valid for **5 minutes** (the countdown starts at 4:59). After that it expires and you ask again, so it uses fresh prices. **3. Sign each step** Click **Approve** on a step; your wallet opens for that one transaction. **Cancel remaining steps** stops the plan; steps already confirmed stay done. **4. Check the result** A step shows as done only after the chain confirms it. Every plan is checked against your health factor. Copilot pauses actions that would push the account toward liquidation. ## Auto-approve Auto-approve lets small, pre-approved steps go through without a confirmation click, within a **per-transaction limit** and a **daily budget** that you set and apply. It is **off** by default. With Freighter, every transaction still opens your wallet to sign; the plan card then says "Auto-approve could not sign this step, so it needs your own signature". ## Assist on every page The **Assist** tab on the right edge of every page opens a lighter guide. It explains what you're looking at ("What is a health factor?", "How is Earn different from Farm?") and hands you to Copilot when you want to act. # Earn Overview Source: https://docs.vanna.finance/stellar/guides/earn/overview Lend XLM or one of three testnet USDC tokens to Vanna's lending pools and earn the interest margin borrowers pay. **Earn** (under **Lend** in the header) is where you supply wallet assets to Vanna's lending pools. Margin accounts borrow from these pools and pay interest; that interest flows to lenders through **vTokens**. ![Earn page Vaults tab listing XLM, BLUSDC, AqUSDC and SoUSDC pools, each Active, with Assets Supplied, Supply APY, Assets Borrowed, Borrow APY, Utilization Rate and Your Supply columns, plus All Pools, search, Deposit and Supply APY filters](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/earn/earn-pools.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=022ed2f6a111e935cd47b49fbb321b36) Earn: the Vaults list with all four lending pools. Click the image to zoom. ## The pools | Pool | Underlying | Receipt | | - | - | - | | XLM | Native XLM | vXLM | | BLUSDC | Blend's testnet USDC | vBLUSDC | | AqUSDC | Aquarius's testnet USDC | vAqUSDC | | SoUSDC | Soroswap's testnet USDC | vSoUSDC | Each pool has its own liquidity, rates and receipt. The three USDC pools are separate markets for separate tokens. ## The page * **Dashboard** (when connected): your Overall Deposit and Net Earnings charts. * **Vaults**: every pool with Assets Supplied, **Supply APY**, Assets Borrowed, **Borrow APY**, **Utilization Rate** and **Your Supply**. Filter by pool, search, or filter by Supply APY. * **Positions**: only the pools you've supplied to. Click a pool to open it. A pool page has the stats strip, the **Supply Liquidity / Withdraw Liquidity** form, and five tabs: | Tab | What's there | | - | - | | **Your Positions** | Your vTokens and what they're worth now | | **Details** | Total supplied and borrowed, available liquidity, Supply and Borrow APY, utilization, oracle price, vToken exchange rate and supply, contract addresses | | **Activity** | Your supply and withdraw history | | **Collateral and Limits** | The account-wide liquidation rule (HF 1.10) and each pool's borrow usage | | **Analytics** | Pool charts, including the borrow-rate curve read from the on-chain rate model | ## How you earn Your vToken balance doesn't change, but each vToken is worth more underlying over time as interest accrues. There's nothing to claim. See [vTokens](/stellar/learn/vtokens). > **[Supply](/stellar/guides/earn/supply)** > > Lend from your wallet and receive vTokens. > **[Withdraw](/stellar/guides/earn/withdraw)** > > Redeem vTokens for the underlying plus interest. # Supply to Earn Source: https://docs.vanna.finance/stellar/guides/earn/supply Lend XLM, BLUSDC, AqUSDC or SoUSDC from your wallet and receive interest-bearing vTokens. Supplying moves tokens from your **wallet** into a Vanna lending pool. You get vTokens back in your wallet. No margin account is needed. ![Earn XLM pool page with Statistics showing Total Supplied 120.72K XLM and Total Borrowed 79.70K XLM, Supply APY 15.26%, Borrow APY 23.11%, Utilization 66.02%, Liquidation Penalty dynamic 0-15%, and a Supply Liquidity form for 10 XLM showing You Get 9.8181405 vXLM, XLM per vXLM 1.0185228 and estimated monthly and yearly earnings](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/earn/earn-pool-supply.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4ea535801e5dff46c7cb6c0f1f4f0a1d) An XLM pool page: Details tab on the left, the Supply Liquidity form on the right with the vXLM you'll receive and estimated earnings. Click the image to zoom. **1. Open the pool** Go to **Earn** and click XLM, BLUSDC, AqUSDC or SoUSDC. Make sure your wallet holds that exact token. **2. Enter an amount** Under **Supply Liquidity**, pick the asset, type an amount or use **10% / 25% / 50% / 100%**. Your wallet balance is shown under the field. **3. Check More Details** Expand **More Details** to see **You Get** (vTokens), the exchange rate (for example XLM per vXLM), the current Supply APY and estimated monthly and yearly earnings at that APY. **4. Sign** Click **Supply Liquidity** and approve in your wallet. Wait for the confirmation. **5. Check your position** Your vTokens appear on the **Your Positions** tab and in **Portfolio → Lender**. ## Good to know * **You get fewer vTokens than tokens supplied.** Each vToken is already worth more than one unit of the underlying (here 1.0185 XLM per vXLM), so 10 XLM buys about 9.82 vXLM. Their value keeps growing. * **100% of XLM is safe.** The form keeps back your wallet's minimum XLM reserve plus a fee buffer, so your account can't get stuck. * **APY isn't fixed.** The estimate uses today's Supply APY, which moves with utilization. * **vTokens aren't collateral.** They stay in your wallet and don't back a margin account. History can lag a confirmed transaction by a few seconds. Next: [Withdraw](/stellar/guides/earn/withdraw). # Withdraw from Earn Source: https://docs.vanna.finance/stellar/guides/earn/withdraw Redeem vTokens for the underlying asset plus the interest it earned. Withdrawing burns your vTokens and sends the underlying, interest included, back to your **wallet**. **1. Open the pool** Go to **Earn → Positions** (or the pool) where you hold vTokens. **2. Switch to Withdraw Liquidity** In the form on the right, choose **Withdraw Liquidity**. **3. Enter vTokens to redeem** The amount is in **vTokens** (for example vXLM), not the underlying. Use **10% / 25% / 50% / 100%**; 100% uses your exact vToken balance. **4. Sign and check** Approve in your wallet, then check the underlying received and any vTokens left. ## When a withdrawal is limited > **The pool doesn't have enough cash** > > Part of every pool is lent to margin accounts. You can only redeem against **Available Liquidity** (shown on **Details**). If none is available, the transaction fails; try again after borrowers repay or utilization falls. > **A large withdrawal fills only partly** > > One redemption pays at most the smallest of: what you asked for, **50% of the pool's total assets**, and the cash available. Only the vTokens for the paid part are burned. The rest stay in your wallet and keep earning; withdraw them in another transaction. > **The pool is paused** > > A paused pool stops deposits, withdrawals and new borrows until it is unpaused. > [!NOTE] > > **Total Supplied** includes money currently lent out. It is not the cash you can withdraw right now; **Available Liquidity** is. See [vTokens](/stellar/learn/vtokens) and [Pool Mechanics](/stellar/learn/lending-pool-mechanics). # AMM LP Pools Source: https://docs.vanna.finance/stellar/guides/farm/amm-liquidity Add two-sided XLM / USDC liquidity on Soroswap or Aquarius from your margin account and earn trading fees. Adding liquidity puts two tokens from your margin account into a Soroswap or Aquarius pool. You get **LP shares** back in the margin account; they earn the pool's trading fees and count as collateral. | Pool | Tokens | | - | - | | Soroswap XLM / SoUSDC | XLM + **SoUSDC** | | Aquarius XLM / AqUSDC | XLM + **AqUSDC** | ![Farm XLM / SoUSDC LP Soroswap pool page with XLM Reserve 219.40K, SoUSDC Reserve 37.24K, Fee Rate 0.30% and Total LP Shares 87.44K, a My LP Position chart with 599.38 LP shares worth \$510.80 and 0.69% share of pool, and an Add Liquidity form with 10 XLM and 1.70 SoUSDC, showing You will receive about 3.99 LP shares backed by 10 XLM plus 1.70 SoUSDC](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/farm/farm-soroswap-lp.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=b1bde141c446f4b0e7d1d5686cd56431) The Soroswap XLM / SoUSDC pool page: reserves, fee and total LP shares on top, your LP position on the left, Add Liquidity on the right. Click the image to zoom. ## Add liquidity **1. Open the pool** On **Farm → LP/Multiple Assets**, click the pair. **2. Enter one side** On **Add Liquidity**, type an amount for either token. The other side fills in automatically from the pool's live price (shown as "1 XLM ≈ … SoUSDC"). **Margin** under each field is what your account holds. **3. Check the summary** **You will receive** (estimated LP shares), **Backed by** (both amounts) and **Share of pool**. **4. Sign** Approve the transaction. > [!TIP] > > You need **both** tokens in the margin account. Get SoUSDC or AqUSDC by [borrowing](/stellar/guides/margin/borrow) it, [swapping](/stellar/guides/trade/spot-swap) for it, or [transferring](/stellar/guides/margin/transfer-collateral) it in. ## Remove liquidity On **Remove Liquidity**, choose how many LP shares to burn (100% uses your exact balance) and sign. Both tokens return to your **margin account**. Removing liquidity doesn't repay debt or send anything to your wallet. ## Good to know * **Collateral value is conservative.** The Risk Engine values an LP position at twice the smaller side of its share of the reserves, which can be a little less than a DEX shows. * **Impermanent loss.** If XLM moves against USDC, your LP holds more of the falling token. With borrowed funds, that loss hits your health factor. * **Liquidation.** If the account is liquidated, LP shares are transferred to the liquidator as they are. See [Health Factor](/stellar/guides/margin/health-factor). # Blend Single-Asset Pools Source: https://docs.vanna.finance/stellar/guides/farm/blend-pools Supply XLM or BLUSDC from your margin account to Blend and earn Blend's supply APY. Blend supply moves **XLM** or **BLUSDC** from your margin account into Blend's testnet lending pool. Blend gives back **b-tokens** (for example bXLM), which stay in your margin account and count as collateral. ![Farm XLM Supply Blend pool page with Supply APY, Borrow APY, Utilization Rate and Total Pool Supply, a My Supply Position chart showing 102.6614 XLM supplied at 1 bXLM = 2.5160 XLM with position value \$17.42 and receipt balance 40.8028 bXLM, and a Supply form for 10 XLM showing Network Stellar Testnet, Source 10.0000 borrow, Deposit 102.6614 to 112.6614, APY and projected monthly and yearly earnings, with a Supply XLM to Blend button](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/farm/farm-blend-supply.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=8ab2f36264e5025ca6d517ddef5b89e8) The Blend XLM pool page: your supply position on the left, the Supply form on the right with the source and projected earnings. Click the image to zoom. ## Supply **1. Open the pool** On **Farm → Lending/Single Assets**, click **XLM** or **BLUSDC**. **2. Enter an amount** On the **Supply** tab, type an amount or use the % chips. **Margin** shows what your margin account holds. **3. Check the summary** **Source** shows how much comes from borrowed funds and how much from your own collateral (borrowed funds are used first). You also see your deposit before → after, the APY and projected earnings. **4. Sign** Click **Supply XLM to Blend** (or BLUSDC) and approve. ## Withdraw On the **Withdraw** tab, enter the amount in **b-tokens** (what Blend burns). The app converts it to the underlying at the live b-rate and shows what you'll get. A 100% withdrawal re-reads your balance right before sending so nothing is left behind. Click **Withdraw ... to Margin Account**. Withdrawn tokens go back to your **margin account**, not your wallet. Repaying a loan or transferring to your wallet is a separate step. ## Good to know * **b-tokens grow in value.** 1 bXLM is worth more than 1 XLM and keeps rising as Blend borrowers pay interest, so your receipt count is smaller than the amount supplied. * **Blend's rates are Blend's.** On testnet they can be extreme. A high supply APY doesn't guarantee a positive spread after your Vanna borrow rate. * **Exits can be limited** by Blend's own liquidity. See [Repay](/stellar/guides/margin/repay) and the [Blend Controller](/stellar/developers/contracts/blend-controller). # Leveraged Yield Source: https://docs.vanna.finance/stellar/guides/farm/leveraged-yield Borrow on Margin, then farm the borrowed funds on Blend, Soroswap or Aquarius, and unwind safely. Leveraged yield means borrowing from Vanna and deploying the loan into a Farm pool, so you earn on more than your own capital. On Stellar you do it in two steps, Margin then Farm, or ask [Copilot](/stellar/guides/copilot) to plan both. ## Open a position **1. Deposit and borrow** On **Margin → Leverage your Assets**, deposit collateral and borrow the token the pool needs, for example XLM or BLUSDC for Blend, or SoUSDC for the Soroswap XLM / SoUSDC pool. See [Borrow](/stellar/guides/margin/borrow). **2. Farm it** Open the pool on **Farm** and supply or add liquidity from the margin account. On Blend, **Source** shows that borrowed funds are used first. See [Blend](/stellar/guides/farm/blend-pools) or [LP Pools](/stellar/guides/farm/amm-liquidity). **3. Check the account** On Margin, **Borrowed money is in** now shows the amount in **Farm**. Watch the health factor and the Liquidation buffer. ![Margin Current Positions account map with collateral, account value, four borrowed assets each with Repay, and a footer showing Borrowed money is in Farm \$579.18 and Idle \$747.47](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/margin/margin-positions.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=189cdb77f05d2ffd0a548d683eb6c215) After farming: the account map shows borrowed money split between Farm and Idle. Click the image to zoom. ## Does it pay? Your net yield is roughly: ```text theme={null} farm APY × amount farmed − borrow APY × amount borrowed ``` Both rates are variable. Compare the pool's supply APY (Farm) with the asset's **Borrow APY** (Earn) and your **Net Borrow Rate** (Margin) before you start. On testnet, rates can swing a lot. > [!WARNING] > > Borrowing XLM to supply XLM to Blend cancels out XLM price moves on that leg. Borrowing USDC to farm XLM does not: you are now long XLM with leverage, and an XLM drop lowers your health factor. ## Unwind **1. Exit the farm** Withdraw from Blend or remove liquidity. Tokens return to the margin account. **2. Swap if needed** If you got back a different token than you owe, [swap](/stellar/guides/trade/spot-swap) for the debt asset. **3. Repay** [Repay](/stellar/guides/margin/repay) each loan in its own asset. **4. Withdraw** [Transfer](/stellar/guides/margin/transfer-collateral) what's left to your wallet. Each step is its own transaction. If one fails, the earlier ones stay done; check your balances before retrying. > [!WARNING] > > At or below a Health Factor of 1.1, a priced account with debt is a liquidation candidate. The current liquidation path transfers remaining collateral to the liquidator; it does not automatically close the SmartAccount. See [Sample Strategies](/stellar/guides/sample-strategies) for worked examples. # Farm Overview Source: https://docs.vanna.finance/stellar/guides/farm/overview Put margin-account funds to work on Blend, Soroswap and Aquarius. Farm positions keep counting as collateral. **Farm** deploys tokens held in your **margin account**, including borrowed ones, into Stellar DeFi protocols. The position stays inside the margin account, so it keeps counting as collateral under the same health factor. ![Farm page with the banner Provide liquidity to Blend, Aquarius and Soroswap straight from your margin account, a stats strip with Net Health Factor 1.82, Your Deposit TVL \$579.18, Your Earnings, Net Farm APY 16.42% and Pending Rewards, and the Vaults tab with Lending/Single Assets selected listing Blend XLM and BLUSDC supply pools with total deposits, total borrow, supply APY, borrow APY, utilization and holding](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/farm/farm-pools.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=0c6d7dfdb38a10289ff91e1941f6700d) Farm: the stats strip, then Vaults with the Lending/Single Assets list (Blend). Click the image to zoom. ## What you can farm | Type | Protocol | Pools | | - | - | - | | **Lending / Single Assets** | Blend | XLM, BLUSDC | | **LP / Multiple Assets** | Soroswap | XLM / SoUSDC | | **LP / Multiple Assets** | Aquarius | XLM / AqUSDC | > **[Blend supply](/stellar/guides/farm/blend-pools)** > > Supply XLM or BLUSDC from your margin account to Blend's lending pool. > **[Soroswap / Aquarius LP](/stellar/guides/farm/amm-liquidity)** > > Add two-sided XLM / USDC liquidity and earn trading fees. ## The page * **Stats strip** (connected): **Net Health Factor**, **Your Deposit TVL**, **Your Earnings**, **Net Farm APY** and **Pending Rewards**. Your Earnings and Pending Rewards read \$0.00 for now: farm positions have no on-chain cost basis on Stellar yet, and BLND / AQUA reward emissions aren't read by the app. * **Vaults | Positions**: all pools, or only the ones you're in. * **LP/Multiple Assets | Lending/Single Assets**: switch between the LP and the Blend lists. Filter by pool, search, or set a threshold. Click a row to open its pool page: stats on top, **All Transactions | Analytics** on the left (your position chart, position value and history), and the action form on the right. ## Farm vs Earn | | Earn | Farm | | - | - | - | | Funds come from | Your wallet | Your margin account | | Goes to | Vanna's lending pools | Blend, Soroswap, Aquarius | | You receive | vTokens in your wallet | A Blend receipt or LP shares in your margin account | | Counts as margin collateral | No | Yes | ## Before you start * Your margin account must hold the right tokens. Blend uses **BLUSDC**, Soroswap **SoUSDC** and Aquarius **AqUSDC**; they are not interchangeable. Borrow or swap for the one you need. * Farmed tokens count as collateral, but they're not free balance. Withdraw from Blend or remove liquidity before you repay or transfer them. For the full borrow-then-farm loop, see [Leveraged Yield](/stellar/guides/farm/leveraged-yield). # For Liquidity Providers Source: https://docs.vanna.finance/stellar/guides/for-liquidity-providers Supply XLM, BLUSDC, AqUSDC or SoUSDC to Vanna's lending pools and earn the interest margin borrowers pay. Use **Earn** to lend from your wallet into a Vanna lending pool. You receive vTokens (vXLM, vBLUSDC, vAqUSDC, vSoUSDC) whose value grows as borrowers pay interest. You don't need a margin account. ## Your path **1. Get the token** Connect your wallet and mint test tokens from **Deposit → Test funds**. See [Connect Your Wallet](/stellar/guides/connect-wallet). **2. Pick a pool** Open **Earn** and compare Supply APY, utilization and your supply across the four pools. **3. Supply** Open the pool, enter an amount under **Supply Liquidity**, check what you get in vTokens and sign. See [Supply](/stellar/guides/earn/supply). **4. Track it** Watch your position and earnings on the pool's **Your Positions** tab and on **Portfolio → Lender**. **5. Withdraw** Redeem vTokens under **Withdraw Liquidity** whenever the pool has cash. See [Withdraw](/stellar/guides/earn/withdraw). ## Good to know * **Yield is variable.** Supply APY rises and falls with how much of the pool is borrowed. * **Liquidity can be busy.** You can withdraw only what isn't currently lent out, and one redemption pays at most 50% of the pool's total assets. * **Your vTokens stay in your wallet.** They are not margin collateral. See [Earn Overview](/stellar/guides/earn/overview) and [Pool Mechanics](/stellar/learn/lending-pool-mechanics). # For Traders and Borrowers Source: https://docs.vanna.finance/stellar/guides/for-traders Open a margin account, borrow up to 10x, then swap or farm with the borrowed funds under one health factor. A **margin account** is your own Soroban smart contract. It holds your collateral and everything you borrow, swap into or farm. One health factor covers all of it. ## Your path **1. Create the account** Open **Margin** and click **Create your Margin Account**. See [Open a Margin Account](/stellar/guides/margin/open-account). **2. Deposit and borrow** In **Leverage your Assets**, deposit XLM, BLUSDC, AqUSDC or SoUSDC and borrow one asset (**Single Borrow**) or two (**Dual Borrow**) at 1x to 10x. See [Borrow](/stellar/guides/margin/borrow). **3. Put the funds to work** [Swap](/stellar/guides/trade/spot-swap) on Soroswap or Aquarius, or [Farm](/stellar/guides/farm/overview) on Blend, Soroswap and Aquarius, straight from the margin account. **4. Watch your health factor** Keep it comfortably above **1.10**. The Margin page's **Liquidation** card shows how far you are from the line in dollars. See [Health Factor](/stellar/guides/margin/health-factor). **5. Unwind** Exit Farm positions, [repay](/stellar/guides/margin/repay) your loans, then [transfer collateral](/stellar/guides/margin/transfer-collateral) back to your wallet. ## Limits to know * New borrows must keep the account's health factor above **1.10**, and the pool must have cash to lend. A pool can't be borrowed past **95%** utilization. * Spot blocks a swap that would drop your health factor below **1.15**. * BLUSDC, AqUSDC and SoUSDC are different tokens. Borrow the one your venue uses. > [!WARNING] > > At or below a Health Factor of 1.1, a priced account with debt is a liquidation candidate. The current liquidation path transfers remaining collateral to the liquidator; it does not automatically close the SmartAccount. See [Margin](/stellar/guides/margin/overview), [Spot](/stellar/guides/trade/spot-swap) and [Farm](/stellar/guides/farm/overview). # Getting Started Source: https://docs.vanna.finance/stellar/guides/getting-started Open Vanna on Stellar testnet, connect a wallet, mint free test tokens and pick what you want to do. Vanna is a credit layer on Stellar (Soroban). You can lend into Vanna's pools, or open one **margin account**, borrow up to **10x** against it, and use the loan in Stellar DeFi: swaps on **Soroswap** and **Aquarius**, and supply on **Blend**. One health factor covers the whole account. **Live app:** [test.vanna.finance](https://test.vanna.finance) (choose **Stellar** in the chain switcher at the top right; the first visit asks for an access code) > [!NOTE] > > This guide describes **Stellar testnet** at [test.vanna.finance](https://test.vanna.finance). Get test tokens from **Deposit → Test funds** in the app header, pick the exact USDC variant (BLUSDC, AqUSDC or SoUSDC) the pool or venue needs, and keep some XLM for fees and reserves. ## Three steps to start **1. Install a wallet and switch it to Testnet** Install [Freighter](https://www.freighter.app/) (OneKey also works) and set its network to **Testnet**. See [Connect Your Wallet](/stellar/guides/connect-wallet). **2. Connect** Open [test.vanna.finance](https://test.vanna.finance), enter your access code if asked, choose **Stellar** in the chain switcher, then click the connect button at the top right and approve the connection in your wallet. **3. Mint test tokens** Click **Deposit** in the header. Under **Test funds**, press **Mint all**, or **Mint** one token at a time: XLM (Friendbot), BLUSDC (Blend faucet), AqUSDC (Aquarius faucet) and SoUSDC (Soroswap faucet). ![Portfolio account modal with Deposit and Transfer tabs, Test funds tiles for 10,000 XLM, BLUSDC, 1,000 AqUSDC and SoUSDC each with a Mint button, a Mint all button, and a Receive panel with the Freighter address and QR code](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/onboarding/deposit-modal-test-funds.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=4ef009b18c5ef268cc0db1dde71f4ccd) The Portfolio account modal: one-click test funds on the left, your receive address and QR code on the right. Click the image to zoom. ## The app at a glance The header groups the pages the way money flows: | Group | Page | What you do there | | - | - | - | | | [Portfolio](/stellar/guides/portfolio) | Net worth, net earnings and health factor; Lender, Trader and Balances tabs | | **Lend** | [Earn](/stellar/guides/earn/overview) | Supply XLM, BLUSDC, AqUSDC or SoUSDC to Vanna's pools | | **Borrow & Trade** | [Margin](/stellar/guides/margin/overview) | Deposit collateral, borrow at 1x to 10x, repay, move collateral | | **Borrow & Trade** | [Trade → Spot](/stellar/guides/trade/spot-swap) | Swap inside your margin account via Soroswap or Aquarius | | **Borrow & Trade** | [Farm](/stellar/guides/farm/overview) | Supply margin funds to Blend, or add LP on Soroswap / Aquarius | | | [Analytics](/stellar/guides/analytics/overview) | Protocol-wide risk, read live from the chain | | | [Copilot](/stellar/guides/copilot) | Ask about your account or describe a change in plain English | | | Rewards | Marked **Soon** in the header | The **Deposit** button and your wallet name sit at the top right. A small **Assist** tab on the right edge of every page opens a guide that explains what you're looking at and can hand you over to Copilot. ## Supported assets | Asset | What it is | Lend (Earn) | Borrow | Margin collateral | | - | - | :-: | :-: | :-: | | XLM | Native Stellar lumens | ✓ | ✓ | ✓ | | BLUSDC | Blend's testnet USDC | ✓ | ✓ | ✓ | | AqUSDC | Aquarius's testnet USDC | ✓ | ✓ | ✓ | | SoUSDC | Soroswap's testnet USDC | ✓ | ✓ | ✓ | > [!WARNING] > > The three USDC tokens are **different contracts**, each priced at about \$1. Blend uses BLUSDC, Aquarius uses AqUSDC and Soroswap uses SoUSDC. Borrowing one does not give you another. Blend supply receipts and Soroswap / Aquarius LP positions held in your margin account also count as collateral. > [!TIP] > > A wallet signature is not the final result. Wait for the confirmation and refreshed balances before the next step that depends on it. Continue with [Connect Your Wallet](/stellar/guides/connect-wallet). # How Vanna Works Source: https://docs.vanna.finance/stellar/guides/how-vanna-works Where your tokens go when you lend, borrow, swap and farm on Vanna's Stellar testnet. Vanna has two sides that meet in its lending pools: * **Lenders** supply assets to a Vanna lending pool and receive **vTokens** (vXLM, vBLUSDC, vAqUSDC, vSoUSDC) that grow in value as borrowers pay interest. * **Traders** open a **margin account**, a personal Soroban smart contract. They deposit collateral, borrow from the pools and use the borrowed funds in Stellar DeFi. ## Follow the tokens | You do | Tokens move | Where they count | | - | - | - | | Supply on **Earn** | Wallet → Vanna lending pool. You get vTokens in your wallet. | Your lending position, not margin collateral | | Deposit on **Margin** | Wallet → your margin account | Collateral | | Borrow on **Margin** | Lending pool → your margin account, plus debt | Collateral **and** debt | | Swap on **Spot** | One token → another, inside the margin account | Still collateral | | Supply / add LP on **Farm** | Margin account → Blend, Soroswap or Aquarius | Still collateral (as a Blend receipt or LP position) | | Repay | Margin account → lending pool | Lowers debt | | Transfer to wallet | Margin account → wallet (health-checked) | Leaves the account | Borrowed funds never go straight to your wallet. They stay in the margin account, where the protocol can see and value them. ## One account, one health factor Every position in a margin account (tokens, Blend supply and LP shares) backs every loan in it. The **health factor** compares the account's total collateral value with its total debt: ```text theme={null} Health factor = total collateral (USD) / total debt (USD) ``` Above **1.10** the account is healthy. At **1.10 or below** anyone can liquidate it. See [Health Factor](/stellar/guides/margin/health-factor). ## The pieces > **Account Manager** > > The entry point for every margin action: create, deposit, borrow, repay, withdraw and route to external protocols. > **Risk Engine + Oracle** > > Values every position with Reflector prices and blocks actions that would leave the account at 1.10 or below. > **Controllers** > > Approved adapters for Blend, Soroswap and Aquarius. Your margin account can only call what the Registry allows. ## What's in the app Earn, Margin, Spot, Farm, Portfolio, Analytics and Copilot. Spot is the only trading surface on Stellar; there are no perps or options. Rewards is marked **Soon**. See [Core Concepts](/stellar/learn/overview) for the accounting model and [Developers](/stellar/developers/overview) for the contracts. # Borrow Source: https://docs.vanna.finance/stellar/guides/margin/borrow Borrow XLM, BLUSDC, AqUSDC or SoUSDC against your collateral at 1x to 10x, with Single or Dual Borrow. Borrowing happens in the **Leverage your Assets** tab, together with a deposit or against collateral already in the account. ![Leverage your Assets tab with a 10 XLM deposit marked WB, Add Collateral, Single Borrow selected on the Single / Dual Borrow toggle, a BLUSDC borrow of 1.6955648 with a Max Value button, Total \$1.70 of Max \$1.70, and the leverage slider at 2 on a 1x, 4x, 7x, 10x scale](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/margin/margin-leverage.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=63cae475feb12253e47c06aee6228fe6) Deposit 10 XLM and borrow BLUSDC at 2x: the Single / Dual Borrow toggle, Max Value and the 1x to 10x slider. Click the image to zoom. **1. Set up the deposit** Under **Deposit**, pick a token and amount. **WB** deposits from your wallet. **MB** sizes the loan against collateral already in the margin account, so nothing new is deposited. **2. Choose Single or Dual Borrow** **Single Borrow** puts the whole loan on one asset. **Dual Borrow** splits it 50/50 across two different assets from two pools (you can edit each amount). **3. Pick the asset** Choose XLM, BLUSDC, AqUSDC or SoUSDC. Borrow the USDC variant your venue uses: BLUSDC for Blend, SoUSDC for Soroswap, AqUSDC for Aquarius. **4. Set the size** Drag the slider (**1x to 10x**), use **− / +**, type an amount, or click **Max Value**. **Total** and **Max** show the loan in USD. Max = deposit × (leverage − 1). **5. Review and sign** **Transaction Details** shows account leverage, what you're depositing and borrowing, margin collateral, outstanding debt, health factor and liquidation buffer, before → after. Click **Deposit & Borrow** (or **Borrow** in MB mode) and approve. ## How many signatures | Case | Transactions | | - | - | | One collateral, Single Borrow | **One**: deposit and borrow together (`deposit_and_borrow`) | | One collateral, Dual Borrow | **Two**: deposit + first borrow, then the second borrow | | Several collaterals | Deposits first, then the borrow(s) | | MB (borrow only) | One borrow per asset | If a combined deposit-and-borrow would exceed Soroban's per-transaction budget, the app splits it into a deposit and then a borrow. If the second borrow of a Dual Borrow fails, the first one stays done. Check your positions before retrying. ## Where the loan goes Borrowed tokens land in your **margin account**, not your wallet, and count as collateral there. From there you can [swap](/stellar/guides/trade/spot-swap) or [farm](/stellar/guides/farm/overview). To take them out, use [Transfer Collateral](/stellar/guides/margin/transfer-collateral); that withdrawal is health-checked. ## Limits * The Risk Engine rejects a borrow unless the account stays **above 1.10** afterward. The app shows the highest leverage that allows, up to 10x. * A pool lends only the cash it holds, and no borrow can push it past **95% utilization**. * The app warns you when the health factor after borrowing would sit between 1.10 and 1.25. ## Interest Debt grows at the pool's **Borrow APY**, which rises with utilization. **Net Borrow Rate** on the Margin page is your account's blended rate. Accrued interest shows in **Positions** and on **Portfolio**. > [!WARNING] > > At or below a Health Factor of 1.1, a priced account with debt is a liquidation candidate. The current liquidation path transfers remaining collateral to the liquidator; it does not automatically close the SmartAccount. Next: [Repay](/stellar/guides/margin/repay). # Deposit Collateral Source: https://docs.vanna.finance/stellar/guides/margin/deposit-collateral Move XLM, BLUSDC, AqUSDC or SoUSDC from your wallet into your margin account, with or without borrowing. Depositing moves tokens from your **wallet** into your **margin account**, where they back your loans. This is different from supplying on Earn. There are two ways to deposit: **Deposit and borrow** Use **Leverage your Assets** when you want to borrow in the same flow. **1. Add collateral** Under **Deposit**, pick the token. Keep the source on **WB** (wallet balance) and enter an amount or use the % chips. Click **+ Add Collateral** to deposit more than one token. **2. Set the borrow** Choose what to borrow and the leverage. Leave leverage at **1x** to deposit without borrowing. **3. Sign** With one collateral, deposit and borrow go out as **one** transaction. With several collaterals, the app deposits first and borrows second. See [Borrow](/stellar/guides/margin/borrow). **Deposit only** Use **Transfer Collateral** (or the header **Deposit → Transfer** tab) to add collateral without creating debt. **1. Pick the direction** Set **From** to your wallet and **To** to the margin account. **2. Choose token and amount** Pick the exact token and enter the amount. **3. Review and sign** Check the health factor before → after and sign. Adding collateral only raises your health factor. See [Transfer Collateral](/stellar/guides/margin/transfer-collateral). ## Good to know * **Supported collateral:** XLM, BLUSDC, AqUSDC and SoUSDC. The three USDC tokens are different; deposit the one you hold. * **XLM reserve:** a 100% XLM deposit keeps back your wallet's minimum reserve plus a fee buffer. * **Check the margin balance**, not only your wallet balance, after the transaction confirms. Next: [Borrow](/stellar/guides/margin/borrow). # Health Factor Source: https://docs.vanna.finance/stellar/guides/margin/health-factor The one number that decides whether you can borrow more, withdraw, or get liquidated. The **health factor (HF)** compares everything your margin account holds with everything it owes: ```text theme={null} Health factor = total collateral (USD) / total debt (USD) ``` Collateral includes tokens you deposited, tokens you borrowed (they sit in the account), tokens you swapped into, Blend supply and Soroswap / Aquarius LP positions. Tokens count at full oracle value, with no per-asset haircuts. LP positions are valued conservatively, at twice the smaller side of the pool's reserves. An account with no debt shows **No debt**. > [!WARNING] > > Health Factor must be strictly above 1.1 for a debt-bearing account to be healthy. Liquidation eligibility also depends on oracle and execution checks; displayed snapshots can lag current state. ## Zones | Health factor | Label in the app | What it means | | - | - | - | | 1.50 and above | **Safe** | Comfortable room | | 1.25 to 1.50 | **Healthy** | Fine, but watch it | | above 1.10 to 1.25 | **At risk** | Close to the line; the app warns before actions that land here | | 1.10 or below | **Liquidation** | Anyone can liquidate the account | The **Liquidation** card on the Margin page shows the HF on a bar from **1.10** to **2.50+** and a **buffer**: how many dollars of collateral value you can lose before reaching 1.10. ```text theme={null} buffer = total collateral − 1.10 × total debt ``` ## What moves it | Up | Down | | - | - | | Depositing collateral | Borrowing more | | Repaying debt | Withdrawing to your wallet | | Your collateral's price rising | Your collateral's price falling | | Your debt asset's price falling | Your debt asset's price rising, interest accruing | Swaps and Farm deposits move value between assets inside the account, so they change the HF only by fees, price impact and how LP positions are valued. ## Where the app checks it * **Borrow:** the Risk Engine requires the account to stay above **1.10** after the borrow. * **Withdraw to wallet:** the app blocks withdrawals that would bring the HF to 1.10 or below; the Risk Engine checks again on-chain. * **Spot:** a swap that would drop the HF below **1.15** is blocked. > [!TIP] > > To raise your health factor fast: [repay](/stellar/guides/margin/repay) some debt or [deposit more collateral](/stellar/guides/margin/deposit-collateral). Farm positions must be exited before their tokens can repay a loan. See [Liquidation](/stellar/guides/margin/liquidation) and the [technical health factor page](/stellar/learn/health-factor). # Liquidation Source: https://docs.vanna.finance/stellar/guides/margin/liquidation What happens when a margin account's health factor reaches 1.10, and how to avoid it. A margin account with debt can be liquidated when its health factor is **1.10 or below**. There is no grace period, and anyone can liquidate it; your signature isn't needed. > [!WARNING] > > Health Factor must be strictly above 1.1 for a debt-bearing account to be healthy. Liquidation eligibility also depends on oracle and execution checks; displayed snapshots can lag current state. ## What happens **1. A liquidator repays all your debt** The liquidator pays every loan in full, from their own tokens, back to the Vanna pools. **2. Your Farm positions go to the liquidator** Blend supply is withdrawn straight to the liquidator, and Soroswap / Aquarius LP tokens are transferred to them. **3. Your remaining tokens go to the liquidator** Every token left in the margin account is swept to the liquidator. > [!WARNING] > > **Liquidation takes all remaining collateral**, not just the debt plus a bonus. Nothing above the debt comes back to you. The account itself stays open (empty, with no debt) and can be used again. ## How to avoid it > **[Watch the buffer](/stellar/guides/margin/health-factor)** > > The Liquidation card shows how many dollars you can lose before 1.10. Keep it large. > **[Repay or add collateral](/stellar/guides/margin/repay)** > > Repaying debt or depositing more both raise the health factor straight away. * Remember that **interest** keeps adding to your debt, and a stablecoin loan against XLM loses health when XLM falls. * **Farm positions can't repay a loan directly.** Exit them first, which takes extra transactions; don't leave it to the last minute. * **Analytics → Liquidations** shows accounts that can be liquidated now and how close others are. ## Settling an account yourself Separately from liquidation, the contract offers owner-authorized **settlement**: it unwinds Farm positions into the margin account and repays debt from its balances. What's left stays in the account until you withdraw it. > [!WARNING] > > At or below a Health Factor of 1.1, a priced account with debt is a liquidation candidate. The current liquidation path transfers remaining collateral to the liquidator; it does not automatically close the SmartAccount. See [Health Factor](/stellar/guides/margin/health-factor) and the [technical liquidation page](/stellar/learn/liquidation). # Open a Margin Account Source: https://docs.vanna.finance/stellar/guides/margin/open-account Create your personal Stellar smart account in one signature before depositing collateral or borrowing. You need a margin account to borrow, swap on Spot or farm. You don't need one to lend on Earn. **1. Connect the owner wallet** Connect the wallet that will own the account. Only this wallet can use it. See [Connect Your Wallet](/stellar/guides/connect-wallet). **2. Start on the Margin page** Open **Margin**. If you don't have an account yet, the action button reads **Create your Margin Account**. Click it. **3. Create Margin Account** The first dialog explains the steps. Click **Create Your Account**. **4. Review and Sign Agreement** Read the terms (collateral requirement, borrowing limits, variable interest, liquidation risk). Tick **I have read and agree to the VANNA Borrow Agreement** and click **Sign Agreement**. **5. Approve in your wallet** Sign the `create_account` transaction. When it confirms, the Margin page loads your new account. ## Good to know * **Two addresses.** Your wallet starts with **G**. Your margin account is a contract and starts with **C**. They hold separate balances. * **Found automatically.** On reconnect, Vanna finds your account on-chain. You never need a second one. * **Closing.** Closing is a contract operation, not a button on the Margin page. An account can't be closed in the ledger it was created in, and closing requires zero debt; it unwinds remaining positions and sends the tokens back to you. Repaying or being liquidated does not close an account by itself. Next: [Deposit Collateral](/stellar/guides/margin/deposit-collateral). # Margin Account Source: https://docs.vanna.finance/stellar/guides/margin/overview Deposit collateral, borrow one or two assets at 1x to 10x, repay and move collateral, all from one Stellar smart account. Your **margin account** is a Soroban smart contract that only you control. It holds your collateral, everything you borrow, and anything you swap or farm with it. One **health factor** covers the whole account. ![Margin page with Leverage your Assets, Repay Loan and Transfer Collateral tabs, a 10 XLM deposit from the wallet balance, Add Collateral, a Single Borrow / Dual Borrow toggle, a BLUSDC borrow with Max Value, a 1x to 10x leverage slider set to 2, and on the right Margin Account Info (Total Borrowed value, Net Available Collateral, Total Value, Net Health Factor 1.82, Net Borrow Rate 3.78%) and a Liquidation card showing 1.82 Safe, liquidation at 1.10 with a dollar buffer](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/margin/margin-leverage.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=63cae475feb12253e47c06aee6228fe6) The Margin page: the Leverage your Assets tab on the left, Margin Account Info and the Liquidation card on the right. Click the image to zoom. ## The three tabs > **[Leverage your Assets](/stellar/guides/margin/borrow)** > > Deposit collateral and borrow in one go, with Single or Dual Borrow and a 1x to 10x slider. > **[Repay Loan](/stellar/guides/margin/repay)** > > Pay back a loan from the margin account's own balance. > **[Transfer Collateral](/stellar/guides/margin/transfer-collateral)** > > Move tokens between your wallet and the margin account. ## The right column | Card | What it shows | | - | - | | **Margin Account Info** | **Total Borrowed value** (debt with interest), **Net Available Collateral** (holdings minus debt), **Total Value** (everything the account holds), **Net Health Factor**, and **Net Borrow Rate** (your blended borrow rate) | | **Liquidation** | The health factor, its zone (Safe, Healthy, At risk, Liquidation), the bar from 1.10 to 2.50+, and the dollar **buffer** you can lose before reaching **1.10** | | **Oracles and LTs** | The on-chain Oracle and Risk Engine contracts, the liquidation threshold and each asset's oracle price | ## Positions ![Positions section with Current Positions and Positions History tabs showing one Account: Collateral 4,745.10 XLM and 399.95 BLUSDC, an Account value node of \$2,532.42 with Interest accrued \$1.73 and Borrow rate 3.78%, Borrowed 4 assets (SOUSDC 76% of debt, XLM 23%, AQUSDC 1%, BLUSDC 1%) each with a Repay button, and a footer saying Borrowed money is in Farm \$579.18 and Idle \$747.47](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/margin/margin-positions.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=189cdb77f05d2ffd0a548d683eb6c215) Current Positions: collateral on the left, loans on the right with Repay, and where the borrowed money is now. Click the image to zoom. **Current Positions** shows the whole account as one map, because every deposit backs every loan: * **Collateral**: what you deposited (borrowed tokens sitting in the account aren't counted twice). * **Account value**: total holdings, with **Interest accrued** and the **Borrow rate**. * **Borrowed**: each loan, its share of total debt and a **Repay** button that opens the Repay tab on that asset. * **Borrowed money is in**: where the borrowed funds sit now, **Farm** (deployed to Blend or LP) or **Idle** (in the account). **Positions History** lists your margin transactions, each linked to Stellar Expert. ## Start here **1. Open an account** [Open a Margin Account](/stellar/guides/margin/open-account). **2. Deposit and borrow** [Deposit collateral](/stellar/guides/margin/deposit-collateral) and [borrow](/stellar/guides/margin/borrow). **3. Use the funds** [Swap](/stellar/guides/trade/spot-swap) or [farm](/stellar/guides/farm/overview), then watch your [health factor](/stellar/guides/margin/health-factor). > [!WARNING] > > At or below a Health Factor of 1.1, a priced account with debt is a liquidation candidate. The current liquidation path transfers remaining collateral to the liquidator; it does not automatically close the SmartAccount. # Repay a Loan Source: https://docs.vanna.finance/stellar/guides/margin/repay Pay back a loan from your margin account's own balance of that asset, partly or in full. Repaying sends tokens from your **margin account** back to the lending pool. It never pulls from your wallet. **1. Open Repay Loan** On **Margin**, open **Repay Loan**, or click **Repay** next to a loan in **Current Positions** to open the tab on that asset. **2. Check the two tiles** **Net Outstanding Amount to Repay** is the live debt for that asset, interest included. **Available Balance in Margin Account** is what the account holds of that asset. **3. Enter the amount** Use **10% / 25% / 50% / 100%** (a share of the debt, capped to your balance) or type an amount. **4. Review and Pay Now** The preview shows Outstanding Debt, Margin Collateral, Health Factor and Liquidation Buffer before → after. Click **Pay Now** and approve. ## Not enough of the asset in the account? The tab tells you and offers **Transfer from wallet**. You have three ways to get the token into the margin account: > **[From your wallet](/stellar/guides/margin/transfer-collateral)** > > Transfer Collateral, wallet → margin account. > **[Swap for it](/stellar/guides/trade/spot-swap)** > > Swap another token in the account on Spot. > **[Exit a Farm position](/stellar/guides/farm/overview)** > > Withdraw from Blend or remove LP liquidity first. ## Good to know * **100% clears the debt.** The app adds a small buffer for interest that accrues while you sign; the contract only takes what is actually owed. * **Repaying from collateral** lowers both your holdings and your debt. It usually raises the health factor; check the preview. * **Repay the right pool.** Each loan is repaid in its own asset: BLUSDC debt with BLUSDC, SoUSDC debt with SoUSDC. Next: [Transfer Collateral](/stellar/guides/margin/transfer-collateral). # Transfer Collateral Source: https://docs.vanna.finance/stellar/guides/margin/transfer-collateral Move tokens between your wallet and your margin account. Withdrawals are health-checked. **Transfer Collateral** moves a token between your wallet and your margin account. The same form is on the header's **Deposit → Transfer** tab. **Wallet → Margin (MB)** Adds collateral without creating debt, so your health factor goes up. **1. Set the direction** **From** your wallet, **To** the margin account. Use the swap button to flip it. **2. Choose token and amount** Pick XLM, BLUSDC, AqUSDC or SoUSDC and an amount. 100% of XLM keeps back your wallet's minimum reserve. **3. Sign** Review and approve (`deposit_collateral_tokens`). **Margin → Wallet (WB)** Withdraws tokens the margin account holds. With open debt, this lowers your health factor. **1. Set the direction** **From** the margin account, **To** your wallet. **2. Choose token and amount** **Max** and the % chips stop at the most you can withdraw while staying safely above **1.10**. **3. Check the health factor and sign** The app blocks a withdrawal that would bring the health factor to 1.10 or below, and warns below 1.25. The Risk Engine checks again on-chain (`withdraw_collateral_balance`). ## Good to know * **Farm positions aren't withdrawable tokens.** Blend supply and LP shares count as collateral, but you must exit them on [Farm](/stellar/guides/farm/overview) before you can transfer the underlying. * **Net Available Collateral is not a withdrawal limit.** It is holdings minus debt. Use **Max** in the form instead. * If a transaction fails, the amount you typed stays in the form so you can retry. See [Deposit Collateral](/stellar/guides/margin/deposit-collateral) and [Health Factor](/stellar/guides/margin/health-factor). # Portfolio Source: https://docs.vanna.finance/stellar/guides/portfolio Net worth, net earnings and health factor across your wallet, lending and margin account, with Lender, Trader and Balances tabs. **Portfolio** is the first item in the header. It brings your wallet, your Earn supply and your margin account together in one view. Every number is read from the chain (or Vanna's indexer) for the connected wallet only. ![Portfolio page with Net worth \$56,435.37 split into Wallet, Lending and Margin equity, Net earnings +\$0.35 with Lending and Trading chips, a Health factor card at 1.82 Safe with the chameleon mascot, Borrowed, Leverage and Interest accrued, and the Lender tab showing Lender Stats and a Lending P\&L chart](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/portfolio/portfolio-overview.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=5b0b956062e165d7879430f8b64d8622) Portfolio: the three header cards and the Lender tab. Click the image to zoom. ## The header cards | Card | What it shows | | - | - | | **Net worth** | Wallet tokens + lending supply (interest included) + margin account **equity** (holdings minus debt), at oracle prices. The bar splits it into Wallet, Lending and Margin equity. | | **Net earnings** | **Lending**: interest earned on your supply. **Trading**: reads \$0.00 because spot and farm P\&L have no on-chain cost basis on Stellar yet. | | **Health factor** | Your margin account's health factor with its zone (Safe, Healthy, At risk, Liquidation), the health bar, and Vanna's chameleon mascot. Below it: **Borrowed**, **Leverage** and **Interest accrued**. The share icon makes a card you can post. | ## Tabs **Lender** **Lending pools**: Lender Stats (Total Holdings, Supplied Assets, Avg Supply APY, Interest earned), a 30-day **Lending P\&L** chart and your positions per pool, with current positions and position history. **Trader** Three sub-tabs: * **Margin**: the same account map as the Margin page (collateral, loans, account value, interest accrued, borrow rate), leverage, health factor and collateral left before liquidation. * **Spot**: every token your margin account holds directly, plus your swap history. * **Farm**: your Blend supply and Soroswap / Aquarius LP positions. **Balances** **Wallet**, **Margin account** and **Total** cards, then a searchable token table for either the wallet or the margin account. The margin account total is shown **before** debt is subtracted. ![Portfolio Balances tab with Wallet \$55,121.28 across 4 tokens, Margin account \$2,532.42 across 7 holdings with debt not subtracted, Total \$57,653.70, and a Wallet token table listing SOUSDC, XLM, AQUSDC and BLUSDC with balance, price and value](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/portfolio/portfolio-balances.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=9e5e42c89e850e688f728ae6eea09013) Balances tab: wallet, margin account and total, with a token table for each. Click the image to zoom. ## Good to know * Margin **equity** (in Net worth) and margin **holdings** (in Balances) differ by your debt. Don't add borrowed funds to your net worth twice. * Blend supply and LP positions count as collateral, but you have to withdraw them on [Farm](/stellar/guides/farm/overview) before you can spend or repay with the underlying tokens. * A transaction can show up in balances a few seconds before it appears in history. **Deposit** and **Transfer** buttons at the top right of the page open the same modal as the header's Deposit button. To act on a position, go to [Earn](/stellar/guides/earn/overview), [Margin](/stellar/guides/margin/overview) or [Farm](/stellar/guides/farm/overview). # Sample Strategies Source: https://docs.vanna.finance/stellar/guides/sample-strategies Worked testnet examples that combine Vanna borrowing, Earn and Farm. Illustrations, not yield promises. These are testnet workflows that combine Vanna borrowing, Earn and Farm. They show how the pieces fit; they are not promises of positive carry, fixed yield or price neutrality. > **[Cross-Pool Rate Carry](/stellar/guides/strategies/cross-pool-rate-carry)** > > Borrow a token on Vanna and supply the same token to Blend. > **[Parallel Rate Carry](/stellar/guides/strategies/parallel-rate-carry)** > > Run XLM and BLUSDC carry legs side by side with Dual Borrow. > **[Earn, Borrow, and Hedge](/stellar/guides/strategies/earn-borrow-hedge)** > > Keep an Earn position while running a separate margin position. > **[Dual Yield Stack](/stellar/guides/strategies/dual-yield-stack)** > > Earn on Vanna's pools and on Blend at the same time. ## Rules for every strategy * **Use the exact token.** BLUSDC for Blend, SoUSDC for Soroswap, AqUSDC for Aquarius. * **Check today's rates** on Earn (Borrow APY) and Farm (supply APY) before you start. * **One account, one health factor.** Every leg in a margin account shares its debt and liquidation risk. * **Earn vTokens don't back margin.** vTokens in your wallet are not collateral for your margin account. * **Spot only.** Stellar has no perps or options, so a hedge has to be built from spot positions. > [!WARNING] > > At or below a Health Factor of 1.1, a priced account with debt is a liquidation candidate. The current liquidation path transfers remaining collateral to the liquidator; it does not automatically close the SmartAccount. # Cross-Pool Rate Carry Source: https://docs.vanna.finance/stellar/guides/strategies/cross-pool-rate-carry Borrow XLM or BLUSDC on Vanna and supply the same token to Blend. An illustrative testnet workflow. Borrow a token from Vanna and supply **the same token** to Blend from your margin account. You earn Blend's supply APY on the borrowed amount and pay Vanna's borrow APY on it. **1. Deposit and borrow** On **Margin → Leverage your Assets**, deposit collateral and borrow **XLM** or **BLUSDC**. See [Borrow](/stellar/guides/margin/borrow). **2. Supply to Blend** On **Farm → Lending/Single Assets**, open the same asset and supply it. See [Blend](/stellar/guides/farm/blend-pools). **3. Monitor the spread** Compare Blend's supply APY with the asset's Borrow APY on Earn, and keep an eye on your health factor. **4. Exit** Withdraw from Blend, [repay](/stellar/guides/margin/repay) the loan in the same asset, then check what's left. ## What it does and doesn't hedge The borrowed and supplied amounts are the same token, so their price moves offset each other. Your own **collateral** is still exposed, both amounts change as interest accrues, and Blend's liquidity and protocol risk remain. The account as a whole is not automatically delta-neutral. See [Sample Strategies](/stellar/guides/sample-strategies) and [Leveraged Yield](/stellar/guides/farm/leveraged-yield). # Dual Yield Stack Source: https://docs.vanna.finance/stellar/guides/strategies/dual-yield-stack Earn on Vanna's lending pools and on Blend at the same time. An illustrative testnet workflow. Hold an **Earn** position in your wallet while a separate, margin-funded **Blend** supply position runs in your margin account. The two yields come from different places, with different custody, rates and withdrawal limits. **1. Earn leg** Supply on **Earn** from your wallet. See [Supply](/stellar/guides/earn/supply). **2. Farm leg** Deposit and borrow on **Margin**, then supply the borrowed token to Blend on **Farm**. See [Leveraged Yield](/stellar/guides/farm/leveraged-yield). **3. Manage each leg** The Earn leg is managed on its pool; the Farm leg through the margin account and its health factor. **4. Exit** Redeem on Earn (it may fill partly). Withdraw from Blend, then repay the loan. ## Good to know * **vTokens don't back the margin leg.** Your Earn position doesn't protect the margin account from liquidation. * **No guaranteed sum.** The combined yield isn't guaranteed to be positive or price-neutral. See [Sample Strategies](/stellar/guides/sample-strategies) and [Repay](/stellar/guides/margin/repay). # Earn, Borrow, and Hedge Source: https://docs.vanna.finance/stellar/guides/strategies/earn-borrow-hedge Keep an Earn position in your wallet while running a separate margin position. An illustrative testnet workflow. Supply an asset on **Earn** from your wallet, and separately run a margin position. The two are held and accounted for separately. **1. Supply on Earn** Lend XLM or a USDC token from your wallet. See [Supply](/stellar/guides/earn/supply). **2. Open the margin leg** Deposit collateral and borrow on **Margin**. See [Borrow](/stellar/guides/margin/borrow). **3. Decide what you're hedging** Write down the exposure you want to offset and which spot tokens offset it. Holding vTokens while borrowing another asset is not a hedge by itself. **4. Exit each side** Redeem vTokens on Earn (a large redemption can fill partly) and unwind / repay the margin leg on its own. > [!NOTE] > > Stellar has no perps or options. Any hedge must be built from spot tokens, for example by swapping inside the margin account on Spot. See [Sample Strategies](/stellar/guides/sample-strategies) and [Withdraw](/stellar/guides/earn/withdraw). # Parallel Rate Carry Source: https://docs.vanna.finance/stellar/guides/strategies/parallel-rate-carry Run XLM and BLUSDC carry legs side by side in one margin account using Dual Borrow. Borrow **XLM** and **BLUSDC** together with **Dual Borrow**, then supply each to its matching Blend pool. Both legs live in one margin account. **1. Dual Borrow** On **Margin → Leverage your Assets**, deposit collateral, switch to **Dual Borrow**, and pick XLM and BLUSDC. See [Borrow](/stellar/guides/margin/borrow). **2. Supply each leg** On **Farm**, supply XLM to the Blend XLM pool and BLUSDC to the Blend BLUSDC pool. **3. Monitor both spreads** Compare each Blend supply APY with its Vanna Borrow APY. Rates, amounts and debt are tracked per asset. **4. Exit both legs** Withdraw each asset from Blend and repay its own loan. Then check for leftovers. ## Good to know * **Shared risk.** The two legs share one health factor. They are not two isolated loans. * **Several transactions.** Opening and closing take several transactions. If one fails after another confirms, check the account before retrying. See [Sample Strategies](/stellar/guides/sample-strategies) and [Repay](/stellar/guides/margin/repay). # Spot Swap Source: https://docs.vanna.finance/stellar/guides/trade/spot-swap Swap tokens inside your margin account on Soroswap or Aquarius, with a live health-factor preview and route. **Trade → Spot** swaps tokens that your **margin account** holds, through **Soroswap** or **Aquarius**. The tokens never leave the account, so whatever you receive keeps counting as collateral. Spot is the only trading surface on Stellar; there are no perps or options. ![Spot swap card with the via Soroswap dropdown open showing Soroswap (XLM / SoUSDC pool, selected) and Aquarius (XLM / AqUSDC pool), 10 XLM in and 1.6920992 SoUSDC out, a quote line 1 XLM = 0.169556 SoUSDC with HF 1.82 to 1.82, a one-hop Soroswap route from XLM to SoUSDC, and a Margin account card showing health factor 1.82, account leverage 2.21x, borrowed \$1,388.42 and swappable XLM](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/trade/spot-swap.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=ca0a04f28aca012f448e1bf268e6569d) Swapping 10 XLM to SoUSDC via Soroswap: the venue picker, the quote line with the health factor before → after, the route, and the Margin account card. Click the image to zoom. ## Venues | Venue | Pool | USDC token | | - | - | - | | **Soroswap** | XLM / SoUSDC | SoUSDC | | **Aquarius** | XLM / AqUSDC | AqUSDC | Pick the venue from the **via ▾** menu next to **Swap**. Each venue only lists its own pair, and the token list resets when you switch. ## Swap **1. Pick the venue** Open **Trade → Spot** and choose **Soroswap** or **Aquarius**. **2. Enter what you pay** Choose the token and amount under **You Pay**, or use the % chips and **Max**. **Swappable** is what the margin account holds of that token. **3. Check the quote** The quote line shows the rate and **HF before → after**. Expand it for the minimum received and slippage. The **Route** card shows the hops and venue. **4. Check the Margin account card** It shows health factor, account leverage, borrowed, and swappable balance, each before → after this swap. **5. Swap** Click **Swap** and approve in your wallet. ## Safety checks * **Health-factor floor:** if a swap would lower your health factor below **1.15**, the button turns into "Health factor would fall below 1.15" and the swap is blocked. Between 1.15 and 1.25 it shows an amber warning. * **Slippage:** **Auto** is 0.5%. The settings gear lets you pick 0.1%, 0.5% or 1.0%, or a custom value; above 3% the app warns you. * **Quotes move.** Prices can change between quote and execution; the minimum received protects you. > [!NOTE] > > You need a margin account with tokens in it to swap. Fund it with [Deposit Collateral](/stellar/guides/margin/deposit-collateral) or [Borrow](/stellar/guides/margin/borrow). ## History **Position History** under the swap card lists your margin account's swaps on both venues, newest first. Portfolio → Trader → Spot shows the same list. See [Health Factor](/stellar/guides/margin/health-factor). # Vanna on Stellar Source: https://docs.vanna.finance/stellar/home One margin account on Stellar: lend, borrow up to 10x, swap on Soroswap or Aquarius, and farm on Blend, all under one health factor. ![Vanna](https://mintcdn.com/vannafinance/UHj8oBBMt2jwIvZH/logo/vanna-dark.png?fit=max\&auto=format\&n=UHj8oBBMt2jwIvZH\&q=85\&s=8d4a259c94861810159a811d7d5a66bd) Composable Crediton Stellar. Earn. Borrow. Trade. Farm. START Get started in three stepsConnect Freighter, mint free test tokens from the Deposit button, then lend, borrow up to 10x, swap on Soroswap or Aquarius, or farm on Blend. ❯ [Open](/stellar/guides/getting-started) [LendersSupply XLM, BLUSDC, AqUSDC or SoUSDC to Vanna's lending pools and earn the interest margin borrowers pay. No margin account needed.❯](/stellar/guides/for-liquidity-providers) [TradersOpen a margin account, borrow one or two assets at 1x to 10x, then swap or farm with the borrowed funds, all under one health factor.❯](/stellar/guides/for-traders) [DevelopersSoroban contracts, protocol controllers, deployed testnet addresses, the math reference and integration guides.❯](/stellar/developers/overview) > [!NOTE] > > **App:** [test.vanna.finance](https://test.vanna.finance) (choose **Stellar** in the chain switcher) · **Network:** Stellar testnet · **Wallet:** Freighter (or OneKey) set to Testnet · Test tokens are free from the app's **Deposit** button. ## What you can do > **[Earn](/stellar/guides/earn/overview)** > > Lend XLM or one of three USDC test tokens and earn borrow interest. > **[Margin](/stellar/guides/margin/overview)** > > Deposit collateral and borrow at 1x to 10x, with Single or Dual Borrow. > **[Spot](/stellar/guides/trade/spot-swap)** > > Swap inside your margin account on Soroswap or Aquarius, with a health-factor preview. > **[Farm](/stellar/guides/farm/overview)** > > Supply margin funds to Blend, or add XLM/USDC liquidity on Soroswap and Aquarius. > **[Portfolio](/stellar/guides/portfolio)** > > Net worth, net earnings and health factor across wallet, lending and margin. > **[Copilot](/stellar/guides/copilot)** > > Ask about your account or describe a change in plain English. ## Learn more > **[How Vanna works](/stellar/guides/how-vanna-works)** > > Where your tokens go when you lend, borrow, swap and farm. > **[Health factor](/stellar/guides/margin/health-factor)** > > The one number that decides whether you can borrow more or get liquidated. > **[Analytics](/stellar/guides/analytics/overview)** > > Live, protocol-wide risk: every margin account read from the chain. > **[FAQ](/stellar/resources/faq)** > > Quick answers about wallets, test funds, leverage and liquidation. # Composable Leverage Source: https://docs.vanna.finance/stellar/learn/composable-leverage How a margin account deploys borrowed funds into Blend, Soroswap and Aquarius through controllers. A margin account can deploy deposited and borrowed assets into approved external protocols while the account keeps its debt to Vanna's lending pools. | Action | Venue | What the account holds afterwards | | - | - | - | | Supply | Blend | b-tokens (a receipt for the supplied asset) | | Add liquidity | Soroswap, Aquarius | LP shares | | Swap | Soroswap, Aquarius | A different token | Protocol **controllers** mediate each action: AccountManager routes the call to a Registry-approved controller, which checks the target and tokens, executes from the margin account, and reports the change so recognized collateral stays correct. ## Shared account risk All positions in an account share its health factor and debt. One profitable Farm position does not isolate it from another position's losses. External positions must be exited before their underlying can repay a loan. ## Execution boundaries Each external action is its own transaction. A deposit and a single borrow can go out together (`deposit_and_borrow`), but borrow-then-farm, LP entries and unwinds take several steps. Earlier confirmed steps survive a later failure, so check the account before retrying. A registered controller doesn't guarantee that an external pool has liquidity; the transaction simulation is the final check. See [Farm](/stellar/guides/farm/overview), [Leveraged Yield](/stellar/guides/farm/leveraged-yield) and [Controllers](/stellar/developers/contracts/controller-facade). # Health Factor Source: https://docs.vanna.finance/stellar/learn/health-factor How the Risk Engine values collateral and debt, and the 1.10 liquidation threshold. Health factor compares recognized collateral value with debt value: ```text theme={null} Health factor = collateral USD / debt USD ``` A priced account with debt must be **strictly above 1.1** to be healthy. At or below 1.1 it is a liquidation candidate. Zero debt is healthy; the contract uses a maximum-integer sentinel for an unbounded ratio. ## What is collateral? Direct token balances use oracle prices. Blend supply is valued using its b-token exchange rate and underlying price. Registered Soroswap and Aquarius LPs can contribute a conservative value based on the smaller USD-valued reserve side. Explicitly unpriced, frozen, revoked, or unavailable positions can contribute zero. Cached values on some paths can differ from current external position value. ## Debt and new borrowing Debt reads include pending pool interest. Existing borrowed proceeds are already part of account assets when held or deployed; do not count the same debt twice as collateral. A standalone new-borrow check compares `(C+B)/(D+B)` with 1.1. Withdrawal compares the reduced collateral to existing debt. Net credits, fees, permissions, and pool limits can further constrain actual borrowing. ## Displayed account metrics Equity is collateral minus debt. The UI labels a nonnegative equity value as Net Available Collateral; it is not a promise that this amount can be withdrawn. Liquidation collateral headroom is `max(0, C-1.1*D)`. Market prices, interest, LP reserve changes, and oracle/configuration changes can move these figures. There is no universal guaranteed maximum leverage or time to liquidation. Read [Liquidation](/stellar/learn/liquidation) and [Math Reference](/stellar/developers/math-reference). # Interest Rate Model Source: https://docs.vanna.finance/stellar/learn/interest-rate-model The utilization-based polynomial borrow-rate curve and the 95% borrow cap. The borrow rate rises as more of a pool's assets are borrowed. Utilization is outstanding debt divided by available cash plus outstanding debt. The implemented curve combines linear, 32nd-power, and 64th-power utilization terms. Defaults use coefficients 0.1, 0.3, and 3.5, producing a smooth curve that steepens at high utilization. It is not a two-slope kink model. ## Configurable economics The rate-model admin can change the coefficients, within an implied worst-case cap of 1000% APR at full utilization. Each pool can also change its rate-model address. A historical example or default coefficient does not establish today's deployed rate. The pool's separate 95% utilization cap limits new borrowing; it is not the interest model's maximum input. Supply yield depends on utilization and borrower interest, and displayed APR is not guaranteed realized APY. Interest accrues between updates. Reads preview it, and subsequent pool operations persist it. See [Rate Model](/stellar/developers/contracts/rate-model) and [Math Reference](/stellar/developers/math-reference). # Pool Mechanics Source: https://docs.vanna.finance/stellar/learn/lending-pool-mechanics Receipt shares, debt shares, lazy interest accrual, origination fees and redemption limits. ## Deposits and receipts Deposits convert underlying into share receipts. Later deposits use the ratio of total assets to receipt supply with a small virtual offset. The first deposit has special initial-share accounting. Token and receipt native decimals affect the final amounts. ## Debt shares Debt uses shares so interest can accrue pool-wide without rewriting every borrower. New debt shares round up; regular repayment shares round down, with dust handling and clamps. Account debt reads include pending interest. ## Lazy interest accrual Read previews floor the pending interest term. Mutations persist interest with ceiling rounding and advance the timestamp. A read-only simulation does not itself commit a pool update. ## Origination fee The fee is computed from gross borrowing and sent to treasury. Gross borrowing becomes debt; the remainder becomes account-held collateral. The frontend records a zero-fee configuration, but the fee is changeable and should be read from the selected pool. ## Redemption limits Requested receipt value is capped by 50% of total assets and available liquidity. Partial execution burns the corresponding receipt quantity. This is not a queued withdrawal request or an automatic promise to send the remainder later. See [exact formulas](/stellar/developers/math-reference) and [pool signatures](/stellar/developers/contracts/lending-pools). # Lending Pools Source: https://docs.vanna.finance/stellar/learn/lending-pools Vanna's four Stellar lending markets: cash, total assets, interest, borrowing and withdrawals. Liquidity providers deposit wallet assets into Vanna pools and receive vTokens. Margin accounts borrow from those pools and accrue interest. Each of the four configured markets—XLM, BLUSDC, AqUSDC, and SoUSDC—has separate liquidity, debt, and receipts. ## Cash and total assets Available liquidity is the underlying held by the pool. Total assets add outstanding debt, including previewed interest. A pool can therefore have substantial total assets but little immediately withdrawable cash. ## Interest and borrowing Rates respond to utilization under an admin-configurable polynomial curve. New borrows cannot push pool utilization above 95%. Borrowers owe the gross amount; an origination fee, if configured, reduces what reaches the SmartAccount. ## Withdrawals Redemption burns receipts at their current conversion rate. A single call pays at most 50% of total assets and the available cash, so a withdrawal can partially fill. The remaining receipts continue to represent a claim on the pool. No cash available means the redemption fails. Pools have pause controls. Pool pause stops deposit, redemption, and new borrow; repayment accounting remains available. See [Pool Mechanics](/stellar/learn/lending-pool-mechanics). # Liquidation Source: https://docs.vanna.finance/stellar/learn/liquidation How a permissionless, liquidator-funded liquidation works at HF 1.10, what moves, and how settlement differs. Liquidation is a permissionless, liquidator-funded full-debt operation. AccountManager verifies the account's current valuation and rejects healthy accounts. Health at or below 1.1 is eligible subject to oracle, configuration, funding, and execution checks. ## What moves The liquidator authorizes the operation and grants AccountManager token allowances. The manager accrues each recognized debt market and transfers repayment tokens from the liquidator to the lending pools. It exits Blend positions directly to the liquidator, transfers held AMM LP tokens to the liquidator, and sweeps remaining direct collateral. **The current liquidation path takes all remaining collateral.** It does not cap proceeds at debt plus 10% or split excess back to the owner. A configuration getter reports a 10% bonus value, but the executable path does not use that number as a payout formula. LP tokens received by the liquidator still need an external exit to realize underlying assets. ## Account status Liquidation does not deactivate or recycle the SmartAccount. Unknown debt symbols or residual debt require further inspection; an event alone is not proof that every liability disappeared. ## Oracle failure If the snapshot reports unpriceable plain collateral, AccountManager withholds liquidation. Missing external-position data and debt-price failures have separate conservative handling. A low displayed health factor during a data failure does not guarantee a successful liquidation transaction. ## Voluntary settlement Owner-authorized `settle_account` unwinds assets into the SmartAccount and attempts repayment from its balances. It returns whether debt is cleared. Remaining collateral stays in the account until withdrawn or swept by explicit `close_account`. Settlement is not an automatic wallet refund or a guaranteed debt-clearing operation. See [Liquidation Bots](/stellar/developers/guides/liquidation-bots) for integration details. # Oracle System Source: https://docs.vanna.finance/stellar/learn/oracle-system How the Reflector-backed oracle prices tokens, Blend receipts and LP positions. Vanna's Oracle service supplies prices to collateral and debt valuation. It reads a configured Reflector-compatible contract and returns an integer price with its decimal scale. ## Price selection The production service may use a 30-second memo. On a fresh lookup, it prefers an available positive five-record TWAP, then a positive spot price. The most recent upstream timestamp must be within 600 seconds. If those fail, an admin fallback can be used for up to 86,400 seconds after it was set. The fallback is not a permanent peg or a live external feed. If no usable price remains, the lookup fails. Repeated calls do not imply new market updates every ledger. ## Position prices Blend receipts are converted to underlying using the reserve b\_rate. AMM LP valuation uses committed reserves and a conservative smaller-side USD calculation. USDC feed aliases can value BLUSDC, AqUSDC, and SoUSDC without making those tokens interchangeable. RiskEngine has distinct handling for operational checks and liquidation snapshots. AccountManager refuses liquidation when plain collateral cannot be priced. Read [Oracle Service](/stellar/developers/contracts/oracle) and [Risk Engine](/stellar/developers/contracts/risk-engine). # Core Concepts Source: https://docs.vanna.finance/stellar/learn/overview The accounting model behind Vanna on Stellar: margin accounts, pools, vTokens, health factor and liquidation. Vanna connects liquidity providers with margin accounts that can use borrowed funds in approved Stellar protocols. These pages explain the accounting behind the app. > **[Margin accounts](/stellar/learn/smart-accounts)** > > Token custody and account-level debt. > **[Lending pools and vTokens](/stellar/learn/lending-pools)** > > Supply, borrowing and how vToken receipts grow. > **[Health factor and liquidation](/stellar/learn/health-factor)** > > Collateral valuation and how liquidation resolves debt. > **[Rates and prices](/stellar/learn/interest-rate-model)** > > The interest-rate curve and the Reflector-backed oracle. > **[Registry](/stellar/learn/registry)** > > Permitted assets, contracts and controllers. > **[Composable leverage](/stellar/learn/composable-leverage)** > > Deploying borrowed capital into Blend, Soroswap and Aquarius. These pages describe the Stellar testnet contracts, with XLM and three distinct USDC test tokens (BLUSDC, AqUSDC, SoUSDC). Contract addresses are listed in [Deployed Contracts](/stellar/developers/deployed-contracts). Also see [vTokens](/stellar/learn/vtokens), [Liquidation](/stellar/learn/liquidation), [Oracle System](/stellar/learn/oracle-system), [Pool Mechanics](/stellar/learn/lending-pool-mechanics) and [Protocol Architecture](/stellar/learn/protocol-architecture). # Protocol Architecture Source: https://docs.vanna.finance/stellar/learn/protocol-architecture The core contracts, per-trader smart accounts and protocol controllers, and how calls flow between them. The protocol has core accounting contracts, per-trader custody contracts, and external-protocol controllers. | Component | Role | | - | - | | AccountManager | Owner authorization, lifecycle, collateral, borrow/repay, strategy routing | | SmartAccount | Custody, address-based collateral ledger, debt and position snapshots | | LendingPool / vToken | Per-market cash, borrow shares, supplier receipts | | RiskEngine / Oracle | USD valuation, solvency checks, feed resolution | | Registry | Core addresses, asset metadata, controller permissions, account membership | | Blend / Soroswap / Aquarius controllers | Approved external actions and ledger updates | | TrackingToken | Per-symbol external receipt accounting | | Deployers | Core and lending-market deployment helpers | Earn deposits enter the pool directly. Margin operations enter AccountManager. External actions route through a Registry-approved controller and execute from SmartAccount custody. ControllerFacade exposes policy checks, while the current typed execution path reads Registry directly to reduce cost. Risk is checked at several points, with an admin-configurable live check after external execution. Valuation snapshots can include caches. See the [developer architecture diagram](/stellar/developers/architecture) and [contract reference](/stellar/developers/contracts/account-manager). # Registry Source: https://docs.vanna.finance/stellar/learn/registry The on-chain directory of contracts, assets, controllers and margin accounts, with its timelocks. Registry is the protocol's configurable directory. It maps core contracts, trader accounts, asset addresses and aliases, lending markets, controller routes, and external tracking metadata. ## Why token identity matters BLUSDC, AqUSDC, and SoUSDC are different test tokens. Registry associates each address with its lending pool and price feed. A shared USD price does not permit spending one variant in another protocol's pool. ## Controller permissions External actions require a registered controller and allowed tokens. After configuration finalization, controller registration is queued for 48 hours; asset, token, and tracking metadata updates have 24-hour queues. Before finalization, the queue methods apply immediately for bootstrap. Admin can cancel proposals and remove permissions. Finalization and admin transfer are explicit contract operations. Metadata includes asset risk fields, but the currently enforced RiskEngine health threshold remains the global 1.1. Do not infer a different liquidation formula from metadata alone. Use the [Registry Reference](/stellar/developers/contracts/registry) and [configured address list](/stellar/developers/deployed-contracts) for integration. # Margin Accounts Source: https://docs.vanna.finance/stellar/learn/smart-accounts Your margin account: a per-trader Soroban contract holding collateral, loans and Farm positions. A margin account is a separately deployed Stellar contract holding a trader's collateral and strategy assets. Your wallet authorizes its use through AccountManager. ## One account, multiple positions The same account can hold direct tokens, Blend supply, and AMM LP positions while owing debt in multiple Vanna lending markets. Health is assessed across the account. Farm cards are views of positions within that shared account, not independent liquidation compartments. Plain-token balances are keyed by token contract address. Tracking symbols identify external positions. BLUSDC, AqUSDC, and SoUSDC remain separate even though their price feeds may all resolve to USDC. ## Lifecycle Creating an account deploys or reactivates a contract. Closing requires no debt and a later ledger than activation; the manager unwinds external assets, sweeps remaining tokens to the owner, and deactivates the account for reuse. Repayment, settlement, and liquidation do not automatically close it. ## Spendable versus valued Collateral value includes recognized external positions, but those positions must be withdrawn or converted before their underlying is spendable. The account's risk ledger can also conservatively credit less than its raw token balance after swaps. Use the UI's current free balance and transaction simulation for actions. See [AccountManager](/stellar/developers/contracts/account-manager) and [SmartAccount](/stellar/developers/contracts/smart-account). # vTokens Source: https://docs.vanna.finance/stellar/learn/vtokens How vToken receipts track your share of a lending pool and grow with borrower interest. vTokens are the receipts issued by Vanna lending pools. Each of the four markets has a separate receipt contract. Your receipt balance measures shares; its underlying redemption value changes with pool assets and debt interest. ## How yield appears You do not need to claim a separate reward to realize lending interest. The value represented by a receipt can grow as interest accrues. Actual redemption still depends on available pool liquidity and the per-call payout cap. The exchange rate is approximately total assets divided by receipt supply; exact execution includes virtual-offset and native-rounding rules. Do not assume deposits always mint an equal number of whole receipts. ![Diagram showing a deposit receiving vTokens, borrower interest, and receipt redemption](https://mintcdn.com/vannafinance/nTvFas2wipJFpeKy/images/stellar/learn/vToken.png?fit=max\&auto=format\&n=nTvFas2wipJFpeKy\&q=85\&s=a8a0f1131813fd5ccb0b78c03b06b8b4) Conceptual interest-accrual example. Higher redemption value is not guaranteed; actual payouts depend on pool assets, liquidity, and caps. Click the image to zoom. ## Transfers and controls Receipts support holder and allowance-based transfers, subject to authorization/freeze controls. Pool-controlled mint/burn and configurable maximum supply are part of the implementation. A receipt's existence does not imply acceptance as collateral by another protocol. Earn receipts in your wallet are separate from margin collateral and external Blend/LP tracking positions. See [Supply](/stellar/guides/earn/supply), [Withdraw](/stellar/guides/earn/withdraw), and [vToken Reference](/stellar/developers/contracts/vtokens). # FAQ Source: https://docs.vanna.finance/stellar/resources/faq Quick answers about using Vanna on Stellar testnet: wallets, test funds, leverage, health factor, liquidation and more. > **Is this real money?** > > No. Vanna on Stellar runs on **Stellar testnet** at [test.vanna.finance](https://test.vanna.finance). Every token is a free test token with no value. Don't send mainnet XLM or USDC to your Vanna addresses; it won't show up. > **Where is the app, and why does it ask for a code?** > > Vanna for both chains is one app at [test.vanna.finance](https://test.vanna.finance). It is in private testing, so your first visit asks for an **access code**; ask the Vanna team for one. After that, pick **Stellar** in the chain switcher at the top right. > **Which wallets can I use?** > > **Freighter** and **OneKey**, both set to Stellar testnet. LOBSTR is listed as **Soon** because it signs for mainnet only. When email sign-in is enabled, the **Sign in to Vanna** dialog also offers email, Google, X and GitHub, which give you a Stellar wallet without an extension. See [Connect Your Wallet](/stellar/guides/connect-wallet). > **How do I get test tokens?** > > Click **Deposit** in the header and use **Test funds**: **Mint** per token or **Mint all**. XLM comes from Friendbot (10,000, once per address), BLUSDC from Blend's faucet (once), AqUSDC from Aquarius's faucet (1,000 per mint, any time) and SoUSDC from Soroswap's faucet (any time, short cooldown). Some mints ask you to approve a trustline. > **Why are there three kinds of USDC?** > > Each Stellar protocol on testnet uses its own USDC token: **BLUSDC** for Blend, **AqUSDC** for Aquarius and **SoUSDC** for Soroswap. They're priced the same (about \$1) but are different contracts, with separate Vanna lending pools. Borrow or hold the one your venue needs. > **What can I lend, borrow and use as collateral?** > > XLM, BLUSDC, AqUSDC and SoUSDC, for all three. Blend supply receipts and Soroswap / Aquarius LP positions held in your margin account also count as collateral. > **Which protocols does Vanna connect to?** > > **Blend** for lending (Farm supply of XLM and BLUSDC), **Soroswap** (XLM / SoUSDC) and **Aquarius** (XLM / AqUSDC) for swaps on Spot and liquidity on Farm. Prices come from **Reflector** through Vanna's oracle. > **What's the maximum leverage?** > > Up to **10x** on the Margin slider, as long as the account stays above a health factor of 1.10 after borrowing. The app shows the highest leverage your deposit allows, and **Max Value** fills it in. > **What is Dual Borrow?** > > A toggle on **Margin → Leverage your Assets**. Instead of one asset, it borrows **two different assets from two pools** against the same deposit, split 50/50 by default. It takes two transactions: deposit plus the first borrow, then the second borrow. See [Borrow](/stellar/guides/margin/borrow). > **What is the health factor?** > > Your margin account's total collateral divided by its total debt, in USD. Above **1.50** is Safe, 1.25 to 1.50 Healthy, above 1.10 to 1.25 At risk. See [Health Factor](/stellar/guides/margin/health-factor). > **When can I be liquidated, and what do I lose?** > > When the health factor is **1.10 or below**. A liquidator repays all your debt and takes **all** remaining collateral, including Blend and LP positions, not just a bonus. Keep a buffer, and repay or add collateral early. See [Liquidation](/stellar/guides/margin/liquidation). > **What does it cost?** > > Borrowers pay the pool's variable **Borrow APY**, which rises with utilization; the Margin page shows your blended **Net Borrow Rate** and Positions shows interest accrued. Every transaction also pays a small Stellar network fee in XLM. Lenders earn the **Supply APY**, paid as growing vToken value. > **Can I withdraw from Earn at any time?** > > Yes, up to the pool's **Available Liquidity** (what isn't lent out). One redemption pays at most 50% of the pool's total assets; anything above that stays as vTokens for another withdrawal. See [Withdraw](/stellar/guides/earn/withdraw). > **Why can't I swap a large amount on Spot?** > > Spot blocks any swap that would lower your health factor below **1.15**, and warns below 1.25. Reduce the amount, repay some debt, or add collateral. See [Spot Swap](/stellar/guides/trade/spot-swap). > **What can Copilot do?** > > Answer questions about your account and prepare transactions from plain English: deposit, borrow, Dual Borrow, repay, swap, Earn supply / withdraw, Blend supply and LP. A plan is valid for 5 minutes and your wallet signs each step. See [Copilot](/stellar/guides/copilot). > **Where are the contracts?** > > Every address is on [Deployed Contracts](/stellar/developers/deployed-contracts). The Account Manager is `CAZLR6EHZXQNZJIFNP6F7SIJQC3P64MKHHQNZSSG5BNAEFCYTTGTDZXB`.