Skip to main content
A swap in Velora settles through one of two execution paths: Delta or Market (this page). Market is the atomic on-chain path. It wraps the Market API for rates, allowances, and transaction-building, and the user signs and submits the transaction themselves. For gasless swaps that settle from a signed intent, see Delta.
This path is exposed as sdk.swap in code (the namespace predates the Delta/Market naming). sdk.swap is the Market execution path for swaps.

When to use this

  • The user has gas on the source chain and is happy to submit a transaction.
  • You need the cheapest path across DEX aggregation (no auction, no off-chain settlement).
  • You want full control over slippage, gas, and recipient.
  • You don’t need crosschain or MEV-protected settlement. See Delta for that.

The flow

1

Get a price route

Call sdk.swap.getRate (or sdk.quote.getQuote with mode: 'market') to choose source token, destination token, amount, and side. The response includes the routed path and expected output.
2

Approve the source token (or sign a Permit)

Call sdk.swap.approveToken so the TokenTransferProxy can pull the source token, or sign a Permit / Permit2 message with TokenTransferProxy as the verifying contract.
3

Build the transaction

Call sdk.swap.buildTx with the price route, slippage (or destAmount), user address, and partner. The response is a fully-populated TransactionRequest.
4

Send it from the wallet

Pass the result of buildTx to your signer’s sendTransaction. The SDK is no longer in the loop after this; you own the broadcast.

Full example

import axios from "axios";
import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
import { constructSimpleSDK, txParamsToViemTxParams } from "@velora-dex/sdk";

const walletClient = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum!),
});
const [account] = await walletClient.getAddresses();

const sdk = constructSimpleSDK(
  { chainId: 1, axios },
  { viemClient: walletClient, account }
);

const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const amount = "10000000000"; // 10,000 USDC

// 1. Quote
const priceRoute = await sdk.swap.getRate({
  srcToken: USDC,
  destToken: ETH,
  amount,
  userAddress: account,
  side: "SELL",
  options: { partner: "my-app-name" },
});

// 2. Approve
await sdk.swap.approveToken(amount, USDC);

// 3. Build the swap transaction
const tx = await sdk.swap.buildTx({
  srcToken: USDC,
  destToken: ETH,
  srcAmount: amount,
  slippage: 50, // 0.5% in basis points
  priceRoute,
  userAddress: account,
  partner: "my-app-name",
  // receiver: "0x..." // optional, if the recipient differs from userAddress
});

// 4. Send it
const hash = await walletClient.sendTransaction({
  ...txParamsToViemTxParams(tx),
  account,
});
console.log("swap submitted:", hash);

Sign a Permit instead of approving

If the source token supports EIP-2612 (or Permit2), skip the on-chain approval and sign a typed-data message with the TokenTransferProxy as the verifying contract.
const tokenTransferProxy = await sdk.swap.getSpender();
// build EIP-712 typed data with verifyingContract = tokenTransferProxy
// pass the signature as `permit` to buildTx
See the Build parameters for transaction endpoint for the supported permit variants.

Other methods

  • sdk.swap.getSpender() returns the TokenTransferProxy address you approve.
  • sdk.swap.getBalances(userAddress): token balances and allowances in one call.
  • sdk.swap.getTokens() lists Velora-supported tokens on the active chain.
  • sdk.swap.getAdapters() returns the DEX adapters available to the router.
  • sdk.swap.swapTx(params) is a one-call orchestrator (rate + build + send). Convenience over the four-step flow.

Partner fee

Add partner (and optionally partnerAddress, partnerFeeBps, partnerTakesSurplus) to every getRate, buildTx, and getQuote call to capture revenue. See Monetize for the full field reference.
Last modified on June 14, 2026