444 lines
11 KiB
Go
444 lines
11 KiB
Go
|
package bybit_connector
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"encoding/json"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type AssetClient struct {
|
||
|
c *Client
|
||
|
params map[string]interface{}
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetAssetOrderRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/exchange/order-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetAssetInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-asset-info",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetDeliveryRecord(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/delivery-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetUsdcSettlement(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/settlement-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetAllCoinsBalance(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-account-coins-balance",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetSingleCoinsBalance(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-account-coin-balance",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetTransferableCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-transfer-coin-list",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) CreateInternalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/asset/transfer/inter-transfer",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) CreateUniversalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/asset/transfer/universal-transfer",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) SetDepositAccount(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/asset/deposit/deposit-to-account",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) WithdrawAsset(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/asset/withdraw/create",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) CancelWithdrawAsset(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/asset/withdraw/cancel",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetInternalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-inter-transfer-list",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetUniversalTransfer(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-universal-transfer-list",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetSubUids(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/transfer/query-sub-member-list",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetAllowedDepositCoin(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/deposit/query-allowed-list",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/deposit/query-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetSubDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/deposit/query-sub-member-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetInternalDepositRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/deposit/query-internal-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetMasterDepositAddress(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/deposit/query-address",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetSubDepositAddress(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/deposit/query-sub-member-address",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetCoinInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/coin/query-info",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
|
||
|
func (s *AssetClient) GetWithdrawalAmount(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/withdraw/withdrawable-amount",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|
||
|
func (s *AssetClient) GetWithdrawalRecords(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/asset/withdraw/query-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
data, err := s.c.callAPI(ctx, r, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
res = new(ServerResponse)
|
||
|
err = json.Unmarshal(data, res)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return res, nil
|
||
|
}
|