Liquidy logo
 
Home/Developer/Swap API
Liquidy Swap API
Developer reference and live playground for the Liquidy Swap router on Rujira mainnet. API base: https://api.liquidy.finance

How it works

The Liquidy Swap API is an off-chain router. It finds the best route between any two tokens through any of the RUJI Trade books and returns a swap message you can submit directly — it does not move funds for you.

  1. Get supported tokens — GET /swap/tokens returns the denoms, decimals, and display metadata for tokens the router can quote and route.
  2. Request a route — POST /swap/route (single route) or /swap/sroute (split route) with input denom, amount in atomics, output denom, and slippage.
  3. Use the best route — the response ranks paths; typically take routes[0]. Each route includes expected output, price impact, and tx.swap (stages + min_return).
  4. Execute on chain — send a CosmWasm execute to the router contract with routes[0].tx as the message and attach the input token as funds (full input.amount for a single route).

Router contract

thor1efrmwk6fzhaugu056mz3nkq4vl0fgpfacm3gp6fhgrdkm4q8rrmsd5a6r5

API base: https://api.liquidy.finance

Swap history (indexed transactions): https://api.liquidy.finance/history

Message shape

A single-route swap is one MsgExecuteContract: the msg field is the API's tx object; funds carries the coin you are swapping in.

{
  "contract": "thor1efrmwk6fzhaugu056mz3nkq4vl0fgpfacm3gp6fhgrdkm4q8rrmsd5a6r5",
  "msg": routes[0].tx,
  "funds": [{ "denom": "<input-denom>", "amount": "<input-amount-atomics>" }]
}

Split routes return multiple legs — broadcast one execute per leg, each funded with that leg's split.amount, not the full input.

Signing with CosmJS

Use CosmJS to sign and broadcast on Rujira / Thorchain-style chains:

  • @cosmjs/cosmwasm-stargate SigningCosmWasmClient and .execute() for contract calls
  • @cosmjs/stargate — wallet, fees, and GasPrice
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";

await client.execute(
  senderAddress,
  routerContract,
  route.tx,                        // routes[0].tx from the API
  "auto",
  undefined,
  [{ denom: inputDenom, amount: inputAmount }],
);

Optional: simulate first with the router's simulate query (see Swap tab) to verify the returned amount before broadcasting.

©2026 Liquidy