API ReferenceVaults, collateral, and riskFunction
getVaultCollateralBalance()
function getVaultCollateralBalance(ctx, params): Promise<CollateralBalance>;Fetches the current CollateralBalance in the CollateralVault
for the provided token and configured account. Reads the available / reserved split directly
from the CollateralVault contract (chain state, not the subgraph); use
getVaultCollateralBalances to list every token at once.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | SDKContext | The SDK context. |
params | GetVaultCollateralBalanceParams | The request-specific parameters. |
Returns
Promise<CollateralBalance>
The collateral balance for the account and token in question.
Example
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;Throws
WalletNotConnectedError If params.accountAddress is
omitted and no signer is configured to resolve a default.