diff --git a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs index f88e11d7..483065d6 100644 --- a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs +++ b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs @@ -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> OnGetMarketSymbolsAsync() diff --git a/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/Currency.cs b/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/Currency.cs index ec69c6cd..ad9639a8 100644 --- a/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/Currency.cs +++ b/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/Currency.cs @@ -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 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; } } } diff --git a/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs b/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs index 477d1667..170bb2e0 100644 --- a/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/KuCoin/ExchangeKuCoinAPI.cs @@ -126,24 +126,82 @@ protected override async Task< IReadOnlyDictionary > OnGetCurrenciesAsync() { + /** + { + "code": "200000", + "data": [ + { + "currency": "BTC", + "name": "BTC", + "fullName": "Bitcoin", + "precision": 8, + "confirms": null, + "contractAddress": null, + "isMarginEnabled": true, + "isDebitEnabled": true, + "chains": [ + { + "chainName" : "BTC", + "withdrawalMinFee" : "0.001", + "withdrawalMinSize" : "0.0012", + "withdrawFeeRate" : "0", + "depositMinSize" : "0.0002", + "isWithdrawEnabled" : true, + "isDepositEnabled" : true, + "preConfirms" : 1, + "contractAddress" : "", + "chainId" : "btc", + "confirms" : 3 + }, + { + "chainName" : "KCC", + "withdrawalMinFee" : "0.00002", + "withdrawalMinSize" : "0.0008", + "withdrawFeeRate" : "0", + "depositMinSize" : null, + "isWithdrawEnabled" : true, + "isDepositEnabled" : true, + "preConfirms" : 20, + "contractAddress" : "0xfa93c12cd345c658bc4644d1d4e1b9615952258c", + "chainId" : "kcc", + "confirms" : 20 + }, + { + "chainName" : "BTC-Segwit", + "withdrawalMinFee" : "0.0005", + "withdrawalMinSize" : "0.0008", + "withdrawFeeRate" : "0", + "depositMinSize" : "0.0002", + "isWithdrawEnabled" : false, + "isDepositEnabled" : true, + "preConfirms" : 2, + "contractAddress" : "", + "chainId" : "bech32", + "confirms" : 2 + } + ] + } + ] + } + */ + Dictionary currencies = new Dictionary(); List symbols = new List(); - // [ { "withdrawMinFee": 100000, "withdrawMinAmount": 200000, "withdrawFeeRate": 0.001, "confirmationCount": 12, "name": "Bitcoin", "tradePrecision": 7, "coin": "BTC","infoUrl": null, "enableWithdraw": true, "enableDeposit": true, "depositRemark": "", "withdrawRemark": "" } ... ] - JToken token = await MakeJsonRequestAsync("/market/open/coins"); + JToken token = await MakeJsonRequestAsync("/currencies"); foreach (JToken currency in token) currencies.Add( - currency["coin"].ToStringInvariant(), + currency["currency"].ToStringInvariant(), new ExchangeCurrency() { - Name = currency["coin"].ToStringInvariant(), - FullName = currency["name"].ToStringInvariant(), - WithdrawalEnabled = currency["enableWithdraw"].ConvertInvariant(), - DepositEnabled = currency["enableDepost"].ConvertInvariant(), - TxFee = currency["withdrawFeeRate"].ConvertInvariant(), - MinConfirmations = currency["confirmationCount"].ConvertInvariant(), + Name = currency["currency"].ToStringInvariant(), + FullName = currency["fullName"].ToStringInvariant(), + WithdrawalEnabled = currency["isDepositEnabled"].ConvertInvariant(), + DepositEnabled = currency["isWithdrawEnabled"].ConvertInvariant(), + TxFee = currency["withdrawalMinFee"].ConvertInvariant(), + MinConfirmations = currency["confirms"].ConvertInvariant(), MinWithdrawalSize = currency[ - "withdrawMinAmount" + "withdrawalMinSize" ].ConvertInvariant(), } );