Skip to main content

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:

FieldUse
environmentSelects bundled canister IDs. The SDK bundles only "mainnet".
agentUses a preconfigured ICP Agent. If you provide an agent, the SDK ignores icHost and identity.
icHostOverrides the ICP replica host.
identitySends signed canister calls with a caller identity.
apiBaseUrlOverrides the Liquidium SDK HTTP API root. The default is https://app.liquidium.fi/api/sdk.
headersAdds headers to SDK HTTP API requests.
canisterIdsPartially overrides lending, ethDeposit, simpleLoans, or pools.{btc,eth,usdt,usdc,icp} for custom deployments.
fetchProvides a custom fetch implementation.
timeoutMsSets the SDK API request timeout in milliseconds. The default is 30_000.
evmRpcUrlCreates a viem public client for ERC-20 reads and native ETH destination checks.
evmRpcHeadersAdds headers to EVM RPC requests.
evmPublicClientUses 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.