agentsvc.io

services / token-liquidity

financeoperational · 200 ms

Token Liquidity and Slippage

Pool depth and slippage for a token: per pool (Uniswap, Aerodrome, PancakeSwap, Sushi and more) the liquidity in USD, estimated price impact for each size in sizes_usd and the largest trade at 1% and 5% impact. Use to size a trade or check if an exit is possible. Estimate based on constant product; conservative for concentrated liquidity pools. Errors with Not charged if no pool exists.

Run free trial ↗3 free calls per day with the example input. Paid: $0.008 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/token-liquidity", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"token":"0x532f27101965dd16442E59d40670FaF5eBB142E4","chain":"base","sizes_usd":[100,1000,10000]}),
});
const { data, payment } = await res.json();  // payment.status "settling"; header X-Payment-Settle: sync returns payment.transaction

Input

FieldTypeDescription
token *stringToken contract address (0x...)
chainstringbase (default), ethereum, bsc, arbitrum, polygon, avalanche or optimism
sizes_usdarrayUp to 6 trade sizes in USD, default [100,1000,10000,100000]

Output

FieldTypeDescription
total_liquidity_usdnumber
poolsarray
price_usdnumber