LCX Liberty. American DeFi. Your keys. Your assets. Your control.
TypeScript SDK
One npm package for the whole API: swaps, cross-chain, tokens, prices and your key. Typed end to end, and it never touches a private key.
Install
npm i lcx-liberty-sdk
The current release is 1.4.0, published on 24 October 2026; Versions, below, says what each release changed. It is an ES module with type declarations and no dependencies, for Node 18 or newer, Deno, Bun, Workers or any bundler. From CommonJS, load it with await import("lcx-liberty-sdk"): a plain require throws a message saying so.
The client
One client, seven namespaces. Each is a thin wrapper over the endpoints documented in the API reference, so anything true there is true here.
import { LibertyDex } from "lcx-liberty-sdk";
const lcx = new LibertyDex({ apiKey: process.env.LCX_API_KEY });| Namespace | What it covers |
|---|---|
lcx.swap | Price, build and submit a same-chain swap. |
lcx.crossChain | Quote across chains, and follow a transfer. |
lcx.multi | The multi token swap: price and build a bundle, on one chain or across two. |
lcx.tokens | The token registry, and what we vouch for. |
lcx.prices | USD prices: one token, a batch, or a past day. |
lcx.chains | Supported chains and index freshness. |
lcx.account | Your key: plan, quota and usage. |
apiKey when you create the client; it talks to https://swap-api.lcx.com. Without a key every call is refused with 401 API_KEY_REQUIRED.A swap, end to end
execute is quote and build in one call. It hands back the quote it priced and the transaction that matches it, so nothing can sign a route it was not shown.
const { quote, transaction } = await lcx.swap.execute({
chainId: 1,
tokenIn: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
tokenOut: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
amountIn: "1000000000000000000", // base units; or amount: "1"
taker: userAddress,
slippageBps: 50,
});
console.log(quote.output.amount, "USDC, floor", quote.output.minimumAmount);
// { to, data, value } — hand it to whatever holds the keys.
await wallet.sendTransaction(transaction);Approvals
Selling an ERC-20 needs an allowance for the router first. Ask before you spend gas on one: required is false when the allowance already covers the trade.
const { required, spender } = await lcx.swap.allowance({
chainId: 1,
token: WETH,
taker: userAddress,
amount: quote.input.amount, // raw units, not decimal
});The chain's native coin needs no approval. See Approvals in Core concepts for the permit path and what a router upgrade means for an existing allowance.
Errors
Every failure arrives as a LibertyError carrying the API's own machine code, so a caller branches on the code rather than matching on a message that is free to change.
import { LibertyError } from "lcx-liberty-sdk";
try {
await lcx.swap.execute(params);
} catch (e) {
if (e instanceof LibertyError) {
// e.code — "no_route", "RATE_LIMITED", "price_moved", ...
// e.status — the HTTP status
// e.details — whatever the endpoint attached
}
}The codes are the ones listed under Errors in Core concepts; the SDK adds none of its own.
Versions
Upgrading changes nothing in a call. Every method takes a plain chainId, and the router a swap goes through (spender and to) always comes from the API, never from the package, so code that never hardcoded an address keeps working.
| Version | Published | What changed |
|---|---|---|
| 1.4.0 | 24 Oct 2026 | World Chain joins the chain list, on router 2 like the other new chains. Its gas coin is ether. |
| 1.3.0 | 19 Oct 2026 | Unichain, Monad, HyperEVM and Arc join the chain list. On Arc, USDC is the gas coin: name it by its contract, not the native sentinel. On HyperEVM a swap takes at most three routes, and a bundle too wide for a block is refused when quoted. |
| 1.2.0 | 12 Oct 2026 | BNB Chain, Polygon, Avalanche and Robinhood Chain join the chain list. Amounts go in base units (amountIn); decimals is optional, and checked when sent. Every call needs an API key. |
| 1.1.0 | 24 Sep 2026 | lcx.multi: the multi token swap, on one chain or across two. |
| 1.0.0 to 1.0.2 | 9 and 10 Sep 2026 | The first release, then README corrections to the router address. |