# Compass Labs API - Complete Reference for LLMs Last updated: 2026-10-01 API Base URL: https://api.compasslabs.ai Documentation: https://docs.compasslabs.ai ================================================================================ ## Introduction Compass is a non-custodial DeFi API for fintech and crypto applications. **Key concepts:** - **Non-custodial**: Compass generates unsigned transaction payloads. Users sign with their own wallets. Compass never holds funds or private keys. - **Product Accounts**: Isolated on-chain smart accounts per product type (Earn, Credit, Trading). Enable transaction bundling and gas sponsorship. - **Transaction Bundling**: Combine multiple DeFi operations into a single atomic transaction (50-70% gas savings). - **Gas Sponsorship**: Pay gas on behalf of users so they never need ETH. Uses EIP-712 typed data signatures. - **Embedded Fees**: Monetize by embedding fees (percentage, fixed, or performance-based) into transactions. **Supported chains:** - Base (chain: "base", chain_id: 8453) - Ethereum (chain: "ethereum", chain_id: 1) - Arbitrum (chain: "arbitrum", chain_id: 42161) - HyperEVM (chain: "hyperevm", chain_id: 999) - Tempo (chain: "tempo", chain_id: 4217) - BNB Smart Chain (chain: "bsc", chain_id: 56) - Robinhood (chain: "robinhood") **Testnet chains** (staging only — production rejects these with 422): - Ethereum Sepolia (chain: "ethereum_sepolia", chain_id: 11155111) **Supported protocols:** - Earn and swap venues: Aave, Aerodrome, Morpho, Pendle, Sky, Uniswap - Crypto-backed loan protocols: Aave, Euler, Morpho - Tokenized asset issuers: Centrifuge, IXS, Midas, Ondo, WisdomTree **Products:** Bridge, Credit, Earn, Gas Sponsorship, Perpetual Trading, Tokenized Assets ================================================================================ ## SDK Installation **Python SDK:** ```bash pip install compass_api_sdk ``` ```python from compass_api_sdk import CompassAPI, models with CompassAPI(api_key_auth="YOUR_API_KEY") as compass_api: # Make API calls result = compass_api.earn.earn_vaults(chain=models.Chain.BASE) ``` **TypeScript SDK:** ```bash npm install @compass-labs/api-sdk ``` ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "YOUR_API_KEY", }); // Make API calls const result = await compassApiSDK.earn.earnVaults({ chain: "base" }); ``` ================================================================================ ## API Endpoints -------------------------------------------------------------------------------- ### Bridge -------------------------------------------------------------------------------- #### POST /v2/cctp/burn **Initiate USDC bridging** Bridge USDC to any chain for any Product account using Circle's CCTP Protocol. Transfer modes: - `standard` (default): ~15-19 minute transfers, free (no fee) - `fast`: ~30 second transfers, requires a small fee (typically ~0.01%) The fee for fast mode is automatically calculated based on Circle's current rates. Flow: 1. Call this endpoint with `gas_sponsorship=false` to get an unsigned transaction, or `gas_sponsorship=true` to get EIP-712 typed data for gas-sponsored execution 2. Owner signs the transaction or typed data 3. Broadcast the transaction on the source chain (or submit to `/gas_sponsorship/prepare`) 4. Wait for Circle's attestation service to attest the burn 5. Call the mint endpoint to receive USDC on the destination chain Supported chains: - Ethereum (domain 0) - Arbitrum (domain 3) - Base (domain 6) Note: The USDC must already be deposited in the Product Account. If approval is needed for the TokenMessengerV2 contract, it will be included in the transaction automatically. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.bridge.cctp_burn(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.DepositForBurnRequestChain.ARBITRUM, amount="3", destination_chain=models.DestinationChain.BASE, gas_sponsorship=True, transfer_mode=models.DepositForBurnRequestTransferMode.STANDARD) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.bridge.cctpBurn({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "arbitrum", amount: "3", destinationChain: "base", gasSponsorship: true, transferMode: "standard", }); console.log(result); } run(); ``` #### POST /v2/cctp/mint **Complete USDC bridging** Prepare a receiveMessage transaction to mint USDC to any Product Account on the destination chain. How it works: This endpoint uses the `bridge_id` from `/burn` to: 1. Look up the bridge session 2. Check if Circle's attestation is ready 3. Depending on the status of the attestation return the following: - if attestation is still pending, return URLs for real-time updates - if attestation is ready, return a transaction to complete the bridging process - if the minting for a given `bridge_id` has been completed, informs with `completed` status Request parameters: - `bridge_id`: The bridge ID returned from `/burn` - `burn_tx_hash`: The transaction hash of the burn transaction on the source chain Response codes: - 200 OK: Attestation is ready, mint transaction is included - 202 Accepted: Attestation is pending, SSE URL for real-time updates is included (The real-time update endpoints are in progress) - 404 Not found: Bridge not found After receiving 202: Either: - Connect to the SSE stream at `sse_url` and wait for `attestation_ready` event (The SSE stream and status endpoint are in progress. Keep an eye on the updates from our team) - Poll this endpoint periodically until you get 200 **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.bridge.cctp_mint(bridge_id="br_cae305798062", burn_tx_hash="0x42c914b870eacc2c1734420f6ab183f95a5b0e0fdbb1c82247183848b76fc8ad", sender="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.bridge.cctpMint({ bridgeId: "br_cae305798062", burnTxHash: "0x42c914b870eacc2c1734420f6ab183f95a5b0e0fdbb1c82247183848b76fc8ad", sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", }); console.log(result); } run(); ``` -------------------------------------------------------------------------------- ### Credit -------------------------------------------------------------------------------- #### GET /v2/credit/balances **Get credit account token balances** Get token balances and transfer history for a credit account. Returns all token balances held by the credit account derived from the owner address, along with complete transfer history and USD valuations. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): - `owner` (string, required): The address of the owner of the credit account. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_balances(chain=models.V2CreditBalancesChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditBalances({ chain: "base", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/credit/borrow **Borrow against collateral** Borrow an asset from Aave using a Credit Account. Bundles an optional swap, collateral supply, and borrow into a single atomic Safe transaction. - If `token_in` equals `collateral_token`, the tokens are supplied directly as collateral. - If `token_in` differs from `collateral_token`, a market swap is performed first. The Credit Account must already be created via `/v2/credit/create_account` and funded with `token_in`. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_borrow(owner="0xfeEb60eBf707DAA8248277058eb8D28EaeCF5425", chain=models.CreditBorrowRequestChain.BASE, borrow_token="WETH", borrow_amount=0.01, sub_account_id=0, token_in="USDC", amount_in=100.0, collateral_token="USDC", interest_rate_mode=models.InterestRateMode.VARIABLE, slippage=0.5, gas_sponsorship=False, fee=None) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditBorrow({ owner: "0xfeEb60eBf707DAA8248277058eb8D28EaeCF5425", chain: "base", tokenIn: "USDC", amountIn: 100, collateralToken: "USDC", borrowToken: "WETH", borrowAmount: 0.01, interestRateMode: "variable", slippage: 0.5, gasSponsorship: false, }); console.log(result); } run(); ``` #### POST /v2/credit/bundle **Execute multiple credit actions** Compose individual credit operations (supply, withdraw, borrow, repay, swap, transfer) into a single atomic Safe transaction. The Credit Account must already be created via `/v2/credit/create_account`. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_bundle(owner="", chain=models.CreditBundleRequestChain.HYPEREVM, actions=[ models.CreditUserOperation( body=models.EarnTransferFromEOAParams( token="", amount="709.93", permit2_signature="", permit2_nonce=210517, permit2_deadline=120606, ), ), ], gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditBundle({ owner: "", chain: "hyperevm", actions: [ { body: { actionType: "V2_TRANSFER_FROM_EOA", token: "", amount: "709.93", permit2Signature: "", permit2Nonce: 210517, permit2Deadline: 120606, }, }, ], gasSponsorship: false, }); console.log(result); } run(); ``` #### POST /v2/credit/create_account **Create credit account** Create a Credit Account for a wallet address. Before using credit features, the owner must create a Credit Account. Each wallet address has one Credit Account per chain. Returns an unsigned transaction to create the account. The `sender` signs and broadcasts this transaction. If owner pays gas: Set `sender` to the owner's address. If someone else pays gas: Set `sender` to the wallet that will sign and broadcast the transaction on behalf of the owner. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_create_account(chain=models.CreateCreditAccountRequestChain.BASE, sender="0xc98949522db2eE403d6c75E91DDEe875a824bB10", owner="0xc98949522db2eE403d6c75E91DDEe875a824bB10", estimate_gas=True) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditCreateAccount({ chain: "base", sender: "0xc98949522db2eE403d6c75E91DDEe875a824bB10", owner: "0xc98949522db2eE403d6c75E91DDEe875a824bB10", }); console.log(result); } run(); ``` #### GET /v2/credit/euler_markets **List curated Euler markets** List curated Euler V2 credit markets for a chain. Euler is permissionless, so credit borrow/repay identify a market by EVK vault address. This returns the borrow markets from Euler's Governed Perspective (the DAO-vetted vault set) -- each with the collateral vaults it accepts and their LTVs -- so callers know which borrow_vault / collateral_vault to use. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_euler_markets(chain=models.V2CreditEulerMarketsChain.ETHEREUM) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditEulerMarkets({ chain: "ethereum", }); console.log(result); } run(); ``` #### POST /v2/credit/loop **Open a leveraged loop** Open a leveraged position in ONE atomic transaction. Supply collateral, borrow against it, swap the borrowed token back to collateral, repeat — until total collateral reaches multiplier x initial_collateral_amount. If any step fails the whole transaction reverts, so a position is never left half-built. See the Leveraged Looping guide for chain coverage, market discovery, vault-share collateral, HyperEVM specifics and the full error list. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_loop(owner="0x5e5b00ed886A6879C2B934612D2312975427fcAf", chain=models.CreditLoopRequestChain.ETHEREUM, collateral_token="WETH", borrow_token="USDC", initial_collateral_amount=1.0, multiplier=2.0, loan_to_value=70.0, protocol=models.CreditProtocol.AAVE, sub_account_id=0, max_slippage_percent=0.5, gas_sponsorship=False, preview=False, pricing=models.CreditLoopRequestPricing.AUTO) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditLoop({ owner: "0x5e5b00ed886A6879C2B934612D2312975427fcAf", chain: "ethereum", protocol: "AAVE", collateralToken: "WETH", borrowToken: "USDC", initialCollateralAmount: 1, multiplier: 2, loanToValue: 70, maxSlippagePercent: 0.5, gasSponsorship: false, }); console.log(result); } run(); ``` #### GET /v2/credit/looped_positions **List looped (leveraged) credit positions** List the leveraged positions held by an owner's Credit Account. Positions are reconstructed from on-chain history rather than from API calls, so a loop assembled by hand through /v2/credit/bundle is recognised the same way as one opened through /v2/credit/loop. Only activity inside the Credit Account is visible — leverage the owner holds directly in their wallet is not. See the Leveraged Looping guide for protocol coverage and how to read leverage, health factor and net APY. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): - `owner` (string, required): The address of the owner of the credit account to get looped positions for. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_looped_positions(chain=models.V2CreditLoopedPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditLoopedPositions({ chain: "base", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### GET /v2/credit/morpho_markets **List curated Morpho markets** List curated Morpho Blue lending markets for a chain. Morpho Blue is permissionless, so credit actions identify a market by its bytes32 market id. This returns the curated market set with live LLTV, supply/borrow APY, utilization, and available liquidity -- read on-chain per request -- so callers know which market_id to use and what it currently costs. **Parameters:** - `offset` (integer, optional): The offset of the first item to return. - `limit` (integer, optional): The number of items to return. - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): - `order_by` (enum: ['tvl_usd', 'liquidity_usd', 'lltv'], optional): Field to order the markets by before paginating. - `direction` (enum: ['asc', 'desc'], optional): Order direction (asc/desc). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_morpho_markets(chain=models.V2CreditMorphoMarketsChain.ETHEREUM, offset=0, limit=100, order_by=models.MorphoMarketOrderBy.TVL_USD, direction=models.V2CreditMorphoMarketsDirection.DESC) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditMorphoMarkets({ offset: 0, limit: 100, chain: "ethereum", orderBy: "tvl_usd", direction: "desc", }); console.log(result); } run(); ``` #### GET /v2/credit/positions **List credit positions** List all Credit positions for a given owner. Returns a unified list of positions (collateral and debt) and an account summary with health factor and LTV. Each position includes event history. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): - `owner` (string, required): The address of the owner of the credit account to get positions for. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_positions(chain=models.V2CreditPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditPositions({ chain: "base", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/credit/rebalance **Rebalance the leveraged credit book** Move one or more leveraged positions to the state you want, in ONE atomic transaction. List the positions to change and the end state you want for each. The API works out whether that means opening, growing, shrinking, delevering or closing, and does them all together. Money freed by shrinking or closing one position pays for growing or opening another, so shifting funds between positions needs no new deposit. Any shortfall is taken from the Credit Account's idle balance, and the call returns 422 if that does not cover it either. See the Leveraged Looping guide for protocol and chain coverage, capital routing and the full error list. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_rebalance(owner="0x4D3c07d1db7E4A9E44285fae9810d6549655bc74", chain=models.CreditRebalanceRequestChain.ETHEREUM, targets=[ { "protocol": models.CreditProtocol.AAVE, "collateral_token": "WETH", "borrow_token": "USDC", "target_multiplier": 2.0, }, ], max_slippage_percent=0.5, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditRebalance({ owner: "0x4D3c07d1db7E4A9E44285fae9810d6549655bc74", chain: "ethereum", targets: [ { protocol: "AAVE", collateralToken: "WETH", borrowToken: "USDC", targetMultiplier: 2, }, ], maxSlippagePercent: 0.5, gasSponsorship: false, }); console.log(result); } run(); ``` #### POST /v2/credit/repay **Repay debt and withdraw collateral** Repay an Aave debt and withdraw collateral from a Credit Account. Bundles repayment, collateral withdrawal, and an optional swap into a single atomic Safe transaction. - If `token_out` is None or equals `withdraw_token`, the withdrawn collateral is kept as-is. - If `token_out` differs from `withdraw_token`, a market swap is performed after withdrawal. The Credit Account must already have a borrow position created via `/v2/credit/borrow`. The repay_token must be available in the Credit Account (or pulled from EOA via Permit2). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_repay(owner="0x831Ad0C52C77708DA5D49dc8278C966dfdD4ddA1", chain=models.CreditRepayRequestChain.BASE, repay_token="WETH", repay_amount=0.01, sub_account_id=0, interest_rate_mode=models.InterestRateMode.VARIABLE, withdraw_token="USDC", withdraw_amount=100.0, slippage=0.5, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditRepay({ owner: "0x831Ad0C52C77708DA5D49dc8278C966dfdD4ddA1", chain: "base", repayToken: "WETH", repayAmount: 0.01, interestRateMode: "variable", withdrawToken: "USDC", withdrawAmount: 100, slippage: 0.5, gasSponsorship: false, }); console.log(result); } run(); ``` #### POST /v2/credit/swap **Swap tokens** Swap one token for another inside a Credit Account. Exchanges tokens the Credit Account already holds in a single atomic transaction, so idle or borrowed balances can be converted without moving funds out first. Returns an unsigned transaction to sign, the expected output amount, and which route priced the swap. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_swap(token_in="USDC", token_out="USDT", amount_in="0.01", owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.CreditSwapRequestChain.BASE, slippage="0.5", gas_sponsorship=False, preview=False, pricing=models.CreditSwapRequestPricing.AUTO) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditSwap({ tokenIn: "USDC", tokenOut: "USDT", amountIn: "0.01", slippage: "0.5", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "base", gasSponsorship: false, pricing: "auto", }); console.log(result); } run(); ``` #### POST /v2/credit/transfer **Transfer tokens to/from Credit Account** Transfer tokens between the owner's EOA and their Credit Account. DEPOSIT (EOA → Credit Account): - With `gas_sponsorship=true`: returns Permit2 EIP-712 typed data to sign. The gas sponsor calls `permitTransferFrom` to pull tokens (1 signature). - With `gas_sponsorship=false`: returns an unsigned ERC-20 transfer transaction. WITHDRAW (Credit Account → EOA): - With `gas_sponsorship=true`: returns SafeTx EIP-712 typed data to sign. The gas sponsor broadcasts the `execTransaction` (1 signature). - With `gas_sponsorship=false`: returns an unsigned `execTransaction`. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_transfer(owner="0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6", chain=models.CreditTransferRequestChain.BASE, token="USDC", amount=100.0, action=models.CreditTransferRequestAction.DEPOSIT, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditTransfer({ owner: "0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6", chain: "base", token: "USDC", amount: 100, action: "DEPOSIT", }); console.log(result); } run(); ``` #### POST /v2/credit/unloop **Unwind a leveraged loop** Unwind a leveraged position in ONE atomic transaction. Withdraw collateral, swap it back to the borrow token, repay, repeat — until the position reaches target_multiplier, or until the debt is cleared exactly if you omit it. If any step fails the whole transaction reverts. See the Leveraged Looping guide for chain coverage, vault-share collateral, shared Aave reserves and the full error list. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.credit.credit_unloop(owner="0x0E407CdeBD8e078E6966ef6740540d25F5897082", chain=models.CreditUnloopRequestChain.ETHEREUM, collateral_token="WETH", borrow_token="USDC", protocol=models.CreditProtocol.AAVE, sub_account_id=0, max_slippage_percent=0.5, allow_partial=False, gas_sponsorship=False, preview=False, pricing=models.CreditUnloopRequestPricing.AUTO) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.credit.creditUnloop({ owner: "0x0E407CdeBD8e078E6966ef6740540d25F5897082", chain: "ethereum", protocol: "AAVE", collateralToken: "WETH", borrowToken: "USDC", maxSlippagePercent: 0.5, allowPartial: false, gasSponsorship: false, }); console.log(result); } run(); ``` -------------------------------------------------------------------------------- ### Earn -------------------------------------------------------------------------------- #### GET /v2/earn/aave_markets **List aave markets** List Aave lending markets with supply and borrow rates. Returns rates organized by token symbol, with chain-specific data for each token. Each token includes rates for all chains where it's available, plus information about which chain offers the highest supply APY. APY values are returned in percentage format (e.g., 4.5 means 4.5%). Tokens with zero APY on both supply and borrow are excluded. To deposit into an Aave market, use the manage endpoint with `venue_type=AAVE`. **Parameters:** - `chain` (string, optional): Optional chain filter. If not provided, returns rates for all chains. - `days` (integer, optional): Window in days used to compute `supply_apy_avg` / `borrow_apy_avg`. Mirrors the `days` parameter of the v1 `/v1/aave/avg_rate` endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_aave_markets(days=30) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnAaveMarkets({ days: 30, }); console.log(result); } run(); ``` #### GET /v2/earn/balances **Get token balances** Get token balances and transfer history for an earn account. Returns on-chain token balances for all tokens the earn account has interacted with, along with the complete transfer history for each token. Balances are keyed by token symbol for easy access. Use this endpoint to display account balances, track token movements, or build transaction history interfaces. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): - `owner` (string, required): The address of the owner of the earn account. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_balances(chain=models.V2EarnBalancesChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnBalances({ chain: "base", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/earn/bundle **Execute multiple earn actions** Combine multiple actions into a single atomic transaction. Bundle swaps and venue deposits/withdrawals into one transaction executed through the Earn Account. This saves gas compared to executing actions separately and ensures all actions succeed or fail together. Example: Swap AUSD to USDC, then deposit USDC into a vault - all in one transaction. Fees: Manage actions (deposits/withdrawals) support optional fee configuration, same as the standalone manage endpoint. Gas sponsorship: Set `gas_sponsorship=true` to receive EIP-712 typed data. Owner signs the typed data, then submit to /gas_sponsorship/prepare. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_bundle(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.V2BundleRequestChain.ETHEREUM, actions=[ { "body": { "action_type": "V2_TRANSFER_FROM_EOA", "token": "USDC", "amount": "100", "permit2_signature": "0x...", "permit2_nonce": 1706000000, "permit2_deadline": 1706001800, }, }, { "body": { "action_type": "V2_SWAP", "token_in": "USDC", "token_out": "AUSD", "amount_in": "100", "slippage": "0.5", }, }, { "body": { "action_type": "V2_MANAGE", "venue": { "type": "VAULT", "vault_address": "0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6", }, "action": models.EarnManageParamsAction.DEPOSIT, "amount": "100", }, }, ], gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnBundle({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "ethereum", actions: [ { body: { actionType: "V2_TRANSFER_FROM_EOA", token: "USDC", amount: "100", permit2Signature: "0x...", permit2Nonce: 1706000000, permit2Deadline: 1706001800, }, }, { body: { actionType: "V2_SWAP", tokenIn: "USDC", tokenOut: "AUSD", amountIn: "100", slippage: "0.5", }, }, { body: { actionType: "V2_MANAGE", venue: { type: "VAULT", vaultAddress: "0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6", }, action: "DEPOSIT", amount: "100", }, }, ], gasSponsorship: false, }); console.log(result); } run(); ``` #### POST /v2/earn/create_account **Create earn account** Create an Earn Account for a wallet address. Before depositing into venues or managing positions, the owner must create an Earn Account. Each wallet address has one Earn Account per chain. Returns an unsigned transaction to create the account. The `sender` signs and broadcasts this transaction. If owner pays gas: Set `sender` to the owner's address. If someone else pays gas: Set `sender` to the wallet that will sign and broadcast the transaction on behalf of the owner. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_create_account(chain=models.CreateAccountRequestChain.BASE, sender="0x06A9aF046187895AcFc7258450B15397CAc67400", owner="0x06A9aF046187895AcFc7258450B15397CAc67400", estimate_gas=True) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnCreateAccount({ chain: "base", sender: "0x06A9aF046187895AcFc7258450B15397CAc67400", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/earn/manage **Manage earn position** Deposit into or withdraw from a yield venue. Use `DEPOSIT` to move tokens from the Earn Account into a vault, Aave market, or Pendle PT position. Use `WITHDRAW` to move tokens back from a venue into the Earn Account. Venue types: - `VAULT`: ERC-4626 vaults (see /vaults for available options) - `AAVE`: Aave lending pools (see /aave_markets for available options) - `PENDLE_PT`: Pendle Principal Tokens (see /pendle_markets for available options) Fees: A fee can be configured and deducted from the transaction amount (not supported for PENDLE_PT): - `FIXED`: A fixed token amount (e.g., 0.1 means 0.1 tokens) - `PERCENTAGE`: A percentage of the amount (e.g., 1.5 means 1.5%) - `PERFORMANCE`: A percentage of realized profit (withdrawals only) Gas sponsorship: Set `gas_sponsorship=true` to receive EIP-712 typed data. Owner signs the typed data, then submit to /gas_sponsorship/prepare. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_manage(venue={ "type": "VAULT", "vault_address": "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A", }, action=models.EarnManageRequestAction.DEPOSIT, amount="0.01", owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.EarnManageRequestChain.BASE, fee={ "recipient": "", "amount": "263.30", "denomination": models.FeeDenomination.PERCENTAGE, }, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnManage({ venue: { type: "VAULT", vaultAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A", }, action: "DEPOSIT", amount: "0.01", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "base", gasSponsorship: false, }); console.log(result); } run(); ``` #### GET /v2/earn/pendle_markets **List pendle markets** List Pendle yield trading markets with TVL and implied APY. Returns Pendle market data including Principal Token (PT), Standardized Yield (SY), and Yield Token (YT) addresses, along with market expiry, TVL, and implied APY. Use this endpoint to discover yield trading opportunities, compare rates across Pendle markets, or build market selection interfaces. APY values are returned in percentage format (e.g., 5.25 means 5.25%). Markets without complete metadata or statistics are excluded. **Parameters:** - `direction` (enum: ['asc', 'desc'], optional): The direction to order the results by. - `offset` (integer, optional): The offset of the first item to return. - `limit` (integer, optional): The number of items to return. - `chain` (string, optional): Optional chain filter. If not provided, returns markets for all chains. - `order_by` (string, optional): Field to order the markets by. One of: tvl_usd, implied_apy. Defaults to tvl_usd; unknown values also fall back to tvl_usd. - `underlying_symbol` (string, optional): Filter markets by underlying asset symbol (e.g., 'USDC', 'WETH'). - `min_tvl_usd` (string, optional): Minimum TVL in USD. Markets with TVL below this value will be excluded. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_pendle_markets(direction=models.V2EarnPendleMarketsDirection.DESC, offset=0, limit=50, order_by="tvl_usd") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnPendleMarkets({ direction: "desc", offset: 0, limit: 50, orderBy: "tvl_usd", }); console.log(result); } run(); ``` #### GET /v2/earn/positions **List earn positions** List all Earn positions for a given owner with PnL tracking. Returns position data including current balance, cost basis, and profit and loss. Use this endpoint to display portfolio performance, track yields over time, or build position management interfaces. Positions are tracked across all venue types (vaults and Aave markets). Each position includes the venue address, deposited amount, and performance metrics. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): - `owner` (string, required): The address of the owner of the earn account to get positions for. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_positions(chain=models.V2EarnPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnPositions({ chain: "base", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### GET /v2/earn/positions_all **List earn positions across all chains** List all Earn positions across all supported chains (Ethereum, Base, Arbitrum). Returns positions grouped by chain, with per-chain and total USD values. Each chain includes Aave, vault, and Pendle PT positions. Chains where the user has no earn account return empty position lists. Use this endpoint for a cross-chain portfolio overview instead of making separate calls per chain to /positions. **Parameters:** - `owner` (string, required): The address of the owner of the earn account. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_positions_all(owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnPositionsAll({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/earn/swap **Swap tokens** Swap one token for another inside an Earn Account. Exchanges tokens the Earn Account already holds in a single atomic transaction, so funds never leave it, and can be chained with other actions through the bundle endpoint (for example, swap ETH to USDC and deposit the USDC into a vault at once). Returns an unsigned transaction to sign and the expected output amount. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_swap(token_in="USDC", token_out="USDT", amount_in="0.01", owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.EarnSwapRequestChain.BASE, slippage="0.5", gas_sponsorship=False, pricing=models.EarnSwapRequestPricing.AUTO) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnSwap({ tokenIn: "USDC", tokenOut: "USDT", amountIn: "0.01", slippage: "0.5", owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "base", gasSponsorship: false, pricing: "auto", }); console.log(result); } run(); ``` #### GET /v2/earn/swap_quote **Quote a swap** Estimate the output of a swap without building a transaction. Returns the expected amount of `token_out` received for selling `amount_in` of `token_in`. On chains with a market route this is the market rate; on HyperEVM, where swaps are firm-priced, it is an indicative price from the firm provider's live levels (`swap_provider` tells you which). This is read-only: it does not build a transaction, require an account, or check balances. Use it to gauge exit liquidity and price impact for a token before entering a position — for example, to warn when a market's underlying asset cannot be swapped back to a stablecoin without large slippage. **Parameters:** - `chain` (enum: ['arbitrum', 'base', 'bsc', 'ethereum', 'hyperevm', 'tempo'], required): Target blockchain network. - `token_in` (string, required): Token to sell (input). A token symbol (e.g. 'WETH') or any token address. - `token_out` (string, optional): Token to buy (output). A token symbol (e.g. 'USDC') or any token address. - `sy_address` (string, optional): Optional Pendle SY (Standardized Yield) address. When provided, `token_in` is overridden with the token the PT actually redeems into on withdrawal (the SY asset if it is a valid token-out, else the SY yield token) — use this to gauge a Pendle position's real exit liquidity rather than the reported underlying. - `amount_in` (string, required): Human-readable amount of `token_in` to quote (token units, not wei). - `slippage` (string, optional): Maximum slippage tolerance as a percentage (e.g., 1 = 1%). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_swap_quote(chain=models.V2EarnSwapQuoteChain.BASE, token_in="WETH", amount_in="1", token_out="USDC", slippage="1.0") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnSwapQuote({ chain: "base", tokenIn: "WETH", tokenOut: "USDC", amountIn: "1", slippage: "1.0", }); console.log(result); } run(); ``` #### POST /v2/earn/transfer **Transfer tokens to/from account** Transfer tokens between an owner's wallet and their Earn Account. Use `DEPOSIT` to move tokens from the owner's wallet into their Earn Account. Use `WITHDRAW` to move tokens from the Earn Account back to the owner's wallet. Gas-sponsored deposits require two steps: Step 1 (once per token): Set up Permit2 allowance 1. Call /gas_sponsorship/approve_transfer to get EIP-712 typed data 2. Owner signs the typed data 3. Submit signature + typed data to /gas_sponsorship/prepare Step 2 (each transfer): Execute the gas-sponsored transfer 1. Call this endpoint with `gas_sponsorship=true` to get EIP-712 typed data 2. Owner signs the typed data 3. Submit signature + typed data to /gas_sponsorship/prepare Note: This endpoint moves tokens to/from the Earn Account itself—not into yield venues. To deposit into a vault or Aave market, use the manage endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_transfer(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.EarnTransferRequestChain.BASE, token="USDC", amount="0.01", action=models.EarnTransferRequestAction.DEPOSIT, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnTransfer({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "base", token: "USDC", amount: "0.01", action: "DEPOSIT", }); console.log(result); } run(); ``` #### GET /v2/earn/vaults **List vaults** List ERC-4626 yield vaults across DeFi venues. Returns vault data including APY, TVL, and underlying asset information. Use this endpoint to discover yield opportunities, compare rates across venues, or build vault selection interfaces. Supports dozens of vaults and markets like Morpho and other ERC-4626 compatible yield venues. To deposit into a vault, use the manage endpoint with `venue_type=VAULTS`. **Parameters:** - `direction` (enum: ['asc', 'desc'], optional): The direction to order the results by. - `offset` (integer, optional): The offset of the first item to return. - `limit` (integer, optional): The number of items to return. - `chain` (string, optional): Optional chain filter. If not provided, returns vaults for all chains. - `order_by` (string, optional): Field to order the vaults by. One of: tvl_usd, liquidity_usd, deposit_cap_usd, apy_7d, apy_30d, apy_90d. Defaults to tvl_usd; unknown values also fall back to tvl_usd. - `asset_symbol` (string, optional): Filter vaults by underlying asset symbol (e.g., 'USDC', 'WETH'). - `min_tvl_usd` (string, optional): Minimum TVL in USD. Vaults with TVL below this value will be excluded. - `min_liquidity_usd` (string, optional): Minimum available liquidity in USD. Vaults below this are excluded. - `min_deposit_cap_usd` (string, optional): Minimum deposit capacity in USD. Vaults below this are excluded. Set to 0 to exclude paused vaults. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.earn.earn_vaults(direction=models.V2EarnVaultsDirection.DESC, offset=0, limit=50, order_by="tvl_usd") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.earn.earnVaults({ direction: "desc", offset: 0, limit: 50, orderBy: "tvl_usd", }); console.log(result); } run(); ``` -------------------------------------------------------------------------------- ### Gas Sponsorship -------------------------------------------------------------------------------- #### POST /v2/gas_sponsorship/approve_transfer **Approve token transfer** Set up a one-time Permit2 allowance for gas-sponsored token transfers. Required when using /earn/transfer or /credit/transfer with `gas_sponsorship=true`. This allowance only needs to be set up once per token. With gas sponsorship (`gas_sponsorship=true`): - Returns EIP-712 typed data for the owner to sign off-chain - Submit signature + typed data to /prepare - Only works for tokens that support EIP-2612 permit (e.g., USDC) Some tokens, like USDT and WETH, do not support EIP-2612 permit. For these tokens, set `gas_sponsorship=false` to receive an unsigned transaction that the owner must sign, submit, and pay gas for. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.gas_sponsorship.gas_sponsorship_approve_transfer(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.Chain.BASE, token="USDT", gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.gasSponsorship.gasSponsorshipApproveTransfer({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", chain: "base", token: "USDT", }); console.log(result); } run(); ``` #### POST /v2/gas_sponsorship/prepare **Prepare gas-sponsored transaction** Prepare a gas-sponsored transaction from signed EIP-712 typed data. Submit the `owner`'s off-chain signature along with the EIP-712 typed data that was signed. Returns an unsigned transaction for the `sender` to sign and broadcast. How gas sponsorship works: 1. Call an endpoint with `gas_sponsorship=true` (e.g., /earn/transfer, /earn/manage, /credit/transfer) to get EIP-712 typed data 2. Owner signs the typed data off-chain 3. Submit signature + typed data to this endpoint 4. Sender signs and broadcasts the returned transaction, paying gas on behalf of the owner Note: For gas-sponsored deposits via /earn/transfer or /credit/transfer, the owner must first set up a Permit2 allowance using /approve_transfer (once per token). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.gas_sponsorship.gas_sponsorship_prepare(owner="0xCE1A77F0abff993d6d3D04d44b70831c6924fb40", chain=models.Chain.ARBITRUM, eip_712={ "domain": { "name": "USD Coin", "version": "2", "chain_id": 42161, "verifying_contract": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", }, "types": { "eip712_domain": [ { "name": "name", "type": "string", }, { "name": "version", "type": "string", }, { "name": "chainId", "type": "uint256", }, { "name": "verifyingContract", "type": "address", }, ], "permit": [ { "name": "owner", "type": "address", }, { "name": "spender", "type": "address", }, { "name": "value", "type": "uint256", }, { "name": "nonce", "type": "uint256", }, { "name": "deadline", "type": "uint256", }, ], }, "primary_type": "Permit", "message": { "owner": "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40", "spender": "0x000000000022D473030F116dDEE9F6B43aC78BA3", "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935", "nonce": "0", "deadline": "1762269774", }, }, signature="0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c", sender="0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d", product=models.Product.EARN) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.gasSponsorship.gasSponsorshipPrepare({ owner: "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40", chain: "arbitrum", eip712: { domain: { name: "USD Coin", version: "2", chainId: 42161, verifyingContract: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", }, types: { eip712Domain: [ { name: "name", type: "string", }, { name: "version", type: "string", }, { name: "chainId", type: "uint256", }, { name: "verifyingContract", type: "address", }, ], permit: [ { name: "owner", type: "address", }, { name: "spender", type: "address", }, { name: "value", type: "uint256", }, { name: "nonce", type: "uint256", }, { name: "deadline", type: "uint256", }, ], }, primaryType: "Permit", message: { owner: "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40", spender: "0x000000000022D473030F116dDEE9F6B43aC78BA3", value: "115792089237316195423570985008687907853269984665640564039457584007913129639935", nonce: "0", deadline: "1762269774", }, }, signature: "0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c", sender: "0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d", }); console.log(result); } run(); ``` -------------------------------------------------------------------------------- ### Perpetual Trading -------------------------------------------------------------------------------- #### GET /v2/perpetual_trading/activity **Aggregated Hyperliquid activity for a user** Return positions, fills, open orders, and (optionally) builder approval state for an end-user in one normalized payload. Each section is fetched in parallel from the Hyperliquid `info` API. If a single upstream call fails the corresponding section returns ``null`` and an entry is added to ``partial_errors``; if every section fails the endpoint responds with 502. Pass ``builder`` to additionally include the user's current approved max fee rate for that builder (used by dashboards to decide whether to prompt the user to sign an `approveBuilderFee` action). **Parameters:** - `owner` (string, required): End-user EOA whose activity should be fetched. - `builder` (string, optional): Optional builder address. When provided, the response includes the current builder-fee approval state for this (owner, builder) pair. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_activity(owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingActivity({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/approve_builder_fee **Approve builder fee** Prepare builder fee approval for the perpetual trading DEX. This is a one-time action required before placing the first trade. Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_approve_builder_fee(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", builder={ "address": "0x88806A71D74AD0a510B350545C9AE490912F0888", "max_fee_rate": "0.01%", }) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingApproveBuilderFee({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", builder: { address: "0x88806A71D74AD0a510B350545C9AE490912F0888", maxFeeRate: "0.01%", }, }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/cancel_order **Cancel order** Prepare an order cancellation. Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_cancel_order(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", asset="AAPL", order_id=12345) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingCancelOrder({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", asset: "AAPL", orderId: 12345, }); console.log(result); } run(); ``` #### GET /v2/perpetual_trading/candles **Get OHLCV candles** Return OHLCV candles for a single asset and interval. Wraps Hyperliquid's ``candleSnapshot`` info type and adds the xyz: HIP-3 DEX prefix server-side so the SDK only needs the bare ticker (e.g. ``AAPL``). Candle ``time`` is returned in unix seconds, ready for TradingView lightweight-charts. Cached for 15 seconds per (symbol, interval, window). **Parameters:** - `symbol` (string, required): Asset ticker (e.g. AAPL, GOLD, EUR). The xyz: HIP-3 DEX prefix is added server-side if not already present. - `interval` (enum: ['1m', '5m', '15m', '1h', '4h', '1d', '1w'], required): Candle interval: 1m, 5m, 15m, 1h, 4h, 1d, 1w - `limit` (integer, optional): Number of candles to return (max 5000, capped by Hyperliquid). - `start_time` (string, optional): Optional start of the candle window in unix milliseconds. If omitted, computed as end_time - limit * interval. - `end_time` (string, optional): Optional end of the candle window in unix milliseconds. Defaults to now. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_candles(symbol="AAPL", interval=models.CandleInterval.ONEH, limit=200) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingCandles({ symbol: "AAPL", interval: "1h", limit: 200, }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/deposit **Deposit USDC to perpetual trading account** Prepare a USDC deposit from Arbitrum via EIP-2612 Permit. Returns EIP-712 typed data for the user to sign off-chain (no gas needed). Compass does NOT broadcast the bridge tx — the integrator's own sponsor wallet calls batchedDepositWithPermit on the HL Bridge2 contract on Arbitrum after the user signs. See api_docs/v2/Products/Perpetual-Trading.mdx "Deposit USDC" section for the bridge-broadcast code. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_deposit(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", amount="100.0") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingDeposit({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", amount: "100.0", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/deposit/sponsor_prepare **Build the Bridge2 deposit tx from a signed permit** Build the Arbitrum tx that completes a USDC deposit to HL. Takes the EIP-2612 permit signature returned by /deposit and returns a fully-encoded `Bridge2.batchedDepositWithPermit` call. The integrator's sponsor wallet (`sender`) broadcasts the returned tx — Compass does not broadcast and does not hold gas keys. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_deposit_sponsor_prepare(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", amount_raw=100000000, deadline=1747097383, signature="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", sender="0x4A83b4413CF41C3244027e1590E35a0F48403F0c") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingDepositSponsorPrepare({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", amountRaw: 100000000, deadline: 1747097383, signature: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", sender: "0x4A83b4413CF41C3244027e1590E35a0F48403F0c", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/enable_unified_account **Enable unified account mode** Check account mode and prepare the enable-unified-account action if needed. If the account is already in unified mode (or portfolio margin), returns the current mode with null typed_data — no signing needed. Otherwise, returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_enable_unified_account(owner="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingEnableUnifiedAccount({ owner: "", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/ensure_leverage **Ensure 1x cross leverage** Check leverage and prepare an updateLeverage action if not 1x cross. If the asset is already at 1x cross leverage, returns leverage_ok=true with null typed_data — no signing needed. Otherwise, returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_ensure_leverage(owner="", asset="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingEnsureLeverage({ owner: "", asset: "", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/execute **Execute signed action** Submit a signed Hyperliquid action for execution. Accepts the signature from any prepare endpoint (market_order, limit_order, cancel_order, withdraw, approve_builder_fee) and POSTs it to the Hyperliquid exchange API. The caller must have already hit a prepare endpoint, so no compass_account registration is performed here. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_execute(action={ "key": "", "key1": "", }, nonce=449590, signature="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingExecute({ action: { "key": "", "key1": "", }, nonce: 449590, signature: "", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/limit_order **Place limit order** Prepare a limit order on a perpetual trading market. Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. Supports GTC and ALO time-in-force. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_limit_order(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", asset="AAPL", side="buy", size="10.0", price="190.00", time_in_force="gtc", reduce_only=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingLimitOrder({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", asset: "AAPL", side: "buy", size: "10.0", price: "190.00", timeInForce: "gtc", reduceOnly: false, }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/market_order **Place market order** Prepare a market order on a perpetual trading market. Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. Executes as an IOC order at the current mark price with slippage protection. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_market_order(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", asset="AAPL", side="buy", size="10.0", slippage_percent=1.0, reduce_only=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingMarketOrder({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", asset: "AAPL", side: "buy", size: "10.0", slippagePercent: 1, reduceOnly: false, }); console.log(result); } run(); ``` #### GET /v2/perpetual_trading/opportunities **List perpetual trading markets** List available perpetual trading markets with key metrics. Returns perp markets (stocks, commodities, forex) with open interest, 24h volume, funding rate, and max leverage. Supports filtering by category, minimum OI/volume, and sorting. Only perpetual trading assets are returned — crypto perps are excluded. **Parameters:** - `min_open_interest` (string, optional): Filter by minimum open interest in USD - `min_volume_24h` (string, optional): Filter by minimum 24h volume in USD - `category` (string, optional): Filter by asset category: stock, commodity, forex - `sort_by` (enum: ['open_interest', 'volume_24h', 'funding_rate'], optional): Sort results by this field - `sort_order` (enum: ['asc', 'desc'], optional): Sort direction **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_opportunities(sort_by=models.PerpetualTradingSortBy.VOLUME_24H, sort_order=models.PerpetualTradingSortOrder.DESC) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingOpportunities({ sortBy: "volume_24h", sortOrder: "desc", }); console.log(result); } run(); ``` #### GET /v2/perpetual_trading/positions **List perpetual trading positions** List open perpetual futures positions for a user. Returns position data including size, entry price, mark price, PnL, liquidation price, leverage, and cumulative funding. Optionally filter by asset ticker. Returns an empty list if no positions are open. **Parameters:** - `owner` (string, required): User's EOA address (looks up their perpetual trading product account) - `asset` (string, optional): Filter to a specific asset ticker (e.g. AAPL) **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_positions(owner="0x06A9aF046187895AcFc7258450B15397CAc67400") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingPositions({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/set_leverage **Set leverage (defaults to market maximum)** Check leverage and prepare an updateLeverage action to the requested value. If `leverage` is omitted, targets the asset's maximum leverage for that market. If the asset is already at the requested leverage, returns leverage_ok=true with null typed_data — no signing needed. Otherwise, returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_set_leverage(owner="", asset="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingSetLeverage({ owner: "", asset: "", }); console.log(result); } run(); ``` #### POST /v2/perpetual_trading/withdraw **Withdraw USDC from perpetual trading account** Prepare a USDC withdrawal from Hyperliquid to Arbitrum. Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. Withdrawal processing takes minutes to hours depending on bridge conditions. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.perpetual_trading.perpetual_trading_withdraw(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", amount="100.0") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.perpetualTrading.perpetualTradingWithdraw({ owner: "0x06A9aF046187895AcFc7258450B15397CAc67400", amount: "100.0", }); console.log(result); } run(); ``` -------------------------------------------------------------------------------- ### Tokenized Assets -------------------------------------------------------------------------------- #### GET /v2/tokenized_assets/balances **Get token balances** Get a Tokenized Assets Account's full token ledger. Returns every token the account has held — including zero balances from fully-exited positions and USDC funding — each with its USD value and transfer history (a superset of `/positions`). Pass `chain=base` or `chain=bsc` for Base or BNB Smart Chain holdings. **Parameters:** - `owner` (string, required): The address of the owner of the Tokenized Assets Account to read balances for. The account address is derived deterministically from this owner; balances are read from the derived account. - `chain` (enum: ['base', 'ethereum', 'arbitrum', 'hyperevm', 'tempo', 'bsc', 'robinhood', 'ethereum_sepolia'], optional): Network to read balances on (defaults to Ethereum). Equities exist on Ethereum only; RWA yield assets also exist on Base. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_balances(owner="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsBalances({ owner: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/create_account **Create account** Create a Tokenized Assets Account for a wallet address. Before trading tokenized assets, the owner must create a Tokenized Assets Account. Each wallet address has one Tokenized Assets Account per chain. Returns an unsigned transaction to create the account. The `sender` signs and broadcasts this transaction. If owner pays gas: Set `sender` to the owner's address. If someone else pays gas: Set `sender` to the wallet that will sign and broadcast the transaction on behalf of the owner. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_create_account(sender="0x18b42407AbC163f595410Ffe773BB98Db40B48F7", owner="0x18b42407AbC163f595410Ffe773BB98Db40B48F7", estimate_gas=True) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsCreateAccount({ sender: "0x18b42407AbC163f595410Ffe773BB98Db40B48F7", owner: "0x18b42407AbC163f595410Ffe773BB98Db40B48F7", }); console.log(result); } run(); ``` #### GET /v2/tokenized_assets/markets **List markets** List the tradable tokenized-asset catalog. Aggregates all four providers — Ondo (tokenized US equities), Midas (RWA yield tokens), IXS (managed vaults), and Centrifuge (deRWA wrappers) — into a single list with live USD pricing, plus APY and TVL for yield assets. Filter by provider, asset class, or chain, and narrow the results with a sector `category` or free-text `search`. **Parameters:** - `category` (string, optional): Filter markets by category (e.g. 'tech', 'finance'). - `search` (string, optional): Case-insensitive substring match against the on-chain symbol, underlying ticker, and underlying name. - `provider` (string, optional): Filter by issuer ('ondo' equities, 'midas' RWA yield). - `asset_class` (string, optional): Filter by asset class (EQUITY, T_BILLS, BASIS_TRADE, BTC_YIELD). - `chain` (string, optional): Filter by network. Equities are Ethereum-only; RWA yield assets exist on Ethereum and Base. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_markets() # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsMarkets({}); console.log(result); } run(); ``` #### GET /v2/tokenized_assets/markets/{symbol} **Get a market** Get extended detail for a single market — an Ondo equity (e.g. `TSLAon`), a Midas RWA yield token (e.g. `mTBILL`), or an IXS managed vault (e.g. `ixv1`). Adds richer market data on top of the `/markets` listing, plus an optional OHLC candle series: pass matching `interval` and `range` query params to include `candles` (available for equities, Midas tokens except `mBTC`, and IXS vaults; omit both for detail without candles). **Parameters:** - `symbol` (string, required): - `chain` (enum: ['base', 'ethereum', 'arbitrum', 'hyperevm', 'tempo', 'bsc', 'robinhood', 'ethereum_sepolia'], optional): Network the market is deployed on (defaults to Ethereum). A token deployed on multiple chains (e.g. Midas RWA on Ethereum and Base) is resolved per chain; 404 if the symbol isn't deployed there. Ondo equities are Ethereum-only. - `interval` (string, optional): Optional candle interval. Must be paired with `range` and form a valid `(interval, range)` pair to include OHLC candles in the response. - `range` (string, optional): Optional lookback window. Must be paired with `interval` and form a valid `(interval, range)` pair to include OHLC candles in the response. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_markets_symbol_(symbol="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsMarketsSymbol({ symbol: "", }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/order **Build an order** Build a tokenized-equity (Ondo) buy/sell order; the product account is the maker. Returns everything needed to place the order in one round-trip: a price quote, a one-time token approval to sign (only until the settlement contract is approved), and the order payload the owner signs off-chain. Only the approval ever touches the chain — the signed order is relayed to market makers, never broadcast. Equities only; RWA yield tokens use `/transact/buy` and `/transact/sell`. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_order(from_token="", to_token="", amount="578.28", owner="", slippage_bps=50) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrder({ fromToken: "", toToken: "", amount: "578.28", owner: "", slippageBps: 50, }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/order/submit **Submit a signed order** Submit a signed equity order to the market-maker network for settlement. Relays the payload from `/order` plus the owner's signature, and returns the order hash. Poll `GET /order/{order_hash}` to track its lifecycle (`pending` → `filled` / `expired` / `cancelled`). **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_order_submit(signed_order={ "key": "", }, signature="", extension="m2a", quote_id="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderSubmit({ signedOrder: { "key": "", }, signature: "", extension: "m2a", quoteId: "", }); console.log(result); } run(); ``` #### GET /v2/tokenized_assets/order/{order_hash} **Get order status** Poll the lifecycle state of a submitted equity order (Ondo). Reports `pending`, `filled`, `expired`, or `cancelled`, with fill details as they arrive. Equity orders only — RWA yield swaps settle in one transaction and have no lifecycle to poll. **Parameters:** - `order_hash` (string, required): **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_order_order_hash_(order_hash="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderOrderHash({ orderHash: "", }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/order/{order_hash}/cancel **Cancel an order** Cancel an unfilled equity order on-chain. Returns an EIP-712 payload the owner signs; a sponsor relays it, or the owner broadcasts it directly. Works only on `pending` or `expired` orders, and only the account that placed the order can cancel it. **Parameters:** - `order_hash` (string, required): **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_order_order_hash_cancel(order_hash="", owner="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderOrderHashCancel({ orderHash: "", tokenizedAssetsCancelOrderRequest: { owner: "", }, }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/order/{order_hash}/charge_fee **Charge a partner fee** Charge a partner fee on a filled equity sell order's USDC proceeds. Equity orders settle off-chain, so fees can't be bundled into the trade — call this after a sell fills and it builds a USDC transfer of your `fee` from the actual proceeds, executed by the product account (owner signs, or EIP-712 with `gas_sponsorship`). **Parameters:** - `order_hash` (string, required): **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_order_order_hash_charge_fee(order_hash="", owner="", fee={ "recipient": "", "amount": 8619.46, "denomination": models.TokenizedAssetsFeeDenomination.PERCENTAGE, }, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderOrderHashChargeFee({ orderHash: "", tokenizedAssetsChargeFeeRequest: { owner: "", fee: { recipient: "", amount: 8619.46, denomination: "PERCENTAGE", }, gasSponsorship: false, }, }); console.log(result); } run(); ``` #### GET /v2/tokenized_assets/positions **List positions** Get an owner's tokenized-asset holdings, priced and aggregated. Returns positions across every asset family the account holds — Ondo equities, Midas RWA yield tokens, and IXS managed vaults — each valued in USD (equities from the Ondo feed, RWA at the latest indexed NAV) with a `total_usd` total. The account is derived from `owner`; pass `chain` for Base (Midas) or BNB Smart Chain (IXS) holdings. **Parameters:** - `owner` (string, required): The address of the owner of the Tokenized Assets Account to get positions for. The account address is derived deterministically from this owner; balances are read from the derived account. - `chain` (enum: ['base', 'ethereum', 'arbitrum', 'hyperevm', 'tempo', 'bsc', 'robinhood', 'ethereum_sepolia'], optional): Network to read positions on (defaults to Ethereum). Equities exist on Ethereum only; RWA yield assets also exist on Base. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_positions(owner="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsPositions({ owner: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/quote **Quote an order** Preview a buy/sell quote for a tokenized equity (Ondo, e.g. `TSLAon`). Read-only price preview: returns the expected input/output amounts and a system-recommended slippage tolerance to carry into `/order`. Equities only — RWA yield tokens (Midas) have no quote step and are rejected with `422 Wrong trade flow`; trade them via `/transact/buy` and `/transact/sell`. **Python (SDK):** ```python from compass_api_sdk import CompassAPI with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_quote(from_token="", to_token="", amount="98.06", owner="") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsQuote({ fromToken: "", toToken: "", amount: "98.06", owner: "", }); console.log(result); } run(); ``` #### GET /v2/tokenized_assets/redemptions **List redemption requests** Get an owner's IXS managed-vault redemption requests and their status. IXS vault sells are asynchronous — `/transact/sell` files a `requestRedeem` that the vault operator settles off-chain later. This reconstructs the owner's requests live from the vault (Compass stores no async state), reporting each as `pending`, `finalized`, or `rejected`. IXS vaults live on BNB Smart Chain (`chain=bsc`, vault `ixv1`). **Parameters:** - `owner` (string, required): The owner of the Tokenized Assets Account whose IXS redemption requests to read. Requests are reconstructed on-chain from the derived product account (the request receiver). - `chain` (enum: ['base', 'ethereum', 'arbitrum', 'hyperevm', 'tempo', 'bsc', 'robinhood', 'ethereum_sepolia'], optional): Network the IXS vault lives on (IXS managed vaults are on BNB Smart Chain). - `vault` (string, optional): The IXS vault handle to read redemptions for (e.g. 'ixv1'). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_redemptions(owner="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", chain=models.V2TokenizedAssetsRedemptionsChain.BSC, vault="ixv1") # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsRedemptions({ owner: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", chain: "bsc", vault: "ixv1", }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/transact/buy **Buy an RWA yield token** Buy an RWA yield token, deposit into an IXS managed vault, or buy a Centrifuge deRWA token, with a stablecoin in one transaction. Set `token_out` to a Midas symbol (`mTBILL`, `mBASIS`, `mBTC`), a Centrifuge deRWA symbol (e.g. `deSPXA`), or an IXS vault address (its shares aren't a registered symbol). The account spends a stablecoin it already holds (fund it with a plain transfer first) and settles inside the product account — an unsigned transaction the owner signs, or EIP-712 with `gas_sponsorship`. All three settle instantly. Equities use the order flow (`/quote`, `/order`). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_transact_buy(token_in="", token_out="", amount_in=4533.23, owner="", chain=models.Chain.ETHEREUM, slippage="0.5", gas_sponsorship=False, fee={ "recipient": "", "amount": "841.37", "denomination": models.TokenizedAssetsFeeDenomination.PERCENTAGE, }) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsTransactBuy({ tokenIn: "", tokenOut: "", amountIn: 4533.23, slippage: "0.5", owner: "", chain: "ethereum", gasSponsorship: false, fee: { recipient: "", amount: "841.37", denomination: "PERCENTAGE", }, }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/transact/sell **Sell an RWA yield token** Sell an RWA yield token, redeem from an IXS managed vault, or sell a Centrifuge deRWA token, back to a stablecoin. Set `token_in` to a Midas symbol (`mTBILL`, `mBASIS`, `mBTC`), a Centrifuge deRWA symbol (e.g. `deSPXA`), or an IXS vault address. Midas redemptions and Centrifuge deRWA swaps are instant and settle in the same transaction; an IXS redemption is asynchronous — it files a `requestRedeem` (`settlement: async`) the vault operator settles off-chain later, so poll `GET /v2/tokenized_assets/redemptions` for status. The transaction executes inside the product account (owner signs, or EIP-712 with `gas_sponsorship`). **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_transact_sell(token_in="", token_out="", amount_in=8512.47, owner="", chain=models.Chain.HYPEREVM, slippage="0.5", gas_sponsorship=False, fee={ "recipient": "", "amount": 3839.45, "denomination": models.TokenizedAssetsFeeDenomination.PERCENTAGE, }) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsTransactSell({ tokenIn: "", tokenOut: "", amountIn: 8512.47, slippage: "0.5", owner: "", chain: "hyperevm", gasSponsorship: false, fee: { recipient: "", amount: 3839.45, denomination: "PERCENTAGE", }, }); console.log(result); } run(); ``` #### POST /v2/tokenized_assets/transfer **Transfer tokens to/from account** Move tokens between the owner's wallet and their Tokenized Assets Account. `DEPOSIT` funds the account from the owner's wallet; `WITHDRAW` sends tokens back. Supports gas sponsorship: with `gas_sponsorship=true` the owner signs EIP-712 typed data (a Permit2 permit on deposit, a product-account transaction on withdrawal) and a sponsor broadcasts; otherwise the owner broadcasts the transaction directly. **Python (SDK):** ```python from compass_api_sdk import CompassAPI, models with CompassAPI( api_key_auth="", ) as compass_api: res = compass_api.tokenized_assets.tokenized_assets_transfer(owner="0x9bDC45AA15FdFFc52E103EA05c260c494A5638f7", token="USDC", amount=100.0, action=models.TokenizedAssetsTransferRequestAction.DEPOSIT, chain=models.Chain.ETHEREUM, gas_sponsorship=False) # Handle response print(res) ``` **Typescript (SDK):** ```typescript import { CompassApiSDK } from "@compass-labs/api-sdk"; const compassApiSDK = new CompassApiSDK({ apiKeyAuth: "", }); async function run() { const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsTransfer({ owner: "0x9bDC45AA15FdFFc52E103EA05c260c494A5638f7", chain: "ethereum", token: "USDC", amount: 100, action: "DEPOSIT", }); console.log(result); } run(); ```