sdk

package
v0.1.64 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 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
	PerpetualTrading *PerpetualTrading
	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 market swap is performed first.

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) 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) Loop added in v0.1.46

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](https://docs.compasslabs.ai/v2/Products/Looping) for chain coverage, market discovery, vault-share collateral, HyperEVM specifics and the full error list.

func (*Credit) LoopedPositions added in v0.1.46

LoopedPositions - 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](https://docs.compasslabs.ai/v2/Products/Looping) for protocol coverage and how to read leverage, health factor and net APY.

func (*Credit) MorphoMarkets added in v0.1.46

MorphoMarkets - 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) 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) Rebalance added in v0.1.46

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](https://docs.compasslabs.ai/v2/Products/Looping) for protocol and chain coverage, capital routing and the full error list.

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

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

func (*Credit) Unloop added in v0.1.46

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](https://docs.compasslabs.ai/v2/Products/Looping) for chain coverage, vault-share collateral, shared Aave reserves and the full error list.

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 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 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 PerpetualTrading added in v0.1.51

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

func (*PerpetualTrading) Activity added in v0.1.51

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 (*PerpetualTrading) ApproveBuilderFee added in v0.1.51

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

func (*PerpetualTrading) CancelOrder added in v0.1.51

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 (*PerpetualTrading) Candles added in v0.1.51

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 (*PerpetualTrading) Deposit added in v0.1.51

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.

func (*PerpetualTrading) DepositSponsorPrepare added in v0.1.51

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 (*PerpetualTrading) EnableUnifiedAccount added in v0.1.51

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 (*PerpetualTrading) EnsureLeverage added in v0.1.51

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 (*PerpetualTrading) Execute added in v0.1.51

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 (*PerpetualTrading) LimitOrder added in v0.1.51

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

func (*PerpetualTrading) MarketOrder added in v0.1.51

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

func (*PerpetualTrading) Opportunities added in v0.1.51

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.

func (*PerpetualTrading) Positions added in v0.1.51

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.

func (*PerpetualTrading) SetLeverage added in v0.1.51

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 (*PerpetualTrading) Withdraw added in v0.1.51

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.

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

func (*TokenizedAssets) Buy added in v0.1.19

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

func (*TokenizedAssets) CreateAccount added in v0.1.19

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

func (*TokenizedAssets) Market added in v0.1.19

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

func (*TokenizedAssets) Markets added in v0.1.19

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

func (*TokenizedAssets) Order added in v0.1.19

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

func (*TokenizedAssets) OrderCancel added in v0.1.19

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

func (*TokenizedAssets) OrderChargeFee added in v0.1.30

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

func (*TokenizedAssets) OrderStatus added in v0.1.19

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

func (*TokenizedAssets) OrderSubmit added in v0.1.19

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

func (*TokenizedAssets) Positions added in v0.1.19

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.

func (*TokenizedAssets) Quote added in v0.1.19

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

func (*TokenizedAssets) Redemptions added in v0.1.33

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

func (*TokenizedAssets) Sell added in v0.1.19

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

func (*TokenizedAssets) Transfer added in v0.1.19

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.

Directories

Path Synopsis
models
sdkinternal

Jump to

Keyboard shortcuts

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