Documentation
¶
Index ¶
- Constants
- Variables
- type APIResponse
- type CreateAPIKeyData
- type CreateAPIKeyRequest
- type DepositAsset
- type DepositPerpClient
- func (c *DepositPerpClient) GetDepositAssets(params GetDepositAssetsParams) ([]DepositAsset, error)
- func (c *DepositPerpClient) GetDepositAssetsByChainID(chainID int, networks ...string) ([]DepositAsset, error)
- func (c *DepositPerpClient) GetDepositAssetsEVM(chainIDs ...int) ([]DepositAsset, error)
- func (c *DepositPerpClient) GetDepositAssetsSolana() ([]DepositAsset, error)
- type DepositSpotClient
- func (c *DepositSpotClient) GetDepositAssets(params GetDepositAssetsParams) ([]DepositAsset, error)
- func (c *DepositSpotClient) GetDepositAssetsByChainID(chainID int, networks ...string) ([]DepositAsset, error)
- func (c *DepositSpotClient) GetDepositAssetsEVM(chainIDs ...int) ([]DepositAsset, error)
- func (c *DepositSpotClient) GetDepositAssetsSolana() ([]DepositAsset, error)
- type EstimateWithdrawFeeParams
- type GetDepositAssetsParams
- type GetNonceData
- type GetNonceRequest
- type GetWithdrawAssetsParams
- type LoginData
- type LoginRequest
- type RegisterClient
- func (c *RegisterClient) CreateAPIKey(desc, network, signature, sourceAddr, ip, sourceCode string) (apiKey, apiSecret string, keyID int64, err error)
- func (c *RegisterClient) FormatSignatureMessage(nonce string) string
- func (c *RegisterClient) GetNonce(sourceAddr string, requestType RegisterType) (string, error)
- func (c *RegisterClient) Login(signature, sourceAddr string, chainID int, agentCode string) (string, int64, error)
- type RegisterType
- type WithdrawAPIParams
- type WithdrawAsset
- type WithdrawFeeEstimate
- type WithdrawRequest
- type WithdrawResponse
- type WithdrawSolanaParams
- type WithdrawlPerpClient
- func (c *WithdrawlPerpClient) EstimateWithdrawFee(params EstimateWithdrawFeeParams) (*WithdrawFeeEstimate, error)
- func (c *WithdrawlPerpClient) GetWithdrawAssets(params GetWithdrawAssetsParams) ([]WithdrawAsset, error)
- func (c *WithdrawlPerpClient) GetWithdrawAssetsByChainID(chainID int, networks ...string) ([]WithdrawAsset, error)
- func (c *WithdrawlPerpClient) GetWithdrawAssetsEVM(chainIDs ...int) ([]WithdrawAsset, error)
- func (c *WithdrawlPerpClient) GetWithdrawAssetsSolana() ([]WithdrawAsset, error)
- func (c *WithdrawlPerpClient) WithdrawAPI(params WithdrawAPIParams) (*WithdrawResponse, error)
- func (c *WithdrawlPerpClient) WithdrawPrivate(req WithdrawRequest) (*WithdrawResponse, error)
- func (c *WithdrawlPerpClient) WithdrawSolana(params WithdrawSolanaParams) (*WithdrawResponse, error)
- type WithdrawlSpotClient
- func (c *WithdrawlSpotClient) EstimateWithdrawFee(params EstimateWithdrawFeeParams) (*WithdrawFeeEstimate, error)
- func (c *WithdrawlSpotClient) GetWithdrawAssets(params GetWithdrawAssetsParams) ([]WithdrawAsset, error)
- func (c *WithdrawlSpotClient) GetWithdrawAssetsByChainID(chainID int, networks ...string) ([]WithdrawAsset, error)
- func (c *WithdrawlSpotClient) GetWithdrawAssetsEVM(chainIDs ...int) ([]WithdrawAsset, error)
- func (c *WithdrawlSpotClient) GetWithdrawAssetsSolana() ([]WithdrawAsset, error)
- func (c *WithdrawlSpotClient) WithdrawAPI(params WithdrawAPIParams) (*WithdrawResponse, error)
- func (c *WithdrawlSpotClient) WithdrawPrivate(req WithdrawRequest) (*WithdrawResponse, error)
Constants ¶
const ( AccountTypeSpot = "spot" AccountTypePerp = "perp" )
AccountType constants
const ( NetworkEVM = "EVM" NetworkSolana = "SOLANA" )
Network constants
const ( ChainIDEthereum = 1 ChainIDBSC = 56 ChainIDArbitrum = 42161 ChainIDSolana = 101 )
ChainID constants
const ( SourceCodeAE = "ae" SourceCodeBroker = "broker" )
Source codes for API key creation
Variables ¶
var ChainIDToName = map[int]string{ ChainIDEthereum: "ETH", ChainIDBSC: "BSC", ChainIDArbitrum: "Arbitrum", }
ChainName mapping for EIP712 signatures
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse[T any] struct { Code string `json:"code"` Message string `json:"message"` MessageDetail string `json:"messageDetail"` Data T `json:"data"` Success bool `json:"success"` }
APIResponse is the common response structure for all API calls
type CreateAPIKeyData ¶
type CreateAPIKeyData struct {
APIKey string `json:"apiKey"`
APISecret string `json:"apiSecret"`
KeyID int64 `json:"keyId"`
APIName *string `json:"apiName"`
}
CreateAPIKeyData represents the API key creation response data
type CreateAPIKeyRequest ¶
type CreateAPIKeyRequest struct {
Desc string `json:"desc"`
IP string `json:"ip,omitempty"`
Network string `json:"network"`
Signature string `json:"signature"`
SourceAddr string `json:"sourceAddr"`
Type string `json:"type"`
SourceCode string `json:"sourceCode,omitempty"`
}
CreateAPIKeyRequest represents a request to create an API key
type DepositAsset ¶
type DepositAsset struct {
Name string `json:"name"`
DisplayName string `json:"displayName"`
ContractAddress string `json:"contractAddress"`
Decimals int `json:"decimals"`
Network string `json:"network"`
ChainID int `json:"chainId"`
DepositType string `json:"depositType"`
Rank int `json:"rank"`
IsNative bool `json:"isNative"`
Admin *string `json:"admin"`
Bank *string `json:"bank"`
TokenVaultAuthority *string `json:"tokenVaultAuthority"`
TokenVault *string `json:"tokenVault"`
TokenMint *string `json:"tokenMint"`
AssociatedTokenProgram *string `json:"associatedTokenProgram"`
TokenProgram *string `json:"tokenProgram"`
SystemProgram *string `json:"systemProgram"`
IxSysvar *string `json:"ixSysvar"`
PriceFeed *string `json:"priceFeed"`
PriceFeedProgram *string `json:"priceFeedProgram"`
SolVault *string `json:"solVault"`
}
DepositAsset represents a deposit asset configuration
type DepositPerpClient ¶
type DepositPerpClient struct {
// contains filtered or unexported fields
}
DepositPerpClient handles perpetual account deposit operations
func NewDepositPerpClient ¶
func NewDepositPerpClient() *DepositPerpClient
NewDepositPerpClient creates a new deposit perpetual client
func NewDepositPerpClientWithHTTP ¶
func NewDepositPerpClientWithHTTP(client *http.Client) *DepositPerpClient
NewDepositPerpClientWithHTTP creates a new deposit perpetual client with custom HTTP client
func (*DepositPerpClient) GetDepositAssets ¶
func (c *DepositPerpClient) GetDepositAssets(params GetDepositAssetsParams) ([]DepositAsset, error)
GetDepositAssets retrieves all available deposit assets for perpetual account
func (*DepositPerpClient) GetDepositAssetsByChainID ¶
func (c *DepositPerpClient) GetDepositAssetsByChainID(chainID int, networks ...string) ([]DepositAsset, error)
GetDepositAssetsByChainID is a convenience method to get deposit assets for a single chain
func (*DepositPerpClient) GetDepositAssetsEVM ¶
func (c *DepositPerpClient) GetDepositAssetsEVM(chainIDs ...int) ([]DepositAsset, error)
GetDepositAssetsEVM gets deposit assets for EVM networks
func (*DepositPerpClient) GetDepositAssetsSolana ¶
func (c *DepositPerpClient) GetDepositAssetsSolana() ([]DepositAsset, error)
GetDepositAssetsSolana gets deposit assets for Solana network
type DepositSpotClient ¶
type DepositSpotClient struct {
// contains filtered or unexported fields
}
DepositSpotClient handles spot account deposit operations
func NewDepositSpotClient ¶
func NewDepositSpotClient() *DepositSpotClient
NewDepositSpotClient creates a new deposit spot client
func NewDepositSpotClientWithHTTP ¶
func NewDepositSpotClientWithHTTP(client *http.Client) *DepositSpotClient
NewDepositSpotClientWithHTTP creates a new deposit spot client with custom HTTP client
func (*DepositSpotClient) GetDepositAssets ¶
func (c *DepositSpotClient) GetDepositAssets(params GetDepositAssetsParams) ([]DepositAsset, error)
GetDepositAssets retrieves all available deposit assets for spot account
func (*DepositSpotClient) GetDepositAssetsByChainID ¶
func (c *DepositSpotClient) GetDepositAssetsByChainID(chainID int, networks ...string) ([]DepositAsset, error)
GetDepositAssetsByChainID is a convenience method to get deposit assets for a single chain
func (*DepositSpotClient) GetDepositAssetsEVM ¶
func (c *DepositSpotClient) GetDepositAssetsEVM(chainIDs ...int) ([]DepositAsset, error)
GetDepositAssetsEVM gets deposit assets for EVM networks
func (*DepositSpotClient) GetDepositAssetsSolana ¶
func (c *DepositSpotClient) GetDepositAssetsSolana() ([]DepositAsset, error)
GetDepositAssetsSolana gets deposit assets for Solana network
type EstimateWithdrawFeeParams ¶
type EstimateWithdrawFeeParams struct {
ChainID int // Required: Chain ID
Network string // Required: Network type (e.g., EVM, SOLANA)
Currency string // Required: Currency name (e.g., ASTER)
}
EstimateWithdrawFeeParams represents parameters for estimating withdrawal fee
type GetDepositAssetsParams ¶
type GetDepositAssetsParams struct {
ChainIDs []int // Required: Chain IDs
Networks []string // Optional: Network types (e.g., EVM, SOLANA)
}
GetDepositAssetsParams represents parameters for getting deposit assets
type GetNonceData ¶
type GetNonceData struct {
Nonce string `json:"nonce"`
}
GetNonceData represents the nonce data in the response
type GetNonceRequest ¶
GetNonceRequest represents a request to get a nonce for registration
type GetWithdrawAssetsParams ¶
type GetWithdrawAssetsParams struct {
ChainIDs []int // Required: Chain IDs
Networks []string // Optional: Network types (e.g., EVM, SOLANA)
}
GetWithdrawAssetsParams represents parameters for getting withdraw assets
type LoginRequest ¶
type LoginRequest struct {
Signature string `json:"signature"`
SourceAddr string `json:"sourceAddr"`
ChainID int `json:"chainId"`
AgentCode string `json:"agentCode,omitempty"`
}
LoginRequest represents a login request
type RegisterClient ¶
type RegisterClient struct {
// contains filtered or unexported fields
}
RegisterClient handles API key registration operations
func NewRegisterClient ¶
func NewRegisterClient() *RegisterClient
NewRegisterClient creates a new registration client
func NewRegisterClientWithHTTP ¶
func NewRegisterClientWithHTTP(client *http.Client) *RegisterClient
NewRegisterClientWithHTTP creates a new registration client with custom HTTP client
func (*RegisterClient) CreateAPIKey ¶
func (c *RegisterClient) CreateAPIKey(desc, network, signature, sourceAddr, ip, sourceCode string) (apiKey, apiSecret string, keyID int64, err error)
CreateAPIKey creates a new API key pair for programmatic access to Asterdex IMPORTANT: The returned apiKey and apiSecret cannot be retrieved later, so save them securely Parameters:
- desc: Description for the API key (must be unique)
- network: Blockchain network (e.g., "56" for BSC)
- signature: The signature from signing the nonce message
- sourceAddr: The wallet address that signed the message
- ip: Optional comma-separated whitelist of IP addresses
- sourceCode: Optional source code ("ae" for Aster, other values for broker)
Returns:
- apiKey: The API key for authentication
- apiSecret: The API secret for signing requests (save this securely!)
- keyID: The unique ID for this API key
- error: Any error that occurred during the request
func (*RegisterClient) FormatSignatureMessage ¶
func (c *RegisterClient) FormatSignatureMessage(nonce string) string
FormatSignatureMessage formats the message that needs to be signed by the user's wallet The user must sign this message with their wallet to proceed with registration Parameters:
- nonce: The nonce returned from GetNonce()
Returns:
- The formatted message string: "You are signing into Astherus {nonce}"
func (*RegisterClient) GetNonce ¶
func (c *RegisterClient) GetNonce(sourceAddr string, requestType RegisterType) (string, error)
GetNonce retrieves a nonce for API key creation The nonce is used to generate a message that needs to be signed by the user's wallet Parameters:
- sourceAddr: The wallet address that will sign the message
- requestType: The type of registration request (LOGIN or CREATE_API_KEY)
Returns:
- nonce: A string nonce to be used in the signature message
- error: Any error that occurred during the request
func (*RegisterClient) Login ¶
func (c *RegisterClient) Login(signature, sourceAddr string, chainID int, agentCode string) (string, int64, error)
Login authenticates a user with their wallet signature and returns an auth token This step is optional - you can directly use CreateAPIKey with the signature Parameters:
- signature: The signature from signing the message
- sourceAddr: The wallet address that signed the message
- chainID: The blockchain network ID (e.g., 56 for BSC)
- agentCode: Optional referral code
Returns:
- token: Authentication token for future API calls
- uid: User ID
- error: Any error that occurred during the request
type RegisterType ¶
type RegisterType string
const ( RegisterTypeLogin RegisterType = "LOGIN" RegisterTypeCreateAPIKey RegisterType = "CREATE_API_KEY" )
type WithdrawAPIParams ¶
type WithdrawAPIParams struct {
ChainID int // Required: Chain ID
Asset string // Required: Asset name (e.g., ASTER)
Amount string // Required: Amount to withdraw
Fee string // Required: Withdrawal fee
Receiver string // Required: Receiver address
Nonce string // Required: Unique nonce (for EVM chains)
UserSignature string // Required: EIP712 signature (for EVM chains)
RecvWindow int64 // Optional: Request validity window in milliseconds (default: 60000)
}
WithdrawAPIParams represents parameters for API-based withdrawal
type WithdrawAsset ¶
type WithdrawAsset struct {
Name string `json:"name"`
DisplayName string `json:"displayName"`
ContractAddress string `json:"contractAddress"`
Decimals int `json:"decimals"`
Network string `json:"network"`
ChainID int `json:"chainId"`
WithdrawType string `json:"withdrawType"`
Rank int `json:"rank"`
IsNative bool `json:"isNative"`
IsProfit bool `json:"isProfit"`
Admin *string `json:"admin"`
Bank *string `json:"bank"`
TokenVaultAuthority *string `json:"tokenVaultAuthority"`
TokenVault *string `json:"tokenVault"`
TokenMint *string `json:"tokenMint"`
AssociatedTokenProgram *string `json:"associatedTokenProgram"`
TokenProgram *string `json:"tokenProgram"`
SystemProgram *string `json:"systemProgram"`
IxSysvar *string `json:"ixSysvar"`
PriceFeed *string `json:"priceFeed"`
PriceFeedProgram *string `json:"priceFeedProgram"`
SolVault *string `json:"solVault"`
}
WithdrawAsset represents a withdraw asset configuration
type WithdrawFeeEstimate ¶
type WithdrawFeeEstimate struct {
GasPrice *float64 `json:"gasPrice"`
GasLimit int `json:"gasLimit"`
NativePrice *float64 `json:"nativePrice"`
TokenPrice float64 `json:"tokenPrice"`
GasCost float64 `json:"gasCost"`
GasUSDValue float64 `json:"gasUsdValue"`
}
WithdrawFeeEstimate represents the estimated withdrawal fee
type WithdrawRequest ¶
type WithdrawRequest struct {
AccountType string `json:"accountType,omitempty"` // spot or perp (not used for API withdrawals)
Amount string `json:"amount"`
ChainID int `json:"chainId"`
Currency string `json:"currency,omitempty"` // Used for bapi endpoint
Asset string `json:"asset,omitempty"` // Used for API endpoint
Fee string `json:"fee"`
Nonce string `json:"nonce,omitempty"` // Required for EVM chains
Receiver string `json:"receiver"`
UserSignature string `json:"userSignature,omitempty"` // Required for EVM chains
}
WithdrawRequest represents a withdrawal request
type WithdrawResponse ¶
WithdrawResponse represents the withdrawal response
type WithdrawSolanaParams ¶
type WithdrawSolanaParams struct {
ChainID int // Required: Must be 101 for Solana
Asset string // Required: Asset name (e.g., USDT)
Amount string // Required: Amount to withdraw
Fee string // Required: Withdrawal fee
Receiver string // Required: Solana receiver address
RecvWindow int64 // Optional: Request validity window in milliseconds (default: 60000)
}
WithdrawSolanaParams represents parameters for Solana withdrawal
type WithdrawlPerpClient ¶
type WithdrawlPerpClient struct {
// contains filtered or unexported fields
}
WithdrawlPerpClient handles perpetual account withdrawal operations
func NewWithdrawlPerpClient ¶
func NewWithdrawlPerpClient() *WithdrawlPerpClient
NewWithdrawlPerpClient creates a new withdrawal perpetual client for public endpoints
func NewWithdrawlPerpClientWithAuth ¶
func NewWithdrawlPerpClientWithAuth(apiKey, secretKey string) *WithdrawlPerpClient
NewWithdrawlPerpClientWithAuth creates a new withdrawal perpetual client with API credentials
func NewWithdrawlPerpClientWithHTTP ¶
func NewWithdrawlPerpClientWithHTTP(client *http.Client, apiKey, secretKey string) *WithdrawlPerpClient
NewWithdrawlPerpClientWithHTTP creates a new withdrawal perpetual client with custom HTTP client
func (*WithdrawlPerpClient) EstimateWithdrawFee ¶
func (c *WithdrawlPerpClient) EstimateWithdrawFee(params EstimateWithdrawFeeParams) (*WithdrawFeeEstimate, error)
EstimateWithdrawFee estimates the withdrawal fee for a given asset
func (*WithdrawlPerpClient) GetWithdrawAssets ¶
func (c *WithdrawlPerpClient) GetWithdrawAssets(params GetWithdrawAssetsParams) ([]WithdrawAsset, error)
GetWithdrawAssets retrieves all available withdraw assets for perpetual account
func (*WithdrawlPerpClient) GetWithdrawAssetsByChainID ¶
func (c *WithdrawlPerpClient) GetWithdrawAssetsByChainID(chainID int, networks ...string) ([]WithdrawAsset, error)
GetWithdrawAssetsByChainID is a convenience method to get withdraw assets for a single chain
func (*WithdrawlPerpClient) GetWithdrawAssetsEVM ¶
func (c *WithdrawlPerpClient) GetWithdrawAssetsEVM(chainIDs ...int) ([]WithdrawAsset, error)
GetWithdrawAssetsEVM gets withdraw assets for EVM networks
func (*WithdrawlPerpClient) GetWithdrawAssetsSolana ¶
func (c *WithdrawlPerpClient) GetWithdrawAssetsSolana() ([]WithdrawAsset, error)
GetWithdrawAssetsSolana gets withdraw assets for Solana network
func (*WithdrawlPerpClient) WithdrawAPI ¶
func (c *WithdrawlPerpClient) WithdrawAPI(params WithdrawAPIParams) (*WithdrawResponse, error)
WithdrawAPI performs a withdrawal using the futures API endpoint with API key authentication This is for EVM chains and requires API key/secret
func (*WithdrawlPerpClient) WithdrawPrivate ¶
func (c *WithdrawlPerpClient) WithdrawPrivate(req WithdrawRequest) (*WithdrawResponse, error)
WithdrawPrivate performs a withdrawal using the private bapi endpoint with user signature This requires an EIP712 signature from the user's wallet
func (*WithdrawlPerpClient) WithdrawSolana ¶
func (c *WithdrawlPerpClient) WithdrawSolana(params WithdrawSolanaParams) (*WithdrawResponse, error)
WithdrawSolana performs a withdrawal to Solana network using the futures API
type WithdrawlSpotClient ¶
type WithdrawlSpotClient struct {
// contains filtered or unexported fields
}
WithdrawlSpotClient handles spot account withdrawal operations
func NewWithdrawlSpotClient ¶
func NewWithdrawlSpotClient() *WithdrawlSpotClient
NewWithdrawlSpotClient creates a new withdrawal spot client for public endpoints
func NewWithdrawlSpotClientWithAuth ¶
func NewWithdrawlSpotClientWithAuth(apiKey, secretKey string) *WithdrawlSpotClient
NewWithdrawlSpotClientWithAuth creates a new withdrawal spot client with API credentials
func NewWithdrawlSpotClientWithHTTP ¶
func NewWithdrawlSpotClientWithHTTP(client *http.Client, apiKey, secretKey string) *WithdrawlSpotClient
NewWithdrawlSpotClientWithHTTP creates a new withdrawal spot client with custom HTTP client
func (*WithdrawlSpotClient) EstimateWithdrawFee ¶
func (c *WithdrawlSpotClient) EstimateWithdrawFee(params EstimateWithdrawFeeParams) (*WithdrawFeeEstimate, error)
EstimateWithdrawFee estimates the withdrawal fee for a given asset
func (*WithdrawlSpotClient) GetWithdrawAssets ¶
func (c *WithdrawlSpotClient) GetWithdrawAssets(params GetWithdrawAssetsParams) ([]WithdrawAsset, error)
GetWithdrawAssets retrieves all available withdraw assets for spot account
func (*WithdrawlSpotClient) GetWithdrawAssetsByChainID ¶
func (c *WithdrawlSpotClient) GetWithdrawAssetsByChainID(chainID int, networks ...string) ([]WithdrawAsset, error)
GetWithdrawAssetsByChainID is a convenience method to get withdraw assets for a single chain
func (*WithdrawlSpotClient) GetWithdrawAssetsEVM ¶
func (c *WithdrawlSpotClient) GetWithdrawAssetsEVM(chainIDs ...int) ([]WithdrawAsset, error)
GetWithdrawAssetsEVM gets withdraw assets for EVM networks
func (*WithdrawlSpotClient) GetWithdrawAssetsSolana ¶
func (c *WithdrawlSpotClient) GetWithdrawAssetsSolana() ([]WithdrawAsset, error)
GetWithdrawAssetsSolana gets withdraw assets for Solana network
func (*WithdrawlSpotClient) WithdrawAPI ¶
func (c *WithdrawlSpotClient) WithdrawAPI(params WithdrawAPIParams) (*WithdrawResponse, error)
WithdrawAPI performs a withdrawal using the spot API endpoint with API key authentication This is for EVM chains and requires API key/secret
func (*WithdrawlSpotClient) WithdrawPrivate ¶
func (c *WithdrawlSpotClient) WithdrawPrivate(req WithdrawRequest) (*WithdrawResponse, error)
WithdrawPrivate performs a withdrawal using the private bapi endpoint with user signature This requires an EIP712 signature from the user's wallet