Skip to main content
POST
/
v2
/
tokenized_assets
/
transact
/
sell
Python (SDK)
from compass_api_sdk import CompassAPI, models


with CompassAPI(
    api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:

    res = compass_api.tokenized_assets.tokenized_assets_transact_sell(token_in="<value>", token_out="<value>", amount_in=8512.47, owner="<value>", chain=models.Chain.ARBITRUM, slippage="0.5", gas_sponsorship=False, fee={
        "recipient": "<value>",
        "amount": 3839.45,
        "denomination": models.TokenizedAssetsFeeDenomination.PERCENTAGE,
    })

    # Handle response
    print(res)
import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsTransactSell({
tokenIn: "<value>",
tokenOut: "<value>",
amountIn: 8512.47,
slippage: "0.5",
owner: "<value>",
chain: "arbitrum",
gasSponsorship: false,
fee: {
recipient: "<value>",
amount: 3839.45,
denomination: "PERCENTAGE",
},
});

console.log(result);
}

run();
curl --request POST \
--url https://api.compasslabs.ai/v2/tokenized_assets/transact/sell \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"amount_in": "500",
"chain": "ethereum",
"gas_sponsorship": false,
"owner": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
"slippage": "0.5",
"token_in": "USDC",
"token_out": "mTBILL"
}
'
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount_in: '500',
chain: 'ethereum',
gas_sponsorship: false,
owner: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B',
slippage: '0.5',
token_in: 'USDC',
token_out: 'mTBILL'
})
};

fetch('https://api.compasslabs.ai/v2/tokenized_assets/transact/sell', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.compasslabs.ai/v2/tokenized_assets/transact/sell",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount_in' => '500',
'chain' => 'ethereum',
'gas_sponsorship' => false,
'owner' => '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B',
'slippage' => '0.5',
'token_in' => 'USDC',
'token_out' => 'mTBILL'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.compasslabs.ai/v2/tokenized_assets/transact/sell"

payload := strings.NewReader("{\n \"amount_in\": \"500\",\n \"chain\": \"ethereum\",\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"slippage\": \"0.5\",\n \"token_in\": \"USDC\",\n \"token_out\": \"mTBILL\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v2/tokenized_assets/transact/sell")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in\": \"500\",\n \"chain\": \"ethereum\",\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"slippage\": \"0.5\",\n \"token_in\": \"USDC\",\n \"token_out\": \"mTBILL\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.compasslabs.ai/v2/tokenized_assets/transact/sell")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in\": \"500\",\n \"chain\": \"ethereum\",\n \"gas_sponsorship\": false,\n \"owner\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"slippage\": \"0.5\",\n \"token_in\": \"USDC\",\n \"token_out\": \"mTBILL\"\n}"

response = http.request(request)
puts response.read_body
{
  "estimated_amount_out": "<string>",
  "transaction": {
    "chainId": "0x2105",
    "data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
    "from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
    "gas": "0x7a120",
    "maxFeePerGas": "0x59682f00",
    "maxPriorityFeePerGas": "0x3b9aca00",
    "nonce": "0x5",
    "to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
    "value": "0x0"
  },
  "eip_712": {
    "domain": {
      "chainId": 8453,
      "verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
    },
    "message": {
      "baseGas": "0",
      "data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
      "gasPrice": "0",
      "gasToken": "0x0000000000000000000000000000000000000000",
      "nonce": "7",
      "operation": 1,
      "refundReceiver": "0x0000000000000000000000000000000000000000",
      "safeTxGas": "0",
      "to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
      "value": "0"
    },
    "primaryType": "SafeTx",
    "types": {
      "EIP712Domain": [
        {
          "name": "chainId",
          "type": "uint256"
        },
        {
          "name": "verifyingContract",
          "type": "address"
        }
      ],
      "SafeTx": [
        {
          "name": "to",
          "type": "address"
        },
        {
          "name": "value",
          "type": "uint256"
        },
        {
          "name": "data",
          "type": "bytes"
        },
        {
          "name": "operation",
          "type": "uint8"
        },
        {
          "name": "safeTxGas",
          "type": "uint256"
        },
        {
          "name": "baseGas",
          "type": "uint256"
        },
        {
          "name": "gasPrice",
          "type": "uint256"
        },
        {
          "name": "gasToken",
          "type": "address"
        },
        {
          "name": "refundReceiver",
          "type": "address"
        },
        {
          "name": "nonce",
          "type": "uint256"
        }
      ]
    }
  },
  "fee_amount": "<string>",
  "settlement": "instant",
  "poll_endpoint": "<string>"
}
{
"error": "<string>",
"message": "<string>"
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json

Buy or sell a swap-traded tokenized asset inside the product account.

Applies to RWA yield assets (Midas mTokens). Equities trade via the order endpoints instead.

token_in
string
required

Token to spend. For a buy this must be a stablecoin the Midas issuance vault accepts (USDC on every supported network; mBASIS also accepts USDT/DAI on Ethereum). For a sell it is the Midas RWA asset to redeem (e.g. 'mTBILL').

Examples:

"USDC"

"mTBILL"

token_out
string
required

Token to receive. For a buy this is the Midas RWA asset to mint (e.g. 'mTBILL'); for a sell it is the payout stablecoin (USDC).

Examples:

"mTBILL"

"USDC"

amount_in
required

Human-readable amount of token_in to trade (token units, not wei).

Required range: x > 0
Example:

500

owner
string
required

The owner's wallet address.

chain
enum<string>
required

Network to trade on. Midas RWA assets exist on Ethereum and Base.

Available options:
base,
ethereum,
arbitrum,
hyperevm,
tempo,
bsc
slippage
default:0.5

Maximum slippage tolerance as a percentage (e.g., 0.5 = 0.5%).

Example:

0.5

gas_sponsorship
boolean
default:false

When true, returns an EIP-712 payload for gas-sponsored execution instead of an unsigned transaction.

fee
TokenizedAssetsFee · object | null

Optional partner fee charged when selling (exiting). It is taken from the payout-token (USDC) proceeds and sent to your fee recipient inside the same execution.

Response

Successful Response

Unsigned trade execution for the owner to sign.

Exactly one of transaction (gas_sponsorship=false) or eip_712 (gas_sponsorship=true) is set.

estimated_amount_out
string
required

Estimated amount of token_out received (human-readable units).

Pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
transaction
UnsignedTransaction · object | null

Unsigned transaction executing the trade in the product account.

Example:
{
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
}
eip_712
BatchedSafeOperationsResponse · object | null

EIP-712 payload for gas-sponsored execution.

Example:
{
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{ "name": "chainId", "type": "uint256" },
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{ "name": "to", "type": "address" },
{ "name": "value", "type": "uint256" },
{ "name": "data", "type": "bytes" },
{ "name": "operation", "type": "uint8" },
{ "name": "safeTxGas", "type": "uint256" },
{ "name": "baseGas", "type": "uint256" },
{ "name": "gasPrice", "type": "uint256" },
{ "name": "gasToken", "type": "address" },
{
"name": "refundReceiver",
"type": "address"
},
{ "name": "nonce", "type": "uint256" }
]
}
}
fee_amount
string | null

Fee charged on the sell, in payout-token (USDC) units. Null when no fee was applied.

Pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
settlement
enum<string>
default:instant

How the trade settles. instant: the signed transaction completes the trade (Midas/Ondo swaps and IXS deposits). async: the transaction only requests an IXS redemption, which the vault operator settles off-chain later — poll poll_endpoint for status.

Available options:
instant,
async
poll_endpoint
string | null

For async settlements, the endpoint to poll for redemption status (GET /v2/tokenized_assets/redemptions). Null for instant trades.