sdk

package
v0.1.67 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 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
	RiskYield        *RiskYield
	// 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 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 RiskYield added in v0.1.67

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

func (*RiskYield) RiskYieldCollect added in v0.1.67

RiskYieldCollect - Collect fees Sweep the fees a position has earned into your account.

func (*RiskYield) RiskYieldCreateAccount added in v0.1.67

RiskYieldCreateAccount - Create account Create the Risk Yield Account that will hold your LP positions.

Liquidity is provided from an account, not from your wallet, so this comes first. The address is deterministic from the `owner`, and it is the **same account as your Earn Account** on this chain — if you already have one, this returns it with `transaction: null` and nothing needs to be signed.

**If the owner pays gas:** set `sender` to the owner's address.

**If someone else pays:** set `sender` to whoever will broadcast.

func (*RiskYield) RiskYieldDecrease added in v0.1.67

RiskYieldDecrease - Withdraw from a position Take liquidity back out of a position.

The collect is bundled in by default and should stay that way: `decreaseLiquidity` only *credits* the tokens to the position, it does not move them. Without the collect the position looks emptied while the funds sit in the position manager.

func (*RiskYield) RiskYieldIncrease added in v0.1.67

RiskYieldIncrease - Add to a position Add liquidity to a position you already hold, over its existing range.

func (*RiskYield) RiskYieldMint added in v0.1.67

RiskYieldMint - Open a position Provide liquidity to a pool over a price range.

The range you ask for is not quite the range you get: ticks are discrete, so a 30% band becomes the usable ticks that bracket it — snapped outward, never inward, because a position that stops earning sooner than you expected is the worse surprise. The `range` in the response is what will actually be opened.

A range also fixes the proportion of the two assets, so a deposit rarely uses all of both. What does not fit is reported as `leftover` and stays in your account rather than being quietly swept.

Set `preview` to see the plan and its simulation without building anything.

func (*RiskYield) RiskYieldPools added in v0.1.67

RiskYieldPools - List pools Pools you could provide liquidity to, ranked by what you would keep.

**Read `lp_earns_fees` first.** The launchpad that dominates this chain graduates tokens into pools whose hook takes the swap fee, so they trade enormously and pay an external liquidity provider nothing. Those pools are listed — they carry the memecoin's price and volume — with a fee APR of exactly zero and a note saying why. Pass `lp_earns_fees=true` to hide them.

The default ordering is `il_adjusted_apr_7d`: the fee APR less the expected impermanent-loss drag from the pair's own volatility. A pool paying 200% on an asset that moves 400% is not a better position than one paying 20% on an asset that moves 30%, and sorting on the raw APR would say it was.

Pools too thin for a rate to mean anything — under 20 swaps a day, or under $1,000 of liquidity — are served with `ranked: false` and always sort last.

func (*RiskYield) RiskYieldPoolsPoolID added in v0.1.67

RiskYieldPoolsPoolID - Get pool detail One pool, with its price history and the caveats that apply to it.

For a pool holding a tokenized stock, `stock_reference` compares the pool's price against the stock's own. They drift: the pool trades around the clock while the stock trades in a session, and that gap is what a liquidity provider is quoting against overnight.

func (*RiskYield) RiskYieldPositions added in v0.1.67

RiskYieldPositions - List LP positions Your liquidity positions: what they hold, what they cost, what they paid.

Only the first of those is on chain. A position reports its liquidity and its range; it does not report the amounts that opened it or what has already been collected. Those come from recorded events, and where there are none `cost_basis.source` is `unavailable` and the PnL fields are null rather than guessed — an invented cost basis would make every number derived from it wrong in the same direction.

`hold_value_usd` is what the deposited amounts would be worth if they had simply been held. The gap between that and `value_usd` is impermanent loss, and it is the number that decides whether the fees were worth it.

`needs_rebalance` and `rebalance_reasons` say what the API would look at, not what it will do: rebalancing realizes the loss, pays gas twice and a swap, and puts the position back at risk from a new price.

func (*RiskYield) RiskYieldRebalance added in v0.1.67

RiskYieldRebalance - Rebalance a position Move a position to a new range, in one transaction.

**`NOOP` is a real answer and often the right one.** Rebalancing realizes the impermanent loss the position has taken so far, pays gas twice and a swap, and puts the position back at risk from a new price. If the position is already centred at the requested width, that is what you will get.

When there is something to do, the transaction unwinds the old position, sweeps it together with the fees, opens the new range and burns the empty NFT. Every leg is sized from the **floor** the previous one guarantees rather than from its quote — they execute in the same transaction, and a mint sized from a quote reverts when the decrease comes back a wei short, leaving the owner having paid gas to dismantle a position. `estimated_dust` is what that safety costs.

The default `vol_scaled` strategy sizes the new range from the pair's own measured volatility: two standard deviations over the horizon. A range narrower than the asset's ordinary movement spends most of its life out of range earning nothing, which is the most common way to lose money doing this on purpose.

func (*RiskYield) RiskYieldRiskScenarios added in v0.1.67

RiskYieldRiskScenarios - Model impermanent loss What this position would do if the price moved — and how likely that is.

A fee APR on a memecoin pair means nothing without the loss it is paid against, which is what this measures.

Each scenario takes **two** independent moves, and keeping them apart is the point. `ratio_move_pct` is how far the pair's ratio travels, and that is what causes impermanent loss. `quote_usd_move_pct` is how far the stock moves in dollars, which scales what the position is worth without touching the ratio at all — a stock-only move produces an impermanent loss of exactly zero. "NVDA drops 10%" and "the memecoin drops 10% against NVDA" are different questions, and one number cannot ask both.

The two most useful columns are `breakeven_fee_apr_pct` — what this position would have to earn for the loss to be worth taking, which you can compare against the pool's actual fee APR — and `days_of_fees_to_recover_il`, which is null when the pool pays liquidity providers nothing, because no amount of time fixes that.

`probabilistic` runs the pair's own measured volatility through a driftless simulation. Driftless deliberately: nobody knows which way a memecoin goes, and a model that assumed one would be predicting returns rather than measuring risk. It is absent when the pair has no measured volatility — which a pool with a few hours of history does not — because a distribution built on zero would report that nothing can happen.

func (*RiskYield) RiskYieldSwap added in v0.1.67

RiskYieldSwap - Swap tokens Trade one token for another from inside your Risk Yield Account.

Mostly used to reach the ratio a range needs before opening a position: a range fixes the proportion of the two assets, and a caller holding one of them has to swap to it.

There is no aggregator on this chain, so the route is a Uniswap v3 pool. The API quotes every enabled fee tier and takes whichever returns the most — a 1% pool with depth beats a 0.05% pool with none, which here is the common case rather than the corner one.

The transaction is simulated before it is returned. A failing simulation is a 422 rather than something to sign: on this chain a token may tax transfers, block an address or be paused, and none of that is visible until the call is actually made.

func (*RiskYield) RiskYieldTokens added in v0.1.67

RiskYieldTokens - List tokens The assets that trade on Robinhood Chain.

Tokenized stocks carry their issuer metadata, including the corporate-action multiplier — balances do not rebase on a split, so a quote for the underlying only becomes a token price once that is applied.

Memecoins carry the launch they came from. Every price carries the source it was resolved from and a confidence: below 0.6 it came from a pool shallow enough that one trade moves it, and every dollar figure derived from it is indicative.

func (*RiskYield) RiskYieldTransfer added in v0.1.67

RiskYieldTransfer - Transfer tokens to/from account Move tokens between your wallet and your Risk Yield Account.

`DEPOSIT` pulls from the owner's wallet into the account; `WITHDRAW` sends them back. Native ETH is supported, which matters here because many pools on this chain are quoted in it.

The account is shared with Earn, so a deposit made through either product is available to both.

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