Documentation
¶
Index ¶
- Variables
- func Bool(b bool) *bool
- func Float32(f float32) *float32
- func Float64(f float64) *float64
- func Int(i int) *int
- func Int64(i int64) *int64
- func Pointer[T any](v T) *T
- func String(s string) *string
- type CompassCLI
- type Credit
- func (s *Credit) CreditBalances(ctx context.Context, request operations.V2CreditBalancesRequest, ...) (*operations.V2CreditBalancesResponse, error)
- func (s *Credit) CreditBorrow(ctx context.Context, request components.CreditBorrowRequest, ...) (*operations.V2CreditBorrowResponse, error)
- func (s *Credit) CreditBundle(ctx context.Context, request components.CreditBundleRequest, ...) (*operations.V2CreditBundleResponse, error)
- func (s *Credit) CreditCreateAccount(ctx context.Context, request components.CreateCreditAccountRequest, ...) (*operations.V2CreditCreateAccountResponse, error)
- func (s *Credit) CreditPositions(ctx context.Context, request operations.V2CreditPositionsRequest, ...) (*operations.V2CreditPositionsResponse, error)
- func (s *Credit) CreditRepay(ctx context.Context, request components.CreditRepayRequest, ...) (*operations.V2CreditRepayResponse, error)
- func (s *Credit) CreditTransfer(ctx context.Context, request components.CreditTransferRequest, ...) (*operations.V2CreditTransferResponse, error)
- type Earn
- func (s *Earn) EarnAaveMarkets(ctx context.Context, request *operations.V2EarnAaveMarketsRequest, ...) (*operations.V2EarnAaveMarketsResponse, error)
- func (s *Earn) EarnBalances(ctx context.Context, request operations.V2EarnBalancesRequest, ...) (*operations.V2EarnBalancesResponse, error)
- func (s *Earn) EarnBundle(ctx context.Context, request components.V2BundleRequest, ...) (*operations.V2EarnBundleResponse, error)
- func (s *Earn) EarnCreateAccount(ctx context.Context, request components.CreateAccountRequest, ...) (*operations.V2EarnCreateAccountResponse, error)
- func (s *Earn) EarnManage(ctx context.Context, request components.EarnManageRequest, ...) (*operations.V2EarnManageResponse, error)
- func (s *Earn) EarnPendleMarkets(ctx context.Context, request operations.V2EarnPendleMarketsRequest, ...) (*operations.V2EarnPendleMarketsResponse, error)
- func (s *Earn) EarnPositions(ctx context.Context, request operations.V2EarnPositionsRequest, ...) (*operations.V2EarnPositionsResponse, error)
- func (s *Earn) EarnPositionsAll(ctx context.Context, request operations.V2EarnPositionsAllRequest, ...) (*operations.V2EarnPositionsAllResponse, error)
- func (s *Earn) EarnSwap(ctx context.Context, request components.EarnSwapRequest, ...) (*operations.V2EarnSwapResponse, error)
- func (s *Earn) EarnTransfer(ctx context.Context, request components.EarnTransferRequest, ...) (*operations.V2EarnTransferResponse, error)
- func (s *Earn) EarnVaults(ctx context.Context, request operations.V2EarnVaultsRequest, ...) (*operations.V2EarnVaultsResponse, error)
- type GasSponsorship
- func (s *GasSponsorship) GasSponsorshipApproveTransfer(ctx context.Context, request components.ApproveTransferRequest, ...) (*operations.V2GasSponsorshipApproveTransferResponse, error)
- func (s *GasSponsorship) GasSponsorshipPrepare(ctx context.Context, request components.SponsorGasRequest, ...) (*operations.V2GasSponsorshipPrepareResponse, error)
- type GlobalMarketsPerps
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsActivity(ctx context.Context, request operations.V2GlobalMarketsPerpsActivityRequest, ...) (*operations.V2GlobalMarketsPerpsActivityResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsApproveBuilderFee(ctx context.Context, ...) (*operations.V2GlobalMarketsPerpsApproveBuilderFeeResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsCancelOrder(ctx context.Context, request components.GlobalMarketsPerpsCancelOrderRequest, ...) (*operations.V2GlobalMarketsPerpsCancelOrderResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsDeposit(ctx context.Context, request components.GlobalMarketsPerpsDepositRequest, ...) (*operations.V2GlobalMarketsPerpsDepositResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsEnableUnifiedAccount(ctx context.Context, ...) (*operations.V2GlobalMarketsPerpsEnableUnifiedAccountResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsEnsureLeverage(ctx context.Context, ...) (*operations.V2GlobalMarketsPerpsEnsureLeverageResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsExecute(ctx context.Context, request components.GlobalMarketsPerpsExecuteRequest, ...) (*operations.V2GlobalMarketsPerpsExecuteResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsLimitOrder(ctx context.Context, request components.GlobalMarketsPerpsLimitOrderRequest, ...) (*operations.V2GlobalMarketsPerpsLimitOrderResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsMarketOrder(ctx context.Context, request components.GlobalMarketsPerpsMarketOrderRequest, ...) (*operations.V2GlobalMarketsPerpsMarketOrderResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsOpportunities(ctx context.Context, ...) (*operations.V2GlobalMarketsPerpsOpportunitiesResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsPositions(ctx context.Context, request operations.V2GlobalMarketsPerpsPositionsRequest, ...) (*operations.V2GlobalMarketsPerpsPositionsResponse, error)
- func (s *GlobalMarketsPerps) GlobalMarketsPerpsWithdraw(ctx context.Context, request components.GlobalMarketsPerpsWithdrawRequest, ...) (*operations.V2GlobalMarketsPerpsWithdrawResponse, error)
- type HTTPClient
- type SDKOption
- func WithClient(client HTTPClient) SDKOption
- func WithRetryConfig(retryConfig retry.Config) SDKOption
- func WithSecurity(security components.Security) SDKOption
- func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption
- func WithServerIndex(serverIndex int) SDKOption
- func WithServerURL(serverURL string) SDKOption
- func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption
- func WithTimeout(timeout time.Duration) SDKOption
- type TokenizedAssets
- func (s *TokenizedAssets) TokenizedAssetsCreateAccount(ctx context.Context, request components.CreateTokenizedAssetsAccountRequest, ...) (*operations.V2TokenizedAssetsCreateAccountResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsMarkets(ctx context.Context, request *operations.V2TokenizedAssetsMarketsRequest, ...) (*operations.V2TokenizedAssetsMarketsResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsMarketsSymbol(ctx context.Context, request operations.V2TokenizedAssetsMarketsSymbolRequest, ...) (*operations.V2TokenizedAssetsMarketsSymbolResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsOrder(ctx context.Context, request components.TokenizedAssetsBuildOrderRequest, ...) (*operations.V2TokenizedAssetsOrderResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsOrderOrderHash(ctx context.Context, request operations.V2TokenizedAssetsOrderOrderHashRequest, ...) (*operations.V2TokenizedAssetsOrderOrderHashResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsOrderOrderHashCancel(ctx context.Context, ...) (*operations.V2TokenizedAssetsOrderOrderHashCancelResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsOrderSubmit(ctx context.Context, request components.TokenizedAssetsSubmitOrderRequest, ...) (*operations.V2TokenizedAssetsOrderSubmitResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsPositions(ctx context.Context, request operations.V2TokenizedAssetsPositionsRequest, ...) (*operations.V2TokenizedAssetsPositionsResponse, error)
- func (s *TokenizedAssets) TokenizedAssetsQuote(ctx context.Context, request components.TokenizedAssetsQuoteRequest, ...) (*operations.V2TokenizedAssetsQuoteResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ServerList = []string{
"https://api.compasslabs.ai",
}
ServerList contains the list of servers available to the SDK
Functions ¶
Types ¶
type CompassCLI ¶
type CompassCLI struct {
SDKVersion string
GasSponsorship *GasSponsorship
Earn *Earn
Credit *Credit
GlobalMarketsPerps *GlobalMarketsPerps
TokenizedAssets *TokenizedAssets
// 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) CreditBalances ¶
func (s *Credit) CreditBalances(ctx context.Context, request operations.V2CreditBalancesRequest, opts ...operations.Option) (*operations.V2CreditBalancesResponse, error)
CreditBalances - 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) CreditBorrow ¶
func (s *Credit) CreditBorrow(ctx context.Context, request components.CreditBorrowRequest, opts ...operations.Option) (*operations.V2CreditBorrowResponse, error)
CreditBorrow - 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) CreditBundle ¶
func (s *Credit) CreditBundle(ctx context.Context, request components.CreditBundleRequest, opts ...operations.Option) (*operations.V2CreditBundleResponse, error)
CreditBundle - 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) CreditCreateAccount ¶
func (s *Credit) CreditCreateAccount(ctx context.Context, request components.CreateCreditAccountRequest, opts ...operations.Option) (*operations.V2CreditCreateAccountResponse, error)
CreditCreateAccount - 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) CreditPositions ¶
func (s *Credit) CreditPositions(ctx context.Context, request operations.V2CreditPositionsRequest, opts ...operations.Option) (*operations.V2CreditPositionsResponse, error)
CreditPositions - 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) CreditRepay ¶
func (s *Credit) CreditRepay(ctx context.Context, request components.CreditRepayRequest, opts ...operations.Option) (*operations.V2CreditRepayResponse, error)
CreditRepay - 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) CreditTransfer ¶
func (s *Credit) CreditTransfer(ctx context.Context, request components.CreditTransferRequest, opts ...operations.Option) (*operations.V2CreditTransferResponse, error)
CreditTransfer - 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) EarnAaveMarkets ¶
func (s *Earn) EarnAaveMarkets(ctx context.Context, request *operations.V2EarnAaveMarketsRequest, opts ...operations.Option) (*operations.V2EarnAaveMarketsResponse, error)
EarnAaveMarkets - 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) EarnBalances ¶
func (s *Earn) EarnBalances(ctx context.Context, request operations.V2EarnBalancesRequest, opts ...operations.Option) (*operations.V2EarnBalancesResponse, error)
EarnBalances - 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) EarnBundle ¶
func (s *Earn) EarnBundle(ctx context.Context, request components.V2BundleRequest, opts ...operations.Option) (*operations.V2EarnBundleResponse, error)
EarnBundle - 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) EarnCreateAccount ¶
func (s *Earn) EarnCreateAccount(ctx context.Context, request components.CreateAccountRequest, opts ...operations.Option) (*operations.V2EarnCreateAccountResponse, error)
EarnCreateAccount - 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) EarnManage ¶
func (s *Earn) EarnManage(ctx context.Context, request components.EarnManageRequest, opts ...operations.Option) (*operations.V2EarnManageResponse, error)
EarnManage - 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) EarnPendleMarkets ¶
func (s *Earn) EarnPendleMarkets(ctx context.Context, request operations.V2EarnPendleMarketsRequest, opts ...operations.Option) (*operations.V2EarnPendleMarketsResponse, error)
EarnPendleMarkets - 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) EarnPositions ¶
func (s *Earn) EarnPositions(ctx context.Context, request operations.V2EarnPositionsRequest, opts ...operations.Option) (*operations.V2EarnPositionsResponse, error)
EarnPositions - 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) EarnPositionsAll ¶
func (s *Earn) EarnPositionsAll(ctx context.Context, request operations.V2EarnPositionsAllRequest, opts ...operations.Option) (*operations.V2EarnPositionsAllResponse, error)
EarnPositionsAll - 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) EarnSwap ¶
func (s *Earn) EarnSwap(ctx context.Context, request components.EarnSwapRequest, opts ...operations.Option) (*operations.V2EarnSwapResponse, error)
EarnSwap - 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) EarnTransfer ¶
func (s *Earn) EarnTransfer(ctx context.Context, request components.EarnTransferRequest, opts ...operations.Option) (*operations.V2EarnTransferResponse, error)
EarnTransfer - 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) EarnVaults ¶
func (s *Earn) EarnVaults(ctx context.Context, request operations.V2EarnVaultsRequest, opts ...operations.Option) (*operations.V2EarnVaultsResponse, error)
EarnVaults - 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) GasSponsorshipApproveTransfer ¶
func (s *GasSponsorship) GasSponsorshipApproveTransfer(ctx context.Context, request components.ApproveTransferRequest, opts ...operations.Option) (*operations.V2GasSponsorshipApproveTransferResponse, error)
GasSponsorshipApproveTransfer - 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) GasSponsorshipPrepare ¶
func (s *GasSponsorship) GasSponsorshipPrepare(ctx context.Context, request components.SponsorGasRequest, opts ...operations.Option) (*operations.V2GasSponsorshipPrepareResponse, error)
GasSponsorshipPrepare - 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) GlobalMarketsPerpsActivity ¶ added in v0.1.3
func (s *GlobalMarketsPerps) GlobalMarketsPerpsActivity(ctx context.Context, request operations.V2GlobalMarketsPerpsActivityRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsActivityResponse, error)
GlobalMarketsPerpsActivity - 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) GlobalMarketsPerpsApproveBuilderFee ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsApproveBuilderFee(ctx context.Context, request components.GlobalMarketsPerpsApproveBuilderFeeRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsApproveBuilderFeeResponse, error)
GlobalMarketsPerpsApproveBuilderFee - 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) GlobalMarketsPerpsCancelOrder ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsCancelOrder(ctx context.Context, request components.GlobalMarketsPerpsCancelOrderRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsCancelOrderResponse, error)
GlobalMarketsPerpsCancelOrder - 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) GlobalMarketsPerpsDeposit ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsDeposit(ctx context.Context, request components.GlobalMarketsPerpsDepositRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsDepositResponse, error)
GlobalMarketsPerpsDeposit - 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). After signing, send the permit signature to the deposit/execute endpoint, where a gas sponsor calls batchedDepositWithPermit on the HL Bridge2.
func (*GlobalMarketsPerps) GlobalMarketsPerpsEnableUnifiedAccount ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsEnableUnifiedAccount(ctx context.Context, request components.GlobalMarketsPerpsEnableUnifiedAccountRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsEnableUnifiedAccountResponse, error)
GlobalMarketsPerpsEnableUnifiedAccount - 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) GlobalMarketsPerpsEnsureLeverage ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsEnsureLeverage(ctx context.Context, request components.GlobalMarketsPerpsEnsureLeverageRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsEnsureLeverageResponse, error)
GlobalMarketsPerpsEnsureLeverage - 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) GlobalMarketsPerpsExecute ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsExecute(ctx context.Context, request components.GlobalMarketsPerpsExecuteRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsExecuteResponse, error)
GlobalMarketsPerpsExecute - 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) GlobalMarketsPerpsLimitOrder ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsLimitOrder(ctx context.Context, request components.GlobalMarketsPerpsLimitOrderRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsLimitOrderResponse, error)
GlobalMarketsPerpsLimitOrder - 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) GlobalMarketsPerpsMarketOrder ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsMarketOrder(ctx context.Context, request components.GlobalMarketsPerpsMarketOrderRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsMarketOrderResponse, error)
GlobalMarketsPerpsMarketOrder - 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) GlobalMarketsPerpsOpportunities ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsOpportunities(ctx context.Context, request *operations.V2GlobalMarketsPerpsOpportunitiesRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsOpportunitiesResponse, error)
GlobalMarketsPerpsOpportunities - 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) GlobalMarketsPerpsPositions ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsPositions(ctx context.Context, request operations.V2GlobalMarketsPerpsPositionsRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsPositionsResponse, error)
GlobalMarketsPerpsPositions - 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) GlobalMarketsPerpsWithdraw ¶ added in v0.1.1
func (s *GlobalMarketsPerps) GlobalMarketsPerpsWithdraw(ctx context.Context, request components.GlobalMarketsPerpsWithdrawRequest, opts ...operations.Option) (*operations.V2GlobalMarketsPerpsWithdrawResponse, error)
GlobalMarketsPerpsWithdraw - 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 ¶
HTTPClient provides an interface for supplying the SDK with a custom HTTP client
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 WithSecurity ¶
func WithSecurity(security components.Security) SDKOption
WithSecurity configures the SDK to use the provided security details
func WithSecuritySource ¶
WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication
func WithServerIndex ¶
WithServerIndex allows the overriding of the default server by index
func WithServerURL ¶
WithServerURL allows providing an alternative server URL
func WithTemplatedServerURL ¶
WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters
func WithTimeout ¶
WithTimeout Optional request timeout applied to each operation
type TokenizedAssets ¶
type TokenizedAssets struct {
// contains filtered or unexported fields
}
func (*TokenizedAssets) TokenizedAssetsCreateAccount ¶
func (s *TokenizedAssets) TokenizedAssetsCreateAccount(ctx context.Context, request components.CreateTokenizedAssetsAccountRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsCreateAccountResponse, error)
TokenizedAssetsCreateAccount - Create a Tokenized Assets Account Create a Tokenized Assets Account for a wallet address.
Before placing orders, the owner must create a Tokenized Assets 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) TokenizedAssetsMarkets ¶
func (s *TokenizedAssets) TokenizedAssetsMarkets(ctx context.Context, request *operations.V2TokenizedAssetsMarketsRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsMarketsResponse, error)
TokenizedAssetsMarkets - List tokenized equity markets List the tokenized US equities available on Ethereum.
Each entry includes the symbol, the underlying ticker, the on-chain contract address, the latest USD price, and 24h price change. Filter by `category` (sector tag) or `search` (substring match against symbol, ticker, or name).
Only Ethereum-deployed tokens are returned; assets that exist only on other chains are omitted.
func (*TokenizedAssets) TokenizedAssetsMarketsSymbol ¶
func (s *TokenizedAssets) TokenizedAssetsMarketsSymbol(ctx context.Context, request operations.V2TokenizedAssetsMarketsSymbolRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsMarketsSymbolResponse, error)
TokenizedAssetsMarketsSymbol - Get a single market Get extended detail for a single tokenized equity (e.g. `TSLAon`).
Includes 52-week range, volume, market cap, holder count, and tradable sessions in addition to the fields returned by `/markets`.
**OHLC candles** are opt-in: pass both `interval` and `range` query params to include a `candles` array in the response. 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) TokenizedAssetsOrder ¶
func (s *TokenizedAssets) TokenizedAssetsOrder(ctx context.Context, request components.TokenizedAssetsBuildOrderRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsOrderResponse, error)
TokenizedAssetsOrder - Build a buy/sell order Build a buy or sell order whose maker is the Tokenized Assets Account.
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) TokenizedAssetsOrderOrderHash ¶
func (s *TokenizedAssets) TokenizedAssetsOrderOrderHash(ctx context.Context, request operations.V2TokenizedAssetsOrderOrderHashRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsOrderOrderHashResponse, error)
TokenizedAssetsOrderOrderHash - Get order status Get the lifecycle state of a submitted order.
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) TokenizedAssetsOrderOrderHashCancel ¶
func (s *TokenizedAssets) TokenizedAssetsOrderOrderHashCancel(ctx context.Context, request operations.V2TokenizedAssetsOrderOrderHashCancelRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsOrderOrderHashCancelResponse, error)
TokenizedAssetsOrderOrderHashCancel - Cancel an unfilled order 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) TokenizedAssetsOrderSubmit ¶
func (s *TokenizedAssets) TokenizedAssetsOrderSubmit(ctx context.Context, request components.TokenizedAssetsSubmitOrderRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsOrderSubmitResponse, error)
TokenizedAssetsOrderSubmit - Submit a signed order Submit a signed order to the resolver network.
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) TokenizedAssetsPositions ¶
func (s *TokenizedAssets) TokenizedAssetsPositions(ctx context.Context, request operations.V2TokenizedAssetsPositionsRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsPositionsResponse, error)
TokenizedAssetsPositions - Get tokenized-asset positions for a wallet Get the tokenized-asset holdings for a wallet.
Returns the balance of every listed tokenized equity at the queried address, plus the latest USD price and a USD-valued balance when pricing is available. Zero balances are omitted, and a `total_usd` aggregate is returned across all priced positions.
Pass the **Tokenized Assets Account address** (returned by `/create_account`), not the owner's wallet — proceeds from filled orders settle into the Tokenized Assets Account.
func (*TokenizedAssets) TokenizedAssetsQuote ¶
func (s *TokenizedAssets) TokenizedAssetsQuote(ctx context.Context, request components.TokenizedAssetsQuoteRequest, opts ...operations.Option) (*operations.V2TokenizedAssetsQuoteResponse, error)
TokenizedAssetsQuote - Preview a buy/sell quote Preview the input/output amounts, fees, and slippage tolerance for an order.
Read-only relative to Fusion: hits “/quote/receive“ only and does not consume a “quote_id“ or commit 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 Fusion's 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.