Skip to Content
EnDocsInstruction Mode API

Instruction Mode API

Overview

  1. Partner code must be agreed upon in advance and passed through the header: Partner-Code;
  2. Currently supported chains: ETH, SOL, BNB chain, Base, Polygon, Arbitrum, Morph. Please notify us in advance for integration with other chains;
  3. Transaction fees:
    • Currently, fees are collected in our contract and settled periodically;
    • Custom fee collection addresses are under development;

HTTP Status Code Definitions

Status CodeDescription
200Success
400Bad Request
403Forbidden (Not whitelisted or signature error)
429Too many requests (Rate limited)

Quote API

Request Path: /bgw-pro/swapx/pro/quote

Request Method: POST

Request Parameters:

Field NameField TypeRequiredDescription
fromSymbolstringNoSource token name
fromContractstringYesSource token contract address, pass empty string for native token
fromAmountstringYesQuote amount (input amount)
fromChainstringYesSource chain
toSymbolstringNoTarget token name
toContractstringYesTarget token contract address, pass empty string for native token
toChainstringYesTarget chain
fromAddressstringNoDebit address, used for gas estimation. If not provided, a default address will be used for gas estimation
estimateGasboolNoWhether to estimate gas, default is false. Should be used together with fromAddress
marketstringNoSpecify quote channel, e.g., uniswap.v3, pancakeswap. All supported markets are used by default
feeRatenumberNoFee rate in per mille (‰), defaults to channel-configured fee rate. Pass 0 for no fee
solMaxAccountsnumberNoMaximum number of accounts, unlimited by default. Only applicable to SOL chain (limiting accounts may affect price advantage)

Request Example:

{ "fromSymbol": "USDT", "fromContract": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "fromAmount": "1", "fromChain": "sol", "toSymbol": "USDC", "fromAddress": "ApPjjUmJuraNuFZ2n41TBzdshd3pmDEQvH6hFukQ1Yv2", "toChain": "sol", "toContract": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "estimateGas": true, "skipCache": true }

Response Description:

Parameter NameParameter TypeRequiredDescription
statusnumberYesResponse code, 0 indicates success
dataobjectYes-
toAmountstringYesOutput amount
marketstringYesChannel name
estimateRevertboolYesChain identifier
slippagestringYesSlippage
computeUnitsnumberNoSOL chain tx compute unit consumption
gasLimitnumberNoEstimated gas limit

Response Example:

{ "status": 0, "data": { "toAmount": "1.000972", "market": "jupiter.router", "slippage": "2", "estimateRevert": true, "gasLimit": 0, "computeUnits": 650000 } }

Get Calldata API

Request Path: /bgw-pro/swapx/pro/swap

Request Method: POST

Request Parameters:

Field NameField TypeRequiredDescription
fromSymbolstringNoSource token name
fromContractstringYesSource token contract address, pass empty string for native token
fromAmountstringYesSell amount (input amount)
fromChainstringYesSource chain
toSymbolstringNoTarget token name
toContractstringYesTarget token contract address, pass empty string for native token
toChainstringYesTarget chain
toMinAmountstringNoMinimum amount to receive. If not provided, calculated using slippage
fromAddressstringYesDebit address
toAddressstringYesRecipient address
slippagenumberNoSlippage in percentage (e.g., 1 means 1%), defaults to system-configured slippage
marketstringYesOptimal channel returned by the quote API
feeRatenumberNoFee rate in per mille (‰), defaults to channel-configured fee rate. Pass 0 for no fee
executorAddressstringNoExecutor contract address. Required if transaction is not initiated by fromAddress
solMaxAccountsnumberNoMaximum number of accounts, unlimited by default. Only applicable to SOL chain
feePayerstringNoFee payer address. Defaults to using fromAddress to pay SOL chain account creation fees
deadlinenumberNoTransaction expiration time in seconds, default is 600 seconds
protocolsstringNoProtocol list, defaults to all supported protocols
requestModstringNoRequest mode, optional values are “simple” or “rich”

Request Example:

{ "fromSymbol": "USDT", "fromContract": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "fromAmount": "0.5", "fromChain": "sol", "toSymbol": "USDC", "fromAddress": "ApPjjUmJuraNuFZ2n41TBzdshd3pmDEQvH6hFukQ1Yv2", "toAddress": "ApPjjUmJuraNuFZ2n41TBzdshd3pmDEQvH6hFukQ1Yv2", "toChain": "sol", "toContract": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "slippage": 1, "toMinAmount": 0.4, "market": "bgw.aggregator" }

Response Description:

Parameter NameParameter TypeRequiredDescription
statusnumberYesResponse code, 0 indicates success
dataobjectYes-
idstringYesOrder ID
marketstringYesChannel name
contractstringNoContract address, returned for EVM chains
calldatastringYesCalldata
deadlinenumberYesOrder timeout (seconds)
computeUnitsnumberNoSOL chain tx compute unit consumption

Response Example:

{ "status": 0, "data": { "id": "9b4d17ccf0e84a9e976788bfc1f31423", "market": "bgw.aggregator", "contract": "", "calldata": "7uXV2gF3AZ2e2ZpGkknQkbhD2XJzDEsMzBWJEBM4iJBu3tF89cmRjeKudo6K4R2bB9321177Hxneuf6zznxphUwxSACYmA7D1AaNW9bpvV5X4khFdufcGrwLsxVHY1j9WFwHHBP6wEhnWT2H5Hdg3HV5cLEpeUtLHBo6y6YRepJ1Bf8L2zJAfTwiicxghTCNg7x7r8b5xSuE4oqVGRFaY11XSM6QykeevMkRBnTFYHqrcnKctiYJF2eQRCnoKMcqwT2frXbafRmj1MC4LKPdnJVjVjkDnqEbAnooBYwQ4AXywjp2h8Sk1BwkEowP4Zko4yUrpbLmq3mUvXoke9vgp52nv5udaYxo6G2w11W1k6Ha7fPBZCHKLyJvuiXcd6Zw5TRZ2KfFnY3ehFvSvedEw3XGUrAH98gGGVHQ1i7rUUb3o7LFFaSReXw2s12BSBHoSCub3emuQJVRACFC9z66sxmvWhrjC7r1vwg7hgKBTrannvkzyq3U9WMzxVBdiDLXcXpFiy2ePDKfzL81tnwaGRpA2x8db6P4UVzk11gvfWwhGi7YnAs8MS85U7ehELVQBJ3tKrjmRgfwx6uardEfmFb6fm86CnbfsZXzmARN2UhMBheUL8YTZAGr8nAUBn7wLkzTWLGbG8zmb8GkD7hAknSVyHy32FGyMsAcqDgW4ZKWNAWBQPmwC9KRfuTbr6YYg98pBLoJgphhJcnhv1jiRyCwyWcxDskAgBigeTKCNBNpJu85eve1V9vGKa8HUKerLZ52QvpCWoEavjFMaAk9x2yeFTVkGQxRWeR8VZxBq3BQTvCtzuZ3wXvDeoHYZKc4bUwxyzLs57cGYHMuhDHJjiXPgrx3CjMTnH2LpfqgQjHGKcHW3vLqBDdBUeLffshPmx5o23LT4h9e8CQVBGQgHzj4SHMoC6V3F5hiLLvM", "deadline": 600, "computeUnits": 650000 } }

Reverse Quote Swap API

The Reverse Quote Swap API combines quoting and transaction building into a single call, supporting two trading modes:

  • exactIn: User specifies the input token amount, and the system calculates the expected output amount.
  • minAmountOut: User specifies the desired minimum output token amount, and the system calculates the required input amount via reverse quoting. If the on-chain execution does not satisfy the amount, the transaction will revert.

Request Path: /bgw-pro/swapx/pro/swapr

Request Method: POST

Request Parameters:

Field NameField TypeRequiredDefaultDescription
fromChainstringYes-Chain identifier, e.g., sol, eth, bnb, base
fromContractstringYes-Source token contract address, pass empty string for native token
toContractstringYes-Target token contract address, pass empty string for native token
amountstringYes-Amount (in token decimals), meaning depends on requestMode
requestModestringYes-Request mode: exactIn or minAmountOut
fromAddressstringYes-User wallet address (debit address), length 1-256
toAddressstringYes-Recipient address, length 1-256
slippagestringNo"0.5"Slippage tolerance percentage (e.g., "0.5" means 0.5%)
feeRatefloat64Yes-Fee rate in per mille, must be >= 0
deadlineintNo600Transaction expiration time in seconds
executorAddressstringNo-Executor contract address. Required if transaction is not initiated by fromAddress

requestMode Description:

Modeamount MeaningDescription
exactInInput token amountForward quoting: given input, calculate output
minAmountOutDesired minimum output token amountReverse quoting: given desired output, calculate required input

Request Example (exactIn mode):

{ "fromChain": "bnb", "fromContract": "0x55d398326f99059ff775485246999027b3197955", "toContract": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "amount": "1", "requestMode": "exactIn", "fromAddress": "0xd8FeBD1C242a282f1b8226d34282942F6F63248b", "toAddress": "0xd8FeBD1C242a282f1b8226d34282942F6F63248b", "slippage": "0.5", "feeRate": 0.003, "deadline": 600 }

Request Example (minAmountOut mode):

{ "fromChain": "bnb", "fromContract": "0x55d398326f99059ff775485246999027b3197955", "toContract": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "amount": "1", "requestMode": "minAmountOut", "fromAddress": "0xd8FeBD1C242a282f1b8226d34282942F6F63248b", "toAddress": "0xd8FeBD1C242a282f1b8226d34282942F6F63248b", "slippage": "0.5", "feeRate": 0.003, "deadline": 600 }

Response Description:

Parameter NameParameter TypeRequiredDescription
statusnumberYesResponse code, 0 indicates success
dataobjectYes-
idstringYesOrder ID
amountInstringYesInput amount
expectedAmountOutstringYesExpected output amount
minAmountOutstringYesMinimum output amount
priceImpactstringYesPrice impact percentage
recommendSlippagenumberYesRecommended slippage
expiresAtnumberYesExpiration timestamp (unix seconds)
marketstringYesChannel name
txs[]objectYesTransaction list
feeobjectYesFee details

txs Array Elements:

Parameter NameParameter TypeRequiredDescription
chainIdnumberYesChain ID
tostringYesTarget contract address
calldatastringYesTransaction calldata
functionstringYesFunction name
gasLimitstringYesGas limit
gasPricestringYesGas price
noncenumberYesNonce
valuestringYesTransaction value

fee Object:

Parameter NameParameter TypeRequiredDescription
totalAmountInUsdstringYesTotal fee in USD
platformFeeobjectYesPlatform fee details
platformFee.amountInUsdstringYesPlatform fee in USD
platformFee.items[]objectYesFee breakdown items

Response Example:

{ "status": 0, "data": { "id": "2dde9b1da4044957aec42e9e93416717", "amountIn": "1", "expectedAmountOut": "0.9969249606918065", "minAmountOut": "0.9919403358883475", "priceImpact": "0.25", "recommendSlippage": 1, "expiresAt": 1770620790, "market": "bgwevmaggregator", "txs": [ { "chainId": 56, "to": "0x6D0034c7DA87e8f0526b21aa890d40a77C755B68", "calldata": "0xd984396a...", "function": "swap", "gasLimit": "752325", "gasPrice": "0.0000000001875", "nonce": 235, "value": "0" } ], "fee": { "totalAmountInUsd": "0.003", "platformFee": { "amountInUsd": "0.003", "items": [ { "token": { "chain": "bnb", "address": "0x55d398326f99059ff775485246999027b3197955", "symbol": "USDT", "decimals": 18 }, "amount": "0.003", "amountInUsd": "0.003" } ] } } } }

MEV Batch Send

Request Path: /bgw-pro/swapx/pro/send

Request Method: POST

Request Parameters:

Parameter NameParameter TypeRequiredDescription
chainstringYesChain name, max 64 characters
txs[]objectYesTransaction list, max 100 items

txs Array Elements:

Parameter NameParameter TypeRequiredDescription
idstringYesOrder ID, max 128 characters
chainstringYesChain name, max 64 characters
rawTxstringYesRaw transaction data for on-chain submission, max 8192 characters
fromstringYesOrder sender address, max 128 characters
noncenumberYesNonce, minimum value is 0
providerstringNoSend provider, max 128 characters

Request Example:

{ "chain": "bnb", "txs": [ { "id": "34bbf08b6ca5bb9d19e2b0e9715d82f6", "chain": "bnb", "rawTx": "0xabc...", "from": "0xabc", "nonce": 1, "provider": "" } ] }

Response Description:

Parameter NameParameter TypeRequiredDescription
statusnumberYesResponse code, 0 indicates success
data[]objectYes-
idstringYesOrder ID
txHashstringYesTransaction hash
codestringNoResponse code, 0 indicates success
messagestringYesError message

Response Example:

{ "status": 0, "data": { "result": [ { "id": "34bbf08b6ca5bb9d19e2b0e9715d82f6", "code": 0, "txHash": "2T4UR7tsgiPQsJuEYMwu8wNzukdjzoLgqTNBQ1KgL13nX7CUTQeEkNz8sEiGA35fCvt7MCNsgRGohFLg9dg932jr" } ] } }

Further Reading

Last updated on