SDK

A single ES module that works with viem wallets. Download it from this site and import it; there is nothing to install from a registry.

Get it

curl -o el3.mjs https://<this site>/sdk/el3.mjs

The module has no dependencies of its own and runs in browsers, Node 20+, Deno and Bun. It signs with any viem WalletClient that has an account, so bring viem for the wallet.

Use it

import { configure, getBook, placeOrder, subscribe } from "./el3.mjs";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";

configure({ site: "https://<this site>" });

const wallet = createWalletClient({
  account: privateKeyToAccount(process.env.KEY),
  transport: http("https://rpc.elysium.kinetiq.xyz"),
});

const book = await getBook(1);
const res = await placeOrder(wallet, { market: 1, isBuy: true, px: "25.10", sz: "2", tif: "GTC" });

const stop = await subscribe({ channel: "trades", market: 1 }, (msg) => console.log(msg.data));

Functions

FunctionWhat it does
configure({ site })Sets the site the SDK talks to. In a browser it defaults to the current origin.
signOrder(wallet, order)Builds the Order, signs it with EIP-712, returns { order, sig } in wire format.
placeOrder(wallet, order)Signs and posts to /v1/order.
cancel(wallet, { market, nonce })Signs a Cancel and posts to /v1/cancel.
getBook(market, depth?)The order book.
getAccount(addr)Collateral, equity, margin, positions, open orders.
getMarkets(), getTrades(market), getStats()The matching REST reads.
subscribe(sub, onMessage)Opens the WebSocket at the published URL; returns a function that closes it.

Prices and sizes accept decimal strings ("25.10") or integers already in 1e6 units as bigint.