diff --git a/bybit_api_client.go b/bybit_api_client.go index 5948fd0..5626b9f 100644 --- a/bybit_api_client.go +++ b/bybit_api_client.go @@ -271,23 +271,33 @@ func (c *Client) NewAccountServiceNoParams() *AccountClient { func (c *Client) NewAssetService(params map[string]interface{}) *AssetClient { return &AssetClient{ - c: c, + c: c, + params: params, } } func (c *Client) NewUserService(params map[string]interface{}) *UserServiceClient { return &UserServiceClient{ - c: c, + c: c, + params: params, } } func (c *Client) NewBrokerService(params map[string]interface{}) *BrokerServiceClient { return &BrokerServiceClient{ - c: c, + c: c, + params: params, } } func (c *Client) NewLendingService(params map[string]interface{}) *LendingServiceClient { + return &LendingServiceClient{ + c: c, + params: params, + } +} + +func (c *Client) NewLendingServiceNoParams() *LendingServiceClient { return &LendingServiceClient{ c: c, } diff --git a/lending.go b/lending.go index 631dc25..2e2941e 100644 --- a/lending.go +++ b/lending.go @@ -12,6 +12,112 @@ type LendingServiceClient struct { params map[string]interface{} } +func (s *LendingServiceClient) GetInsLoanInfo(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/ins-loan/product-infos", + 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 *LendingServiceClient) GetInsMarginCoinInfo(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/ins-loan/ensure-tokens-convert", + 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 *LendingServiceClient) GetInsLoanOrders(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/ins-loan/loan-order", + 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 *LendingServiceClient) GetInsRepayOrders(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/ins-loan/repaid-history", + 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 *LendingServiceClient) GetInsLoanToValue(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) { + r := &request{ + method: http.MethodGet, + endpoint: "/v5/ins-loan/ltv-convert", + 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 *LendingServiceClient) GetC2cLendingCoinInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) { if err = handlers.ValidateParams(s.params); err != nil { return nil, err diff --git a/models/lendingResponse.go b/models/lendingResponse.go index c42c255..871600d 100644 --- a/models/lendingResponse.go +++ b/models/lendingResponse.go @@ -60,3 +60,90 @@ type LendingOrderRecord struct { type LendingOrdersRecordsResult struct { List []LendingOrderRecord `json:"list"` } + +type MarginProductInfo struct { + ProductId string `json:"productId"` + Leverage string `json:"leverage"` + SupportSpot int `json:"supportSpot"` + SupportContract int `json:"supportContract"` + SupportMarginTrading int `json:"supportMarginTrading"` + WithdrawLine string `json:"withdrawLine"` + TransferLine string `json:"transferLine"` + SpotBuyLine string `json:"spotBuyLine"` + SpotSellLine string `json:"spotSellLine"` + ContractOpenLine string `json:"contractOpenLine"` + LiquidationLine string `json:"liquidationLine"` + StopLiquidationLine string `json:"stopLiquidationLine"` + ContractLeverage string `json:"contractLeverage"` + TransferRatio string `json:"transferRatio"` + SpotSymbols []string `json:"spotSymbols"` + ContractSymbols []string `json:"contractSymbols"` + SupportUSDCContract int `json:"supportUSDCContract"` + SupportUSDCOptions int `json:"supportUSDCOptions"` + USDTPerpetualOpenLine string `json:"USDTPerpetualOpenLine"` + USDCContractOpenLine string `json:"USDCContractOpenLine"` + USDCOptionsOpenLine string `json:"USDCOptionsOpenLine"` + USDTPerpetualCloseLine string `json:"USDTPerpetualCloseLine"` + USDCContractCloseLine string `json:"USDCContractCloseLine"` + USDCOptionsCloseLine string `json:"USDCOptionsCloseLine"` + USDCContractSymbols []string `json:"USDCContractSymbols"` + USDCOptionsSymbols []string `json:"USDCOptionsSymbols"` + MarginLeverage string `json:"marginLeverage"` + USDTPerpetualLeverage []LeverageInfo `json:"USDTPerpetualLeverage"` + USDCContractLeverage []LeverageInfo `json:"USDCContractLeverage"` +} + +type LeverageInfo struct { + Symbol string `json:"symbol"` + Leverage string `json:"leverage"` +} + +type TokenInfo struct { + Token string `json:"token"` + ConvertRatioList []ConvertRatio `json:"convertRatioList"` +} + +type ConvertRatio struct { + Ladder string `json:"ladder"` + ConvertRatio string `json:"convertRatio"` +} + +type MarginToken struct { + ProductId string `json:"productId"` + TokenInfo []TokenInfo `json:"tokenInfo"` +} + +// LoanInfo To do +type LoanInfo struct { + OrderId string `json:"orderId"` + OrderProductId string `json:"orderProductId"` + ParentUid string `json:"parentUid"` + LoanTime string `json:"loanTime"` + LoanCoin string `json:"loanCoin"` + LoanAmount string `json:"loanAmount"` + UnpaidAmount string `json:"unpaidAmount"` + UnpaidInterest string `json:"unpaidInterest"` + RepaidAmount string `json:"repaidAmount"` + RepaidInterest string `json:"repaidInterest"` + InterestRate string `json:"interestRate"` + Status string `json:"status"` + Leverage string `json:"leverage"` + SupportSpot string `json:"supportSpot"` + SupportContract string `json:"supportContract"` + WithdrawLine string `json:"withdrawLine"` + TransferLine string `json:"transferLine"` + SpotBuyLine string `json:"spotBuyLine"` + SpotSellLine string `json:"spotSellLine"` + ContractOpenLine string `json:"contractOpenLine"` + LiquidationLine string `json:"liquidationLine"` + StopLiquidationLine string `json:"stopLiquidationLine"` + ContractLeverage string `json:"contractLeverage"` + TransferRatio string `json:"transferRatio"` + SpotSymbols []string `json:"spotSymbols"` + ContractSymbols []string `json:"contractSymbols"` + SupportUSDCContract string `json:"supportUSDCContract"` + SupportUSDCOptions string `json:"supportUSDCOptions"` + SupportMarginTrading string `json:"supportMarginTrading"` + USDTPerpetualOpenLine string `json:"USDTPerpetualOpenLine"` + USDCContractOpenLine string `json:"USDCContractOpenLine"` +}