Python
from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="<YOUR_API_KEY_HERE>", ) as compass_api: res = compass_api.swap.odos(token_in="0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", token_out="0xdac17f958d2ee523a2206206994597c13d831ec7", amount=1.5, max_slippage_percent=0.5, chain=models.Chain.ETHEREUM_MAINNET, sender="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B") # Handle response print(res)
{ "chainId": 123, "data": "<string>", "from": "<string>", "gas": 123, "to": "<string>", "value": 123, "nonce": 123, "maxFeePerGas": 123, "maxPriorityFeePerGas": 123, "authorizationList": [] }
Swap between two tokens using Odos Smart Order Routing.
Required Allowances
In order to make this transaction, token allowances need to be set for the following contracts.
OdosRouter
Your Compass API Key. Get your key here.
Successful Response
The response is of type object.
object
Was this page helpful?