Skip to content

Commit 67c7301

Browse files
authored
Binance, KuCoin - Fix GetCurrenciesAsync (#854)
* Fix GetCurrencies for Binance * Fix GetCurrencies for KuCoin
1 parent dad0ec7 commit 67c7301

File tree

3 files changed

+224
-123
lines changed

3 files changed

+224
-123
lines changed

src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,38 @@ protected override async Task<
141141
payload
142142
);
143143

144-
return result
145-
.Where(x => !string.IsNullOrWhiteSpace(x.AssetCode))
144+
var exchangeCurrencies = result
146145
.ToDictionary(
147-
x => x.AssetCode,
146+
x => x.Coin,
148147
x =>
149148
new ExchangeCurrency
150149
{
151-
Name = x.AssetCode,
152-
FullName = x.AssetName,
153-
DepositEnabled = x.EnableCharge ?? false,
154-
WithdrawalEnabled = x.EnableWithdraw.GetValueOrDefault(false),
155-
MinConfirmations = x.ConfirmTimes.GetValueOrDefault(0),
156-
MinWithdrawalSize = x.MinProductWithdraw.GetValueOrDefault(
157-
decimal.Zero
158-
),
159-
TxFee = x.FeeRate.GetValueOrDefault(decimal.Zero),
160-
CoinType = x.ParentCode
150+
Name = x.Coin,
151+
FullName = x.Name,
152+
DepositEnabled = x.DepositAllEnable ?? false,
153+
WithdrawalEnabled = x.WithdrawAllEnable.GetValueOrDefault(false),
154+
MinConfirmations = x.NetworkList
155+
.Where(n => n.IsDefault)
156+
.Select(n => n.MinConfirm)
157+
.FirstOrDefault() ?? 0,
158+
MinWithdrawalSize = x.NetworkList
159+
.Where(n => n.IsDefault)
160+
.Select(n => n.WithdrawMin)
161+
.FirstOrDefault() ?? decimal.Zero,
162+
TxFee = x.NetworkList
163+
.Where(n => n.IsDefault)
164+
.Select(n => n.WithdrawFee)
165+
.FirstOrDefault() ?? decimal.Zero,
166+
CoinType = x.IsLegalMoney == true
167+
? "FIAT"
168+
: x.NetworkList
169+
.Where(n => n.IsDefault)
170+
.Select(n => n.NetworkName)
171+
.FirstOrDefault() ?? "CRYPTO",
161172
}
162173
);
174+
175+
return exchangeCurrencies;
163176
}
164177

165178
protected override async Task<IEnumerable<string>> OnGetMarketSymbolsAsync()
Lines changed: 130 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,179 @@
11
using System;
2+
using System.Collections.Generic;
23
using Newtonsoft.Json;
34

5+
/**
6+
[
7+
{
8+
"coin": "AGLD",
9+
"depositAllEnable": true,
10+
"withdrawAllEnable": true,
11+
"name": "Adventure Gold",
12+
"free": "0",
13+
"locked": "0",
14+
"freeze": "0",
15+
"withdrawing": "0",
16+
"ipoing": "0",
17+
"ipoable": "0",
18+
"storage": "0",
19+
"isLegalMoney": false,
20+
"trading": true,
21+
"networkList": [
22+
{
23+
"network": "ETH",
24+
"coin": "AGLD",
25+
"withdrawIntegerMultiple": "0.00000001",
26+
"isDefault": true,
27+
"depositEnable": true,
28+
"withdrawEnable": true,
29+
"depositDesc": "",
30+
"withdrawDesc": "",
31+
"specialTips": "",
32+
"specialWithdrawTips": "",
33+
"name": "Ethereum (ERC20)",
34+
"resetAddressStatus": false,
35+
"addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
36+
"memoRegex": "",
37+
"withdrawFee": "4.67",
38+
"withdrawMin": "9.34",
39+
"withdrawMax": "9999999",
40+
"depositDust": "0.0012",
41+
"minConfirm": 6,
42+
"unLockConfirm": 64,
43+
"sameAddress": false,
44+
"estimatedArrivalTime": 5,
45+
"busy": false,
46+
"contractAddressUrl": "https://etherscan.io/address/",
47+
"contractAddress": "0x32353a6c91143bfd6c7d363b546e62a9a2489a20"
48+
}
49+
]
50+
},
51+
...
52+
]
53+
*/
54+
455
namespace ExchangeSharp.BinanceGroup
556
{
657
public class Currency
758
{
8-
[JsonProperty("id")]
9-
public long? Id { get; set; }
10-
11-
[JsonProperty("assetCode")]
12-
public string AssetCode { get; set; }
13-
14-
[JsonProperty("assetName")]
15-
public string AssetName { get; set; }
16-
17-
[JsonProperty("unit")]
18-
public string Unit { get; set; }
19-
20-
[JsonProperty("transactionFee")]
21-
public double? TransactionFee { get; set; }
59+
[JsonProperty("coin")]
60+
public string Coin { get; set; }
2261

23-
[JsonProperty("commissionRate")]
24-
public long? CommissionRate { get; set; }
62+
[JsonProperty("depositAllEnable")]
63+
public bool? DepositAllEnable { get; set; }
2564

26-
[JsonProperty("freeAuditWithdrawAmt")]
27-
public long? FreeAuditWithdrawAmt { get; set; }
65+
[JsonProperty("withdrawAllEnable")]
66+
public bool? WithdrawAllEnable { get; set; }
2867

29-
[JsonProperty("freeUserChargeAmount")]
30-
public long? FreeUserChargeAmount { get; set; }
68+
[JsonProperty("name")]
69+
public string Name { get; set; }
3170

32-
[JsonProperty("minProductWithdraw")]
33-
public decimal? MinProductWithdraw { get; set; }
71+
[JsonProperty("free")]
72+
public decimal? Free { get; set; }
3473

35-
[JsonProperty("withdrawIntegerMultiple")]
36-
public float? WithdrawIntegerMultiple { get; set; }
37-
38-
[JsonProperty("confirmTimes")]
39-
public int? ConfirmTimes { get; set; }
40-
41-
[JsonProperty("chargeLockConfirmTimes")]
42-
public int? ChargeLockConfirmTimes { get; set; }
74+
[JsonProperty("locked")]
75+
public decimal? Locked { get; set; }
4376

44-
[JsonProperty("createTime")]
45-
public object CreateTime { get; set; }
77+
[JsonProperty("freeze")]
78+
public decimal? Freeze { get; set; }
4679

47-
[JsonProperty("test")]
48-
public long? Test { get; set; }
80+
[JsonProperty("withdrawing")]
81+
public decimal? Withdrawing { get; set; }
4982

50-
[JsonProperty("url")]
51-
public Uri Url { get; set; }
83+
[JsonProperty("ipoing")]
84+
public decimal? Ipoing { get; set; }
5285

53-
[JsonProperty("addressUrl")]
54-
public Uri AddressUrl { get; set; }
86+
[JsonProperty("ipoable")]
87+
public decimal? Ipoable { get; set; }
5588

56-
[JsonProperty("blockUrl")]
57-
public string BlockUrl { get; set; }
89+
[JsonProperty("storage")]
90+
public decimal? Storage { get; set; }
5891

59-
[JsonProperty("enableCharge")]
60-
public bool? EnableCharge { get; set; }
61-
62-
[JsonProperty("enableWithdraw")]
63-
public bool? EnableWithdraw { get; set; }
92+
[JsonProperty("isLegalMoney")]
93+
public bool IsLegalMoney { get; set; }
6494

65-
[JsonProperty("regEx")]
66-
public string RegEx { get; set; }
95+
[JsonProperty("trading")]
96+
public bool Trading { get; set; }
6797

68-
[JsonProperty("regExTag")]
69-
public string RegExTag { get; set; }
98+
[JsonProperty("networkList")]
99+
public List<Network> NetworkList { get; set; }
100+
}
70101

71-
[JsonProperty("gas")]
72-
public long? Gas { get; set; }
102+
public class Network
103+
{
104+
[JsonProperty("network")]
105+
public string NetworkName { get; set; }
73106

74-
[JsonProperty("parentCode")]
75-
public string ParentCode { get; set; }
107+
[JsonProperty("coin")]
108+
public string Coin { get; set; }
76109

77-
[JsonProperty("isLegalMoney")]
78-
public bool? IsLegalMoney { get; set; }
110+
[JsonProperty("withdrawIntegerMultiple")]
111+
public decimal? WithdrawIntegerMultiple { get; set; }
79112

80-
[JsonProperty("reconciliationAmount")]
81-
public long? ReconciliationAmount { get; set; }
113+
[JsonProperty("isDefault")]
114+
public bool IsDefault { get; set; }
82115

83-
[JsonProperty("seqNum")]
84-
public long? SeqNum { get; set; }
116+
[JsonProperty("depositEnable")]
117+
public bool DepositEnable { get; set; }
85118

86-
[JsonProperty("chineseName")]
87-
public string ChineseName { get; set; }
119+
[JsonProperty("withdrawEnable")]
120+
public bool WithdrawEnable { get; set; }
88121

89-
[JsonProperty("cnLink")]
90-
public Uri CnLink { get; set; }
122+
[JsonProperty("depositDesc")]
123+
public string DepositDesc { get; set; }
91124

92-
[JsonProperty("enLink")]
93-
public Uri EnLink { get; set; }
125+
[JsonProperty("withdrawDesc")]
126+
public string WithdrawDesc { get; set; }
94127

95-
[JsonProperty("logoUrl")]
96-
public string LogoUrl { get; set; }
128+
[JsonProperty("specialTips")]
129+
public string SpecialTips { get; set; }
97130

98-
[JsonProperty("fullLogoUrl")]
99-
public Uri FullLogoUrl { get; set; }
131+
[JsonProperty("specialWithdrawTips")]
132+
public string SpecialWithdrawTips { get; set; }
100133

101-
[JsonProperty("forceStatus")]
102-
public bool? ForceStatus { get; set; }
134+
[JsonProperty("name")]
135+
public string NetworkDisplayName { get; set; }
103136

104137
[JsonProperty("resetAddressStatus")]
105138
public bool? ResetAddressStatus { get; set; }
106139

107-
[JsonProperty("chargeDescCn")]
108-
public object ChargeDescCn { get; set; }
140+
[JsonProperty("addressRegex")]
141+
public string AddressRegex { get; set; }
109142

110-
[JsonProperty("chargeDescEn")]
111-
public object ChargeDescEn { get; set; }
143+
[JsonProperty("memoRegex")]
144+
public string MemoRegex { get; set; }
112145

113-
[JsonProperty("assetLabel")]
114-
public object AssetLabel { get; set; }
146+
[JsonProperty("withdrawFee")]
147+
public decimal? WithdrawFee { get; set; }
115148

116-
[JsonProperty("sameAddress")]
117-
public bool? SameAddress { get; set; }
118-
119-
[JsonProperty("depositTipStatus")]
120-
public bool? DepositTipStatus { get; set; }
149+
[JsonProperty("withdrawMin")]
150+
public decimal? WithdrawMin { get; set; }
121151

122-
[JsonProperty("dynamicFeeStatus")]
123-
public bool? DynamicFeeStatus { get; set; }
152+
[JsonProperty("withdrawMax")]
153+
public decimal? WithdrawMax { get; set; }
124154

125-
[JsonProperty("depositTipEn")]
126-
public object DepositTipEn { get; set; }
155+
[JsonProperty("depositDust")]
156+
public decimal? DepositDust { get; set; }
127157

128-
[JsonProperty("depositTipCn")]
129-
public object DepositTipCn { get; set; }
158+
[JsonProperty("minConfirm")]
159+
public int? MinConfirm { get; set; }
130160

131-
[JsonProperty("assetLabelEn")]
132-
public object AssetLabelEn { get; set; }
161+
[JsonProperty("unLockConfirm")]
162+
public int? UnLockConfirm { get; set; }
133163

134-
[JsonProperty("supportMarket")]
135-
public object SupportMarket { get; set; }
164+
[JsonProperty("sameAddress")]
165+
public bool? SameAddress { get; set; }
136166

137-
[JsonProperty("feeReferenceAsset")]
138-
public string FeeReferenceAsset { get; set; }
167+
[JsonProperty("estimatedArrivalTime")]
168+
public int? EstimatedArrivalTime { get; set; }
139169

140-
[JsonProperty("feeRate")]
141-
public decimal? FeeRate { get; set; }
170+
[JsonProperty("busy")]
171+
public bool? Busy { get; set; }
142172

143-
[JsonProperty("feeDigit")]
144-
public long? FeeDigit { get; set; }
173+
[JsonProperty("contractAddressUrl")]
174+
public string ContractAddressUrl { get; set; }
145175

146-
[JsonProperty("legalMoney")]
147-
public bool? LegalMoney { get; set; }
176+
[JsonProperty("contractAddress")]
177+
public string ContractAddress { get; set; }
148178
}
149179
}

0 commit comments

Comments
 (0)