sdk

package
v0.1.37-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerList = []string{

	"https://api.compasslabs.ai",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func Pointer

func Pointer[T any](v T) *T

Pointer provides a helper function to return a pointer to a type

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type CompassCLI

type CompassCLI struct {
	SDKVersion         string
	GasSponsorship     *GasSponsorship
	Earn               *Earn
	Credit             *Credit
	GlobalMarketsPerps *GlobalMarketsPerps
	TokenizedAssets    *TokenizedAssets
	Onramp             *Onramp
	// contains filtered or unexported fields
}

CompassCLI - Compass API: Compass Labs DeFi API

func New

func New(opts ...SDKOption) *CompassCLI

New creates a new instance of the SDK with the provided options

type Credit

type Credit struct {
	// contains filtered or unexported fields
}

func (*Credit) Balances added in v0.1.10

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.

func (*Credit) Borrow added in v0.1.10

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 swap is performed first via 1inch.

The Credit Account must already be created via `/v2/credit/create_account` and funded with `token_in`.

func (*Credit) Bundle added in v0.1.10

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`.

func (*Credit) CreateAccount added in v0.1.10

CreateAccount - 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.

func (*Credit) CreditLoop added in v0.1.34

CreditLoop - Open a leveraged loop Open a leveraged loop into an Aave or Morpho market in ONE atomic transaction.

Repeatedly supplies collateral, borrows at the requested loan-to-value, and swaps the borrow back to collateral. Each iteration's supply uses the swap's GUARANTEED minimum output (enforced on-chain), so a fill anywhere within the slippage tolerance can never break a later step; any positive surplus stays in the Credit Account (the preview reports the bound as estimated_max_dust). Very large loops relative to pool depth can still exceed the slippage tolerance through their own cumulative price impact — size accordingly or raise max_slippage_percent.

The Credit Account must already hold initial_collateral_amount of collateral_token. For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets.

func (*Credit) CreditLoopedPositions added in v0.1.34

CreditLoopedPositions - List looped (leveraged) credit positions List looped (leveraged) positions for a credit account owner.

Detects loops from the account's on-chain history: a transaction containing lending + borrowing + swap legs is a loop transaction. Returns one position per Morpho market / Aave collateral+debt reserve pair, each with its complete per-transaction history, lifetime totals, and live on-chain state (health factor, USD values, leverage) for open positions. Covers Aave V3 and Morpho Blue.

func (*Credit) CreditMorphoMarkets added in v0.1.34

CreditMorphoMarkets - 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.

func (*Credit) CreditRebalance added in v0.1.37

CreditRebalance - Rebalance the leveraged credit book Rebalance the leveraged credit book in ONE atomic transaction.

List only the positions to change — anything not named is left untouched; remove a position with close=true. Each target states an end state: target_equity_usd (net USD committed) × target_multiplier.

Releasing targets run first (each unwind/delever frees tokens into the Credit Account), the freed tokens are then routed by swaps at a GUARANTEED minimum output (enforced on-chain), and consuming targets run last — so moving a levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is simply a close plus an open in the same transaction.

Net book growth is funded from the Credit Account's existing idle balance — fund it first via /v2/credit/transfer; a net release stays in the Credit Account as idle balance. Any swap surplus above the guaranteed floors also stays in the Credit Account (preview.estimated_max_dust) — recoverable, never lost.

A book already at its target returns transaction: null with the preview — the call is idempotent and safe to drive from a converge-to-target loop.

A rebalance too large for one transaction is rejected with a 422 — split it into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and every leveraging step respects the protocol's borrow limits; Aave targets share one account-level health factor, which the preview reports.

For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the current book via /v2/credit/looped_positions.

func (*Credit) CreditUnloop added in v0.1.35

CreditUnloop - Unwind a leveraged loop Unwind an Aave or Morpho loop in ONE atomic transaction.

Repeatedly withdraws collateral, swaps it to the borrow token at a GUARANTEED minimum output (enforced on-chain), and repays. The floor discipline means a swap filling anywhere within the slippage tolerance can never break a later step; any positive surplus stays in the Credit Account as borrow-token dust (the preview reports the bound as estimated_max_dust).

Omit target_multiplier for a full close: the debt is cleared exactly — accrued interest included — and the pair collateral is returned to the Credit Account. Pass 1 to clear the debt but keep the collateral supplied, or a value above 1 to delever to that multiplier (it must be below the position's current multiplier).

Each withdrawal is sized to keep the position's health factor ≥ 1.02 at that step, so a position opened very close to the liquidation threshold may need more than one transaction to fully close — set allow_partial=true to return the maximum single-transaction progress (preview.fully_unwound=false), then call unloop again to finish. Very large unwinds relative to pool depth can still exceed the slippage tolerance through their own cumulative price impact.

For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect open loops via /v2/credit/looped_positions.

func (*Credit) EulerMarkets added in v0.1.30

EulerMarkets - 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.

func (*Credit) Positions added in v0.1.10

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.

func (*Credit) Repay added in v0.1.10

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 swap is performed after withdrawal via 1inch.

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).

func (*Credit) Transfer added in v0.1.10

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`.

type Earn

type Earn struct {
	// contains filtered or unexported fields
}

func (*Earn) AaveMarkets added in v0.1.10

AaveMarkets - 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](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position) with `venue_type=AAVE`.

func (*Earn) Balances added in v0.1.10

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.

func (*Earn) Bundle added in v0.1.10

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](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction).

func (*Earn) CreateAccount added in v0.1.10

CreateAccount - 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.

func (*Earn) Manage added in v0.1.10

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](https://docs.compasslabs.ai/v2/api-reference/earn/list-vaults) for available options) - `AAVE`: Aave lending pools (see [/aave_markets](https://docs.compasslabs.ai/v2/api-reference/earn/list-aave-markets) for available options) - `PENDLE_PT`: Pendle Principal Tokens (see [/pendle_markets](https://docs.compasslabs.ai/v2/api-reference/earn/list-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](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction).

func (*Earn) PendleMarkets added in v0.1.10

PendleMarkets - 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.

func (*Earn) Positions added in v0.1.10

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.

func (*Earn) PositionsAll added in v0.1.10

PositionsAll - 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.

func (*Earn) Swap added in v0.1.10

Swap tokens within Earn Account Swap tokens within an Earn Account.

Use this endpoint to exchange one token for another without transferring funds out of the Earn Account.

The swap executes atomically within the Earn Account and can be combined with other actions using the [bundle endpoint](https://docs.compasslabs.ai/v2/api-reference/earn/execute-multiple-earn-actions). For example, swap ETH to USDC, then deposit USDC into a vault—all in one transaction.

Returns either an unsigned transaction (when `gas_sponsorship=false`) or EIP-712 typed data for off-chain signing (when `gas_sponsorship=true`). For gas-sponsored swaps, submit the signed typed data to `/gas_sponsorship/prepare`.

func (*Earn) SwapQuote added in v0.1.30

SwapQuote - Quote a swap (read-only) 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`, routed via 1inch. 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.

func (*Earn) Transfer added in v0.1.10

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](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) to get EIP-712 typed data 2. Owner signs the typed data 3. Submit signature + typed data to [/gas_sponsorship/prepare](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)

**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](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction)

**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](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position).

func (*Earn) Vaults added in v0.1.10

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](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position) with `venue_type=VAULTS`.

type GasSponsorship

type GasSponsorship struct {
	// contains filtered or unexported fields
}

func (*GasSponsorship) ApproveTransfer added in v0.1.10

ApproveTransfer - Approve token transfer Set up a one-time Permit2 allowance for gas-sponsored token transfers.

Required when using [/earn/transfer](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account) 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](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/prepare-gas-sponsored-transaction) - 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.

func (*GasSponsorship) Prepare added in v0.1.10

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](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account), [/earn/manage](https://docs.compasslabs.ai/v2/api-reference/earn/manage-earn-position), [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account)) 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](https://docs.compasslabs.ai/v2/api-reference/earn/transfer-tokens-tofrom-account) or [/credit/transfer](https://docs.compasslabs.ai/v2/api-reference/credit/transfer-tokens-tofrom-account), the owner must first set up a Permit2 allowance using [/approve_transfer](https://docs.compasslabs.ai/v2/api-reference/gas-sponsorship/approve-token-transfer) (once per token).

type GlobalMarketsPerps added in v0.1.1

type GlobalMarketsPerps struct {
	// contains filtered or unexported fields
}

func (*GlobalMarketsPerps) Activity added in v0.1.10

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).

func (*GlobalMarketsPerps) ApproveBuilderFee added in v0.1.10

ApproveBuilderFee - Approve builder fee Prepare builder fee approval for the global markets perps 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.

func (*GlobalMarketsPerps) CancelOrder added in v0.1.10

CancelOrder - 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.

func (*GlobalMarketsPerps) Candles added in v0.1.10

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).

func (*GlobalMarketsPerps) Deposit added in v0.1.10

Deposit USDC to global markets perps 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/Global-Markets.mdx "Deposit USDC" section for the bridge-broadcast code.

func (*GlobalMarketsPerps) DepositSponsorPrepare added in v0.1.10

DepositSponsorPrepare - 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.

func (*GlobalMarketsPerps) EnableUnifiedAccount added in v0.1.10

EnableUnifiedAccount - 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.

func (*GlobalMarketsPerps) EnsureLeverage added in v0.1.10

EnsureLeverage - 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.

func (*GlobalMarketsPerps) Execute added in v0.1.10

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.

func (*GlobalMarketsPerps) LimitOrder added in v0.1.10

LimitOrder - Place limit order Prepare a limit order on a global markets perps 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.

func (*GlobalMarketsPerps) MarketOrder added in v0.1.10

MarketOrder - Place market order Prepare a market order on a global markets perps 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.

func (*GlobalMarketsPerps) Opportunities added in v0.1.10

Opportunities - List global markets perps markets List available global markets perps 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 global markets perps assets are returned — crypto perps are excluded.

func (*GlobalMarketsPerps) Positions added in v0.1.10

Positions - List global markets perps 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.

func (*GlobalMarketsPerps) SetLeverage added in v0.1.30

SetLeverage - 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.

func (*GlobalMarketsPerps) Withdraw added in v0.1.10

Withdraw USDC from global markets perps 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.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for supplying the SDK with a custom HTTP client

type Onramp added in v0.1.26

type Onramp struct {
	// contains filtered or unexported fields
}

func (*Onramp) Create added in v0.1.26

Create a fiat on-ramp payment + get the checkout link Create a fiat on-ramp payment and return the browser-checkout handoff.

A fiat card + identity-verification flow can only render in a browser, so this endpoint returns a **`checkout_url`** (a Compass-hosted page) together with `payment_id`, the one-time-wallet `deposit_address`, an initial `status`, and a `user_instructions` string.

**How to drive this (CLI / MCP agent / UI):**

  1. **Present `checkout_url` to the user and open it in a browser.** It renders the card payment + identity verification and delivers USDC on Ethereum to the destination wallet. (An MCP agent cannot open a browser itself — show the link and ask the user to open it.)
  2. **Poll `GET /v2/onramp/status?payment_id=...`** until `status` becomes `delivered` (or `failed`). `pending` = awaiting payment, `processing` = payment received and bridging/swapping to USDC.
  3. Once `delivered`, the USDC is in the user's own wallet — continue with the tokenized buy.

Funds are never held by Compass: the `deposit_address` is a one-time wallet owned solely by the user's wallet.

func (*Onramp) Quote added in v0.1.26

Quote - Get a fiat on-ramp quote (card -> USDC on Ethereum) Get an indicative quote for buying USDC on Ethereum with a card.

Returns the estimated USDC the user will receive for a given fiat amount, the exchange rate, fee breakdown (`business_fees` is `0`), and the provider min/max limits. The output is always **USDC on Ethereum** delivered to the `destination_address` — this is a non-custodial on-ramp, so Compass never holds the funds.

This quote is indicative and may expire (`expires_at`). To actually start a payment, call `POST /v2/onramp/create`.

func (*Onramp) Status added in v0.1.26

Status - Get the status of a fiat on-ramp payment Get the current status of a fiat on-ramp payment.

Poll this after `create` until `status` is `delivered`. The `status` field is one of:

  • `pending` — awaiting the card payment in the hosted checkout.
  • `processing` — payment received; bridging/swapping the proceeds to USDC.
  • `delivered` — USDC has been delivered to the destination wallet (`delivery_tx_hash` and `output_amount_delivered` are populated).
  • `failed` — the payment failed, expired, or was refunded.

State is re-read live from the on-ramp provider on every call — Compass stores nothing of its own.

type SDKOption

type SDKOption func(*CompassCLI)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithRetryConfig

func WithRetryConfig(retryConfig retry.Config) SDKOption

func WithSecurity

func WithSecurity(security components.Security) SDKOption

WithSecurity configures the SDK to use the provided security details

func WithSecuritySource

func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

func WithServerIndex

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows providing an alternative server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

func WithTimeout

func WithTimeout(timeout time.Duration) SDKOption

WithTimeout Optional request timeout applied to each operation

type TokenizedAssets

type TokenizedAssets struct {
	// contains filtered or unexported fields
}

func (*TokenizedAssets) Balances added in v0.1.30

Balances - Get account balances Get the token balances of a Tokenized Assets Account.

Returns each token held in the account with its current balance, USD value, and transfer history. Pass `chain=base` for Base holdings.

func (*TokenizedAssets) Buy added in v0.1.19

Buy an RWA yield token (Midas: mTBILL/mBASIS/mBTC) Buy (mint) an RWA yield asset (e.g. `mTBILL`) inside the product account.

Mints `token_out` directly from Midas with `token_in` (a stablecoin already held by the Tokenized Assets Account — fund it with a plain transfer first). `token_in` must be a payment token the Midas issuance vault accepts (USDC on every supported network; mBASIS also accepts USDT/DAI on Ethereum). Returns an unsigned transaction for the owner to sign, or an EIP-712 payload when `gas_sponsorship` is true.

`token_out` must be a Midas RWA asset; equities trade via the order endpoints (`/quote`, `/order`, `/order/submit`).

func (*TokenizedAssets) CreateAccount added in v0.1.19

CreateAccount - Create a Tokenized Assets Account Create a Tokenized Assets Account for a wallet address.

Required once before **either** trade flow — tokenized-equity orders (Ondo, via `/quote` + `/order`) and RWA-yield-token swaps (Midas, via `/transact/buy` + `/transact/sell`) both settle into this one account.

Each wallet address has one Tokenized Assets Account, isolated from the owner's Earn, Credit, and other product accounts.

The account address is deterministic. If it already exists, the response returns `transaction: null` and you can skip straight to building orders.

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.

func (*TokenizedAssets) Market added in v0.1.19

Market - Get a single market Get extended detail for a single tokenized market.

Works for both asset families: an Ondo **equity** (e.g. `TSLAon`) or a Midas **RWA yield token** (e.g. `mTBILL`). Equities add 52-week range, volume, market cap, holder count, and tradable sessions on top of the `/markets` fields; RWA-yield entries instead carry `apy_7d`/`apy_30d` and `tvl_usd`.

**OHLC candles are an equities-only feature** — opt in by passing both `interval` and `range` query params to include a `candles` array. They must be provided together and must form one of the supported pairs:

- `1min` / `5min` / `15min` with `range=1day` - `1hour` / `4hour` with `range=1month` - `12hour` with `range=3month` - `1day` with `range=3month` / `6month` / `1year` / `all`

Omitting both returns the market detail without `candles`.

func (*TokenizedAssets) Markets added in v0.1.19

Markets - List tokenized asset markets List tokenized asset markets: Ondo equities and Midas RWA yield tokens.

Each entry carries `provider` (`ondo` | `midas`), `asset_class` (`EQUITY` | `T_BILLS` | `BASIS_TRADE` | `BTC_YIELD`), `chain`, the symbol, underlying ticker, contract address, latest USD price, and 24h change; RWA-yield entries add `apy_7d`/`apy_30d` and `tvl_usd`. Filter with `provider`, `asset_class`, and `chain`, plus `category` (sector tag — equities only) or `search` (substring match against symbol, ticker, or name).

Equities are Ethereum-only; RWA yield tokens also list on Base — pass `chain=base` to see them. How to trade each: `asset_class=EQUITY` → `/quote` + `/order`; the RWA classes → `/transact/buy` + `/transact/sell`.

func (*TokenizedAssets) Order added in v0.1.19

Order - Build a tokenized-equity buy/sell order (Ondo) Build a tokenized-**equity** (Ondo) buy/sell order; maker is the product account.

**Equities only.** RWA yield tokens (Midas — `mTBILL`, `mBASIS`, `mBTC`) are rejected with 422 `Wrong trade flow`; trade them via `/transact/buy` & `/transact/sell`. Equity orders are always USDC-paired (USDC→equity to buy, equity→USDC to sell) and settle on-chain.

Returns up to three pieces in a single round-trip:

  • **`quote`** — preview of the input/output amounts and fees.
  • **`approval_safe_tx_eip712`** — only present when the account's allowance to the settlement contract is below `amount`. The owner signs this EIP-712 payload, then it is broadcast via `POST /v2/gas_sponsorship/prepare` (or the owner can broadcast directly) to set the on-chain allowance. Wait for that transaction to confirm before signing the order.
  • **`order`** — the order metadata (`order_hash`, `extension`, `quote_id`, `order_message`) plus `safe_message_eip712`, an EIP-712 payload the owner signs off-chain to authorize the order. The signature is submitted to `/order/submit` and is **never** broadcast on-chain.

The owner never broadcasts the order itself — only the (one-time) approval transaction ever hits the chain.

func (*TokenizedAssets) OrderCancel added in v0.1.19

OrderCancel - Cancel an unfilled tokenized-equity order (Ondo) Build the EIP-712 payload to cancel an unfilled order on-chain.

Returns “cancel_safe_tx_eip712“, an EIP-712 payload that authorizes the on-chain cancellation. Sign with the Tokenized Assets Account's owner via “wallet.signTypedData(...)“ and relay via “POST /v2/gas_sponsorship/prepare“ so the sponsor broadcasts the cancellation on the product account. The owner can also broadcast the resulting transaction directly without using gas sponsorship.

Cancellation works on `pending` and `expired` orders only. Only the Tokenized Assets Account that placed the order can cancel it.

func (*TokenizedAssets) OrderChargeFee added in v0.1.30

OrderChargeFee - Charge a partner fee on a filled sell order's USDC proceeds Build a USDC fee transfer on a filled equity sell order's proceeds.

Equity orders fill off-chain via a third-party venue, so the fee can't be bundled into the trade. Once the sell order has filled, call this with the order hash and your `fee` (recipient + percentage/fixed); it reads the actual filled USDC proceeds and returns a `transfer(recipient, fee)` executed by the product account — an unsigned transaction the owner signs, or an EIP-712 payload when `gas_sponsorship` is true.

func (*TokenizedAssets) OrderStatus added in v0.1.19

OrderStatus - Get tokenized-equity order status (Ondo) Get the lifecycle state of a submitted tokenized-**equity** order (Ondo).

Equity-order flow only: RWA-yield trades (`/transact/buy`, `/transact/sell`) are plain swaps that settle in a single transaction and have no order lifecycle to poll.

The `status` field is one of `pending`, `filled`, `expired`, or `cancelled`. Partial fills stay in `pending` while `filled_amount` is populated as fills come in; once an order fully fills, `fill_tx_hash` is also returned.

Upstream protocol states beyond these four (e.g. `partially-filled`, `refunded`) are mapped onto this set.

func (*TokenizedAssets) OrderSubmit added in v0.1.19

OrderSubmit - Submit a signed tokenized-equity order (Ondo) Submit a signed order for settlement.

The body echoes the `order` fields from `/order` (`signed_order`, `extension`, `quote_id`, optionally `order_hash`) plus the owner's signature over `order.safe_message_eip712`. The maker on the order struct is the Tokenized Assets Account, not the owner's wallet — pass `signed_order` back unchanged.

Returns the order hash and a server-side ISO 8601 timestamp. Subsequent calls to `GET /order/{order_hash}` track the lifecycle (`pending` → `filled` / `expired` / `cancelled`).

func (*TokenizedAssets) Positions added in v0.1.19

Positions - Get tokenized-asset positions for an owner Get the tokenized-asset holdings for an owner.

Covers **both** asset families held in the account — Ondo equities and Midas RWA yield tokens (`mTBILL`, `mBASIS`, `mBTC`). The Tokenized Assets Account address is derived deterministically from the `owner` query param; balances are read from that account (proceeds from equity orders and RWA swaps both settle there). Equity positions are priced from the Ondo feed; RWA positions are valued at the latest indexed NAV. Pass `chain=base` for Base holdings (equities are Ethereum-only). Zero balances are omitted, and a `total_usd` aggregate is returned across all priced positions.

Returns 400 `ACCOUNT_NOT_DEPLOYED` if the owner has no Tokenized Assets Account deployed yet — create one via `/create_account` first.

func (*TokenizedAssets) Quote added in v0.1.19

Quote - Preview a tokenized-equity buy/sell quote (Ondo) Preview a buy/sell quote for a tokenized **equity** (Ondo, e.g. `TSLAon`).

**Equities only.** RWA yield tokens (Midas — `mTBILL`, `mBASIS`, `mBTC`) are rejected here with 422 `Wrong trade flow`; they have no auction/quote step — buy/sell them directly via `/transact/buy` & `/transact/sell`.

Returns the input/output amounts, fees, and slippage tolerance for an order.

Read-only: previews the quote without consuming a “quote_id“ or committing an order. Pair with `POST /order`: surface this preview to the user, and on confirm pass the body plus “recommended_slippage_bps“ to `/order`.

The response carries:

  • **`quote`** — input/output token amounts, fees, and an “est_fill_seconds“ upper bound.
  • **`recommended_slippage_bps`** — system-derived slippage tolerance that clears the current auction floor; pass back as “slippage_bps“ on `/order` so the build call validates against the same floor the user was shown.
  • **`auction_range_bps`** — worst-case bps gap between the auction end amount and the reference quote amount. Use to surface a thin-liquidity warning to the user.

func (*TokenizedAssets) Redemptions added in v0.1.33

Redemptions - Get IXS vault redemption requests for an owner Get an owner's IXS vault redemption requests (async redemption status).

IXS managed-vault **sells** are asynchronous: `/transact/sell` returns a `requestRedeem` transaction, and the vault operator settles it off-chain later. This endpoint reconstructs the owner's requests directly from the vault on every call (Compass persists no async state) — each entry carries its `status` (`pending` | `finalized` | `rejected`), the `shares` requested, and, while `pending`, the `expected_net_assets` it would settle for at the current NAV (a preview, not a guarantee).

IXS vaults live on BNB Smart Chain — pass `chain=bsc` (the default) and the `vault` handle (default `ixv1`).

func (*TokenizedAssets) Sell added in v0.1.19

Sell an RWA yield token (Midas: mTBILL/mBASIS/mBTC) Sell (redeem) an RWA yield asset (e.g. `mTBILL`) inside the product account.

Redeems `token_in` (a Midas RWA asset held by the Tokenized Assets Account) directly with Midas into `token_out` (USDC). Returns an unsigned transaction for the owner to sign, or an EIP-712 payload when `gas_sponsorship` is true.

Instant redemption draws on Midas's on-chain liquidity and is subject to a small redemption fee and daily limit.

func (*TokenizedAssets) Transfer added in v0.1.19

Transfer - Deposit to / withdraw from a Tokenized Assets Account Move tokens between the owner's wallet and their Tokenized Assets Account.

Use `DEPOSIT` to fund the account from the owner's wallet, or `WITHDRAW` to send tokens from the account back to the owner. Equity orders settle in USDC; RWA yield assets trade against USDC on Ethereum and Base.

With `gas_sponsorship=true` the response is EIP-712 typed data the owner signs off-chain, then submits to `POST /v2/gas_sponsorship/prepare` so the sponsor broadcasts and pays the gas:

  • **DEPOSIT** returns a Permit2 `PermitTransferFrom`. The owner must first grant a one-time token->Permit2 allowance (gaslessly via `POST /v2/gas_sponsorship/approve_transfer`).
  • **WITHDRAW** returns a Safe transaction the account executes.

With `gas_sponsorship=false` a DEPOSIT returns an unsigned ERC-20 transfer the owner broadcasts directly, and a WITHDRAW returns an unsigned Safe `execTransaction` the owner signs and broadcasts.

Directories

Path Synopsis
models
sdkinternal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL