Skip to main content
CollateralVault lets you interact with a deployed collateral lending pool: pledge any Ankara Chain RWA token as collateral, borrow the vault’s configured stablecoin up to the configured loan-to-value (LTV) ratio, repay, or liquidate an undercollateralized loan. Token prices are read from an on-chain oracle to calculate live LTV in real time.
Stellar Soroban only in v1. CollateralVault is backed by a Soroban contract — pass a StellarAdapter. Calling any method with an EVMAdapter will throw. EVM support is planned for a future release.
CollateralVault is a singleton per network — one vault instance holds many loans. You do not deploy it via TokenFactory; it is provisioned once per deployment environment by the platform operator. Obtain the vault’s contract address from the Ankara Chain network registry or your platform configuration.

Import


Constructor

IAdapter
required
A StellarAdapter connected to the Stellar network where the vault is deployed. Obtain it from tokenFactory.adapter after constructing TokenFactory with network: "stellar" or "stellar-testnet".
string
required
The Soroban contract ID of the deployed CollateralVault (starts with "C...").

Borrower Methods

openLoan

Pledges collateralAmount of an RWA token and borrows borrowAmount of the vault’s stablecoin. The oracle price of the collateral token is checked at the time of opening to ensure the borrow amount does not exceed the vault’s LTV.
string
required
Soroban contract ID of the RWA token to pledge as collateral (e.g. the address of a deployed FarmlandToken).
bigint
required
Amount of collateral token to lock, in the token’s native precision (typically 1e7 for Stellar tokens).
bigint
required
Amount of stablecoin to borrow, in the stablecoin’s native precision. Must not exceed collateralValue × ltvBps / 10000.
Returns: Promise<{ loanId: number; txHash: string }>
number
Unique integer ID for this loan. Use it with repayLoan, liquidate, and getLoan.
string
Transaction hash of the loan opening.

repayLoan

Repays the full borrowed amount and releases the collateral back to the borrower. You must approve the vault to spend the borrowed stablecoin before calling this.
number
required
The loan ID returned from openLoan.

liquidate

Liquidates an undercollateralized loan by seizing the collateral. Anyone can call this once a loan’s live LTV (from currentLtvBps) has crossed the liquidation threshold — it is not restricted to an admin.
number
required
The ID of the loan to liquidate.

Read Methods

getLoan

Returns the full state of a loan.
number
required
The loan ID to query.
string
Address of the borrower.
string
Contract ID of the pledged collateral token.
bigint
Locked collateral amount.
string
Contract ID of the borrowed stablecoin.
bigint
Borrowed amount in the stablecoin’s precision.
number
The LTV (in basis points) locked in at loan open time. This value does not change if the vault’s global LTV config is updated later.
bigint
Unix timestamp when the loan was opened.
LoanStatus
OPEN (0) · REPAID (1) · LIQUIDATED (2)

getBorrowerLoans

Returns an array of loan IDs associated with the given borrower. If borrower is omitted, defaults to the connected signer’s own loans.
string
Optional wallet address to query. Defaults to the connected signer.

currentLtvBps

Returns the live, oracle-priced current LTV of an open loan in basis points. This differs from loan.ltvBps — it recalculates using the latest oracle price, so it changes as the collateral token’s value moves.
number
required
The open loan ID.

isLiquidatable

Returns true if the loan’s live LTV has crossed the liquidation threshold and can be liquidated.

getBorrowedToken

Returns the contract ID of the stablecoin the vault lends out. This is a vault-level constant, not per-loan.

getOracle

Returns the contract ID of the price oracle the vault uses to value collateral.

getLtvBps

Returns the vault’s current maximum LTV in basis points (e.g. 6000 = 60%).

getLiquidationThresholdBps

Returns the liquidation threshold in basis points. When a loan’s currentLtvBps exceeds this value, anyone can call liquidate.

isPaused

Returns true if the vault has been administratively paused. Paused vaults reject new loan opens, repayments, and liquidations.

Admin Methods

These methods require the vault’s admin/manager role.

setLtvBps

Updates the vault’s maximum LTV for new loans. Existing loans retain their original locked-in LTV.
number
required
New maximum LTV in basis points, e.g. 5000 for 50%.

setLiquidationThresholdBps

Updates the LTV threshold at which loans become liquidatable.
number
required
New liquidation threshold in basis points. Should be higher than ltvBps to give borrowers a buffer.

setOracle

Replaces the price oracle used to value collateral.
string
required
Soroban contract ID of the new oracle.

pause

Pauses all vault operations.

unpause

Resumes vault operations.

Properties


Full Example


Type Reference