Skip to main content
Vanna runs three isolated lending pool contracts, one per supported asset. Each pool manages LP deposits (issuing vTokens), borrow issuance (via AccountManager), and interest accrual. All three pools share the same interface — only the underlying asset differs.

Liquidity Provider Functions

deposit_xlm / deposit_usdc

Deposits amount_wad of the pool’s native asset from lender, mints vTokens proportional to the LP’s share of the pool. Authorization: lender.require_auth() Parameters: What happens:
  1. Calls update_state() to accrue pending interest
  2. Computes vToken amount: floor(amount × vtoken_supply / total_assets)
  3. Transfers native asset from lender to pool
  4. Mints vTokens to lender
Events emitted:

redeem_vxlm / redeem_vusdc

Burns tokens_to_redeem vTokens and transfers the underlying asset back to the lender. Authorization: lender.require_auth() What happens:
  1. Calls update_state() to accrue pending interest
  2. Computes underlying: floor(vtoken_amount × total_assets / vtoken_supply)
  3. Burns vTokens from lender
  4. Transfers underlying asset to lender
Panics if: Pool balance is insufficient to cover the redemption Events emitted:

Borrow Functions (AccountManager Only)

These functions are restricted to the registered AccountManager. Direct calls from other addresses will panic.

lend_to

Issues a borrow from the pool to smart_account. Called by AccountManager after RiskEngine approval. Authorization: AccountManager.require_auth() What happens:
  1. update_state() — accrue interest
  2. Convert amount_wad to borrow shares and add to UserBorrowSharesWAD(smart_account)
  3. Deduct origination fee: fee = floor(amount × origination_fee_rate / WAD) → send to treasury
  4. Transfer amount_wad worth of assets to smart_account
Returns: true on success

collect_from

Accepts a repayment from smart_account. Called by AccountManager during repay or liquidation. Authorization: AccountManager.require_auth() What happens:
  1. update_state() — accrue interest
  2. Convert amount_wad to borrow shares and subtract from UserBorrowSharesWAD(smart_account)
  3. Decrease BorrowsWAD by amount_wad
Returns: true on success

State & Query Functions

update_state

Accrues interest since last update. Must be called before any borrow or repayment.
No-op if called in the same ledger as the last update.

get_borrow_balance

Returns the current outstanding debt (in WAD) for trader, including accrued interest.
This is the primary function used by RiskEngine and AccountManager to read outstanding debt.

get_total_liquidity_in_pool

Returns the pool’s current native asset balance in WAD (physical tokens held, not including outstanding borrows).

get_borrows

Returns the total outstanding borrows in WAD (including interest accrued since last update, but not yet written to state).

total_assets

Returns liquidity + borrows — the pool’s theoretical total, including outstanding debt.
This is the denominator for vToken exchange rate calculations.

get_rate_factor

Returns (now - last_updated) × rate_per_sec in WAD — the accrual factor since the last state update.

Conversion Functions

convert_xlm_to_vtoken

Computes how many vTokens amount of the underlying asset would mint at current exchange rate.

convert_vtoken_to_xlm

Computes how much underlying vtoken_amount vTokens would redeem to at current exchange rate.

convert_asset_borrow_shares

Converts a raw asset amount to borrow shares at current rates.

convert_borrow_shares_asset

Converts borrow shares to the underlying asset amount.

Pool Storage


Pool Configuration


Error Codes