Skip to content

Repository files navigation

npm license

Liquidium SDK

Liquidium SDK

TypeScript client for Liquidium lending and accountless Simple Loans.

Documentation · API reference · Simple Loans example

Install

npm install @liquidium/client

Usage

import { Asset, Chain, LiquidiumClient } from "@liquidium/client";

const client = new LiquidiumClient();

const [collateralPool, borrowPool] = await Promise.all([
  client.market.findPool({ asset: Asset.BTC, chain: Chain.BTC }),
  client.market.findPool({ asset: Asset.USDC, chain: Chain.ETH }),
]);

const loan = await client.simpleLoans.create({
  collateral: {
    poolId: collateralPool.id,
    asset: Asset.BTC,
    amount: 50_000n,
  },
  borrow: {
    poolId: borrowPool.id,
    asset: Asset.USDC,
    amount: 9_000_000n,
    chain: Chain.ETH,
    destination: "0x2222222222222222222222222222222222222222",
  },
  refund: {
    chain: Chain.BTC,
    destination: "1BoatSLRHtKNngkdXEeobR76b53LETtpyT",
  },
  ltvMaxBps: 6_000n,
  depositWindowSeconds: 3_600n,
});

const deposit = loan.initialDeposit.targets[Chain.BTC];

console.log("Loan reference:", loan.ref);
console.log("Send collateral to:", deposit?.target.address);

Use client.simpleLoans for accountless borrowing. Use client.accounts, client.lending, and client.positions for profile-based lending.

Amounts use bigint values in each asset's smallest unit. Read pool decimals before converting user input.

Asset.ETH supports native ETH on Chain.ETH and ckETH ICRC transfers on Chain.ICP. Both routes use 18 decimals, so amounts are expressed in wei (0.005 ETH is 5_000_000_000_000_000n). For native ETH deposits and repayments, select mechanism: "transfer" to send ETH to a generated deposit address or mechanism: "contractInteraction" to send ETH through the payable deposit helper. Transfer is the default when mechanism is omitted. ckETH routes use the generated ICRC target.

Native ETH borrows and withdrawals do not support addresses with deployed contract bytecode, including smart contract wallets. The same restriction applies to Simple Loan borrow destinations and native ETH collateral refund destinations.

See the quick start for LTV validation, repayment, and recovery.

Examples

Development

Requires Node.js 20+ and pnpm 11+.

pnpm install
pnpm build
pnpm typecheck
pnpm test

License

MIT

Releases

Packages

Used by

Contributors

Languages