v1

latestOpenAPI 3.1.02026-07-13172871.5 KB
Smart Order Routing

Assemble Odos quote into transaction

Provide valid call data for a given quoted path. This is called after calling the sor/quote endpoint and receiving back a quote and pathID.

A quote only lasts for 60 seconds. If it is not assembled in that time, it will not be available to assemble, and the path will need to be quoted again.

Use the information provided by this endpoint directly. Do not try to modify the call data. You will make a mistake and you will end up losing money. We will not provide support for users modifying the call data provided by our API. The data the API provides is directly able to be executed on chain.

Request Body

ParameterDescriptionRequired
userAddrAddress of the user who requested the quoteYes
pathIdID of the Path returned from the sor/quote/{version} endpointYes
simulateSimulate the transaction to make sure it can actually be executed. This increases the response time to receive transaction data. Defaults to False.No
receiverOptionally, specify a different receiver address for the transaction output, default receiver is userAddrNo

Response Body

ParameterDescription
deprecatedIf the endpoint or any part of the request is deprecated, this field will be populated with a message. This field is omitted if there is nothing to notify on.
blockNumberBlock number the quote was generated for
gasEstimateA very naive gas estimate
gasEstimateValueUSD Value of the gasEstimate
inputTokensList of input token addresses and amounts
outputTokensList of output token addresses and amounts
netOutValueUSD value of the sum of the output tokens after gas
outValuesA list of the output values of the given output tokens. In the same order as the outputTokens list
transactionTransaction data needed for execution
simulationSimulation results

Transaction

This structure can be signed by a wallet and be executed against the Odos router.

In the smart contract that makes the swap, the data field of the transaction given in the response can be used in a low level call from another contract:

(bool success, bytes memory result) = router.call{value: $ethInput}(data)

Where $ethInput is 0 unless the native coin of the network is an input, in which case the value should be set to the corresponding path input amount. Approvals for ERC20 inputs should be made to the router address prior to the call. The address of the router can be found in the to field of the response, as well as from the /info/router/{version}/{chain_id} endpoint.

ParameterDescription
chainIdThe chain ID for the path to execute one
gasSuggested gas limit. Either 2X the naive gas estimate or 10% more than the simulated gas estimate
gasPriceGas price used to calculate the path
valueInput amount of gas token. 0 if the gas token is not one of the inputs
toOdos router address to be used for the transaction
fromSource of the executed transaction
dataCall data for the Odos router. This is the payload used by our executor contracts to execute the necessary DEX swaps.
nonceThe standard ETH nonce

Simulation

This the result of the simulation

ParameterDescription
isSuccessIf the transaction reverted or not
amountsOutAmounts out when the path was simulated
simGasUsedGas used by the simulation
gasEstimateEstimate from a eth_estimateGas RPC call for the path
simulationErrorIf a simulation error occurs, it will show up here.
post/sor/assemble

Request body

userAddrstring required
pathIdstring required
simulateboolean nullable
receiverstring nullable
permit2Signaturestring nullable

Example request

{
  "pathId": "95bb963d193cd229a0b4087f34382ea2",
  "simulate": false,
  "userAddr": "0x47E2D28169738039755586743E2dfCF3bd643f86"
}

Response

Successful Response

deprecatedstring nullable
traceIdstring nullable
blockNumberinteger required
gasEstimateinteger required
gasEstimateValuenumber required
netOutValuenumber required
outValuesstring[] required