okxweb3

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SolanaChainIndex = "501"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	IsSigner   bool   `json:"isSigner"`
	IsWritable bool   `json:"isWritable"`
	Pubkey     string `json:"pubkey"`
}

type ChainInfo

type ChainInfo struct {
	Name       string `json:"name"`
	LogoUrl    string `json:"logoUrl"`
	ShortName  string `json:"shortName"`
	ChainIndex string `json:"chainIndex"`
}

type Client

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

func NewClient

func NewClient(apiKey, secretKey, passphrase string, transportProxy *http.Transport) *Client

func (*Client) GetAllTokenBalancesByAddress

func (client *Client) GetAllTokenBalancesByAddress(ctx context.Context, chainIndex string, address string) ([]TokenBalance, error)

func (*Client) GetRealtimePrice

func (client *Client) GetRealtimePrice(ctx context.Context, chainIndex string, tokenAddresses []string) (map[string]decimal.Decimal, error)

func (*Client) GetSupportedChains

func (client *Client) GetSupportedChains(ctx context.Context) ([]ChainInfo, error)

func (*Client) Quote

func (client *Client) Quote(ctx context.Context, chainIndex string, userWalletAddress, inputToken, outputToken string, amount *big.Int, slippageBps int) (*SwapInstruction, error)

func (*Client) SendSwapTransaction

func (client *Client) SendSwapTransaction(ctx context.Context, svcCtx *svc.ServiceContext, wallet *solana.Wallet, swapInstruction *SwapInstruction, priorityLevel settings.PriorityLevel, maxRetries uint) (string, error)

type DexProtocol

type DexProtocol struct {
	DexName string `json:"dexName"`
	Percent string `json:"percent"`
}

type DexRouter

type DexRouter struct {
	Router        string      `json:"router"`
	RouterPercent string      `json:"routerPercent"`
	SubRouterList []SubRouter `json:"subRouterList"`
}

type Instruction

type Instruction struct {
	Data      string    `json:"data"`
	Accounts  []Account `json:"accounts"`
	ProgramId string    `json:"programId"`
}

type Quote

type Quote struct {
	AmountOut string `json:"amountOut"`
	DexName   string `json:"dexName"`
	TradeFee  string `json:"tradeFee"`
}

type RealtimePrice

type RealtimePrice struct {
	ChainIndex   string          `json:"chainIndex"`
	TokenAddress string          `json:"tokenAddress"`
	Time         string          `json:"time"`
	Price        decimal.Decimal `json:"price"`
}

type RouterResult

type RouterResult struct {
	ChainId               string          `json:"chainId"`
	ChainIndex            string          `json:"chainIndex"`
	DexRouterList         []DexRouter     `json:"dexRouterList"`
	EstimateGasFee        decimal.Decimal `json:"estimateGasFee"`
	FromToken             Token           `json:"fromToken"`
	FromTokenAmount       decimal.Decimal `json:"fromTokenAmount"`
	PriceImpactPercentage decimal.Decimal `json:"priceImpactPercentage"`
	QuoteCompareList      []Quote         `json:"quoteCompareList"`
	SwapMode              string          `json:"swapMode"`
	ToToken               Token           `json:"toToken"`
	ToTokenAmount         decimal.Decimal `json:"toTokenAmount"`
	TradeFee              decimal.Decimal `json:"tradeFee"`
}

type SubRouter

type SubRouter struct {
	DexProtocol []DexProtocol `json:"dexProtocol"`
	FromToken   Token         `json:"fromToken"`
	ToToken     Token         `json:"toToken"`
}

type SwapInstruction

type SwapInstruction struct {
	AddressLookupTableAccount []string      `json:"addressLookupTableAccount"`
	InstructionLists          []Instruction `json:"instructionLists"`
	RouterResult              RouterResult  `json:"routerResult"`
	Tx                        Transaction   `json:"tx"`
}

type Token

type Token struct {
	Decimal              decimal.Decimal `json:"decimal"`
	IsHoneyPot           bool            `json:"isHoneyPot"`
	TaxRate              decimal.Decimal `json:"taxRate"`
	TokenContractAddress string          `json:"tokenContractAddress"`
	TokenSymbol          string          `json:"tokenSymbol"`
	TokenUnitPrice       decimal.Decimal `json:"tokenUnitPrice"`
}

type TokenAssets

type TokenAssets struct {
	TokenAssets []TokenBalance `json:"tokenAssets"`
}

type TokenBalance

type TokenBalance struct {
	ChainIndex           string          `json:"chainIndex"`
	TokenContractAddress string          `json:"tokenContractAddress"`
	Symbol               string          `json:"symbol"`
	Balance              decimal.Decimal `json:"balance"`
	TokenPrice           decimal.Decimal `json:"tokenPrice"`
	IsRiskToken          bool            `json:"isRiskToken"`
	RawBalance           string          `json:"rawBalance"`
	Address              string          `json:"address"`
}

type Transaction

type Transaction struct {
	From             string          `json:"from"`
	MinReceiveAmount decimal.Decimal `json:"minReceiveAmount"`
	Slippage         decimal.Decimal `json:"slippage"`
	To               string          `json:"to"`
}

Jump to

Keyboard shortcuts

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