Documentation Index
Fetch the complete documentation index at: https://docs.akka.finance/llms.txt
Use this file to discover all available pages before exploring further.
The /dex-compare endpoint returns the AKKA aggregated quote alongside the top individual DEX pool quotes for the same pair and amount. Use it to show users the price advantage of aggregation.
How it works
AKKA splits and routes trades across multiple pools to find the best rate. A single DEX can only use its own liquidity. The difference is your value proposition.
curl -H "apikey: YOUR_API_KEY" \
"https://api.akka.finance/swap/v1/999/dex-compare?src=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&dst=0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb&amount=1000000000000000000"
{
"akkaQuote": "12723902882990271",
"decimalsOut": 18,
"pools": [
{
"poolAddress": "0xabc...",
"poolType": "uni_v3",
"amountOut": "12650000000000000",
"decimalsOut": 18
},
{
"poolAddress": "0xdef...",
"poolType": "slipstream",
"amountOut": "12580000000000000",
"decimalsOut": 18
},
{
"poolAddress": "0x123...",
"poolType": "algebra_v4",
"amountOut": "12490000000000000",
"decimalsOut": 18
}
]
}
Calculating the savings
import { formatUnits } from 'viem';
interface DexCompareResult {
akkaQuote: string;
decimalsOut: number;
pools: { poolAddress: string; poolType: string; amountOut: string; decimalsOut: number }[];
}
function calculateSavings(data: DexCompareResult) {
const akka = Number(formatUnits(BigInt(data.akkaQuote), data.decimalsOut));
return data.pools.map((pool) => {
const dex = Number(formatUnits(BigInt(pool.amountOut), pool.decimalsOut));
const savingsPercent = ((akka - dex) / dex) * 100;
return {
poolType: pool.poolType,
dexOutput: dex,
akkaOutput: akka,
savingsPercent: savingsPercent.toFixed(2),
};
});
}
Example output:
| DEX | DEX Output | AKKA Output | Savings |
|---|
| uni_v3 | 0.01265 UBTC | 0.01272 UBTC | +0.58% |
| slipstream | 0.01258 UBTC | 0.01272 UBTC | +1.13% |
| algebra_v4 | 0.01249 UBTC | 0.01272 UBTC | +1.87% |
React component
Display a comparison table in your swap UI:
import { useState, useEffect } from 'react';
import { formatUnits } from 'viem';
const API_BASE = 'https://api.akka.finance';
const API_KEY = process.env.NEXT_PUBLIC_AKKA_API_KEY!;
interface Pool {
poolType: string;
amountOut: string;
decimalsOut: number;
}
interface CompareData {
akkaQuote: string;
decimalsOut: number;
pools: Pool[];
}
export function DexComparison({
src, dst, amount,
}: {
src: string; dst: string; amount: string;
}) {
const [data, setData] = useState<CompareData | null>(null);
useEffect(() => {
if (!amount || amount === '0') return;
const params = new URLSearchParams({ src, dst, amount });
fetch(`${API_BASE}/swap/v1/999/dex-compare?${params}`, {
headers: { apikey: API_KEY },
})
.then((r) => r.json())
.then(setData)
.catch(console.error);
}, [src, dst, amount]);
if (!data || data.pools.length === 0) return null;
const akkaAmount = Number(formatUnits(BigInt(data.akkaQuote), data.decimalsOut));
return (
<table>
<thead>
<tr>
<th>Source</th>
<th>Output</th>
<th>vs AKKA</th>
</tr>
</thead>
<tbody>
<tr style={{ fontWeight: 'bold' }}>
<td>AKKA (aggregated)</td>
<td>{akkaAmount.toFixed(8)}</td>
<td>—</td>
</tr>
{data.pools.map((pool) => {
const dexAmount = Number(formatUnits(BigInt(pool.amountOut), pool.decimalsOut));
const diff = ((akkaAmount - dexAmount) / dexAmount) * 100;
return (
<tr key={pool.poolType}>
<td>{pool.poolType}</td>
<td>{dexAmount.toFixed(8)}</td>
<td style={{ color: diff > 0 ? 'green' : 'red' }}>
{diff > 0 ? '+' : ''}{diff.toFixed(2)}%
</td>
</tr>
);
})}
</tbody>
</table>
);
}
Backend usage
For analytics dashboards or reports:
const API_BASE = 'https://api.akka.finance';
const API_KEY = process.env.AKKA_API_KEY!;
async function getAkkaSavings(src: string, dst: string, amount: string) {
const params = new URLSearchParams({ src, dst, amount });
const res = await fetch(`${API_BASE}/swap/v1/999/dex-compare?${params}`, {
headers: { apikey: API_KEY },
});
const data = await res.json();
if (!data.pools?.length) return null;
const bestDex = data.pools[0]; // pools are sorted by amountOut descending
const akka = BigInt(data.akkaQuote);
const best = BigInt(bestDex.amountOut);
const savingsBps = Number((akka - best) * 10000n / best);
return {
akkaOutput: data.akkaQuote,
bestDexOutput: bestDex.amountOut,
bestDexType: bestDex.poolType,
savingsBps,
savingsPercent: (savingsBps / 100).toFixed(2),
};
}
The pools array is sorted by amountOut descending — the first entry is the best single-DEX quote. Compare it against akkaQuote to get the minimum savings percentage.