Vaults, collateral, and risk
Deposit, withdraw, and read collateral in the Collateral Vault, and size the collateral a LOC needs.
Collateral lives in the Collateral Vault, not in the LOC. You deposit tokens once, and each open LOC
reserves part of that balance for as long as it lasts. That’s why sdk.vault.getCollateralBalance
returns a CollateralBalance split in
two: the Available balance can be withdrawn or back a new LOC, and the Reserved balance can’t.
Deposits and withdrawals are workflows, sdk.vault.buildDepositWorkflow and
sdk.vault.buildWithdrawWorkflow, documented with the rest of the vault’s methods on
VaultModule.
How much collateral a LOC needs depends on its pair. A Static LOC is backed 1:1 in the token it
credits. A Dynamic LOC is backed by a different token at an oracle price and the pair’s collateral
factor: sdk.loc.getRequiredCollateralForDynamic fetches both and returns the amount, and
sdk.loc.getCollateralFactor returns the pair’s creation and liquidation factors. Both are on
LOCModule. The model is set out in
Collateral and risk.
A vault balance, and what withdrawing all of it pays out:
const balance = await sdk.vault.getCollateralBalance({ tokenAddress: WETH,});// `reserved` is locked by reserving contracts; only `available` can be// withdrawn// or back a new LOC. Withdrawals pay the vault fee, so the wallet// receives:const feeBasisPoints = await sdk.vault.getWithdrawalFeeBasisPoints();const fee = (balance.available * BigInt(feeBasisPoints)) / 10_000n;const received = balance.available - fee;Primary APIs
Interfaces
CollateralBalance— An account’s balance of one token in the Collateral Vault, split into the Available balance and the Reserved balance.VaultModule— Collateral Vault operations: read Available and Reserved balances, deposit and withdraw collateral, and sign the vault authorizations that…