@deserialize/ultra-agg-sdk
v0.1.0
Published
TypeScript client for the Deserialize Ultra Aggregator: one API for DeFi data and actions across swaps, memecoins, perps, prediction markets and RWAs on Solana and EVM. Includes an executor for the steps[] action contract.
Readme
@deserialize/ultra-agg-sdk
TypeScript client for the Deserialize Ultra Aggregator — one API for DeFi data and actions across swaps, memecoins, perps, prediction markets and RWAs on Solana and EVM (Ethereum, Base, Arbitrum, BSC, Polygon).
The API is read + build only: it never holds funds, never signs, and never submits. Every action returns an ordered steps[] for the user's wallet to sign and send. This SDK wraps the REST API and includes an executor that walks steps[] against a wallet you provide.
The REST API is complete on its own and needs no key (10 req/s free); this package is a convenience layer.
Install
npm i @deserialize/ultra-agg-sdkQuote and read
import { UltraAggClient } from "@deserialize/ultra-agg-sdk";
const ultra = new UltraAggClient();
// or: new UltraAggClient({ baseUrl, apiKey })
const quote = await ultra.swapQuote({
chain: "solana",
inputToken: "So11111111111111111111111111111111111111112",
outputToken: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amountIn: "1000000000", // base units (1 SOL)
});
console.log(quote.best.provider, quote.best.output.amount);Build an action and execute it
swapBuild returns an ActionResponse whose steps[] your wallet signs. You
supply a StepWallet; the SDK never sees a key.
import { UltraAggClient, executeSteps, type StepWallet } from "@deserialize/ultra-agg-sdk";
const ultra = new UltraAggClient();
const action = await ultra.swapBuild({
chain: "base",
inputToken: WETH,
outputToken: USDC,
amountIn: "1000000000000000000",
taker: wallet.address,
});
await executeSteps(action, wallet as StepWallet);A StepWallet implements the signing/broadcasting your app already does:
interface StepWallet {
address: string;
sendEvmTransaction?: (tx) => Promise<{ txHash: string }>;
sendSolanaTransaction?: (tx) => Promise<{ txHash: string }>;
waitForTransaction?: (chain, txHash) => Promise<void>;
signTypedData: (chain, payload) => Promise<string>;
}Live streams
import { UltraAggStream } from "@deserialize/ultra-agg-sdk";
const stream = new UltraAggStream("https://ultra-api.deserialize.xyz", {
onEvent: (msg) => console.log(msg.stream, msg.data),
});
stream.connect();
stream.subscribe("prices", { chain: "solana" });The steps[] contract
Full documentation of the action contract, the three step kinds, the template language and worked examples: https://ultra-api.deserialize.xyz/llms.txt
License
MIT
