Documentation
¶
Index ¶
- type Go100XAPIClient
- func (go100XClient *Go100XAPIClient) ApproveSigner(params *types.ApproveRevokeSignerRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ApproveUSDB(ctx context.Context, amount *big.Int) (*geth_types.Transaction, error)
- func (go100XClient *Go100XAPIClient) CancelAllOpenOrders(product *types.Product) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) CancelOrder(params *types.CancelOrderRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) CancelOrderAndReplace(params *types.CancelOrderAndReplaceRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) DepositUSDB(ctx context.Context, amount *big.Int) (*geth_types.Transaction, error)
- func (go100XClient *Go100XAPIClient) Get24hrPriceChangeStatistics(product *types.Product) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) GetKlineData(params *types.KlineDataRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) GetPerpetualPosition(product *types.Product) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) GetPerpetualPositionAllProducts() (*http.Response, error)
- func (go100XClient *Go100XAPIClient) GetProduct(symbol string) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) GetProductById(id int64) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) GetSpotBalances() (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ListApprovedSigners() (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ListOpenOrders(product *types.Product) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ListOpenOrdersAllProducts() (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ListOrders(params *types.ListOrdersRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ListOrdersAllProducts(ids []string) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ListProducts() (*http.Response, error)
- func (go100XClient *Go100XAPIClient) NewOrder(params *types.NewOrderRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) OrderBook(params *types.OrderBookRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) RevokeSigner(params *types.ApproveRevokeSignerRequest) (*http.Response, error)
- func (go100XClient *Go100XAPIClient) ServerTime() (*http.Response, error)
- func (go100XClient *Go100XAPIClient) WaitTransaction(ctx context.Context, transaction *geth_types.Transaction) (*geth_types.Receipt, error)
- func (go100XClient *Go100XAPIClient) Withdraw(params *types.WithdrawRequest) (*http.Response, error)
- type Go100XAPIClientConfiguration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Go100XAPIClient ¶
type Go100XAPIClient struct { SubAccountId int64 // Subaccount ID. HttpClient *http.Client // HTTP client for making requests. EthClient types.IEthClient // Ethereum client for interacting with the blockchain. // contains filtered or unexported fields }
Go100XAPIClient is the main client for interacting with the 100X API.
func NewGo100XAPIClient ¶
func NewGo100XAPIClient(config *Go100XAPIClientConfiguration) (*Go100XAPIClient, error)
NewGo100XAPIClient creates a new Go100XAPIClient instance. Initializes the client with the provided configuration.
Parameters:
- config: A pointer to Go100XAPIClientConfiguration containing the configuration settings.
Returns:
- A pointer to Go100XAPIClient.
- An error if initialization fails.
func (*Go100XAPIClient) ApproveSigner ¶
func (go100XClient *Go100XAPIClient) ApproveSigner(params *types.ApproveRevokeSignerRequest) (*http.Response, error)
ApproveSigner approves a Signer for a SubAccount. This operation allows the specified Signer to sign transactions on behalf of the SubAccount.
Params:
- params: An instance of types.ApproveRevokeSignerRequest containing the necessary parameters for approving the signer.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ApproveUSDB ¶
func (go100XClient *Go100XAPIClient) ApproveUSDB(ctx context.Context, amount *big.Int) (*geth_types.Transaction, error)
ApproveUSDB approves 100x to spend USDB on your behalf.
Parameters:
- ctx: The context.Context for the Ethereum transaction.
- amount: The amount of USDB tokens to approve, specified as a *big.Int.
Returns:
- A pointer to a geth_types.Transaction representing the Ethereum transaction.
- An error if the Ethereum transaction fails or encounters an issue.
func (*Go100XAPIClient) CancelAllOpenOrders ¶
func (go100XClient *Go100XAPIClient) CancelAllOpenOrders(product *types.Product) (*http.Response, error)
CancelAllOpenOrders cancels all active orders on a specific product for the SubAccount.
Params:
- product: The product for which all active orders should be canceled.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) CancelOrder ¶
func (go100XClient *Go100XAPIClient) CancelOrder(params *types.CancelOrderRequest) (*http.Response, error)
CancelOrder cancels an active order on the SubAccount.
Params:
- params: An instance of types.CancelOrderRequest containing the necessary parameters to identify the order to cancel.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) CancelOrderAndReplace ¶
func (go100XClient *Go100XAPIClient) CancelOrderAndReplace(params *types.CancelOrderAndReplaceRequest) (*http.Response, error)
CancelOrderAndReplace cancels an order and creates a new order on the SubAccount.
Params:
- params: An instance of types.CancelOrderAndReplaceRequest containing the necessary parameters to identify the order to cancel and the new order parameters.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) DepositUSDB ¶
func (go100XClient *Go100XAPIClient) DepositUSDB(ctx context.Context, amount *big.Int) (*geth_types.Transaction, error)
DepositUSDB sends USDB to 100x.
Parameters:
- ctx: The context.Context for the Ethereum transaction.
- amount: The amount of USDB tokens to deposit, specified as a *big.Int.
Returns:
- A pointer to a geth_types.Transaction representing the Ethereum transaction.
- An error if the Ethereum transaction fails or encounters an issue.
func (*Go100XAPIClient) Get24hrPriceChangeStatistics ¶
func (go100XClient *Go100XAPIClient) Get24hrPriceChangeStatistics(product *types.Product) (*http.Response, error)
Get24hrPriceChangeStatistics returns 24-hour rolling window price change statistics. These statistics do not reflect the UTC day, but rather a 24-hour rolling window for the previous 24 hours. If no `Product` is provided, ticker data for all assets will be returned.
Parameters:
- product: A pointer to a Product struct for which the statistics are being retrieved. If nil, ticker data for all assets will be returned.
Returns:
- A pointer to an http.Response containing the response from the server.
- An error if the request fails.
func (*Go100XAPIClient) GetKlineData ¶
func (go100XClient *Go100XAPIClient) GetKlineData(params *types.KlineDataRequest) (*http.Response, error)
GetKlineData retrieves Kline/Candlestick bars for a symbol based on the provided parameters.
Parameters:
- params: A pointer to a KlineDataRequest struct containing the parameters for the request, including symbol, interval (timeframe), startTime, and optional endTime.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) GetPerpetualPosition ¶
func (go100XClient *Go100XAPIClient) GetPerpetualPosition(product *types.Product) (*http.Response, error)
GetPerpetualPosition retrieves the perpetual position for a specific product and SubAccount.
Parameters:
- product: The product for which the perpetual position is requested.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) GetPerpetualPositionAllProducts ¶ added in v1.1.1
func (go100XClient *Go100XAPIClient) GetPerpetualPositionAllProducts() (*http.Response, error)
GetPerpetualPositionAllProducts retrieves the perpetual position for all products for a SubAccount.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) GetProduct ¶
func (go100XClient *Go100XAPIClient) GetProduct(symbol string) (*http.Response, error)
GetProduct returns details for a specific product by its symbol.
Parameters:
- symbol: The symbol of the product for which details are being retrieved.
Returns:
- A pointer to an http.Response containing the response from the server with product details.
- An error if the request fails.
func (*Go100XAPIClient) GetProductById ¶
func (go100XClient *Go100XAPIClient) GetProductById(id int64) (*http.Response, error)
GetProductById retrieves details for a specific product by its unique identifier.
Parameters:
- id: The ID of the product.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) GetSpotBalances ¶
func (go100XClient *Go100XAPIClient) GetSpotBalances() (*http.Response, error)
GetSpotBalances retrieves spot balances for the SubAccount.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ListApprovedSigners ¶
func (go100XClient *Go100XAPIClient) ListApprovedSigners() (*http.Response, error)
ListApprovedSigners retrieves a list of all approved signers for a specific `SubAccount`.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ListOpenOrders ¶
ListOpenOrders retrieves all open orders on the `SubAccount` for a specific product.
Parameters:
- product: A pointer to a `types.Product` struct representing the product for which open orders are to be retrieved.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ListOpenOrdersAllProducts ¶ added in v1.1.1
func (go100XClient *Go100XAPIClient) ListOpenOrdersAllProducts() (*http.Response, error)
ListOpenOrdersAllProducts retrieves all open orders on the `SubAccount` for a all products.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ListOrders ¶
func (go100XClient *Go100XAPIClient) ListOrders(params *types.ListOrdersRequest) (*http.Response, error)
ListOrders retrieves all orders on the `SubAccount` for a specific product.
Parameters:
- params: A pointer to a `types.ListOrdersRequest` struct containing parameters for listing orders.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ListOrdersAllProducts ¶ added in v1.1.1
func (go100XClient *Go100XAPIClient) ListOrdersAllProducts(ids []string) (*http.Response, error)
ListOrders retrieves all orders on the `SubAccount` for a specific product.
Parameters:
- params: A pointer to a `types.ListOrdersRequest` struct containing parameters for listing orders.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ListProducts ¶
func (go100XClient *Go100XAPIClient) ListProducts() (*http.Response, error)
ListProducts retrieves a list of products available for trading on the platform.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) NewOrder ¶
func (go100XClient *Go100XAPIClient) NewOrder(params *types.NewOrderRequest) (*http.Response, error)
NewOrder creates a new order on the SubAccount.
Params:
- params: An instance of types.NewOrderRequest containing the order parameters, including the order type (limit/market), quantity, side (buy/sell), price, and symbol.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) OrderBook ¶
func (go100XClient *Go100XAPIClient) OrderBook(params *types.OrderBookRequest) (*http.Response, error)
OrderBook retrieves the order book (bids and asks) for a specific market.
Parameters:
- params: A pointer to an OrderBookRequest struct containing the parameters for the request.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) RevokeSigner ¶
func (go100XClient *Go100XAPIClient) RevokeSigner(params *types.ApproveRevokeSignerRequest) (*http.Response, error)
RevokeSigner revokes a Signer for a SubAccount. This operation disables the specified Signer from signing transactions on behalf of the SubAccount.
Params:
- params: An instance of types.ApproveRevokeSignerRequest containing the necessary parameters for revoking the signer.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) ServerTime ¶
func (go100XClient *Go100XAPIClient) ServerTime() (*http.Response, error)
ServerTime retrieves the current server time from the API.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
func (*Go100XAPIClient) WaitTransaction ¶
func (go100XClient *Go100XAPIClient) WaitTransaction(ctx context.Context, transaction *geth_types.Transaction) (*geth_types.Receipt, error)
WaitTransaction waits for a transaction to be mined and returns its receipt.
Parameters:
- ctx: The context.Context for the Ethereum transaction.
- transaction: The Ethereum transaction (*geth_types.Transaction) to monitor.
Returns:
- A pointer to a geth_types.Receipt containing the transaction receipt once the transaction is mined.
- An error if the transaction fails to be mined or encounters an issue.
func (*Go100XAPIClient) Withdraw ¶
func (go100XClient *Go100XAPIClient) Withdraw(params *types.WithdrawRequest) (*http.Response, error)
Withdraw initiates a withdrawal of USDB from the 100x account.
Params:
- params: An instance of types.WithdrawRequest containing the withdrawal parameters, including the withdrawal amount and destination address.
Returns:
- A pointer to an http.Response containing the response from the API call.
- An error if the API call fails or if the response is not as expected.
type Go100XAPIClientConfiguration ¶
type Go100XAPIClientConfiguration struct { Env types.Environment // `constants.ENVIRONMENT_TESTNET` or `constants.ENVIRONMENT_MAINNET`. PrivateKey string // Private key as a string, e.g., `0x2638b4...` or `2638b4...`. RpcUrl string // RPC URL of the Ethereum client, e.g., `https://sepolia.blast.io` or `https://rpc.blastblockchain.com`. SubAccountId uint8 // ID of the subaccount to use. }
Go100XAPIClientConfiguration holds the configuration for the Go100X API client.