forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flexible_adjust_ltv.go
88 lines (73 loc) · 2.28 KB
/
flexible_adjust_ltv.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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/v2/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
}