123 lines
2.9 KiB
Go
123 lines
2.9 KiB
Go
|
package bybit_connector
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/wuhewuhe/bybit.go.api/handlers"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type SpotLeverageClient struct {
|
||
|
c *Client
|
||
|
params map[string]interface{}
|
||
|
}
|
||
|
|
||
|
func (s *SpotLeverageClient) GetLeverageTokenInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
if err = handlers.ValidateParams(s.params); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/spot-lever-token/info",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
r.setParams(s.params)
|
||
|
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 *SpotLeverageClient) GetLeverageTokenOrders(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
if err = handlers.ValidateParams(s.params); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/spot-lever-token/order-record",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
r.setParams(s.params)
|
||
|
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 *SpotLeverageClient) GetLeverageTokenMarket(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
if err = handlers.ValidateParams(s.params); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
r := &request{
|
||
|
method: http.MethodGet,
|
||
|
endpoint: "/v5/spot-lever-token/reference",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
r.setParams(s.params)
|
||
|
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 *SpotLeverageClient) PurchaseLeverageToken(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
if err = handlers.ValidateParams(s.params); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/spot-lever-token/purchase",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
r.setParams(s.params)
|
||
|
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 *SpotLeverageClient) RedeemLeverageToken(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||
|
if err = handlers.ValidateParams(s.params); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
r := &request{
|
||
|
method: http.MethodPost,
|
||
|
endpoint: "/v5/spot-lever-token/redeem",
|
||
|
secType: secTypeSigned,
|
||
|
}
|
||
|
r.setParams(s.params)
|
||
|
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
|
||
|
}
|