Astraea API Server 0.6.1
An XRP Ledger API server with history you can check.

Vaults and lending

Vaults, loan brokers and loans on the ledger, answered as Clio does and proved offline

The XRP Ledger has two amendments for on-chain lending. SingleAssetVault (XLS-65) adds the Vault: a pool of one asset, XRP, a token or an MPT, that depositors put money into in exchange for shares. LendingProtocol (XLS-66) adds the LoanBroker, which draws on a vault and keeps first-loss cover, and the Loan, one borrower’s obligation to a broker. The shares of a vault are an MPT issuance of their own, so a vault’s depositors are the holders of that MPT.

Astraea serves these objects the way Clio 2.8 does: the same fields, the same selectors, the same errors. A service built against Clio works against Astraea without changes, and gets the full history behind it.

§What you can ask

QuestionRequest
Is lending enabled on this network?feature, then SingleAssetVault and LendingProtocol in the answer, read from the ledger’s Amendments object
A vault and its sharesvault_info by vault_id, or by owner and seq: the Vault with its share issuance under shares
A loan broker or a loanledger_entry by index, or with the vault, loan_broker and loan selectors; JSON or binary
Everything one account ownsaccount_objects with type vault, loan_broker or loan, and deletion_blockers_only
Who holds a vault’s sharesmpt_holders with the vault’s ShareMPTID
An account’s MPT issuances and balancesaccount_mptoken_issuances and account_mptokens
The transactions of one kind, or of one MPTaccount_tx with tx_type and mpt_issuance_id filters
What changed in a ledgerledger with transactions and expand, or the transactions stream

Every state question can name an earlier ledger. On a server with an old-state index (--old-state, see running.md), vault_info, ledger_entry and account_objects also answer on ledgers before the hot state’s snapshot.

The transactions that make and move these objects (VaultCreate, VaultDeposit, VaultWithdraw, LoanBrokerSet, LoanSet with its CounterpartySignature, LoanPay, LoanManage and the rest) are stored and decoded like any other, in tx, account_tx, ledger and proof_tx.

§Listing every vault, broker and loan

Listing all objects of a type with ledger_data and type does not scale: the server walks the whole state tree in key order and each page holds only the matches in the slice it walked. On mainnet that is tens of thousands of pages on any server, so a few pages give a sample, not a list.

To know every object, follow ledgers from the one where SingleAssetVault was enabled. No lending object can exist before it, so each one first appears as a CreatedNode in the metadata of a later transaction, and its changes and deletion follow. Apply the transactions of a ledger in the order of meta.TransactionIndex, not in the order the ledger answer lists them; that order is by hash. Fields at their default value, zero included, are left out of NewFields and FinalFields, and a field that grows from zero does not appear in PreviousFields, so keep the earlier value yourself. API has the details of each request.

§Proving a vault’s state

proof_entry takes the same selectors as ledger_entry, so it can prove a vault, a broker or a loan: the object with this content is in the state of a validated ledger, or it is not there. The package is checked offline with witness-verify evidence, without trusting Astraea or any node. A lender’s assets, a broker’s cover or a loan’s outstanding principal can be shown to someone who does not run a server. See Proof Engine and Evidence format.

§MPT assets

An Issue that holds an MPT, a vault’s Asset among them, is shown with the 24-byte mpt_issuance_id that xrpld and Clio give: the issuance sequence in big-endian order, then the issuer’s account. Before 0.6.0 Astraea gave the sequence bytes in the order xrpld stores them, little-endian, so a vault whose asset was an MPT showed an ID that matched no issuance. A test pins the right ID on a real devnet vault.

§Checked against Clio

The lending group of the Clio check sends the requests of a lending dashboard in their own shapes: type-filtered ledger_data pages, each object by ID, the ledgers that changed them and feature, compared in full with a local or public Clio. Tests compare account_objects, ledger_entry, vault_info, the MPT methods and the account_tx filters with answers public Clio gave on real devnet and mainnet objects.

Two differences from xrpld, the same as Clio: a Loan blocks deleting the borrower’s account, and a Vault does not. Unlike Clio, vault_info honours ledger_hash.