@lunexfinance/sdk
v0.1.1
Published
TypeScript SDK for the Lunex protocol on Arc Network. Swap, liquidity, yield, and Circle CCTP V2 bridge.
Maintainers
Readme
@lunex/sdk
TypeScript-first SDK for the Lunex protocol on Arc Network. Quote, swap, manage liquidity, and bridge USDC across chains via Circle CCTP V2 in a few lines of code.
import { Lunex } from "@lunex/sdk";
const lunex = new Lunex({ apiKey: process.env.LUNEX_KEY! });
const quote = await lunex.quote({ tokenIn: "USDC", tokenOut: "EURC", amountIn: "100" });
const tx = await lunex.swap({ walletAddress: "0x...", tokenIn: "USDC", tokenOut: "EURC", amountIn: "100" });Install
npm install @lunex/sdkDEX methods
lunex.quote(params)| executable quotelunex.swap(params)| unsigned swap txlunex.price({ base, quote })| live mid pricelunex.liquidity({ pool? })| reserves + LP supplylunex.info()| adapter metadatalunex.waitForTx(hash)| poll Arc RPC for receipt
Bridge (Circle CCTP V2)
The bridge module always returns unsigned tx payloads. The integrator signs every transaction with their own wallet | Lunex never holds keys.
const prepared = await lunex.bridge.prepare({
sourceChain: "base-sepolia",
amount: "100000000", // 100 USDC, 6 decimals
mintRecipient: "0xUserDcwAddress", // optional | defaults to source EOA
});
// 1. Sign approve on source chain
await wallet.sendTx(prepared.approveTx);
// 2. Sign burn on source chain
const burnHash = await wallet.sendTx(prepared.burnTx);
// 3. Wait for Circle attestation (Lunex relays)
const att = await lunex.bridge.attestation(burnHash);
// 4. Build the unsigned receiveMessage tx for Arc, sign it on Arc
const { receiveTx } = await lunex.bridge.mint({ message: att.message!, attestation: att.attestation! });
await arcWallet.sendTx(receiveTx);Or use the convenience helper:
await lunex.bridge.execute({
signer: { sendTx, arcSendTx },
params: { sourceChain: "base-sepolia", amount: "100000000", mintRecipient: dcw },
onStatus: (s) => console.log(s),
});Supported source chains
ethereum-sepolia, base-sepolia, arbitrum-sepolia, avalanche-fuji, polygon-amoy, optimism-sepolia.
mintRecipient
Configurable. If you pass it, USDC mints at that address on Arc regardless of which EOA signed the burn | useful for Distributed Custody Wallets (DCW) where the signing key is separate from the destination address.
Burn, mint, and recover endpoints
lunex.bridge.burnt({ sourceTxHash, sourceChain })checks whether a source burn has a ready attestation.lunex.bridge.mint({ message, attestation })builds the unsigned ArcreceiveMessagetx.lunex.bridge.recover({ sourceTxHash, sourceChain })rebuilds the Arc mint tx for funds stuck after burn.
Integrator calls receiveMessage on Arc. The SDK builds the unsigned tx | you keep custody. The bridge.execute() helper wraps the full flow if you provide an Arc signer.
Features
- TypeScript-first | strict types on every payload
- Automatic retries on 429 / 5xx with jittered backoff
- Configurable timeout, base URL, and
fetchimplementation LunexErrorwith status, code, and raw response data- Zero React deps | works in Node 18+, Bun, Deno, browsers, edge runtimes
Auth
Pass your key via the apiKey constructor option. The SDK sends it as x-api-key on every authenticated request. Get a key from the Lunex SDK developer portal at /lunexsdk.
Publishing
cd packages/sdk
npm install
npm run build
npm login # one-time, requires npm 2FA
npm publish --access public # publishes the current version
# bump:
npm version patch && git push --tagsprepublishOnly runs tsup to emit ESM + CJS + .d.ts into dist/ before publishing.
