hypermid

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 12 Imported by: 0

README

hypermid-sdk-go

Go SDK for the Hypermid Partner API — swap, bridge, and on-ramp across 90+ chains (EVM, Solana, Bitcoin, Sui, NEAR, Tron, TON, XRP, Doge).

go get github.com/Hypermid/hypermid-sdk-go

Quick start

No API key required. The SDK works anonymously out of the box at the default fee tier — pass an API key only if you're a partner with custom fee terms.

package main

import (
    "context"
    "fmt"
    "log"

    hypermid "github.com/Hypermid/hypermid-sdk-go"
)

func main() {
    // Anonymous — works immediately, no signup
    hm := hypermid.New(nil)

    // Or, partner with custom fees:
    // hm := hypermid.New(&hypermid.Config{APIKey: os.Getenv("HYPERMID_API_KEY")})

    chains, err := hm.GetChains(context.Background())
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Supported chains: %d\n", len(chains.Chains))
}

Features

  • GetQuote / Execute / GetStatus — the swap pipeline
  • GetChains / GetTokens — supported chains and tokens
  • GetBalances — multi-ecosystem wallet balances + USD totals
  • RegisterInboundReceiver — SuperSwap V2 inbound deposits
  • On-ramp helpers — GetOnrampQuote, GetOnrampCheckout, GetOnrampStatus
  • VerifyWebhookSignature — HMAC webhook signature verification

Authentication

The API is open by default — every endpoint works without authentication, so you can integrate, test, and ship without a signup.

An API key is only needed if you're a partner with negotiated terms (custom fee splits, fee discounts, volume tiers, higher rate limits, webhook events scoped to your traffic). When set, the SDK sends it as the X-API-Key header.

Apply for a partner account at partner.hypermid.io.

Documentation

Full reference: https://docs.hypermid.io

License

MIT

Documentation

Overview

Package hypermid provides a Go client for the Hypermid Partner API.

The SDK supports all Hypermid API endpoints including cross-chain swaps (LI.FI + Near Intents), fiat on-ramp, partner analytics, and webhooks.

Usage:

client := hypermid.New(nil) // anonymous, 100 req/min

// With API key for higher rate limits (2000 req/min)
client := hypermid.New(&hypermid.Config{
    APIKey: "your-api-key",
})

chains, err := client.GetChains(context.Background())

Index

Constants

View Source
const (
	// EVM Chains
	ChainIDEthereum  = 1
	ChainIDOptimism  = 10
	ChainIDBSC       = 56
	ChainIDGnosis    = 100
	ChainIDPolygon   = 137
	ChainIDXLayer    = 196
	ChainIDArbitrum  = 42161
	ChainIDAvalanche = 43114
	ChainIDBase      = 8453
	ChainIDPlasma    = 1012
	ChainIDBerachain = 80094
	ChainIDMonad     = 10143

	// Non-EVM (LI.FI supported)
	ChainIDSolana  = 1151111081099710
	ChainIDBitcoin = 20000000000001
	ChainIDSui     = 9270000000000000

	// Near Intents-only chains
	ChainIDNear        = niBase + 1
	ChainIDTon         = niBase + 2
	ChainIDTron        = niBase + 3
	ChainIDXRP         = niBase + 4
	ChainIDDogecoin    = niBase + 5
	ChainIDLitecoin    = niBase + 6
	ChainIDBitcoinCash = niBase + 7
	ChainIDStellar     = niBase + 8
	ChainIDCardano     = niBase + 9
	ChainIDAptos       = niBase + 10
	ChainIDStarknet    = niBase + 11
	ChainIDDash        = niBase + 12
	ChainIDZcash       = niBase + 13
	ChainIDAleo        = niBase + 14
	ChainIDAdi         = niBase + 15
)

ChainID constants for all supported chains.

Variables

This section is empty.

Functions

func IsDepositFailed

func IsDepositFailed(resp *DepositStatusResponse) bool

IsDepositFailed returns true if a Near Intents swap failed.

func IsDepositRefunded

func IsDepositRefunded(resp *DepositStatusResponse) bool

IsDepositRefunded returns true if a Near Intents swap was refunded.

func IsDepositSuccess

func IsDepositSuccess(resp *DepositStatusResponse) bool

IsDepositSuccess returns true if a Near Intents swap completed successfully.

func IsLiFiRoute

func IsLiFiRoute(resp *ExecuteResponse) bool

IsLiFiRoute returns true if the execute response is a LI.FI route (has transactionRequest).

func IsLiFiStatusTerminal

func IsLiFiStatusTerminal(status string) bool

IsLiFiStatusTerminal returns true if a LI.FI status is terminal.

func IsManualDeposit

func IsManualDeposit(resp *ExecuteResponse) bool

IsManualDeposit returns true if a Near Intents deposit requires manual user action (QR code / copy address).

func IsNIStatusTerminal

func IsNIStatusTerminal(status string) bool

IsNIStatusTerminal returns true if a Near Intents deposit status is terminal (no more polling needed).

func IsNearIntentsChain

func IsNearIntentsChain(chainID int) bool

IsNearIntentsChain returns true if the chain ID belongs to a Near Intents-only chain.

func IsNearIntentsRoute

func IsNearIntentsRoute(resp *ExecuteResponse) bool

IsNearIntentsRoute returns true if the execute response is a Near Intents route (has depositAddress).

func IsSuperSwapRoute added in v1.1.0

func IsSuperSwapRoute(resp *ExecuteResponse) bool

IsSuperSwapRoute returns true if the execute response is a SuperSwap V2 route (wallet, has transactionRequest).

func IsSuperSwapStatusTerminal added in v1.1.0

func IsSuperSwapStatusTerminal(status string) bool

IsSuperSwapStatusTerminal returns true if a SuperSwap V2 status is terminal (vocabulary: PENDING | DONE | FAILED | NOT_FOUND | INVALID).

func IsWalletDeposit

func IsWalletDeposit(resp *ExecuteResponse) bool

IsWalletDeposit returns true if the deposit can be done programmatically via wallet.

func SupportsWalletDeposit

func SupportsWalletDeposit(chainID int) bool

SupportsWalletDeposit returns true if the chain supports wallet-connected deposit mode. Chains with wallet connectors: EVM, Solana, Bitcoin, Sui, TON, Tron. Other Near Intents chains (NEAR, XRP, DOGE, etc.) require manual deposit.

func VerifyWebhookSignature

func VerifyWebhookSignature(body []byte, signature string, secret string) bool

VerifyWebhookSignature validates an incoming webhook signature.

When Hypermid sends a webhook, it includes:

  • X-Hypermid-Signature: HMAC-SHA256 hex digest of the raw body
  • X-Hypermid-Event: event type (e.g. "swap.completed")

body is the raw request body, signature is the X-Hypermid-Signature header value, and secret is the webhook signing secret returned when the webhook was created.

Uses constant-time comparison to prevent timing attacks.

Types

type ApiError

type ApiError struct {
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
}

ApiError represents the error object in an API response envelope.

type ApiMeta

type ApiMeta struct {
	RequestID string         `json:"requestId"`
	Timestamp int64          `json:"timestamp"`
	RateLimit *RateLimitInfo `json:"rateLimit,omitempty"`
}

ApiMeta contains metadata returned with every API response.

type BalanceChainMeta

type BalanceChainMeta struct {
	OK         bool   `json:"ok"`
	Error      string `json:"error,omitempty"`
	Source     string `json:"source,omitempty"`
	DurationMs int    `json:"durationMs"`
	Stale      bool   `json:"stale,omitempty"`
}

BalanceChainMeta is the per-chain fetch status (use to render retry chips for failing chains rather than hiding them).

type BalancesParams

type BalancesParams struct {
	Address  string `json:"-"`
	ChainIDs []int  `json:"-"`
}

BalancesParams is the input for GetBalances. ChainIDs is optional and is sent as a comma-separated `chainIds` query param (not a JSON body).

type BalancesResponse

type BalancesResponse struct {
	Address         string                      `json:"address"`
	TotalBalanceUSD string                      `json:"totalBalanceUSD"`
	Balances        map[string][]TokenBalance   `json:"balances"`
	ChainMeta       map[string]BalanceChainMeta `json:"chainMeta,omitempty"`
	CachedAt        string                      `json:"cachedAt,omitempty"`
	CacheHit        bool                        `json:"cacheHit,omitempty"`
}

BalancesResponse is the GetBalances result.

type Chain

type Chain struct {
	ID          int         `json:"id"`
	Key         string      `json:"key"`
	Name        string      `json:"name"`
	ChainType   string      `json:"chainType"`
	NativeToken NativeToken `json:"nativeToken"`
	Provider    string      `json:"provider,omitempty"`
}

Chain represents a supported blockchain.

type ChainStat

type ChainStat struct {
	Chain  string  `json:"chain"`
	Count  int     `json:"count"`
	Volume float64 `json:"volume"`
}

ChainStat contains per-chain statistics.

type ChainsResponse

type ChainsResponse struct {
	Chains []Chain `json:"chains"`
}

ChainsResponse is the response from GetChains.

type Client

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

Client is the Hypermid API client.

func New

func New(cfg *Config) *Client

New creates a new Hypermid client. Pass nil for default configuration.

func (*Client) CreateOnrampCheckout

func (c *Client) CreateOnrampCheckout(ctx context.Context, params OnrampCheckoutParams) (OnrampCheckoutResponse, error)

CreateOnrampCheckout creates a fiat-to-crypto purchase session.

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, params CreateWebhookParams) (WebhookCreated, error)

CreateWebhook registers a webhook endpoint. The returned WebhookCreated includes the signing secret, which is only returned on creation.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, webhookID string) (DeleteWebhookResponse, error)

DeleteWebhook deletes a webhook by ID.

func (*Client) Execute

func (c *Client) Execute(ctx context.Context, params ExecuteParams) (ExecuteResponse, error)

Execute returns full transaction data for execution.

func (*Client) ExecuteSwap

func (c *Client) ExecuteSwap(ctx context.Context, params ExecuteParams, hooks *ExecuteSwapHooks, cfg *PollConfig) (*ExecuteSwapResult, error)

ExecuteSwap runs the full swap lifecycle: execute -> sign/deposit -> poll -> complete.

func (*Client) GetBalances

func (c *Client) GetBalances(ctx context.Context, params BalancesParams) (BalancesResponse, error)

GetBalances returns multi-ecosystem token balances and the total USD value for an address. The backend auto-detects the address ecosystem (EVM / Sui / Tron / NEAR / Solana / Bitcoin); pass ChainIDs to restrict EVM coverage to specific chains.

func (*Client) GetChains

func (c *Client) GetChains(ctx context.Context) (ChainsResponse, error)

GetChains returns all supported chains (LI.FI + Near Intents).

func (*Client) GetConnections

func (c *Client) GetConnections(ctx context.Context, params ConnectionsParams) (json.RawMessage, error)

GetConnections returns available connections (which token pairs can be swapped).

func (*Client) GetDepositStatus

func (c *Client) GetDepositStatus(ctx context.Context, params DepositStatusParams) (DepositStatusResponse, error)

GetDepositStatus checks the status of a Near Intents deposit/swap.

func (*Client) GetGasPrices

func (c *Client) GetGasPrices(ctx context.Context, params GasPricesParams) (json.RawMessage, error)

GetGasPrices returns gas prices for specified chains.

func (*Client) GetOnrampAssets

func (c *Client) GetOnrampAssets(ctx context.Context, params OnrampAssetsParams) (json.RawMessage, error)

GetOnrampAssets returns asset configuration (min/max amounts, precision, payment methods).

func (*Client) GetOnrampConfig

func (c *Client) GetOnrampConfig(ctx context.Context) (OnrampConfigResponse, error)

GetOnrampConfig returns supported chains and tokens for on-ramp.

func (*Client) GetOnrampQuote

func (c *Client) GetOnrampQuote(ctx context.Context, params OnrampQuoteParams) (json.RawMessage, error)

GetOnrampQuote returns a fiat-to-crypto price quote.

func (*Client) GetOnrampStatus

func (c *Client) GetOnrampStatus(ctx context.Context, orderUID string) (OnrampStatusResponse, error)

GetOnrampStatus checks on-ramp order status.

func (*Client) GetPartnerInfo

func (c *Client) GetPartnerInfo(ctx context.Context) (PartnerInfo, error)

GetPartnerInfo returns partner account details.

func (*Client) GetPartnerStats

func (c *Client) GetPartnerStats(ctx context.Context, params *PartnerStatsParams) (PartnerStats, error)

GetPartnerStats returns aggregated partner statistics.

func (*Client) GetPartnerTransactions

func (c *Client) GetPartnerTransactions(ctx context.Context, params *PaginationParams) (PaginatedTransactions, error)

GetPartnerTransactions returns paginated transaction history.

func (*Client) GetQuote

func (c *Client) GetQuote(ctx context.Context, params QuoteParams) (QuoteResponse, error)

GetQuote returns the best swap quote for a token pair.

func (*Client) GetRoutes

func (c *Client) GetRoutes(ctx context.Context, params RoutesParams) (json.RawMessage, error)

GetRoutes returns available routes for a token pair (multi-route comparison).

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context, params StatusParams) (StatusResponse, error)

GetStatus checks the status of a cross-chain swap.

func (*Client) GetTokens

func (c *Client) GetTokens(ctx context.Context, params *TokensParams) (TokensResponse, error)

GetTokens returns available tokens, optionally filtered by chains and keywords.

func (*Client) GetTools

func (c *Client) GetTools(ctx context.Context) (json.RawMessage, error)

GetTools returns available bridge/swap tools.

func (*Client) ListWebhooks

func (c *Client) ListWebhooks(ctx context.Context) (WebhooksListResponse, error)

ListWebhooks returns all registered webhooks.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (PingResponse, error)

Ping returns API health status, version, uptime, and provider statuses.

func (*Client) RecordSwapEvent

func (c *Client) RecordSwapEvent(ctx context.Context, params SwapEventParams) (SwapEventResponse, error)

RecordSwapEvent records a swap event for analytics.

func (*Client) RegisterInboundReceiver

func (c *Client) RegisterInboundReceiver(ctx context.Context, params InboundReceiverParams) (InboundReceiverResponse, error)

RegisterInboundReceiver registers a SuperSwap V2 inbound deposit so the backend executes the PulseChain-side output. The deposit must already be on-chain, and an EIP-712 signature over the registration is required.

func (*Client) SubmitDeposit

func (c *Client) SubmitDeposit(ctx context.Context, params DepositSubmitParams) (DepositSubmitResponse, error)

SubmitDeposit submits a deposit transaction hash after sending tokens to a Near Intents deposit address.

func (*Client) WaitForDepositCompletion

func (c *Client) WaitForDepositCompletion(ctx context.Context, params DepositStatusParams, cfg *PollConfig) (DepositStatusResponse, error)

WaitForDepositCompletion polls Near Intents deposit/swap status until a terminal state is reached (SUCCESS, REFUNDED, or FAILED).

func (*Client) WaitForLiFiCompletion

func (c *Client) WaitForLiFiCompletion(ctx context.Context, params LiFiStatusParams, cfg *PollConfig) (StatusResponse, error)

WaitForLiFiCompletion polls LI.FI swap status until a terminal state is reached (DONE or FAILED).

type Config

type Config struct {
	// APIKey for authenticated access (2000 req/min, partner fee tier).
	// Optional — anonymous access allows 100 req/min.
	APIKey string
	// BaseURL override (default: https://api.hypermid.io).
	BaseURL string
	// Timeout for HTTP requests (default: 30s).
	Timeout time.Duration
	// HTTPClient is a custom http.Client to use. If nil, a default client is created.
	HTTPClient *http.Client
}

Config configures the Hypermid client.

type ConnectionsParams

type ConnectionsParams struct {
	FromChain string `json:"fromChain"`
	FromToken string `json:"fromToken"`
	ToChain   string `json:"toChain,omitempty"`
}

ConnectionsParams are parameters for GetConnections.

type CreateWebhookParams

type CreateWebhookParams struct {
	URL    string   `json:"url"`
	Events []string `json:"events,omitempty"`
}

CreateWebhookParams are parameters for CreateWebhook.

type DeleteWebhookResponse

type DeleteWebhookResponse struct {
	Deleted bool   `json:"deleted"`
	ID      string `json:"id"`
}

DeleteWebhookResponse is the response from DeleteWebhook.

type DepositStatusParams

type DepositStatusParams struct {
	DepositAddress string `json:"depositAddress"`
	DepositMemo    string `json:"depositMemo,omitempty"`
}

DepositStatusParams are parameters for GetDepositStatus.

type DepositStatusResponse

type DepositStatusResponse struct {
	Provider       string       `json:"provider"`
	Status         string       `json:"status"`
	DepositAddress string       `json:"depositAddress"`
	SwapDetails    *SwapDetails `json:"swapDetails,omitempty"`
}

DepositStatusResponse is the response from GetDepositStatus.

type DepositSubmitParams

type DepositSubmitParams struct {
	TxHash         string `json:"txHash"`
	DepositAddress string `json:"depositAddress"`
}

DepositSubmitParams are parameters for SubmitDeposit.

type DepositSubmitResponse

type DepositSubmitResponse struct {
	Submitted      bool   `json:"submitted"`
	TxHash         string `json:"txHash"`
	DepositAddress string `json:"depositAddress"`
	NextStep       string `json:"nextStep"`
}

DepositSubmitResponse is the response from SubmitDeposit.

type ExecuteParams

type ExecuteParams struct {
	FromChain     string `json:"fromChain"`
	FromToken     string `json:"fromToken"`
	FromAmount    string `json:"fromAmount"`
	ToChain       string `json:"toChain"`
	ToToken       string `json:"toToken"`
	FromAddress   string `json:"fromAddress"`
	ToAddress     string `json:"toAddress"`
	DepositMode   string `json:"depositMode,omitempty"`
	Slippage      string `json:"slippage,omitempty"`
	Order         string `json:"order,omitempty"`
	RefundAddress string `json:"refundAddress,omitempty"`
}

ExecuteParams are parameters for Execute.

type ExecuteQuote

type ExecuteQuote struct {
	FromToken     Token           `json:"fromToken"`
	ToToken       Token           `json:"toToken"`
	FromAmount    string          `json:"fromAmount"`
	ToAmount      string          `json:"toAmount"`
	ToAmountMin   string          `json:"toAmountMin"`
	EstimatedTime int             `json:"estimatedTime"`
	GasCosts      json.RawMessage `json:"gasCosts"`
	FeeCosts      json.RawMessage `json:"feeCosts"`
}

ExecuteQuote contains quote details returned with a LI.FI execute response.

type ExecuteResponse

type ExecuteResponse struct {
	Provider    string `json:"provider"`
	DepositMode string `json:"depositMode,omitempty"`
	FeeBps      int    `json:"feeBps"`

	// LI.FI fields
	TransactionRequest *TransactionRequest `json:"transactionRequest,omitempty"`
	Quote              *ExecuteQuote       `json:"quote,omitempty"`

	// Near Intents fields
	DepositAddress    string   `json:"depositAddress,omitempty"`
	DepositMemo       string   `json:"depositMemo,omitempty"`
	ExpectedOutput    string   `json:"expectedOutput,omitempty"`
	ExpectedOutputUsd *float64 `json:"expectedOutputUsd,omitempty"`
	MinAmountOut      string   `json:"minAmountOut,omitempty"`
	TimeEstimate      *int     `json:"timeEstimate,omitempty"`
	CorrelationID     string   `json:"correlationId,omitempty"`

	// SuperSwap V2 fields (Provider == "superswap"). Approve ApprovalAddress
	// (source DiamondShell, equals TransactionRequest.To), then sign and
	// broadcast TransactionRequest above.
	Source          string `json:"source,omitempty"`
	ApprovalAddress string `json:"approvalAddress,omitempty"`
	EstimatedOutput string `json:"estimatedOutput,omitempty"`
	MinOutput       string `json:"minOutput,omitempty"`
	V2              bool   `json:"v2,omitempty"`

	// Instructions (present for both providers)
	Instructions map[string]string `json:"instructions,omitempty"`
}

ExecuteResponse is the response from Execute. Check Provider to determine if it's a LI.FI or Near Intents response.

type ExecuteSwapHooks

type ExecuteSwapHooks struct {
	// OnExecute is called when the execute response is received.
	OnExecute func(resp *ExecuteResponse)
	// OnTransactionRequest is called when a LI.FI transactionRequest is ready.
	// You MUST sign and broadcast it, then return the transaction hash.
	// If nil, ExecuteSwap returns after receiving the transactionRequest.
	OnTransactionRequest func(resp *ExecuteResponse) (txHash string, err error)
	// OnDepositRequired is called when a Near Intents deposit address is ready
	// and depositMode is "wallet". You MUST send tokens and return the tx hash.
	// If nil, ExecuteSwap returns after receiving the deposit address.
	OnDepositRequired func(resp *ExecuteResponse) (txHash string, err error)
}

ExecuteSwapHooks provides callback hooks for the swap execution lifecycle.

type ExecuteSwapResult

type ExecuteSwapResult struct {
	// Provider is "lifi" or "near-intents".
	Provider string
	// ExecuteResponse is the initial execute response.
	ExecuteResponse *ExecuteResponse
	// DepositStatus is the final Near Intents deposit status (if applicable).
	DepositStatus *DepositStatusResponse
	// LiFiStatus is the final LI.FI status (if applicable).
	LiFiStatus *StatusResponse
	// Error message if the swap failed.
	Error string
}

ExecuteSwapResult contains the final state of an ExecuteSwap call.

type GasPricesParams

type GasPricesParams struct {
	Chains string `json:"chains"`
}

GasPricesParams are parameters for GetGasPrices.

type HypermidError

type HypermidError struct {
	// Code is the API error code (e.g. "NO_ROUTE_FOUND", "RATE_LIMITED").
	Code string
	// Msg is the human-readable error message.
	Msg string
	// Status is the HTTP status code.
	Status int
	// Meta contains request metadata (requestId, timestamp, rateLimit).
	Meta ApiMeta
	// Details contains additional error details (lifiCode, toolErrors, etc.).
	Details map[string]interface{}
}

HypermidError is returned when the API responds with an error.

func (*HypermidError) Error

func (e *HypermidError) Error() string

type HypermidNetworkError

type HypermidNetworkError struct {
	Msg   string
	Cause error
}

HypermidNetworkError is returned when a network-level error occurs.

func (*HypermidNetworkError) Error

func (e *HypermidNetworkError) Error() string

func (*HypermidNetworkError) Unwrap

func (e *HypermidNetworkError) Unwrap() error

type HypermidPollTimeoutError

type HypermidPollTimeoutError struct {
	Msg string
}

HypermidPollTimeoutError is returned when status polling exceeds the maximum wait time or attempts.

func (*HypermidPollTimeoutError) Error

func (e *HypermidPollTimeoutError) Error() string

type HypermidTimeoutError

type HypermidTimeoutError struct {
	TimeoutMs int
}

HypermidTimeoutError is returned when a request exceeds the configured timeout.

func (*HypermidTimeoutError) Error

func (e *HypermidTimeoutError) Error() string

type InboundReceiverParams

type InboundReceiverParams struct {
	TxHash            string `json:"txHash"`
	FromAddress       string `json:"fromAddress"`
	ToAddress         string `json:"toAddress"`
	OutputToken       string `json:"outputToken"`
	DestinationDomain int    `json:"destinationDomain"`
	Signature         string `json:"signature"`
}

InboundReceiverParams registers a SuperSwap V2 inbound deposit.

type InboundReceiverResponse

type InboundReceiverResponse struct {
	Registered bool   `json:"registered"`
	RecordID   string `json:"recordId"`
	USDCAmount string `json:"usdcAmount"`
	Status     string `json:"status"`
}

InboundReceiverResponse is the RegisterInboundReceiver result.

type LiFiStatusParams

type LiFiStatusParams struct {
	TxHash    string `json:"txHash"`
	Bridge    string `json:"bridge,omitempty"`
	FromChain string `json:"fromChain,omitempty"`
	ToChain   string `json:"toChain,omitempty"`
}

LiFiStatusParams are parameters for polling LI.FI swap status.

type NativeToken

type NativeToken struct {
	Symbol   string `json:"symbol"`
	Name     string `json:"name"`
	Decimals int    `json:"decimals"`
}

NativeToken represents a chain's native token.

type OnrampAssetsParams

type OnrampAssetsParams struct {
	Currency      string `json:"currency"`
	Chain         string `json:"chain"`
	OrderCurrency string `json:"orderCurrency,omitempty"`
}

OnrampAssetsParams are parameters for GetOnrampAssets.

type OnrampCheckoutParams

type OnrampCheckoutParams struct {
	WalletAddress string      `json:"walletAddress"`
	CryptoToken   string      `json:"cryptoToken"`
	CryptoChain   string      `json:"cryptoChain"`
	FiatCurrency  string      `json:"fiatCurrency"`
	FiatAmount    interface{} `json:"fiatAmount"`
	Email         string      `json:"email,omitempty"`
	ReturnURL     string      `json:"returnUrl,omitempty"`
	PaymentMode   string      `json:"paymentMode,omitempty"`
}

OnrampCheckoutParams are parameters for CreateOnrampCheckout.

type OnrampCheckoutResponse

type OnrampCheckoutResponse struct {
	RedirectURL      string `json:"redirectUrl"`
	OrderUID         string `json:"orderUid"`
	ExternalOrderUID string `json:"externalOrderUid"`
}

OnrampCheckoutResponse is the response from CreateOnrampCheckout.

type OnrampConfigResponse

type OnrampConfigResponse struct {
	Chains map[string][]string `json:"chains"`
}

OnrampConfigResponse is the response from GetOnrampConfig.

type OnrampQuoteParams

type OnrampQuoteParams struct {
	FiatAmount    interface{} `json:"fiatAmount"`
	FiatCurrency  string      `json:"fiatCurrency"`
	CryptoToken   string      `json:"cryptoToken"`
	CryptoChain   string      `json:"cryptoChain"`
	WalletAddress string      `json:"walletAddress,omitempty"`
	PaymentMode   string      `json:"paymentMode,omitempty"`
	UserCountry   string      `json:"userCountry,omitempty"`
}

OnrampQuoteParams are parameters for GetOnrampQuote.

type OnrampStatusResponse

type OnrampStatusResponse struct {
	Status    string `json:"status"`
	OrderUID  string `json:"orderUid"`
	DstAmount string `json:"dstAmount,omitempty"`
	TxHash    string `json:"txHash,omitempty"`
	Message   string `json:"message,omitempty"`
}

OnrampStatusResponse is the response from GetOnrampStatus.

type PaginatedTransactions

type PaginatedTransactions struct {
	Items      []Transaction `json:"items"`
	Total      int           `json:"total"`
	Page       int           `json:"page"`
	Limit      int           `json:"limit"`
	TotalPages int           `json:"totalPages"`
}

PaginatedTransactions is a paginated list of transactions.

type PaginationParams

type PaginationParams struct {
	Page  int `json:"page,omitempty"`
	Limit int `json:"limit,omitempty"`
}

PaginationParams are optional pagination parameters.

type PartnerInfo

type PartnerInfo struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Email       string  `json:"email"`
	Status      string  `json:"status"`
	Tier        string  `json:"tier"`
	FeeBps      int     `json:"fee_bps"`
	VolumeTotal float64 `json:"volume_total"`
	TxCount     int     `json:"tx_count"`
	CreatedAt   string  `json:"created_at"`
}

PartnerInfo contains partner account details.

type PartnerStats

type PartnerStats struct {
	TxCount            int            `json:"tx_count"`
	CompletedCount     int            `json:"completed_count"`
	FailedCount        int            `json:"failed_count"`
	VolumeUsd          float64        `json:"volume_usd"`
	FeesEarnedUsd      float64        `json:"fees_earned_usd"`
	AvgDurationSeconds float64        `json:"avg_duration_seconds"`
	ByChain            []ChainStat    `json:"by_chain"`
	ByProvider         []ProviderStat `json:"by_provider"`
}

PartnerStats contains aggregated partner statistics.

type PartnerStatsParams

type PartnerStatsParams struct {
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

PartnerStatsParams are optional parameters for GetPartnerStats.

type PingProviders

type PingProviders struct {
	LiFi        string `json:"lifi"`
	NearIntents string `json:"nearIntents"`
	RampNow     string `json:"rampnow"`
}

PingProviders contains provider health statuses.

type PingResponse

type PingResponse struct {
	Status    string        `json:"status"`
	Version   string        `json:"version"`
	Uptime    float64       `json:"uptime"`
	Timestamp int64         `json:"timestamp"`
	Providers PingProviders `json:"providers"`
}

PingResponse is the response from Ping.

type PollConfig

type PollConfig struct {
	// PollInterval is the time between polls (default: 5s).
	PollIntervalMs int
	// MaxWaitMs is the maximum total time to wait (default: 600000 = 10 min).
	MaxWaitMs int
	// MaxPolls is the maximum number of poll attempts (default: 0 = unlimited).
	MaxPolls int
}

PollConfig configures polling behavior for WaitForDepositCompletion and WaitForLiFiCompletion.

type ProviderStat

type ProviderStat struct {
	Provider string `json:"provider"`
	Count    int    `json:"count"`
}

ProviderStat contains per-provider statistics.

type QuoteParams

type QuoteParams struct {
	FromChain   string `json:"fromChain"`
	FromToken   string `json:"fromToken"`
	FromAmount  string `json:"fromAmount"`
	ToChain     string `json:"toChain"`
	ToToken     string `json:"toToken"`
	FromAddress string `json:"fromAddress"`
	ToAddress   string `json:"toAddress,omitempty"`
	Slippage    string `json:"slippage,omitempty"`
	Order       string `json:"order,omitempty"`
}

QuoteParams are parameters for GetQuote.

type QuoteResponse

type QuoteResponse struct {
	Quote      json.RawMessage `json:"quote"`
	Provider   string          `json:"provider"`
	FeeBps     int             `json:"feeBps"`
	IsDryQuote bool            `json:"isDryQuote"`
}

QuoteResponse is the response from GetQuote.

type RateLimitInfo

type RateLimitInfo struct {
	Limit     int   `json:"limit"`
	Remaining int   `json:"remaining"`
	Reset     int64 `json:"reset"`
}

RateLimitInfo contains rate limit details from the API response.

type RoutesParams

type RoutesParams struct {
	FromChain   string      `json:"fromChain"`
	FromToken   string      `json:"fromToken"`
	FromAmount  string      `json:"fromAmount"`
	ToChain     string      `json:"toChain"`
	ToToken     string      `json:"toToken"`
	FromAddress string      `json:"fromAddress"`
	ToAddress   string      `json:"toAddress,omitempty"`
	Slippage    interface{} `json:"slippage,omitempty"`
	Order       string      `json:"order,omitempty"`
}

RoutesParams are parameters for GetRoutes.

type StatusParams

type StatusParams struct {
	// LI.FI fields
	TxHash    string `json:"txHash,omitempty"`
	Bridge    string `json:"bridge,omitempty"`
	FromChain string `json:"fromChain,omitempty"`
	ToChain   string `json:"toChain,omitempty"`

	// Near Intents fields
	Provider      string `json:"provider,omitempty"`
	CorrelationID string `json:"correlationId,omitempty"`
}

StatusParams are parameters for GetStatus. For LI.FI status: set TxHash (and optionally Bridge, FromChain, ToChain). For Near Intents status: set Provider to "near-intents" and CorrelationID.

type StatusResponse

type StatusResponse struct {
	Provider string `json:"provider"`
	Status   string `json:"status,omitempty"`
	// Extra carries provider-specific fields beyond Provider/Status — e.g. for
	// SuperSwap V2: hyperlaneMessageId, subStatus, sending, receiving,
	// destinationTxHash. Populated by UnmarshalJSON below.
	Extra map[string]interface{} `json:"-"`
}

StatusResponse is the response from GetStatus.

func (*StatusResponse) UnmarshalJSON added in v1.1.0

func (s *StatusResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes Provider/Status into their typed fields and collects every other key into Extra, so provider-specific data (e.g. SuperSwap V2's hyperlaneMessageId / sending / receiving legs) is never dropped.

type SwapDetails

type SwapDetails struct {
	AmountOut                string   `json:"amountOut,omitempty"`
	AmountOutFormatted       string   `json:"amountOutFormatted,omitempty"`
	AmountOutUsd             *float64 `json:"amountOutUsd,omitempty"`
	DestinationChainTxHashes []string `json:"destinationChainTxHashes,omitempty"`
	RefundedAmount           string   `json:"refundedAmount,omitempty"`
	RefundReason             string   `json:"refundReason,omitempty"`
}

SwapDetails contains swap completion details for Near Intents deposits.

type SwapEventParams

type SwapEventParams struct {
	Provider        string   `json:"provider,omitempty"`
	FromChain       string   `json:"from_chain,omitempty"`
	FromToken       string   `json:"from_token,omitempty"`
	ToChain         string   `json:"to_chain,omitempty"`
	ToToken         string   `json:"to_token,omitempty"`
	AmountUsd       *float64 `json:"amount_usd,omitempty"`
	FeeUsd          *float64 `json:"fee_usd,omitempty"`
	TxHash          string   `json:"tx_hash,omitempty"`
	WalletHash      string   `json:"wallet_hash,omitempty"`
	Status          string   `json:"status"`
	FromAmount      string   `json:"from_amount,omitempty"`
	ToAmount        string   `json:"to_amount,omitempty"`
	DurationSeconds *int     `json:"duration_seconds,omitempty"`
	ErrorMessage    string   `json:"error_message,omitempty"`
}

SwapEventParams are parameters for RecordSwapEvent.

type SwapEventResponse

type SwapEventResponse struct {
	Updated bool  `json:"updated"`
	ID      int64 `json:"id"`
}

SwapEventResponse is the response from RecordSwapEvent.

type Token

type Token struct {
	Address  string `json:"address"`
	Symbol   string `json:"symbol"`
	Name     string `json:"name"`
	Decimals int    `json:"decimals"`
	ChainID  int    `json:"chainId"`
	LogoURI  string `json:"logoURI,omitempty"`
	PriceUSD string `json:"priceUSD,omitempty"`
}

Token represents a token on a chain.

type TokenBalance

type TokenBalance struct {
	ChainID    int      `json:"chainId"`
	Address    string   `json:"address"`
	Symbol     string   `json:"symbol"`
	Name       string   `json:"name"`
	Decimals   int      `json:"decimals"`
	Balance    string   `json:"balance"`
	PriceUSD   float64  `json:"priceUSD"`
	BalanceUSD float64  `json:"balanceUSD"`
	LogoURI    string   `json:"logoURI"`
	Providers  []string `json:"providers"`
}

TokenBalance is a single token holding for an address.

type TokensParams

type TokensParams struct {
	Chains   string `json:"chains,omitempty"`
	Keywords string `json:"keywords,omitempty"`
}

TokensParams are optional parameters for GetTokens.

type TokensResponse

type TokensResponse struct {
	Tokens map[string][]Token `json:"tokens"`
}

TokensResponse is the response from GetTokens.

type Transaction

type Transaction struct {
	ID              int     `json:"id"`
	Provider        string  `json:"provider"`
	FromChain       string  `json:"from_chain"`
	FromToken       string  `json:"from_token"`
	ToChain         string  `json:"to_chain"`
	ToToken         string  `json:"to_token"`
	AmountUsd       float64 `json:"amount_usd"`
	FeeUsd          float64 `json:"fee_usd"`
	TxHash          string  `json:"tx_hash"`
	WalletHash      string  `json:"wallet_hash"`
	Status          string  `json:"status"`
	FromAmount      string  `json:"from_amount"`
	ToAmount        string  `json:"to_amount"`
	DurationSeconds int     `json:"duration_seconds"`
	CreatedAt       string  `json:"created_at"`
}

Transaction represents a single partner transaction.

type TransactionRequest

type TransactionRequest struct {
	To       string `json:"to"`
	Data     string `json:"data"`
	Value    string `json:"value"`
	From     string `json:"from"`
	ChainID  int    `json:"chainId"`
	GasLimit string `json:"gasLimit,omitempty"`
	GasPrice string `json:"gasPrice,omitempty"`
}

TransactionRequest contains the transaction data to sign and broadcast (LI.FI).

type Webhook

type Webhook struct {
	ID        string   `json:"id"`
	URL       string   `json:"url"`
	Events    []string `json:"events"`
	Status    string   `json:"status"`
	CreatedAt string   `json:"created_at"`
}

Webhook represents a registered webhook.

type WebhookCreated

type WebhookCreated struct {
	Webhook
	// Secret is the webhook signing secret. Only returned on creation.
	Secret string `json:"secret"`
}

WebhookCreated is returned from CreateWebhook and includes the signing secret.

type WebhooksListResponse

type WebhooksListResponse struct {
	Webhooks []Webhook `json:"webhooks"`
}

WebhooksListResponse is the response from ListWebhooks.

Jump to

Keyboard shortcuts

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