Skip to content

Commit

Permalink
Binance, KuCoin - Fix GetCurrenciesAsync (#854)
Browse files Browse the repository at this point in the history
* Fix GetCurrencies for Binance

* Fix GetCurrencies for KuCoin
  • Loading branch information
v36u authored Nov 22, 2024
1 parent dad0ec7 commit 67c7301
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 123 deletions.
39 changes: 26 additions & 13 deletions src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,38 @@ protected override async Task<
payload
);

return result
.Where(x => !string.IsNullOrWhiteSpace(x.AssetCode))
var exchangeCurrencies = result
.ToDictionary(
x => x.AssetCode,
x => x.Coin,
x =>
new ExchangeCurrency
{
Name = x.AssetCode,
FullName = x.AssetName,
DepositEnabled = x.EnableCharge ?? false,
WithdrawalEnabled = x.EnableWithdraw.GetValueOrDefault(false),
MinConfirmations = x.ConfirmTimes.GetValueOrDefault(0),
MinWithdrawalSize = x.MinProductWithdraw.GetValueOrDefault(
decimal.Zero
),
TxFee = x.FeeRate.GetValueOrDefault(decimal.Zero),
CoinType = x.ParentCode
Name = x.Coin,
FullName = x.Name,
DepositEnabled = x.DepositAllEnable ?? false,
WithdrawalEnabled = x.WithdrawAllEnable.GetValueOrDefault(false),
MinConfirmations = x.NetworkList
.Where(n => n.IsDefault)
.Select(n => n.MinConfirm)
.FirstOrDefault() ?? 0,
MinWithdrawalSize = x.NetworkList
.Where(n => n.IsDefault)
.Select(n => n.WithdrawMin)
.FirstOrDefault() ?? decimal.Zero,
TxFee = x.NetworkList
.Where(n => n.IsDefault)
.Select(n => n.WithdrawFee)
.FirstOrDefault() ?? decimal.Zero,
CoinType = x.IsLegalMoney == true
? "FIAT"
: x.NetworkList
.Where(n => n.IsDefault)
.Select(n => n.NetworkName)
.FirstOrDefault() ?? "CRYPTO",
}
);

return exchangeCurrencies;
}

protected override async Task<IEnumerable<string>> OnGetMarketSymbolsAsync()
Expand Down
230 changes: 130 additions & 100 deletions src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/Currency.cs
Original file line number Diff line number Diff line change
@@ -1,149 +1,179 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

/**
[
{
"coin": "AGLD",
"depositAllEnable": true,
"withdrawAllEnable": true,
"name": "Adventure Gold",
"free": "0",
"locked": "0",
"freeze": "0",
"withdrawing": "0",
"ipoing": "0",
"ipoable": "0",
"storage": "0",
"isLegalMoney": false,
"trading": true,
"networkList": [
{
"network": "ETH",
"coin": "AGLD",
"withdrawIntegerMultiple": "0.00000001",
"isDefault": true,
"depositEnable": true,
"withdrawEnable": true,
"depositDesc": "",
"withdrawDesc": "",
"specialTips": "",
"specialWithdrawTips": "",
"name": "Ethereum (ERC20)",
"resetAddressStatus": false,
"addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
"memoRegex": "",
"withdrawFee": "4.67",
"withdrawMin": "9.34",
"withdrawMax": "9999999",
"depositDust": "0.0012",
"minConfirm": 6,
"unLockConfirm": 64,
"sameAddress": false,
"estimatedArrivalTime": 5,
"busy": false,
"contractAddressUrl": "https://etherscan.io/address/",
"contractAddress": "0x32353a6c91143bfd6c7d363b546e62a9a2489a20"
}
]
},
...
]
*/

namespace ExchangeSharp.BinanceGroup
{
public class Currency
{
[JsonProperty("id")]
public long? Id { get; set; }

[JsonProperty("assetCode")]
public string AssetCode { get; set; }

[JsonProperty("assetName")]
public string AssetName { get; set; }

[JsonProperty("unit")]
public string Unit { get; set; }

[JsonProperty("transactionFee")]
public double? TransactionFee { get; set; }
[JsonProperty("coin")]
public string Coin { get; set; }

[JsonProperty("commissionRate")]
public long? CommissionRate { get; set; }
[JsonProperty("depositAllEnable")]
public bool? DepositAllEnable { get; set; }

[JsonProperty("freeAuditWithdrawAmt")]
public long? FreeAuditWithdrawAmt { get; set; }
[JsonProperty("withdrawAllEnable")]
public bool? WithdrawAllEnable { get; set; }

[JsonProperty("freeUserChargeAmount")]
public long? FreeUserChargeAmount { get; set; }
[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("minProductWithdraw")]
public decimal? MinProductWithdraw { get; set; }
[JsonProperty("free")]
public decimal? Free { get; set; }

[JsonProperty("withdrawIntegerMultiple")]
public float? WithdrawIntegerMultiple { get; set; }

[JsonProperty("confirmTimes")]
public int? ConfirmTimes { get; set; }

[JsonProperty("chargeLockConfirmTimes")]
public int? ChargeLockConfirmTimes { get; set; }
[JsonProperty("locked")]
public decimal? Locked { get; set; }

[JsonProperty("createTime")]
public object CreateTime { get; set; }
[JsonProperty("freeze")]
public decimal? Freeze { get; set; }

[JsonProperty("test")]
public long? Test { get; set; }
[JsonProperty("withdrawing")]
public decimal? Withdrawing { get; set; }

[JsonProperty("url")]
public Uri Url { get; set; }
[JsonProperty("ipoing")]
public decimal? Ipoing { get; set; }

[JsonProperty("addressUrl")]
public Uri AddressUrl { get; set; }
[JsonProperty("ipoable")]
public decimal? Ipoable { get; set; }

[JsonProperty("blockUrl")]
public string BlockUrl { get; set; }
[JsonProperty("storage")]
public decimal? Storage { get; set; }

[JsonProperty("enableCharge")]
public bool? EnableCharge { get; set; }

[JsonProperty("enableWithdraw")]
public bool? EnableWithdraw { get; set; }
[JsonProperty("isLegalMoney")]
public bool IsLegalMoney { get; set; }

[JsonProperty("regEx")]
public string RegEx { get; set; }
[JsonProperty("trading")]
public bool Trading { get; set; }

[JsonProperty("regExTag")]
public string RegExTag { get; set; }
[JsonProperty("networkList")]
public List<Network> NetworkList { get; set; }
}

[JsonProperty("gas")]
public long? Gas { get; set; }
public class Network
{
[JsonProperty("network")]
public string NetworkName { get; set; }

[JsonProperty("parentCode")]
public string ParentCode { get; set; }
[JsonProperty("coin")]
public string Coin { get; set; }

[JsonProperty("isLegalMoney")]
public bool? IsLegalMoney { get; set; }
[JsonProperty("withdrawIntegerMultiple")]
public decimal? WithdrawIntegerMultiple { get; set; }

[JsonProperty("reconciliationAmount")]
public long? ReconciliationAmount { get; set; }
[JsonProperty("isDefault")]
public bool IsDefault { get; set; }

[JsonProperty("seqNum")]
public long? SeqNum { get; set; }
[JsonProperty("depositEnable")]
public bool DepositEnable { get; set; }

[JsonProperty("chineseName")]
public string ChineseName { get; set; }
[JsonProperty("withdrawEnable")]
public bool WithdrawEnable { get; set; }

[JsonProperty("cnLink")]
public Uri CnLink { get; set; }
[JsonProperty("depositDesc")]
public string DepositDesc { get; set; }

[JsonProperty("enLink")]
public Uri EnLink { get; set; }
[JsonProperty("withdrawDesc")]
public string WithdrawDesc { get; set; }

[JsonProperty("logoUrl")]
public string LogoUrl { get; set; }
[JsonProperty("specialTips")]
public string SpecialTips { get; set; }

[JsonProperty("fullLogoUrl")]
public Uri FullLogoUrl { get; set; }
[JsonProperty("specialWithdrawTips")]
public string SpecialWithdrawTips { get; set; }

[JsonProperty("forceStatus")]
public bool? ForceStatus { get; set; }
[JsonProperty("name")]
public string NetworkDisplayName { get; set; }

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

[JsonProperty("chargeDescCn")]
public object ChargeDescCn { get; set; }
[JsonProperty("addressRegex")]
public string AddressRegex { get; set; }

[JsonProperty("chargeDescEn")]
public object ChargeDescEn { get; set; }
[JsonProperty("memoRegex")]
public string MemoRegex { get; set; }

[JsonProperty("assetLabel")]
public object AssetLabel { get; set; }
[JsonProperty("withdrawFee")]
public decimal? WithdrawFee { get; set; }

[JsonProperty("sameAddress")]
public bool? SameAddress { get; set; }

[JsonProperty("depositTipStatus")]
public bool? DepositTipStatus { get; set; }
[JsonProperty("withdrawMin")]
public decimal? WithdrawMin { get; set; }

[JsonProperty("dynamicFeeStatus")]
public bool? DynamicFeeStatus { get; set; }
[JsonProperty("withdrawMax")]
public decimal? WithdrawMax { get; set; }

[JsonProperty("depositTipEn")]
public object DepositTipEn { get; set; }
[JsonProperty("depositDust")]
public decimal? DepositDust { get; set; }

[JsonProperty("depositTipCn")]
public object DepositTipCn { get; set; }
[JsonProperty("minConfirm")]
public int? MinConfirm { get; set; }

[JsonProperty("assetLabelEn")]
public object AssetLabelEn { get; set; }
[JsonProperty("unLockConfirm")]
public int? UnLockConfirm { get; set; }

[JsonProperty("supportMarket")]
public object SupportMarket { get; set; }
[JsonProperty("sameAddress")]
public bool? SameAddress { get; set; }

[JsonProperty("feeReferenceAsset")]
public string FeeReferenceAsset { get; set; }
[JsonProperty("estimatedArrivalTime")]
public int? EstimatedArrivalTime { get; set; }

[JsonProperty("feeRate")]
public decimal? FeeRate { get; set; }
[JsonProperty("busy")]
public bool? Busy { get; set; }

[JsonProperty("feeDigit")]
public long? FeeDigit { get; set; }
[JsonProperty("contractAddressUrl")]
public string ContractAddressUrl { get; set; }

[JsonProperty("legalMoney")]
public bool? LegalMoney { get; set; }
[JsonProperty("contractAddress")]
public string ContractAddress { get; set; }
}
}
Loading

0 comments on commit 67c7301

Please sign in to comment.