diff --git a/v2/client.go b/v2/client.go index 4a66fb4f..57f618e0 100644 --- a/v2/client.go +++ b/v2/client.go @@ -1050,3 +1050,7 @@ func (c *Client) NewGetFlexibleLoanOngoingOrdersService() *GetFlexibleLoanOngoin func (c *Client) NewFlexibleLoanRepayService() *FlexibleLoanRepayService { return &FlexibleLoanRepayService{c: c} } + +func (c *Client) NewFlexibleLoanAdjustLTVService() *FlexibleLoanAdjustLTVService { + return &FlexibleLoanAdjustLTVService{c: c} +} diff --git a/v2/flexible_adjust_ltv.go b/v2/flexible_adjust_ltv.go new file mode 100644 index 00000000..9a7d7558 --- /dev/null +++ b/v2/flexible_adjust_ltv.go @@ -0,0 +1,88 @@ +package binance + +import ( + "context" + "net/http" +) + +type FLAdjustLTVDirection string + +const ( + FLAdjustLTVAdditional FLAdjustLTVDirection = "ADDITIONAL" + FLAdjustLTVReduced FLAdjustLTVDirection = "REDUCED" +) + +type FlexibleLoanAdjustLTVService struct { + c *Client + loanCoin string + collateralCoin string + adjustmentAmount float64 + direction FLAdjustLTVDirection +} + +type FLAdjustLTVStatus string + +const ( + FLAdjustLTVSucceeds FLAdjustLTVStatus = "Succeeds" + FLAdjustLTVFailed FLAdjustLTVStatus = "Failed" + FLAdjustLTVProcessing FLAdjustLTVStatus = "Processing" +) + +type FlexibleLoanAdjustLTVResp struct { + LoanCoin string `json:"loanCoin"` + CollateralCoin string `json:"collateralCoin"` + Direction string `json:"direction"` + AdjustmentAmount string `json:"adjustmentAmount"` + CurrentLTV string `json:"currentLTV"` + Status FLAdjustLTVStatus `json:"status"` +} + +// LoanCoin set loanCoin +func (s *FlexibleLoanAdjustLTVService) LoanCoin(loanCoin string) *FlexibleLoanAdjustLTVService { + s.loanCoin = loanCoin + return s +} + +// CollateralCoin set collateralCoin +func (s *FlexibleLoanAdjustLTVService) CollateralCoin(coll string) *FlexibleLoanAdjustLTVService { + s.collateralCoin = coll + return s +} + +// AdjustmentAmount set adjustmentAmount +func (s *FlexibleLoanAdjustLTVService) AdjustmentAmount(amt float64) *FlexibleLoanAdjustLTVService { + s.adjustmentAmount = amt + return s +} + +// Direction set direction +func (s *FlexibleLoanAdjustLTVService) Direction(direction FLAdjustLTVDirection) *FlexibleLoanAdjustLTVService { + s.direction = direction + return s +} + +// Do send request +func (s *FlexibleLoanAdjustLTVService) Do(ctx context.Context, opts ...RequestOption) (res *FlexibleLoanAdjustLTVResp, err error) { + r := &request{ + method: http.MethodPost, + endpoint: "/sapi/v1/loan/flexible/adjust/ltv", + secType: secTypeSigned, + } + + r.setParam("loanCoin", s.loanCoin) + r.setParam("collateralCoin", s.collateralCoin) + r.setParam("adjustmentAmount", s.adjustmentAmount) + r.setParam("direction", s.direction) + + data, err := s.c.callAPI(ctx, r, opts...) + if err != nil { + return nil, err + } + + res = new(FlexibleLoanAdjustLTVResp) + err = json.Unmarshal(data, res) + if err != nil { + return nil, err + } + return res, nil +}