Skip to content

Commit a61a61f

Browse files
committed
v1.6.9
1 parent 26fcb37 commit a61a61f

File tree

17 files changed

+224
-196
lines changed

17 files changed

+224
-196
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.6.9 - 2024-03-04
4+
### Updated
5+
- Add minStepSize/maxSize in ShowTokenData struct
6+
- Return baseToken/quoteToken for ticker and pair endpoints
7+
38
## 1.6.8 - 2024-02-19
49
### Updated
510
- Parse deposit status

cmd/test/exchange_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ func TestPairInfo(t *testing.T) {
117117
c := new(spot.Client)
118118
c.SetAppConfig(appConfig)
119119
r, err := c.GetPair(&request.PairInfoRequest{
120-
Token1: 3,
121-
Token2: 5,
120+
Token1: 0,
121+
Token2: 9,
122122
})
123123
if err != nil {
124124
t.Errorf("%v", err)

cmd/test/init_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package test
22

33
import (
4+
"fmt"
5+
"github.com/BurntSushi/toml"
46
"github.com/degatedev/degate-sdk-golang/conf"
57
"github.com/degatedev/degate-sdk-golang/log"
68
)
@@ -9,8 +11,16 @@ var appConfig = &conf.AppConfig{
911
AccountId: 0,
1012
AccountAddress: "",
1113
AssetPrivateKey: "",
14+
BaseUrl: "",
1215
}
1316

1417
func init() {
18+
fmt.Println("hahahhaha")
19+
_, err := toml.DecodeFile("./credential.toml", appConfig)
20+
if err != nil {
21+
panic(fmt.Sprintf("init appConfig failed, err=%+v", err))
22+
}
23+
fmt.Println("init appConfig success")
24+
fmt.Println(appConfig.BaseUrl)
1525
log.Init(appConfig.Debug)
1626
}

cmd/test/market_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func TestTicker24(t *testing.T) {
123123
Symbol: "ETH",
124124
})
125125
conf.Conf.AddToken(&model.TokenInfo{
126-
Id: 2,
126+
Id: 9,
127127
Symbol: "USDC",
128128
})
129129
client := new(spot.Client)
@@ -184,4 +184,4 @@ func TestBookTicker(t *testing.T) {
184184
} else {
185185
t.Logf("%v", lib.String(response))
186186
}
187-
}
187+
}

degate/binance/market.go

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,32 @@ type TickerResponse struct {
3737
}
3838

3939
type Ticker struct {
40-
Symbol string `json:"symbol"`
41-
PriceChange string `json:"priceChange"`
42-
PriceChangePercent string `json:"priceChangePercent"`
43-
WeightedAvgPrice string `json:"weightedAvgPrice"`
44-
PrevClosePrice string `json:"prevClosePrice"`
45-
LastPrice string `json:"lastPrice"`
46-
LastQty string `json:"lastQty"`
47-
BidPrice string `json:"bidPrice"`
48-
BidQty string `json:"bidQty"`
49-
AskPrice string `json:"askPrice"`
50-
AskQty string `json:"askQty"`
51-
OpenPrice string `json:"openPrice"`
52-
HighPrice string `json:"highPrice"`
53-
LowPrice string `json:"lowPrice"`
54-
Volume string `json:"volume"`
55-
QuoteVolume string `json:"quoteVolume"`
56-
OpenTime int64 `json:"openTime"`
57-
CloseTime int64 `json:"closeTime"`
58-
FirstId string `json:"firstId"`
59-
LastId string `json:"lastId"`
60-
Count int `json:"count"`
61-
MakerFee string `json:"makerFee"`
62-
TakerFee string `json:"takerFee"`
63-
PairId uint64 `json:"pairId"`
40+
Symbol string `json:"symbol"`
41+
PriceChange string `json:"priceChange"`
42+
PriceChangePercent string `json:"priceChangePercent"`
43+
WeightedAvgPrice string `json:"weightedAvgPrice"`
44+
PrevClosePrice string `json:"prevClosePrice"`
45+
LastPrice string `json:"lastPrice"`
46+
LastQty string `json:"lastQty"`
47+
BidPrice string `json:"bidPrice"`
48+
BidQty string `json:"bidQty"`
49+
AskPrice string `json:"askPrice"`
50+
AskQty string `json:"askQty"`
51+
OpenPrice string `json:"openPrice"`
52+
HighPrice string `json:"highPrice"`
53+
LowPrice string `json:"lowPrice"`
54+
Volume string `json:"volume"`
55+
QuoteVolume string `json:"quoteVolume"`
56+
OpenTime int64 `json:"openTime"`
57+
CloseTime int64 `json:"closeTime"`
58+
FirstId string `json:"firstId"`
59+
LastId string `json:"lastId"`
60+
Count int `json:"count"`
61+
MakerFee string `json:"makerFee"`
62+
TakerFee string `json:"takerFee"`
63+
PairId uint64 `json:"pairId"`
64+
BaseToken *ShowTokenData `json:"baseToken"`
65+
QuoteToken *ShowTokenData `json:"quoteToken"`
6466
}
6567

6668
type PairPriceResponse struct {

degate/binance/token.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package binance
2+
3+
type ShowTokenData struct {
4+
TokenID uint64 `json:"token_id"`
5+
Chain string `json:"chain"`
6+
Code string `json:"code"`
7+
Symbol string `json:"symbol"`
8+
Decimals int32 `json:"decimals"`
9+
Volume string `json:"volume"`
10+
ShowDecimals int32 `json:"show_decimals"`
11+
IsQuotableToken bool `json:"is_quotable_token"`
12+
IsGasToken bool `json:"is_gas_token"`
13+
IsListToken bool `json:"is_list_token"`
14+
Active bool `json:"active"`
15+
IsTrustedToken bool `json:"is_trusted_token"`
16+
Priority uint64 `json:"priority"`
17+
MinStepSize string `json:"min_step_size"`
18+
MaxSize string `json:"max_size"`
19+
}

degate/lib/convert.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ func ConvertTicker(t *model.Ticker) (ticker *binance.Ticker) {
386386
ticker.MakerFee = t.MakerFee
387387
ticker.TakerFee = t.TakerFee
388388
ticker.PairId = t.PairId
389+
ticker.BaseToken = t.BaseToken
390+
ticker.QuoteToken = t.QuoteToken
389391
return
390392
}
391393

@@ -955,8 +957,8 @@ func ConvertTradeFee(fees []*model.TradeFee) (tradeFees []*binance.TradeFee) {
955957
return
956958
}
957959

958-
func ConvertTokenInfoToTokenData(info *model.TokenInfo) *model.ShowTokenData {
959-
data := &model.ShowTokenData{
960+
func ConvertTokenInfoToTokenData(info *model.TokenInfo) *binance.ShowTokenData {
961+
data := &binance.ShowTokenData{
960962
TokenID: uint64(info.Id),
961963
Chain: info.Chain,
962964
Code: info.Code,

degate/lib/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package lib
22

33
import (
44
"encoding/json"
5+
"github.com/degatedev/degate-sdk-golang/degate/binance"
56
"math/big"
67
"strings"
78
"time"
89

9-
"github.com/degatedev/degate-sdk-golang/degate/model"
1010
"github.com/degatedev/degate-sdk-golang/log"
1111
"github.com/shopspring/decimal"
1212
)
@@ -41,7 +41,7 @@ func FormatTime(t int64) string {
4141
return time.Unix(t, 0).Format(timeFormat)
4242
}
4343

44-
func GetSymbol(buyToken *model.ShowTokenData, sellToken *model.ShowTokenData, isBuy bool) (symbol string) {
44+
func GetSymbol(buyToken *binance.ShowTokenData, sellToken *binance.ShowTokenData, isBuy bool) (symbol string) {
4545
if buyToken == nil || sellToken == nil {
4646
return
4747
}

degate/model/account.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ type TradesResponse struct {
176176
}
177177

178178
type TradeFee struct {
179-
MakerCommission string `json:"maker_commission"`
180-
TakerCommission string `json:"taker_commission"`
181-
BaseToken *ShowTokenData `json:"base_token"`
182-
QuoteToken *ShowTokenData `json:"quote_token"`
179+
MakerCommission string `json:"maker_commission"`
180+
TakerCommission string `json:"taker_commission"`
181+
BaseToken *binance.ShowTokenData `json:"base_token"`
182+
QuoteToken *binance.ShowTokenData `json:"quote_token"`
183183
}
184184

185185
type TradeFeeResponse struct {

degate/model/model.go

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,37 @@ type TokenInfo struct {
1818
}
1919

2020
type Ticker struct {
21-
BaseTokenID uint64 `json:"base_token_id"`
22-
QuoteTokenID uint64 `json:"quote_token_id"`
23-
PriceChange string `json:"price_change"`
24-
PriceChangePercent string `json:"price_change_percent"`
25-
WeightedAvgPrice string `json:"weighted_avg_price"`
26-
PrevClosePrice string `json:"prev_close_price"`
27-
LastPrice string `json:"last_price"`
28-
LastQty string `json:"last_qty"`
29-
BidPrice string `json:"bid_price"`
30-
BidQty string `json:"bid_qty"`
31-
AskPrice string `json:"ask_price"`
32-
AskQty string `json:"ask_qty"`
33-
OpenPrice string `json:"open_price"`
34-
HighPrice string `json:"high_price"`
35-
LowPrice string `json:"low_price"`
36-
Volume string `json:"volume"`
37-
QuoteVolume string `json:"quote_volume"`
38-
OpenTime int64 `json:"open_time"`
39-
CloseTime int64 `json:"close_time"`
40-
FirstId string `json:"first_id"`
41-
LastId string `json:"last_id"`
42-
Count uint64 `json:"count"`
43-
WeekHighPrice string `json:"week_high_price"`
44-
WeekLowPrice string `json:"week_low_price"`
45-
BaseTokenPrice string `json:"base_token_price"`
46-
QuoteTokenPrice string `json:"quote_token_price"`
47-
MakerFee string `json:"maker_fee"`
48-
TakerFee string `json:"taker_fee"`
49-
PairId uint64 `json:"pair_id"`
21+
BaseTokenID uint64 `json:"base_token_id"`
22+
QuoteTokenID uint64 `json:"quote_token_id"`
23+
PriceChange string `json:"price_change"`
24+
PriceChangePercent string `json:"price_change_percent"`
25+
WeightedAvgPrice string `json:"weighted_avg_price"`
26+
PrevClosePrice string `json:"prev_close_price"`
27+
LastPrice string `json:"last_price"`
28+
LastQty string `json:"last_qty"`
29+
BidPrice string `json:"bid_price"`
30+
BidQty string `json:"bid_qty"`
31+
AskPrice string `json:"ask_price"`
32+
AskQty string `json:"ask_qty"`
33+
OpenPrice string `json:"open_price"`
34+
HighPrice string `json:"high_price"`
35+
LowPrice string `json:"low_price"`
36+
Volume string `json:"volume"`
37+
QuoteVolume string `json:"quote_volume"`
38+
OpenTime int64 `json:"open_time"`
39+
CloseTime int64 `json:"close_time"`
40+
FirstId string `json:"first_id"`
41+
LastId string `json:"last_id"`
42+
Count uint64 `json:"count"`
43+
WeekHighPrice string `json:"week_high_price"`
44+
WeekLowPrice string `json:"week_low_price"`
45+
BaseTokenPrice string `json:"base_token_price"`
46+
QuoteTokenPrice string `json:"quote_token_price"`
47+
MakerFee string `json:"maker_fee"`
48+
TakerFee string `json:"taker_fee"`
49+
PairId uint64 `json:"pair_id"`
50+
BaseToken *binance.ShowTokenData `json:"base_token"`
51+
QuoteToken *binance.ShowTokenData `json:"quote_token"`
5052
}
5153

5254
func (t *Ticker) ToBookTicker() (bookTicker *BookTicker) {

0 commit comments

Comments
 (0)