Skip to main content

LendingModule

@liquidium/client


@liquidium/client / LendingModule

Class: LendingModule

Defined in: packages/client/src/modules/lending/lending.ts:118

Borrow, withdraw, supply, inflow reporting, and fee-estimation helpers.

Constructors​

Constructor​

new LendingModule(canisterContext, apiClient, evmReadClient): LendingModule

Defined in: packages/client/src/modules/lending/lending.ts:119

Parameters​

canisterContext​

CanisterContext

apiClient​

ApiClient | undefined

evmReadClient​

EvmReadClient | undefined

Returns​

LendingModule

Methods​

borrow()​

borrow(params): Promise<BorrowOutflowDetails>

Defined in: packages/client/src/modules/lending/lending.ts:501

Creates a borrow outflow using the provided wallet adapter.

This is the convenience form of prepareBorrow(...) plus execution. Same-asset policy validation runs before the wallet is asked to sign.

Parameters​

params​

CreateBorrowRequest & WalletExecutionParams

Borrow request fields plus signerChain and signerWalletAdapter.

Returns​

Promise<BorrowOutflowDetails>

The lending canister receipt as OutflowDetails.

Throws​

LiquidiumError If SDK validation or protocol submission fails.

Throws​

Error If the wallet adapter rejects message signing.

Remarks​

id is always present. txid may be missing on the first response; the SDK does not poll for it. Use history or app-level polling if you need the chain transaction id.


estimateInflowFee()​

estimateInflowFee(request): Promise<InflowFeeEstimate>

Defined in: packages/client/src/modules/lending/lending.ts:618

Estimates the network/deposit fee for an inflow target.

ETH-chain deposit-address estimates are served by the deposit-address canister. BTC estimates include the ckBTC minter deposit fee and ledger fee. ICP-chain estimates return the corresponding ICRC ledger fee.

Parameters​

request​

AssetIdentifier

Asset and chain pair to estimate for.

Returns​

Promise<InflowFeeEstimate>

Total fee estimate rounded up in the asset's base units.


getDepositAddress()​

getDepositAddress(request): Promise<string>

Defined in: packages/client/src/modules/lending/lending.ts:558

Returns the read-only deposit address for an ETH-chain inflow target.

This is a query call that does not create or mutate state. Use it when you need the deposit address without hitting the authorization-gated update path.

Parameters​

request​

GetDepositAddressRequest

Profile, pool, asset, and supply action.

Returns​

Promise<string>

The EVM deposit address for the derived account.


getEvmSupplyContext()​

getEvmSupplyContext(request): Promise<EvmSupplyContext>

Defined in: packages/client/src/modules/lending/lending.ts:543

Fetches ERC-20 supply planning data with the configured EVM read client.

Requires evmRpcUrl or evmPublicClient on the client. Used internally by contract-interaction supply.

Parameters​

request​

GetEvmSupplyContextRequest

Profile, pool, wallet, amount (token base units), and action.

Returns​

Promise<EvmSupplyContext>

Locally computed EvmSupplyContext for approvals and deposit.


isBorrowingDisabled()​

isBorrowingDisabled(): Promise<boolean>

Defined in: packages/client/src/modules/lending/lending.ts:721

Returns whether borrowing is currently disabled by the protocol.

Returns​

Promise<boolean>

true when the lending canister reports borrowing disabled.


prepareBorrow()​

prepareBorrow(request): Promise<BorrowAction>

Defined in: packages/client/src/modules/lending/lending.ts:328

Prepares a borrow action that can be signed and submitted later.

Use this when you need explicit control over signing and submission. When the selected pool disables same-asset borrowing, preparation rejects profiles whose supplied balance in that pool is at or above its dust threshold.

Parameters​

request​

CreateBorrowRequest

Profile, pool, amount (borrow asset base units), outflow address, and signer wallet.

Returns​

Promise<BorrowAction>

A signable BorrowAction with submit wired to the canister.

Throws​

LiquidiumError If request validation, destination validation, or protocol preparation fails.


prepareWithdraw()​

prepareWithdraw(request): Promise<WithdrawAction>

Defined in: packages/client/src/modules/lending/lending.ts:134

Prepares a withdraw action that can be signed and submitted later.

Use this when you need explicit control over signing and submission.

Parameters​

request​

CreateWithdrawRequest

Profile, pool, amount (pool asset base units), outflow address, and signer wallet.

Returns​

Promise<WithdrawAction>

A signable WithdrawAction with submit wired to the canister.

Throws​

LiquidiumError If request validation, destination validation, or protocol preparation fails.


submitInflow()​

submitInflow(request): Promise<SubmitInflowResponse>

Defined in: packages/client/src/modules/lending/lending.ts:690

Submits an inflow transaction id for faster indexing.

Uses the Liquidium SDK API.

Parameters​

request​

SubmitInflowRequest

Broadcast txid plus inflow operation and optional chain.

Returns​

Promise<SubmitInflowResponse>

Acknowledgement including the submitted txid.

Throws​

LiquidiumError If the chain is unsupported or the API request fails.


supply()​

supply(request): Promise<SupplyFlow>

Defined in: packages/client/src/modules/lending/lending.ts:530

Resolves a supply target for a deposit or repayment and optionally broadcasts it.

Transfer mode can return manual broadcast instructions when wallet fields are omitted. Contract-interaction mode always requires walletAdapter, account, and amount because it must prepare and submit approval/deposit calls.

The SDK does not poll for inflow status. When a txid is returned, it is the caller's responsibility to track confirmation state using their own polling.

Parameters​

request​

SupplyFlowRequest

Returns​

Promise<SupplyFlow>

A SupplyFlow receipt with type, target, submit, and an optional txid present when the SDK broadcast for you.

Throws​

LiquidiumError If validation, transfer planning, or protocol submission fails.

Throws​

Error If the wallet adapter rejects or fails to broadcast a transaction.


withdraw()​

withdraw(params): Promise<WithdrawOutflowDetails>

Defined in: packages/client/src/modules/lending/lending.ts:304

Creates a withdraw outflow using the provided wallet adapter.

This is the convenience form of prepareWithdraw(...) plus execution.

Parameters​

params​

CreateWithdrawRequest & WalletExecutionParams

Withdraw request fields plus signerChain and signerWalletAdapter.

Returns​

Promise<WithdrawOutflowDetails>

The canister OutflowDetails for the completed withdraw.

Throws​

LiquidiumError If SDK validation or protocol submission fails.

Throws​

Error If the wallet adapter rejects message signing.