-
Notifications
You must be signed in to change notification settings - Fork 4
/
quote.go
53 lines (49 loc) · 1.84 KB
/
quote.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
package go_cowswap
import (
"context"
"time"
)
func (c *Client) Quote(ctx context.Context, o *QuoteReq) (*QuoteResponse, int, error) {
endpoint := "/quote"
var dataRes QuoteResponse
statusCode, err := c.doRequest(ctx, endpoint, "POST", &dataRes, o)
if err != nil {
return nil, statusCode, &ErrorCowResponse{Code: statusCode, ErrorType: "do_request_error", Description: err.Error()}
}
return &dataRes, statusCode, nil
}
type QuoteReq struct {
SellToken string `json:"sellToken"`
BuyToken string `json:"buyToken"`
Receiver string `json:"receiver"`
AppData string `json:"appData"`
PartiallyFillable bool `json:"partiallyFillable"`
SellTokenBalance string `json:"sellTokenBalance"`
BuyTokenBalance string `json:"buyTokenBalance"`
PriceQuality string `json:"priceQuality"`
SigningScheme string `json:"signingScheme"`
OnchainOrder bool `json:"onchainOrder"`
Kind string `json:"kind"`
SellAmountBeforeFee string `json:"sellAmountBeforeFee"`
From string `json:"from"`
}
type QuoteResponse struct {
Quote struct {
SellToken string `json:"sellToken"`
BuyToken string `json:"buyToken"`
Receiver string `json:"receiver"`
SellAmount string `json:"sellAmount"`
BuyAmount string `json:"buyAmount"`
ValidTo int `json:"validTo"`
AppData string `json:"appData"`
FeeAmount string `json:"feeAmount"`
Kind string `json:"kind"`
PartiallyFillable bool `json:"partiallyFillable"`
SellTokenBalance string `json:"sellTokenBalance"`
BuyTokenBalance string `json:"buyTokenBalance"`
SigningScheme string `json:"signingScheme"`
} `json:"quote"`
From string `json:"from"`
Expiration time.Time `json:"expiration"`
ID int `json:"id"`
}