Skip to content

Vestige legacy swap aggregator

The aggregator routes a swap across Algorand DEX pools to get the best output, then builds the transactions for you to sign. It has the same four routes as Vestige’s swap/v4 aggregator, with one difference: the router fee goes to the Algorand fee sink, not to Nodely.

The fee is a share of the trade, set by the trade’s value v: the input’s worth in USD, valued through ALGO.

fee_bps = min(200, round(25 + 120 × max(0, log10($1 / v)) + 75 × max(0, log10(v / $300))))
Trade value $0.01 $0.10 $0.30 $1 to $300 $1,000 $3,000 $10,000 $30,000 about $65,000 and more
Fee 2.00 % 1.45 % 0.88 % 0.25 % 0.64 % 1.00 % 1.39 % 1.75 % 2.00 % (the cap)

An input that can’t be valued pays 0.25 %. GET /swap/v4/fee gives the schedule’s parameters, and every quote gives the fee that applies in fee_bps. amount_out is already net of it.

Swap Where the fee comes from How it reaches the fee sink
ALGO in Off the deposit: combo.amount_in is amount minus the fee Inner payment of your swap call
ALGO out Off the output Inner payment of your swap call
ASA to ASA That share of the input asset, which the router keeps; the rest is swapped The router converts what it has kept to ALGO and pays it to the fee sink monthly. Nothing is sold during your swap, so amount_out is exactly what the rest of the input buys
  • The fee sink is Y76M3MSY6DKBRHBL7C3NNDXGS5IIMQVQVUAB6MP4XEMMGVF2QWNPL226CA. With ALGO on one side, the payment is part of the atomic group you sign: you can check it before signing and see it on chain afterwards. The ASA-to-ASA conversion is done by the router contract itself, which can pay the proceeds only to the fee sink.
  • Positive slippage: when a swap into ALGO delivers more than its quote (the pools moved in your favour), the router pays 50 % of the extra ALGO to the fee sink, in the same inner payment as the fee, and you get the other 50 %. The swap call logs it as router_surplus. Your minimum output doesn’t change: the share comes only from output above the quote. On a swap into an ASA, everything above the quote is yours.
  • Nodely takes nothing else: no spread on the quote, no hidden fee in the minimum output and no token discount scheme. Nothing from the fee or the slippage share goes to Nodely.

The fee sink collects Algorand’s transaction fees and pays block proposers. A swap fee paid into it funds the network’s validators.

  1. Quote: GET /swap/v4 with the two assets and the amount.
  2. Build: POST /swap/v4/transactions with the quote as the body, your address and a slippage. You get one atomic group of unsigned transactions.
  3. Sign and send: sign the transactions whose signers holds your address and submit the whole group in order to any algod.
import algosdk from "algosdk";
const API = "https://vestleg.api.nodely.io";
const algod = new algosdk.Algodv2("", "https://mainnet-api.4160.nodely.dev", "");
const account = algosdk.mnemonicToSecretKey(process.env.MNEMONIC);
const sender = account.addr.toString();
// 1. Quote: 100 ALGO (in microALGO) to USDC, fixed input
const quote = await fetch(
`${API}/swap/v4?from_asa=0&to_asa=31566704&amount=100000000&mode=sef&sender=${sender}`,
).then((r) => r.json());
console.log("USDC out:", quote.amount_out / 1e6, "fee bps:", quote.fee_bps);
// 2. Build: 0.5 % slippage
const res = await fetch(`${API}/swap/v4/transactions?sender=${sender}&slippage=0.005`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(quote),
});
if (!res.ok) throw new Error(JSON.stringify((await res.json()).detail)); // 409: quote again
const group = await res.json();
// 3. Sign yours, keep pre-signed ones (stxn) as given, send in order
const signed = group.map((t) =>
t.stxn
? Buffer.from(t.stxn, "base64")
: algosdk.decodeUnsignedTransaction(Buffer.from(t.txn, "base64")).signTxn(account.sk),
);
const { txid } = await algod.sendRawTransaction(signed).do();
await algosdk.waitForConfirmation(algod, txid, 4);

A wallet connector (for example @txnlab/use-wallet) can sign the same list: decode each txn and pass them to the wallet’s signTransactions, asking it to sign only those whose signers holds your address.

Parameter Notes
from_asa, to_asa Required. Asset ids, 0 for ALGO
amount Required, in base units (microALGO for ALGO)
mode Required. sef: fixed input, amount goes in. sfe: fixed output, amount comes out
sender Optional, the account that will swap (the sender you’ll pass to /swap/v4/transactions). If it already holds the output asset, network_fee leaves out the opt-in. address is accepted as an alias; sender wins when both are given
enabled_providers, disabled_providers Optional, comma-separated provider codes (below)
denominating_asset_id For asset_in_price and asset_out_price, default 0

100 ALGO to USDC (trimmed: the route has 11 hops, the first one is shown):

{
"mode": "sef", "amount": 100000000, "asset_in": 0, "asset_out": 31566704,
"asset_in_price": 1, "asset_out_price": 12.54373327266576,
"amount_out": 7935706, "network_fee": 66000, "price_impact": 0.0021, "fee_bps": 25,
"combo": {
"asset_in": 0, "asset_out": 31566704, "amount_in": 99750000, "amount_out": 7935706, "network_fee": 66000,
"transactions": [
{ "asset_in": 0, "asset_out": 1134696561, "amount_in": 62842500, "amount_out": 50860026, "network_fee": 34700,
"swaps": [{ "provider": "XA", "bps": 100000000, "application_id": 1134695678, "amount_in": 62842500,
"amount_out": 50860026, "fee": 0, "network_fee": 8000 }] },
"…"
]
},
"single": { "...": "the best single path, same shape" }
}
  • combo splits the amount over up to 200 pieces across pools and paths of up to four hops; single is the best single path. amount_out is combo’s.
  • Each entry of combo.transactions is one hop between two assets. Its swaps are the pools of that hop, with their share in bps (100,000,000 = 100 %) and the pool’s own fee in fee.
  • fee_bps is the router fee that applies to this trade. It’s absent when the input is so small that the fee rounds to zero units.
  • network_fee, in microALGO, is what the group that /swap/v4/transactions builds for this quote pays in transaction fees: the post-quantum worst case and your opt-in to the output asset included. Route choice counts it, so a small trade takes a short route instead of a wide one whose fees would eat the gain.
  • router_min_balance is set when the route needs the router to opt in to an asset it doesn’t hold yet: the 0.1 ALGO minimum balance that the swap pays (below).
  • Positions too small to sell are refused. A pool won’t take less than its minimum input (a Tinyman 2.0 pool needs a fee of at least one base unit, so 334 units at a 0.30 % fee). A buy whose output couldn’t be sold back to ALGO, USDC or the input asset through the router’s pools gets 404 {"detail": "No route"}: quote a larger amount. Sells into ALGO or USDC are never refused.
  • Quotes are repeatable: the same request at the same round gives the same quote.

Provider codes:

Code Venue Code Venue
T3 Tinyman 2.0 AF Algofi
PT Pact AS Algofi NanoSwap (stable)
PS Pact StableSwap H2 Humble 2.0
PW Pact weighted FL Folks lending deposit and withdraw
PC Pact concentrated liquidity ff… A pool of two Folks fAssets, routed between their underlying assets (for example ffT3)
TA tALGO mint and burn XA xALGO mint and burn
Parameter Notes
Body Required. The /swap/v4 answer, as received
sender Required. The account that swaps
slippage Required. A fraction: 0.01 = 1 %. The group fails on chain if the output would fall below amount_out × (1 − slippage)
random_signer Accepted, as Vestige

This route allows bursts of 20 requests per IP (2 per second sustained, as the rest of the API).

The answer is one atomic group, in order. 1 ALGO to USDC from an account not yet opted in to USDC:

[
{ "txn": "iqRhcmN2xCBUmYbC…", "signers": ["KSMYNQU3…"], "message": "Opt in to asset 31566704" },
{ "txn": "iqNhbXTOAA9CQKNm…", "signers": ["KSMYNQU3…"], "message": "Deposit 1000000 of 0 into the router" },
{ "txn": "jaRhcGFhmsQEohkt…", "signers": ["KSMYNQU3…"], "message": "Swap 1000000 of 0 for at least 78909 of 31566704 through the router (4 pool legs)" },
{ "txn": "jaRhcGFhkcQEqDGH…", "signers": ["KSMYNQU3…"], "message": "Router references" }
]
  • txn is an unsigned transaction, base64-encoded msgpack. message says what it does. Sign every transaction whose signers holds your address. A transaction that comes with stxn is already signed: submit those bytes as given.
  • There’s no separate fee payment: the swap call’s own transaction fee covers the pools’ inner transactions. A wide route adds one or more Router references calls, which only carry the pools’ accounts, assets and boxes.
  • Post-quantum ready fees. Every transaction you sign carries 2,000 microALGO more than it needs with an ed25519 key: the worst case of a Falcon-1024 (post-quantum) signature, which costs three minimum fees. An account with a Falcon key can sign and send the same group unchanged. The quote’s network_fee already counts it.
  • The group includes the opt-ins it needs: yours into the output asset, and the router’s into an asset it hasn’t held yet. Nodely has opted the router in to the most traded assets in advance. For any other asset, the router’s minimum balance (0.1 ALGO) is paid once, by the first account that swaps it through the router: with ALGO in, it’s part of the deposit and the opt-in happens inside the swap; with an ASA in, the group starts with that payment and an opt-in call. Any part of it the router doesn’t spend is refunded in the same call.
  • Every group is run through algod simulate before it’s returned, with the post-quantum fees on. If it would fail (not enough balance, a pool moved, a missing opt-in), you get 409 with the reason in detail, never a group that fails on chain. Quote again and retry.
  • A quote whose output couldn’t be sold back (see GET /swap/v4) gets 404 No route here too.
  • When the quote as sent doesn’t fit one group of 16 transactions, the route is re-quoted to fit, and the first message says so. Check message before you sign if the exact route matters.

/swap/v4/fee takes address and answers the same for every address:

{"bps_fee":5000,"router_fee_bps":25,"router_fee_bps_large":200,"router_fee_large_from_usd":300,
"router_fee_schedule":{"base_bps":25,"cap_bps":200,"large_above_usd":300,"large_bps_per_decade":75,"small_below_usd":1,"small_bps_per_decade":120},
"token_amount":0,"token_liquidity_amount":0}
  • bps_fee keeps Vestige’s meaning: the share of output above the quote (positive slippage) taken from the swapper, in 1/10,000. Vestige’s aggregator app keeps bps_fee × (received − expected) / 10000 for its operator (8000, 80 %, for a wallet without its token). Here it is 5000: half, paid to the fee sink, and only when the output is ALGO (the fee sink holds no ASA, so on an ASA output you keep all of it). Your guaranteed minimum is unaffected.
  • router_fee_schedule holds the router fee formula’s parameters: fee_bps = min(cap_bps, round(base_bps + small_bps_per_decade × max(0, log10(small_below_usd / v)) + large_bps_per_decade × max(0, log10(v / large_above_usd)))). It’s absent when the router fee is off.
  • router_fee_bps is the schedule’s base (what a $1 to $300 trade pays), router_fee_bps_large the cap and router_fee_large_from_usd the value above which the fee rises with size. A quote gives the fee that applies in fee_bps.

/swap/v4/history gives the swaps and volume through the Nodely Router per bin: interval (default 86400 seconds), start, denominating_asset_id.

Mainnet app 3772077474 (“Nodely Router”)
Version 2.7, live since 2026-11-16 (morning, CET)
What it does Runs every pool leg of a route as an inner transaction of one swap call (40 to 55 legs fit one group), checks your minimum output once, on the total, and pays the router fee and any positive-slippage share to the fee sink. On ASA-to-ASA swaps it keeps the fee in the input asset
Venues it can run Tinyman 2.0, Pact (constant product, stable, weighted, concentrated), Algofi and NanoSwap, Folks lending and Folks-wrapped pools, tALGO and xALGO
Humble Routed only on its own, as a direct call outside the router: its contract must be alone in its group
Fee limits The contract refuses a fee above 200 bps (2 %) and below a floor of 25 bps, so the API can’t charge outside the schedule’s range
Fee conversion ASA fees the router holds are sold for ALGO by a sweeper call, which the contract pays only to the fee sink and refuses while the router is paused
Admin A 2-of-3 multisig, KSMYNQU35MEYX3T2467G2O22IWE7VNABEG4ZUPEGDN7MDU63RLXD2XBHDM. Every admin, guardian and sweeper action (pause, fee floor, sweep, authority changes) is logged on chain by the app
Safety A guardian key, which is a Falcon-1024 (post-quantum) account, can pause swaps. The app is still being tuned and Nodely can update it; it will be locked against updates once it’s final

The router lets a wide split route keep its quote. On 2026-11-16, 60 simulated ALGO-input swaps through version 2.6 all built, and each group guaranteed exactly 99.00 % of its quote at 1 % slippage. Plain groups of direct pool calls had kept 78 to 99 % of wide quotes.

If the router is paused, quotes and transactions still answer, from an outside aggregator, with that aggregator’s own fee instead of the Nodely fee. Such a quote carries a route_payload: send the quote back unchanged to /swap/v4/transactions. Transactions the aggregator pre-signs come back with empty signers and the signed bytes in stxn. If the outside aggregator isn’t available, the API routes through direct pool calls, without the router and without a Nodely fee.