GET /quote
What a buy or sale gets right now. Sends nothing.
GET https://marketmayhem.co/api/v1/quoteParameters
Section titled “Parameters”| Name | In | Required | Meaning |
|---|---|---|---|
token | query | yes | The token |
side | query | yes | |
amount | query | yes | Whole units of the exact side |
exact | query | Default in | |
slippageBps | query | Default 50 |
Response
Section titled “Response”| Field | Type | Required | Meaning |
|---|---|---|---|
token | object | yes | The token traded |
token.address | string | yes | A 0x address |
token.symbol | string | yes | |
token.pool | string | yes | A 0x address |
token.feeTier | integer | yes | |
token.pair | object | yes | |
token.pair.address | string | yes | The pair currency’s contract (WBNB for BNB) |
token.pair.decimals | integer | yes | Its decimals |
token.pair.symbol | string | yes | Its symbol, e.g. BNB |
side | buy · sell | yes | buy: pay the pair currency, get the token; sell: the reverse |
exact | in · out | yes | in: pay is fixed; out: receive is fixed |
slippageBps | integer | yes | The tolerance the limit is set from |
pay | object | yes | What is spent |
pay.amount | string | yes | A decimal amount in whole units, as a string: “0.05” |
pay.wei | string | yes | The same amount in the smallest unit, an integer as a string |
pay.symbol | string | yes | The currency, e.g. BNB or the token’s ticker |
receive | object | yes | What comes back, at the price now |
receive.amount | string | yes | A decimal amount in whole units, as a string: “0.05” |
receive.wei | string | yes | The same amount in the smallest unit, an integer as a string |
receive.symbol | string | yes | The currency, e.g. BNB or the token’s ticker |
limit | object | yes | The floor (or ceiling) written into the trade: it reverts rather than fill worse |
limit.amount | string | yes | A decimal amount in whole units, as a string: “0.05” |
limit.wei | string | yes | The same amount in the smallest unit, an integer as a string |
limit.kind | minReceive · maxPay | yes | |
siteFee | object | yes | The site fee this trade pays |
siteFee.amount | string | yes | A decimal amount in whole units, as a string: “0.05” |
siteFee.wei | string | yes | The same amount in the smallest unit, an integer as a string |
siteFee.symbol | string | yes | The currency, e.g. BNB or the token’s ticker |
siteFee.bps | integer | yes | Its rate, in basis points |
priceImpactPct | number | yes | How far this trade moves the price, in per cent |
A real response
Section titled “A real response”Captured from BSC testnet, exactly as the API sent it (long calldata shortened).
{ "token": { "address": "0x136bfd5f42250a568ce06ed1b145729b400e391c", "symbol": "BRNT", "pool": "0x0c779f6d50f5d27df85a84e8fc15e66202076e6d", "feeTier": 10000, "pair": { "address": "0xae13d989dac2f0debff460ac112a837c89baa7cd", "decimals": 18, "symbol": "BNB" } }, "side": "buy", "exact": "in", "slippageBps": 50, "pay": { "amount": "0.001", "wei": "1000000000000000", "symbol": "BNB" }, "receive": { "amount": "3548145.668617171169913355", "wei": "3548145668617171169913355", "symbol": "BRNT" }, "limit": { "kind": "minReceive", "amount": "3530404.940274085314063788", "wei": "3530404940274085314063788" }, "siteFee": { "amount": "0.00001", "wei": "10000000000000", "symbol": "BNB", "bps": 100 }, "priceImpactPct": 0.7534}Errors
Section titled “Errors”Every error is { "error": { "code", "message", "fix"? } }. This endpoint can answer:
UNKNOWN_TOKEN: That address is not a token launched on Market Mayhem.INVALID_SIDE:sidemust be buy or sell.INVALID_EXACT:exactmust be in or out.INVALID_AMOUNT: The amount is not a positive decimal number, or both/neither of amount and percent were sent.AMOUNT_TOO_SMALL: The amount is too small to get anything after the site fee, or out of the pool.TOO_MANY_DECIMALS: The amount has more decimal places than the currency has.INVALID_SLIPPAGE: The slippage is outside what is allowed.POOL_TOO_THIN: The pool cannot fill that size in one trade.RATE_LIMITED: Too many requests from this address in the last minute.