Skip to main content

API reference

The SDK exports LiquidiumClient, error types, constants, module request types, response types, and wallet action types from @liquidium/client.

Client modules​

The client provides the following modules:

ModulePurpose
client.accountsProfile lifecycle, account lookup, and linked wallets
client.activitiesActivity lists and receipt-oriented status
client.historyUser history and confirmed protocol-wide activity through the Liquidium SDK API
client.simpleLoansAccountless Simple Loans with generated deposit and repayment targets
client.lendingSupply, borrow, withdraw, recovery, and inflow reporting
client.liquidationsCandidate scanning, liquidation execution, and status lookup
client.marketPools, prices, and pool rate lookups
client.positionsPer-pool positions, health, and aggregate stats
client.quotePure quote helpers from market inputs

Shared status types​

Use LiquidiumStatus for flow state across Simple Loans, activities, lending responses, and history entries.

The following types define shared status data:

TypePurpose
LiquidiumStatusOperation, state, and optional confirmation progress
LiquidiumOperationdeposit, borrow, repayment, withdrawal, or liquidation
LiquidiumStateaction_required, confirming, processing, active, completed, failed, or expired
ActivityInflow or outflow activity returned by activity APIs
GetActivityStatusResponseFound or missing result from client.activities.getStatus(...)

For UI guidance, see the status system.

For APR and estimated APY semantics, see market data.

Error behavior​

Public SDK methods can reject with LiquidiumError. Branch on its stable LiquidiumErrorCode value instead of parsing message.

client.simpleLoans.create(...) can also reject with SimpleLoanCreatedError after the remote loan is created but before the SDK loads its hydrated state. Recover the loan with the error's loanId or ref. Do not call create(...) again.

For retry decisions and recovery code, see Handle errors.

Profile recovery​

  • client.lending.getRecoveryBalance(profileId, poolId) reads the live recovery balance in base units.
  • client.lending.prepareRecovery(request) returns a RecoveryAction for BTC/ETH message signing.
  • client.lending.recover(request) accepts a RecoverWithWalletRequest or RecoverWithIcpRequest and returns a RecoveryResult.

Recovery reads balances independently of positions and rejection history. A result contains the gross amount, ledgerCanisterId, recovery transfer blockIndex, and a processing status. It does not contain an activities API outflow ID. Except for the ICP pool, it does not confirm final wallet delivery. See Recover profile funds for authorization, fees, and tracking.

Liquidations​

Use client.liquidations.scan(request) for cursor-based candidate discovery, client.liquidations.liquidate(request) for automatic debt-ledger allowance handling and execution, and client.liquidations.getLiquidation(liquidationId) for status lookup. Approval failures throw LiquidiumError with code LIQUIDATION_APPROVAL_FAILED; in this case, liquidation was not submitted.

minCollateralAmount is required in collateral-asset base units. The canister enforces it before transfer fees on bad-debt and hybrid paths only; normal collateral-backed liquidations ignore it and allow smaller partial fills. buyBadDebt defaults to false. Setting it to true permits bad-debt repayment but can still use the normal path. See Minimum collateral and partial fills.

The SDK exports these public types:

TypePurpose
ScanLiquidationsRequestOptional cursor, accounts to scan, and maximum candidates to return
LiquidationScanResultCandidates, scanned account count, and next cursor
LiquidationCandidateLiquidatable borrower, health factor, total debt, and pool positions
LiquidationCandidatePositionPool, asset, debt, collateral, threshold, bonus, and protocol fee
LiquidationCandidateAssetSupported asset symbol or legacy SOL candidate symbol
ExecuteLiquidationRequestBorrower, pools, debt amount, receiver, required minimum collateral, and optional bad-debt choice
LiquidationResultLiquidation id, timestamp, amounts, assets, lifecycle state, and transfer states
LiquidationAmountsDebt repaid and net collateral received in base units
LiquidationAssetChain-key ledger principal or unknown asset type
CkLiquidationAssetChain-key ledger route with its required ledger canister principal
UnknownLiquidationAssetAsset route the lending canister cannot identify
LiquidationStatusProgress, success, or failed lifecycle status
LiquidationProgressStatusPending or processing lifecycle state without an error
LiquidationSuccessStatusSuccessful lifecycle state without an error
LiquidationFailedStatusFailed lifecycle state with its required protocol error
LiquidationTransferPending, successful, or failed collateral or change transfer
LiquidationPendingTransferPending transfer without an error
LiquidationSuccessTransferSuccessful transfer without an error
LiquidationFailedTransferFailed transfer with its required error

See Liquidations for allowance, slippage, receiver, and refund requirements.

History​

Use client.history.getUserTransactionHistory(profileId, filters?) for paginated profile transaction history. It accepts cursor, limit, market, poolId, operations, states, from, and to.

Use client.history.getLiquidationHistory(profileId, filters?) for paginated liquidation history. It accepts cursor, limit, market, poolId, from, and to.

Continue pagination with the opaque nextCursor value.

Use client.history.getProtocolActivity(filters?) for recent confirmed activity across the protocol. It calls GET /v2/history/activities, accepts poolId, operations, and limit, and returns an unpaginated array with each pool's asset, decimals, and base-unit amount. History and protocol activity entries expose txids?: string[].

Asset identifiers​

AssetIdentifier is a union of named types for each supported asset and transfer-chain pair.

TypeAssetChain
BtcOnBtcAssetIdentifierBTCBTC
EthOnEthAssetIdentifierETHETH
UsdcOnEthAssetIdentifierUSDCETH
UsdtOnEthAssetIdentifierUSDTETH
BtcOnIcpAssetIdentifierBTCICP
EthOnIcpAssetIdentifierETHICP
IcpOnIcpAssetIdentifierICPICP
UsdcOnIcpAssetIdentifierUSDCICP
UsdtOnIcpAssetIdentifierUSDTICP

Generated reference​

The generated API reference is built from the @liquidium/client exports.

Regenerate it with TypeDoc and typedoc-plugin-markdown after changing exported APIs:

pnpm docs:api