Get Buy Quote
Get a price quote for buying tokens with native currency. Endpoint:/evm/buy/quote
| Parameter | Type | Required | Description |
|---|---|---|---|
chain | string | Yes | Chain identifier: eth, base, or bsc |
token | string | Yes | Token contract address |
swapMode | string | Yes | ExactIn (specify input) or ExactOut (specify output) |
amountIn | string | Conditional | Amount of native currency in wei. Required for ExactIn |
amountOut | string | Conditional | Amount of tokens to receive. Required for ExactOut |
wallet | string | Yes | Wallet address for the quote |
- Socket.IO
- HTTP
socket.emit(
"/evm/buy/quote",
{
chain: "eth",
token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
swapMode: "ExactIn",
amountIn: "1000000000000000000", // 1 ETH
wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e",
},
(response) => {
console.log(response);
}
);
await fetch("https://api.chainworks.co/evm/buy/quote", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CHAINWORKS_API_AUTH_TOKEN,
},
body: JSON.stringify({
chain: "eth",
token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
swapMode: "ExactIn",
amountIn: "1000000000000000000", // 1 ETH
wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e",
}),
});
{
"success": true,
"result": {
"chain": "eth",
"isBuy": true,
"token": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
"swapMode": "ExactIn",
"price": 0.00000234,
"priceImpact": 0.0012,
"amountIn": "1000000000000000000",
"expectedAmountOut": "427350427350427350427350"
}
}
Get Sell Quote
Get a price quote for selling tokens for native currency. Endpoint:/evm/sell/quote
| Parameter | Type | Required | Description |
|---|---|---|---|
chain | string | Yes | Chain identifier |
token | string | Yes | Token contract address |
swapMode | string | Yes | Always ExactIn |
amountIn | string | Yes | Amount of tokens to sell, in raw units |
wallet | string | Yes | Wallet address |
- Socket.IO
- HTTP
socket.emit(
"/evm/sell/quote",
{
chain: "eth",
token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE
swapMode: "ExactIn",
amountIn: "1000000000000000000000000", // 1,000,000 PEPE
wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e",
},
(response) => {
console.log(response);
}
);
await fetch("https://api.chainworks.co/evm/sell/quote", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CHAINWORKS_API_AUTH_TOKEN,
},
body: JSON.stringify({
chain: "eth",
token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE
swapMode: "ExactIn",
amountIn: "1000000000000000000000000", // 1,000,000 PEPE
wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e",
}),
});
Get Route Quote
Get a price quote for swapping one token for another, routed through up to four pools. Endpoint:/evm/route/quote
| Parameter | Type | Required | Description |
|---|---|---|---|
chain | string | Yes | Chain identifier. See Supported Chains |
tokenIn | string | Yes | Address of the token to sell |
tokenOut | string | Yes | Address of the token to buy. Must differ from tokenIn |
amountIn | string | Yes | Amount of tokenIn in raw units. Min: 1, max: 2^256 - 1 |
maxHops | number | No | Maximum number of pools in the route. Integer, 1-4 (default: 3) |
enforceSimplePaths | boolean | No | Whether the route may pass through each token only once (default: true) |
sources | string[] | No | Restrict routing to these pool types: v2, v3, v4, launchpad. Must not be empty when sent |
factories | string[] | No | Restrict routing to pools of these factory addresses |
wallet | string | No | Wallet that will execute the swap |
recipient | string | No | Address that will receive tokenOut |
- Socket.IO
- HTTP
socket.emit(
"/evm/route/quote",
{
chain: "eth",
tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
tokenOut: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE
amountIn: "1000000000", // 1,000 USDC
wallet: "0xYourWalletAddress",
},
(response) => {
console.log(response);
}
);
await fetch("https://api.chainworks.co/evm/route/quote", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CHAINWORKS_API_AUTH_TOKEN,
},
body: JSON.stringify({
chain: "eth",
tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
tokenOut: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE
amountIn: "1000000000", // 1,000 USDC
wallet: "0xYourWalletAddress",
}),
});
{
"success": true,
"result": {
"requestId": "7c1f0b8e-3d52-4a96-9f0e-2b6a4d8c1e73",
"chain": "eth",
"swapMode": "ExactIn",
"tokenIn": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"tokenOut": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
"amountIn": "1000000000",
"expectedAmountOut": "140028011204481792717086834",
"price": 140463483146067420,
"priceImpact": 0.0031,
"priceUsd": "0.00000712",
"route": [
{
"source": "v3",
"factory": "0x1f98431c8ad98523631ae4a59f235664d466c5f8",
"poolAddress": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
"tokenIn": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"tokenOut": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"fee": 500,
"amountIn": "1000000000",
"amountOut": "285571428571428571"
},
{
"source": "v3",
"factory": "0x1f98431c8ad98523631ae4a59f235664d466c5f8",
"poolAddress": "0x11950d141ecb863f01007add7d1a342041227b58",
"tokenIn": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"tokenOut": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
"fee": 3000,
"amountIn": "285571428571428571",
"amountOut": "140028011204481792717086834"
}
],
"verified": {
"method": "universalRouter",
"executionVerified": true,
"taxesMeasured": false,
"amountOut": "140028011204481792717086834",
"blockNumber": 19500012,
"deltaBps": 0
},
"gas": {
"estimate": "245000",
"priceWei": "2000000000",
"costNative": "490000000000000",
"basis": "simulation"
},
"block": 19500012
}
}
| Field | Type | Description |
|---|---|---|
requestId | string | Identifier of this quote |
chain | string | Chain identifier |
swapMode | string | Always ExactIn |
tokenIn | string | Address of the token sold |
tokenOut | string | Address of the token bought |
amountIn | string | Amount of tokenIn in raw units |
expectedAmountOut | string | Expected amount of tokenOut in raw units |
price | number | Spot price, in raw tokenOut units per raw tokenIn unit |
priceImpact | number | Price impact as a fraction (0.0031 = 0.31%) |
priceBasis | string | executed when the route has no spot price. price is then expectedAmountOut / amountIn and priceImpact is 0. Absent otherwise |
priceUsd | string | USD price of one whole tokenOut. May be absent |
route | object[] | Pools the swap passes through, in order. See below |
partialFill | object | Present when the route can only use part of amountIn |
partialFill.amountInConsumed | string | Amount of tokenIn the route uses, in raw units |
partialFill.amountInUnspent | string | Amount of tokenIn left over, in raw units |
partialFill.reason | string | Always loaded_liquidity_limit |
quotedOnChain | boolean | true when the route was priced by an on-chain quoter. Absent otherwise |
verified | object | On-chain check of the route. May be absent. See below |
auditWarnings | object[] | Safety findings per token, as { token, findings }. Present when there are any |
hookAuditWarnings | object[] | Safety findings per V4 hook, as { hook, findings }. Present when there are any |
taxWarnings | object[] | Transfer taxes the quote assumed. Present when there are any. See below |
gas.estimate | string | Gas units for the route |
gas.priceWei | string | Gas price used, in wei |
gas.costNative | string | gas.estimate times gas.priceWei, in wei |
gas.basis | string | simulation when measured by simulating the swap, model when estimated |
block | number | Block the quote was built on. May be absent |
route:
| Field | Type | Description |
|---|---|---|
source | string | Pool type: v2, v3, v4, or launchpad |
factory | string | Factory address. Present on v2 and v3 pools |
poolAddress | string | Pool address. Present on v2, v3, and launchpad pools |
poolId | string | Pool id. Present on v4 pools |
poolManager | string | Pool manager address. Present on v4 pools |
dex | string | DEX name. Present on launchpad pools, and on v4 pools of a known DEX |
tokenIn | string | Token entering the pool |
tokenOut | string | Token leaving the pool |
fee | number | Pool fee in hundredths of a basis point (3000 = 0.3%) |
amountIn | string | Amount entering the pool, in raw units |
amountOut | string | Amount leaving the pool, in raw units |
grossAmountOut | string | Pool output before the token’s transfer fee. Present when tokenOut charges one |
transferFeeBps | number | Transfer fee of tokenOut in basis points. Present when tokenOut charges one |
transferFeeAmount | string | Transfer fee deducted, in raw units. Present when tokenOut charges one |
launch | object | Present on launchpad pools. Carries launchpad (string), token (string), backingToken (string), graduated (boolean, always false), and progressPercent (number | null, 0 to 100) |
verified:
| Field | Type | Description |
|---|---|---|
method | string | universalRouter, partialUniversalRouter, or universalQuoter |
executionVerified | boolean | Whether the swap was simulated end to end |
taxesMeasured | boolean | Always false |
amountOut | string | Amount of tokenOut the check returned, in raw units |
blockNumber | number | Block the check ran at |
deltaBps | number | Difference between the quoted output and amountOut in basis points. Positive when the quote is higher |
taxWarnings:
| Field | Type | Description |
|---|---|---|
token | string | Token the tax applies to |
side | string | buy, sell, or transfer |
assumedBps | number | Tax the quote applied, in basis points |
mutable | boolean | Whether the token can change this tax |
reason | string | Why the tax was assumed. May be absent |
reportedBps | number | Tax the token reports, in basis points. May be absent |
minimumBps | number | Lowest tax the token can set, in basis points. May be absent |
maximumBps | number | Highest tax the token can set, in basis points. May be absent |
- Rejected with
TOKEN_UNSAFE,TOKEN_TAX_UNKNOWN,TOKEN_AUDIT_PENDING, orTOKEN_AUDIT_UNKNOWNwhentokenInortokenOutfails the token safety check. See Error Handling.

