Configure the client
Create the client with defaults for Liquidium mainnet:
import { LiquidiumClient } from "@liquidium/client";
const client = new LiquidiumClient();
In a Vite app, pass a configuration object to add custom transports, headers, canister IDs, or Ethereum read support:
const client = new LiquidiumClient({
apiBaseUrl: "https://app.liquidium.fi/api/sdk",
headers: {
"x-client-name": "my-app",
},
evmRpcUrl: import.meta.env.VITE_EVM_RPC_URL,
});
Configuration fields
The client accepts the following configuration fields:
| Field | Use |
|---|---|
environment | Selects bundled canister IDs. The SDK bundles only "mainnet". |
agent | Uses a preconfigured ICP Agent. If you provide an agent, the SDK ignores icHost and identity. |
icHost | Overrides the ICP replica host. |
identity | Sends signed canister calls with a caller identity. |
apiBaseUrl | Overrides the Liquidium SDK HTTP API root. The default is https://app.liquidium.fi/api/sdk. |
headers | Adds headers to SDK HTTP API requests. |
canisterIds | Partially overrides lending, ethDeposit, simpleLoans, or pools.{btc,eth,usdt,usdc,icp} for custom deployments. |
fetch | Provides a custom fetch implementation. |
timeoutMs | Sets the SDK API request timeout in milliseconds. The default is 30_000. |
evmRpcUrl | Creates a viem public client for ERC-20 reads and native ETH destination checks. |
evmRpcHeaders | Adds headers to EVM RPC requests. |
evmPublicClient | Uses an existing viem-compatible client. readContract is required. Mainnet chain and getCode enable native ETH destination checks. The SDK uses this client instead of evmRpcUrl and evmRpcHeaders. |
If your app already manages ICP transport and identity setup, pass a custom agent:
import { HttpAgent } from "@icp-sdk/core/agent";
import { Ed25519KeyIdentity } from "@icp-sdk/core/identity";
import { LiquidiumClient } from "@liquidium/client";
const identity = Ed25519KeyIdentity.generate();
const agent = await HttpAgent.create({
host: "https://icp-api.io",
identity,
});
const client = new LiquidiumClient({ agent });
To override canister IDs for a custom deployment, use nested fields:
const client = new LiquidiumClient({
canisterIds: {
lending: "aaaaa-aa",
simpleLoans: "u5rm3-niaaa-aaaar-qb7eq-cai",
pools: {
btc: "bbbbb-bb",
eth: "ccccc-cc",
},
},
});
The client rejects removed flat keys such as instantLoans, btcPool, and ercPool with LiquidiumErrorCode.VALIDATION_ERROR.
If an example needs Ethereum reads, set VITE_INFURA_API_KEY or VITE_EVM_RPC_URL.