Skip to main content
This guide covers everything you need to start integrating with Vanna Protocol from a TypeScript/JavaScript environment — reading pool state, checking health factors, and executing margin operations.

Prerequisites


Installation


Network Configuration


Contract Addresses

All addresses are available in Deployed Contracts. Import them centrally:

Simulating (Reading) Contracts

For read-only operations, use server.simulateTransaction(). No signing required.

Reading Pool State


Reading a User’s Margin Account


Connecting a Freighter Wallet


Executing Transactions

See Transaction Flow for the complete pattern: build → simulate → sign → submit.

Reading Oracle Prices


Handling Errors

Soroban errors from contract panics appear in simulation as SimulationError or in transaction results as invokeHostFunctionError. Parse them:
Common error patterns:
  • InsufficientBalance — caller doesn’t have enough tokens
  • InsufficientPoolBalance — pool can’t cover withdrawal
  • RiskEngineNotInitialized — missing registry setup
  • Health factor check failure — logged as a contract panic with specific error code

Next Steps

Transaction Flow

Build, simulate, sign, and submit Soroban transactions step by step.

Mercury Indexer

Query historical events and transaction history via the Mercury indexer.

Integrate Lending

End-to-end guide for deposit and vToken redemption.

Integrate Margin

Create accounts, deposit collateral, and borrow assets.