> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vanna.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Events and 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`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.