diff --git a/build/csharpTranspiler.ts b/build/csharpTranspiler.ts index bfa62519e14e0..d400642f29971 100644 --- a/build/csharpTranspiler.ts +++ b/build/csharpTranspiler.ts @@ -1381,6 +1381,8 @@ class NewTranspiler { [/testSharedMethods\.assertTimestampAndDatetime\(exchange, skippedProperties, method, orderbook\)/, '// testSharedMethods.assertTimestampAndDatetime (exchange, skippedProperties, method, orderbook)'], // tmp disabling timestamp check on the orderbook [ /void function/g, 'void'], [/(\w+)\.spawn\(([^,]+),(.+)\)/gm, '$1.spawn($2, new object[] {$3})'], + // apply 'getPreTranspilationRegexes' here, bcz in CS we don't have pre-transpilation regexes + [/exchange.jsonStringifyWithNull/g, 'json'], ]; if (isWs) { diff --git a/build/goTranspiler.ts b/build/goTranspiler.ts index 9cd537aa33be7..4f25abf500bc3 100644 --- a/build/goTranspiler.ts +++ b/build/goTranspiler.ts @@ -2551,7 +2551,9 @@ func (this *${className}) Init(userConfig map[string]interface{}) { [/(interface{}\sfunc\sEquals.+\n.*\n.+\n.+|func Equals\(.+\n.*\n.*\n.*\})/gm, ''], // remove equals // Fix infinite loop bug in WebSocket tests - move now = exchange.Milliseconds() outside success check [/(\s+)(if IsTrue\(IsEqual\(success, true\)\) \{\s*\n[\s\S]*?)(\s+now = exchange\.Milliseconds\(\)\s*\n\s*\})/gm, '$1$2$1now = exchange.Milliseconds()$3'], - + // apply 'getPreTranspilationRegexes' here, bcz in GO we don't have pre-transpilation regexes + [/exchange.JsonStringifyWithNull/g, 'JsonStringify'], + // [ /object exchange(?=[,)])/g, 'Exchange exchange' ], diff --git a/build/transpile.ts b/build/transpile.ts index b865c53985469..cbfbec24d4aa5 100644 --- a/build/transpile.ts +++ b/build/transpile.ts @@ -101,6 +101,14 @@ class Transpiler { return uncameled; } + getPreTranspilationRegexes () { + // here are regexes for common language functions, which might have uniform behavior across all other langs, except JS. so, we apply JS-specific modification, during pre-transpilation process + // by this way (to edit JS only behavior), we avoid the necessity of language-specific placeholder methods across different langs' base classes + return [ + [ /exchange.jsonStringifyWithNull/g, 'JSON.stringify' ], + ]; + } + getCommonRegexes (): any[] { return [ @@ -119,6 +127,7 @@ class Transpiler { [ /\.safeList2/g, '.safe_list_2'], [ /\.safeIntegerProduct2/g, '.safe_integer_product_2'], [ /\.safeNumberOmitZero/g, '.safe_number_omit_zero'], + [ /\.exceptionMessage/g, '.exception_message'], [ /\.fetchOHLCVS/g, '.fetch_ohlcvs'], [ /\.fetchOHLCVWs/g, '.fetch_ohlcvws'], [ /\.parseOHLCVS/g, '.parse_ohlcvs'], @@ -2431,6 +2440,8 @@ class Transpiler { [ /function equals \([\S\s]+?return true;?\n}\n/g, '' ], ])); + allFiles = allFiles.map( file => this.regexAll(file, this.getPreTranspilationRegexes())); + const flatResult = await this.webworkerTranspile (allFiles, fileConfig, parserConfig); const exchangeCamelCaseProps = (str: string) => { diff --git a/cs/ccxt/base/Exchange.BaseMethods.cs b/cs/ccxt/base/Exchange.BaseMethods.cs index df63a525e944e..04f67569a8f06 100644 --- a/cs/ccxt/base/Exchange.BaseMethods.cs +++ b/cs/ccxt/base/Exchange.BaseMethods.cs @@ -391,7 +391,12 @@ public virtual object safeBool(object dictionary, object key, object defaultValu * @description safely extract boolean value from dictionary or list * @returns {bool | undefined} */ - return this.safeBoolN(dictionary, new List() {key}, defaultValue); + object value = this.safeValue(dictionary, key, defaultValue); + if (isTrue((value is bool))) + { + return value; + } + return defaultValue; } public virtual object safeDictN(object dictionaryOrList, object keys, object defaultValue = null) @@ -422,7 +427,16 @@ public virtual object safeDict(object dictionary, object key, object defaultValu * @description safely extract a dictionary from dictionary or list * @returns {object | undefined} */ - return this.safeDictN(dictionary, new List() {key}, defaultValue); + object value = this.safeValue(dictionary, key, defaultValue); + if (isTrue(isEqual(value, null))) + { + return defaultValue; + } + if (isTrue(isTrue(((value is IDictionary))) && !isTrue(((value is IList) || (value.GetType().IsGenericType && value.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>))))))) + { + return value; + } + return defaultValue; } public virtual object safeDict2(object dictionary, object key1, object key2, object defaultValue = null) @@ -475,7 +489,16 @@ public virtual object safeList(object dictionaryOrList, object key, object defau * @description safely extract an Array from dictionary or list * @returns {Array | undefined} */ - return this.safeListN(dictionaryOrList, new List() {key}, defaultValue); + object value = this.safeValue(dictionaryOrList, key, defaultValue); + if (isTrue(isEqual(value, null))) + { + return defaultValue; + } + if (isTrue(((value is IList) || (value.GetType().IsGenericType && value.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))))) + { + return value; + } + return defaultValue; } public virtual void handleDeltas(object orderbook, object deltas) @@ -7473,7 +7496,8 @@ public async virtual Task fetchPaginatedCallDynamic(object method, objec uniqueResults = this.removeRepeatedElementsFromArray(result); } object key = ((bool) isTrue((isEqual(method, "fetchOHLCV")))) ? 0 : "timestamp"; - return this.filterBySinceLimit(uniqueResults, since, limit, key); + object sortedRes = this.sortBy(uniqueResults, key); + return this.filterBySinceLimit(sortedRes, since, limit, key); } public async virtual Task safeDeterministicCall(object method, object symbol = null, object since = null, object limit = null, object timeframe = null, object parameters = null) @@ -8352,5 +8376,39 @@ public virtual void cleanCache(object subscription) } } } + + public virtual object timeframeFromMilliseconds(object ms) + { + if (isTrue(isLessThanOrEqual(ms, 0))) + { + return ""; + } + object second = 1000; + object minute = multiply(60, second); + object hour = multiply(60, minute); + object day = multiply(24, hour); + object week = multiply(7, day); + if (isTrue(isEqual(mod(ms, week), 0))) + { + return add((divide(ms, week)), "w"); + } + if (isTrue(isEqual(mod(ms, day), 0))) + { + return add((divide(ms, day)), "d"); + } + if (isTrue(isEqual(mod(ms, hour), 0))) + { + return add((divide(ms, hour)), "h"); + } + if (isTrue(isEqual(mod(ms, minute), 0))) + { + return add((divide(ms, minute)), "m"); + } + if (isTrue(isEqual(mod(ms, second), 0))) + { + return add((divide(ms, second)), "s"); + } + return ""; + } } diff --git a/cs/ccxt/base/Exchange.cs b/cs/ccxt/base/Exchange.cs index 52bc564c1eb36..d182dad8a0929 100644 --- a/cs/ccxt/base/Exchange.cs +++ b/cs/ccxt/base/Exchange.cs @@ -1024,7 +1024,7 @@ public void setProperty(object obj, object property, object defaultValue = null) } } - public string exceptionMessage(object exc) + public string exceptionMessage(object exc, bool includeStack = true) { var e = exc as Exception; if (e != null && e is System.AggregateException) @@ -1037,7 +1037,7 @@ public string exceptionMessage(object exc) e = inner; } } - var message = e != null ? e.ToString() : "Exception occurred, but no message available."; + var message = e != null ? (includeStack ? e.ToString() : e.Message) : "Exception occurred, but no message available."; return message.Substring(0, Math.Min(100000, message.Length)); } diff --git a/cs/ccxt/exchanges/bigone.cs b/cs/ccxt/exchanges/bigone.cs index dbc3ddcaf5699..0598615c9e5a4 100644 --- a/cs/ccxt/exchanges/bigone.cs +++ b/cs/ccxt/exchanges/bigone.cs @@ -1426,7 +1426,7 @@ public override object parseOrder(object order, object market = null) { // // { - // "id": "42154072251", + // "id": "42154072252", // "asset_pair_name": "SOL-USDT", // "price": "20", // "amount": "0.5", diff --git a/cs/ccxt/exchanges/bingx.cs b/cs/ccxt/exchanges/bingx.cs index f912d2e7a704c..671b8aba22271 100644 --- a/cs/ccxt/exchanges/bingx.cs +++ b/cs/ccxt/exchanges/bingx.cs @@ -65,6 +65,7 @@ public override object describe() { "fetchDeposits", true }, { "fetchDepositWithdrawFee", "emulated" }, { "fetchDepositWithdrawFees", true }, + { "fetchFundingHistory", true }, { "fetchFundingRate", true }, { "fetchFundingRateHistory", true }, { "fetchFundingRates", true }, @@ -1882,6 +1883,101 @@ public override object parseFundingRateHistory(object contract, object market = }; } + /** + * @method + * @name bingx#fetchFundingHistory + * @description fetches historical funding received + * @see https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Get%20Account%20Profit%20and%20Loss%20Fund%20Flow + * @param {string} symbol unified symbol of the market to fetch the funding history for + * @param {int} [since] timestamp in ms of the earliest funding to fetch + * @param {int} [limit] the maximum amount of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure} to fetch + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {int} [params.until] timestamp in ms of the latest funding to fetch + * @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure} + */ + public async override Task fetchFundingHistory(object symbol = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object paginate = false; + var paginateparametersVariable = this.handleOptionAndParams(parameters, "fetchFundingHistory", "paginate"); + paginate = ((IList)paginateparametersVariable)[0]; + parameters = ((IList)paginateparametersVariable)[1]; + if (isTrue(paginate)) + { + return await this.fetchPaginatedCallDeterministic("fetchFundingHistory", symbol, since, limit, "24h", parameters); + } + object request = new Dictionary() { + { "incomeType", "FUNDING_FEE" }, + }; + object market = null; + if (isTrue(!isEqual(symbol, null))) + { + market = this.market(symbol); + ((IDictionary)request)["symbol"] = getValue(market, "id"); + } + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["startTime"] = since; + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["limit"] = limit; + } + object until = this.safeInteger2(parameters, "until", "endTime"); + if (isTrue(!isEqual(until, null))) + { + parameters = this.omit(parameters, new List() {"until"}); + ((IDictionary)request)["endTime"] = until; + } + object response = await this.swapV2PrivateGetUserIncome(this.extend(request, parameters)); + // { + // "code": 0, + // "msg": "", + // "data": [ + // { + // "symbol": "LDO-USDT", + // "incomeType": "FUNDING_FEE", + // "income": "-0.0292", + // "asset": "USDT", + // "info": "Funding Fee", + // "time": 1702713615000, + // "tranId": "170***6*2_3*9_20***97", + // "tradeId": "170***6*2_3*9_20***97" + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + return this.parseIncomes(data, market, since, limit); + } + + public override object parseIncome(object income, object market = null) + { + // { + // "symbol": "LDO-USDT", + // "incomeType": "FUNDING_FEE", + // "income": "-0.0292", + // "asset": "USDT", + // "info": "Funding Fee", + // "time": 1702713615000, + // "tranId": "170***6*2_3*9_20***97", + // "tradeId": "170***6*2_3*9_20***97" + // } + object marketId = this.safeString(income, "symbol"); + object currencyId = this.safeString(income, "asset"); + object timestamp = this.safeInteger(income, "time"); + return new Dictionary() { + { "info", income }, + { "symbol", this.safeSymbol(marketId, market, null, "swap") }, + { "code", this.safeCurrencyCode(currencyId) }, + { "timestamp", timestamp }, + { "datetime", this.iso8601(timestamp) }, + { "id", this.safeString(income, "tranId") }, + { "amount", this.safeNumber(income, "income") }, + { "type", "funding" }, + }; + } + /** * @method * @name bingx#fetchOpenInterest diff --git a/cs/ccxt/exchanges/bitget.cs b/cs/ccxt/exchanges/bitget.cs index b30c41ff8e90c..6e141269dfa76 100644 --- a/cs/ccxt/exchanges/bitget.cs +++ b/cs/ccxt/exchanges/bitget.cs @@ -3351,7 +3351,6 @@ public override object parseTicker(object ticker, object market = null) object marketId = this.safeString(ticker, "symbol"); object close = this.safeString2(ticker, "lastPr", "lastPrice"); object timestamp = this.safeIntegerOmitZero(ticker, "ts"); // exchange bitget provided 0 - object change = this.safeString(ticker, "change24h"); object category = this.safeString(ticker, "category"); object markPrice = this.safeString(ticker, "markPrice"); object marketType = null; @@ -3365,7 +3364,8 @@ public override object parseTicker(object ticker, object market = null) object percentage = this.safeString(ticker, "price24hPcnt"); if (isTrue(isEqual(percentage, null))) { - percentage = Precise.stringMul(change, "100"); + object change24h = this.safeString(ticker, "change24h"); + percentage = Precise.stringMul(change24h, "100"); } return this.safeTicker(new Dictionary() { { "symbol", this.safeSymbol(marketId, market, null, marketType) }, @@ -3382,7 +3382,7 @@ public override object parseTicker(object ticker, object market = null) { "close", close }, { "last", close }, { "previousClose", null }, - { "change", change }, + { "change", null }, { "percentage", percentage }, { "average", null }, { "baseVolume", this.safeString2(ticker, "baseVolume", "volume24h") }, diff --git a/cs/ccxt/exchanges/bitrue.cs b/cs/ccxt/exchanges/bitrue.cs index 5ba268362fd7b..6d499dde61a77 100644 --- a/cs/ccxt/exchanges/bitrue.cs +++ b/cs/ccxt/exchanges/bitrue.cs @@ -2459,7 +2459,7 @@ public async override Task cancelOrder(object id, object symbol = null, // "code": "0", // "msg": "Success", // "data": { - // "orderId": 1690615847831143159 + // "orderId": 1690615847831143154 // } // } // diff --git a/cs/ccxt/exchanges/bybit.cs b/cs/ccxt/exchanges/bybit.cs index b8aeadc6ceac6..4f56d25023a21 100644 --- a/cs/ccxt/exchanges/bybit.cs +++ b/cs/ccxt/exchanges/bybit.cs @@ -833,6 +833,7 @@ public override object describe() { "170203", typeof(InvalidOrder) }, { "170204", typeof(InvalidOrder) }, { "170206", typeof(InvalidOrder) }, + { "170209", typeof(RestrictedLocation) }, { "170210", typeof(InvalidOrder) }, { "170213", typeof(OrderNotFound) }, { "170217", typeof(InvalidOrder) }, @@ -2968,7 +2969,7 @@ public async override Task fetchFundingRateHistory(object symbol = null, parameters = ((IList)paginateparametersVariable)[1]; if (isTrue(paginate)) { - return await this.fetchPaginatedCallDeterministic("fetchFundingRateHistory", symbol, since, limit, "8h", parameters, 200); + return await this.fetchPaginatedCallDynamic("fetchFundingRateHistory", symbol, since, limit, parameters, 200); } if (isTrue(isEqual(limit, null))) { @@ -2978,6 +2979,7 @@ public async override Task fetchFundingRateHistory(object symbol = null, { "limit", limit }, }; object market = this.market(symbol); + object fundingTimeFrameMins = this.safeInteger(getValue(market, "info"), "fundingInterval"); symbol = getValue(market, "symbol"); ((IDictionary)request)["symbol"] = getValue(market, "id"); object type = null; @@ -3005,7 +3007,11 @@ public async override Task fetchFundingRateHistory(object symbol = null, { // end time is required when since is not empty object fundingInterval = multiply(multiply(multiply(60, 60), 8), 1000); - ((IDictionary)request)["endTime"] = add(since, multiply(limit, fundingInterval)); + if (isTrue(!isEqual(fundingTimeFrameMins, null))) + { + fundingInterval = multiply(multiply(fundingTimeFrameMins, 60), 1000); + } + ((IDictionary)request)["endTime"] = this.sum(since, multiply(limit, fundingInterval)); } } object response = await this.publicGetV5MarketFundingHistory(this.extend(request, parameters)); @@ -10163,7 +10169,7 @@ public override object parseLongShortRatio(object info, object market = null) * @name bybit#fetchMarginMode * @description fetches the margin mode of the trading pair * @see https://bybit-exchange.github.io/docs/v5/account/account-info - * @param {string} [symbol] unified symbol of the market to fetch the margin mode for (not used by bybit) + * @param {string} [symbol] unified symbol of the market to fetch the margin mode for * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure} */ @@ -10171,6 +10177,7 @@ public async override Task fetchMarginMode(object symbol, object paramet { parameters ??= new Dictionary(); await this.loadMarkets(); + object market = this.market(symbol); object response = await this.privateGetV5AccountInfo(parameters); // // { @@ -10189,7 +10196,7 @@ public async override Task fetchMarginMode(object symbol, object paramet // } // object result = this.safeDict(response, "result", new Dictionary() {}); - return this.parseMarginMode(result); + return this.parseMarginMode(result, market); } public override object parseMarginMode(object marginMode, object market = null) diff --git a/cs/ccxt/exchanges/coinbase.cs b/cs/ccxt/exchanges/coinbase.cs index 10d006de8d596..215fec10c4992 100644 --- a/cs/ccxt/exchanges/coinbase.cs +++ b/cs/ccxt/exchanges/coinbase.cs @@ -4379,12 +4379,13 @@ public async override Task fetchBidsAsks(object symbols = null, object p * @method * @name coinbase#withdraw * @description make a withdrawal - * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#send-money + * @see https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/send-crypto * @param {string} code unified currency code * @param {float} amount the amount to withdraw * @param {string} address the address to withdraw to * @param {string} [tag] an optional tag for the withdrawal * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.network] the cryptocurrency network to use for the withdrawal using the lowercase name like bitcoin, ethereum, solana, etc. * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure} */ public async override Task withdraw(object code, object amount, object address, object tag = null, object parameters = null) diff --git a/cs/ccxt/exchanges/cryptocom.cs b/cs/ccxt/exchanges/cryptocom.cs index a2bd0e46cddb9..68f6c453b61af 100644 --- a/cs/ccxt/exchanges/cryptocom.cs +++ b/cs/ccxt/exchanges/cryptocom.cs @@ -445,6 +445,7 @@ public override object describe() { "219", typeof(InvalidOrder) }, { "306", typeof(InsufficientFunds) }, { "314", typeof(InvalidOrder) }, + { "315", typeof(InvalidOrder) }, { "325", typeof(InvalidOrder) }, { "415", typeof(InvalidOrder) }, { "10001", typeof(ExchangeError) }, diff --git a/cs/ccxt/exchanges/cryptomus.cs b/cs/ccxt/exchanges/cryptomus.cs index 30bea22d3b76a..a96874717fdfd 100644 --- a/cs/ccxt/exchanges/cryptomus.cs +++ b/cs/ccxt/exchanges/cryptomus.cs @@ -771,7 +771,7 @@ public async override Task createOrder(object symbol, object type, objec } // // { - // "order_id": "01JEXAFCCC5ZVJPZAAHHDKQBNG" + // "order_id": "01JEXAFCCC5ZVJPZAAHHDKQBMG" // } // return this.parseOrder(response, market); diff --git a/cs/ccxt/exchanges/htx.cs b/cs/ccxt/exchanges/htx.cs index d3188999b465a..4070c1b4e85f0 100644 --- a/cs/ccxt/exchanges/htx.cs +++ b/cs/ccxt/exchanges/htx.cs @@ -145,7 +145,7 @@ public override object describe() { "urls", new Dictionary() { { "logo", "https://user-images.githubusercontent.com/1294454/76137448-22748a80-604e-11ea-8069-6e389271911d.jpg" }, { "hostnames", new Dictionary() { - { "contract", "api.hbdm.com" }, + { "contract", "api.hbdm.vn" }, { "spot", "api.huobi.pro" }, { "status", new Dictionary() { { "spot", "status.huobigroup.com" }, diff --git a/cs/ccxt/exchanges/hyperliquid.cs b/cs/ccxt/exchanges/hyperliquid.cs index 90034f879ecd0..642ec9eac25e1 100644 --- a/cs/ccxt/exchanges/hyperliquid.cs +++ b/cs/ccxt/exchanges/hyperliquid.cs @@ -1473,6 +1473,7 @@ public override object parseTicker(object ticker, object market = null) { "datetime", null }, { "previousClose", this.safeNumber(ticker, "prevDayPx") }, { "close", this.safeNumber(ticker, "midPx") }, + { "last", this.safeNumber(ticker, "price") }, { "bid", this.safeNumber(bidAsk, 0) }, { "ask", this.safeNumber(bidAsk, 1) }, { "quoteVolume", this.safeNumber(ticker, "dayNtlVlm") }, diff --git a/cs/ccxt/exchanges/krakenfutures.cs b/cs/ccxt/exchanges/krakenfutures.cs index 18ff2f0496dec..7ccb26328474c 100644 --- a/cs/ccxt/exchanges/krakenfutures.cs +++ b/cs/ccxt/exchanges/krakenfutures.cs @@ -1552,6 +1552,7 @@ public async override Task fetchOrder(object id, object symbol = null, o * @param {int} [since] Timestamp (ms) of earliest order. * @param {int} [limit] How many orders to return. * @param {object} [params] Exchange specific parameters + * @param {bool} [params.trigger] set to true if you wish to fetch only trigger orders * @returns An array of [order structures]{@link https://docs.ccxt.com/?id=order-structure} */ public async override Task fetchClosedOrders(object symbol = null, object since = null, object limit = null, object parameters = null) @@ -1572,14 +1573,23 @@ public async override Task fetchClosedOrders(object symbol = null, objec { ((IDictionary)request)["from"] = since; } - object response = await this.historyGetOrders(this.extend(request, parameters)); + object isTrigger = this.safeBool2(parameters, "trigger", "stop", false); + object response = null; + if (isTrue(isTrigger)) + { + parameters = this.omit(parameters, new List() {"trigger", "stop"}); + response = await this.historyGetTriggers(this.extend(request, parameters)); + } else + { + response = await this.historyGetOrders(this.extend(request, parameters)); + } object allOrders = this.safeList(response, "elements", new List() {}); object closedOrders = new List() {}; for (object i = 0; isLessThan(i, getArrayLength(allOrders)); postFixIncrement(ref i)) { object order = getValue(allOrders, i); object eventVar = this.safeDict(order, "event", new Dictionary() {}); - object orderPlaced = this.safeDict(eventVar, "OrderPlaced"); + object orderPlaced = this.safeDict2(eventVar, "OrderPlaced", "OrderTriggerActivated"); if (isTrue(!isEqual(orderPlaced, null))) { object innerOrder = this.safeDict(orderPlaced, "order", new Dictionary() {}); @@ -1603,6 +1613,7 @@ public async override Task fetchClosedOrders(object symbol = null, objec * @param {int} [since] Timestamp (ms) of earliest order. * @param {int} [limit] How many orders to return. * @param {object} [params] Exchange specific parameters + * @param {bool} [params.trigger] set to true if you wish to fetch only trigger orders * @returns An array of [order structures]{@link https://docs.ccxt.com/?id=order-structure} */ public async override Task fetchCanceledOrders(object symbol = null, object since = null, object limit = null, object parameters = null) @@ -1623,19 +1634,29 @@ public async override Task fetchCanceledOrders(object symbol = null, obj { ((IDictionary)request)["from"] = since; } - object response = await this.historyGetOrders(this.extend(request, parameters)); + object response = null; + object isTrigger = this.safeBool2(parameters, "trigger", "stop", false); + if (isTrue(isTrigger)) + { + parameters = this.omit(parameters, new List() {"trigger", "stop"}); + response = await this.historyGetTriggers(this.extend(request, parameters)); + } else + { + response = await this.historyGetOrders(this.extend(request, parameters)); + } object allOrders = this.safeList(response, "elements", new List() {}); object canceledAndRejected = new List() {}; for (object i = 0; isLessThan(i, getArrayLength(allOrders)); postFixIncrement(ref i)) { object order = getValue(allOrders, i); object eventVar = this.safeDict(order, "event", new Dictionary() {}); - object orderPlaced = this.safeDict(eventVar, "OrderPlaced"); + object isCancelledTriggerOrder = (inOp(eventVar, "OrderTriggerCancelled")); + object orderPlaced = this.safeDict2(eventVar, "OrderPlaced", "OrderTriggerCancelled"); if (isTrue(!isEqual(orderPlaced, null))) { object innerOrder = this.safeDict(orderPlaced, "order", new Dictionary() {}); object filled = this.safeString(innerOrder, "filled"); - if (isTrue(isEqual(filled, "0"))) + if (isTrue(isTrue(isEqual(filled, "0")) || isTrue(isCancelledTriggerOrder))) { ((IDictionary)innerOrder)["status"] = "canceled"; // status not available in the response ((IList)canceledAndRejected).Add(innerOrder); @@ -3122,7 +3143,13 @@ public override object sign(object path, object api = null, object method = null body = postData; } else if (isTrue(getArrayLength(new List(((IDictionary)parameters).Keys)))) { - postData = this.urlencode(parameters); + if (isTrue(inOp(parameters, "orderIds"))) + { + postData = this.urlencodeWithArrayRepeat(parameters); + } else + { + postData = this.urlencode(parameters); + } query = add(query, add("?", postData)); } object url = add(getValue(getValue(this.urls, "api"), api), query); diff --git a/cs/ccxt/exchanges/kucoin.cs b/cs/ccxt/exchanges/kucoin.cs index 011714e11bd85..8a778b418ea25 100644 --- a/cs/ccxt/exchanges/kucoin.cs +++ b/cs/ccxt/exchanges/kucoin.cs @@ -578,7 +578,7 @@ public override object describe() { "400370", typeof(InvalidOrder) }, { "400400", typeof(BadRequest) }, { "400401", typeof(AuthenticationError) }, - { "400500", typeof(InvalidOrder) }, + { "400500", typeof(RestrictedLocation) }, { "400600", typeof(BadSymbol) }, { "400760", typeof(InvalidOrder) }, { "401000", typeof(BadRequest) }, diff --git a/cs/ccxt/exchanges/okx.cs b/cs/ccxt/exchanges/okx.cs index 00befca216bfc..2284e5b782096 100644 --- a/cs/ccxt/exchanges/okx.cs +++ b/cs/ccxt/exchanges/okx.cs @@ -1737,8 +1737,10 @@ public override object parseMarket(object market) maxLeverage = Precise.stringMax(maxLeverage, "1"); object maxSpotCost = this.safeNumber(market, "maxMktSz"); object status = this.safeString(market, "state"); + object instIdCode = this.safeInteger(market, "instIdCode"); return this.extend(fees, new Dictionary() { { "id", id }, + { "instIdCode", instIdCode }, { "symbol", symbol }, { "base", bs }, { "quote", quote }, diff --git a/cs/ccxt/exchanges/xt.cs b/cs/ccxt/exchanges/xt.cs index 2d76ecd408ff9..16e372355f1c4 100644 --- a/cs/ccxt/exchanges/xt.cs +++ b/cs/ccxt/exchanges/xt.cs @@ -1908,8 +1908,8 @@ public override object parseTicker(object ticker, object market = null) { "change", this.safeNumber(ticker, "cv") }, { "percentage", this.parseNumber(percentage) }, { "average", null }, - { "baseVolume", null }, - { "quoteVolume", this.safeNumber2(ticker, "a", "v") }, + { "baseVolume", this.safeNumber(ticker, "a") }, + { "quoteVolume", this.safeNumber(ticker, "v") }, { "info", ticker }, }, market); } @@ -3930,7 +3930,7 @@ public async override Task fetchLedger(object code = null, object since // "hasNext": false, // "items": [ // { - // "id": "207260567109387524", + // "id": "207260567109387525", // "coin": "usdt", // "symbol": "btc_usdt", // "type": "FEE", diff --git a/cs/ccxt/wrappers/bingx.cs b/cs/ccxt/wrappers/bingx.cs index 84cad89994af9..215433c114574 100644 --- a/cs/ccxt/wrappers/bingx.cs +++ b/cs/ccxt/wrappers/bingx.cs @@ -265,6 +265,46 @@ public async Task> FetchFundingRateHistory(string symbo return ((IList)res).Select(item => new FundingRateHistory(item)).ToList(); } /// + /// fetches historical funding received + /// + /// + /// See
+ /// + /// + /// since + /// + /// int : timestamp in ms of the earliest funding to fetch + /// + /// + /// + /// limit + /// + /// int : the maximum amount of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure} to fetch + /// + /// + /// + /// params + /// + /// object : extra parameters specific to the exchange API endpoint + /// + /// + /// + /// params.until + /// + /// int : timestamp in ms of the latest funding to fetch + /// + /// + /// + ///
+ /// object[] a list of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}. + public async Task> FetchFundingHistory(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + { + var since = since2 == 0 ? null : (object)since2; + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchFundingHistory(symbol, since, limit, parameters); + return ((IList)res).Select(item => new FundingHistory(item)).ToList(); + } + /// /// retrieves the open interest of a trading pair /// /// diff --git a/cs/ccxt/wrappers/bybit.cs b/cs/ccxt/wrappers/bybit.cs index e56ca2e2af484..6796f6c7f433a 100644 --- a/cs/ccxt/wrappers/bybit.cs +++ b/cs/ccxt/wrappers/bybit.cs @@ -2874,7 +2874,7 @@ public async Task> FetchLongShortRatioHistory(string symbol /// /// symbol /// - /// string : unified symbol of the market to fetch the margin mode for (not used by bybit) + /// string : unified symbol of the market to fetch the margin mode for /// /// /// diff --git a/cs/ccxt/wrappers/coinbase.cs b/cs/ccxt/wrappers/coinbase.cs index 7653579fbc666..f11701f17f63f 100644 --- a/cs/ccxt/wrappers/coinbase.cs +++ b/cs/ccxt/wrappers/coinbase.cs @@ -1113,7 +1113,7 @@ public async Task FetchBidsAsks(List symbols = null, Dictionary /// make a withdrawal /// /// - /// See
+ /// See
/// /// /// tag @@ -1127,6 +1127,12 @@ public async Task FetchBidsAsks(List symbols = null, Dictionary /// object : extra parameters specific to the exchange API endpoint /// /// + /// + /// params.network + /// + /// string : the cryptocurrency network to use for the withdrawal using the lowercase name like bitcoin, ethereum, solana, etc. + /// + /// /// ///
/// object a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}. diff --git a/cs/ccxt/wrappers/krakenfutures.cs b/cs/ccxt/wrappers/krakenfutures.cs index f3c51435f4a33..9e1f2516122a5 100644 --- a/cs/ccxt/wrappers/krakenfutures.cs +++ b/cs/ccxt/wrappers/krakenfutures.cs @@ -487,6 +487,12 @@ public async Task FetchOrder(string id, string symbol = null, Dictionary< /// object : Exchange specific parameters /// ///
+ /// + /// params.trigger + /// + /// bool : set to true if you wish to fetch only trigger orders + /// + /// /// ///
/// undefined undefined. @@ -521,6 +527,12 @@ public async Task> FetchClosedOrders(string symbol = null, Int64? si /// object : Exchange specific parameters /// /// + /// + /// params.trigger + /// + /// bool : set to true if you wish to fetch only trigger orders + /// + /// /// /// /// undefined undefined. diff --git a/cs/tests/Generated/Base/test.capitalize.cs b/cs/tests/Generated/Base/test.capitalize.cs new file mode 100644 index 0000000000000..e0cdf822ae46c --- /dev/null +++ b/cs/tests/Generated/Base/test.capitalize.cs @@ -0,0 +1,40 @@ +using ccxt; +using ccxt.pro; +namespace Tests; + +// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN: +// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code + +public partial class BaseTest +{ + public void testCapitalize() + { + var exchange = new ccxt.Exchange(new Dictionary() { + { "id", "sampleexchange" }, + }); + // Test 1: Basic lowercase string + Assert(isEqual(exchange.capitalize("hello"), "Hello")); + // Test 2: Preserve rest of string (camelCase) + Assert(isEqual(exchange.capitalize("fooBar"), "FooBar")); + // Test 3: Preserve rest of string (mixed case) + Assert(isEqual(exchange.capitalize("helloWorld"), "HelloWorld")); + // Test 4: Already capitalized + Assert(isEqual(exchange.capitalize("Hello"), "Hello")); + // Test 5: All uppercase (should preserve rest) + Assert(isEqual(exchange.capitalize("hELLO"), "HELLO")); + // Test 6: Single character lowercase + Assert(isEqual(exchange.capitalize("a"), "A")); + // Test 7: Single character uppercase + Assert(isEqual(exchange.capitalize("A"), "A")); + // Test 8: Empty string + Assert(isEqual(exchange.capitalize(""), "")); + // Test 9: String starting with number + Assert(isEqual(exchange.capitalize("123abc"), "123abc")); + // Test 10: String with spaces + Assert(isEqual(exchange.capitalize("hello world"), "Hello world")); + // Test 11: Underscore separated (snake_case) + Assert(isEqual(exchange.capitalize("foo_bar_baz"), "Foo_bar_baz")); + // Test 12: All caps input (preserve rest) + Assert(isEqual(exchange.capitalize("aBC"), "ABC")); + } +} \ No newline at end of file diff --git a/cs/tests/Generated/Base/test.deepExtend.cs b/cs/tests/Generated/Base/test.deepExtend.cs index 63e319e8a1e99..7b55aee6cbe52 100644 --- a/cs/tests/Generated/Base/test.deepExtend.cs +++ b/cs/tests/Generated/Base/test.deepExtend.cs @@ -7,12 +7,83 @@ namespace Tests; public partial class BaseTest { - public object testDeepExtend() + public void testDeepExtend() { var exchange = new ccxt.Exchange(new Dictionary() { { "id", "sampleexchange" }, }); - Assert(isEqual(exchange.parseToNumeric("1"), 1)); - return true; // dummy for now + object obj1 = new Dictionary() { + { "a", 1 }, + { "b", new List() {1, 2, 3} }, + { "c", new List() {new Dictionary() { + { "test1", 1 }, + { "test2", 1 }, + }} }, + { "d", null }, + { "e", "not_undefined" }, + { "sub", new Dictionary() { + { "a", 1 }, + { "b", new List() {1, 2} }, + { "c", new List() {new Dictionary() { + { "test1", 1 }, + { "test2", 2 }, + }} }, + { "d", null }, + { "e", "not_undefined" }, + { "other1", "x" }, + } }, + { "other1", "x" }, + }; + object obj2 = new Dictionary() { + { "a", 2 }, + { "b", new List() {3, 4} }, + { "c", new List() {new Dictionary() { + { "test1", 2 }, + { "test3", 3 }, + }} }, + { "d", "not_undefined" }, + { "e", null }, + { "sub", new Dictionary() { + { "a", 2 }, + { "b", new List() {3, 4} }, + { "c", new List() {new Dictionary() { + { "test1", 2 }, + { "test3", 3 }, + }} }, + { "d", "not_undefined" }, + { "e", null }, + { "other2", "y" }, + } }, + { "other2", "y" }, + }; + // deepExtend + object deepExtended = exchange.deepExtend(obj1, obj2); + object compareTo = new Dictionary() { + { "a", 2 }, + { "b", new List() {3, 4} }, + { "c", new List() {new Dictionary() { + { "test1", 2 }, + { "test3", 3 }, + }} }, + { "d", "not_undefined" }, + { "e", null }, + { "sub", new Dictionary() { + { "a", 2 }, + { "b", new List() {3, 4} }, + { "c", new List() {new Dictionary() { + { "test1", 2 }, + { "test3", 3 }, + }} }, + { "d", "not_undefined" }, + { "e", null }, + { "other1", "x" }, + { "other2", "y" }, + } }, + { "other1", "x" }, + { "other2", "y" }, + }; + // todo: results are different across langs. + // to avoid delay to this PR, I comment out this now, but will return to this after this PR merged + AssertDeepEqual(exchange, null, "testDeepExtend", deepExtended, compareTo); } } \ No newline at end of file diff --git a/cs/tests/Generated/Base/test.safeMethods.cs b/cs/tests/Generated/Base/test.safeMethods.cs index 2f14e49193aac..9baaa7ee86f21 100644 --- a/cs/tests/Generated/Base/test.safeMethods.cs +++ b/cs/tests/Generated/Base/test.safeMethods.cs @@ -20,6 +20,9 @@ public void testSafeMethods() { "dict", new Dictionary() { { "a", 1 }, } }, + { "listOfDicts", new List() {new Dictionary() { + { "a", 1 }, + }} }, { "str", "heLlo" }, { "strNumber", "3" }, { "zeroNumeric", 0 }, @@ -89,6 +92,10 @@ public void testSafeMethods() Assert(equals(dictObject, compareDict)); Assert(isEqual(exchange.safeList(inputDict, "dict"), null)); Assert(isEqual(exchange.safeList(inputList, 1), null)); + object arrayOfDicts = exchange.safeList(inputDict, "listOfDicts"); + Assert(equals(getValue(arrayOfDicts, 0), new Dictionary() { + { "a", 1 }, + })); // safeList2 listObject = exchange.safeList2(inputDict, "a", "list"); Assert(equals(dictObject, compareDict)); diff --git a/cs/tests/Generated/Base/tests.init.cs b/cs/tests/Generated/Base/tests.init.cs index 23023f9e12b47..30b5852da3647 100644 --- a/cs/tests/Generated/Base/tests.init.cs +++ b/cs/tests/Generated/Base/tests.init.cs @@ -16,6 +16,7 @@ async public Task baseTestsInit() testCryptography(); testDatetime(); testDecimalToPrecision(); + testCapitalize(); testNumberToString(); testPrecise(); testSafeMethods(); diff --git a/cs/tests/Generated/Exchange/Base/test.currency.cs b/cs/tests/Generated/Exchange/Base/test.currency.cs index 9da784e9dada7..71a68233c15e4 100644 --- a/cs/tests/Generated/Exchange/Base/test.currency.cs +++ b/cs/tests/Generated/Exchange/Base/test.currency.cs @@ -63,8 +63,23 @@ public static void testCurrency(Exchange exchange, object skippedProperties, obj { return; } - // - testSharedMethods.assertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor); + try + { + testSharedMethods.assertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor); + } catch(Exception e) + { + object message = exchange.exceptionMessage(e); + // check structure if key is numeric, not string + if (isTrue(isGreaterThanOrEqual(getIndexOf(message, "\"id\" key"), 0))) + { + // @ts-ignore + ((IDictionary)format)["id"] = 123; + testSharedMethods.assertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor); + } else + { + assert(isEqual(message, ""), message); + } + } // testSharedMethods.checkPrecisionAccuracy(exchange, skippedProperties, method, entry, "precision"); testSharedMethods.assertGreaterOrEqual(exchange, skippedProperties, method, entry, "fee", "0"); diff --git a/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs b/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs index f03208709ed6c..e20ae0694be6f 100644 --- a/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs +++ b/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs @@ -718,14 +718,14 @@ public void assertRoundMinuteTimestamp(Exchange exchange, object skippedProperti object ts = exchange.safeString(entry, key); assert(isEqual(Precise.stringMod(ts, "60000"), "0"), add("timestamp should be a multiple of 60 seconds (1 minute)", logText)); } - public object deepEqual(object a, object b) + public object deepEqual(Exchange exchange, object a, object b) { return isEqual(json(a), json(b)); } public void assertDeepEqual(Exchange exchange, object skippedProperties, object method, object a, object b) { object logText = logTemplate(exchange, method, new Dictionary() {}); - assert(deepEqual(a, b), add(add(add(add("two dicts do not match: ", json(a)), " != "), json(b)), logText)); + assert(deepEqual(exchange, a, b), add(add(add(add("two dicts do not match: ", json(a)), " != "), json(b)), logText)); } } diff --git a/dist/ccxt.browser.js b/dist/ccxt.browser.js index cd2d9a2b47d42..5c703a7a61964 100644 --- a/dist/ccxt.browser.js +++ b/dist/ccxt.browser.js @@ -22600,6 +22600,9 @@ class Exchange { throw e; } } + jsonStringifyWithNull(obj) { + return JSON.stringify(obj, (_, v) => (v === undefined ? null : v)); + } parseJson(jsonString) { try { if (this.isJsonEncodedObject(jsonString)) { @@ -23812,7 +23815,11 @@ class Exchange { * @description safely extract boolean value from dictionary or list * @returns {bool | undefined} */ - return this.safeBoolN(dictionary, [key], defaultValue); + const value = this.safeValue(dictionary, key, defaultValue); + if (typeof value === 'boolean') { + return value; + } + return defaultValue; } safeDictN(dictionaryOrList, keys, defaultValue = undefined) { /** @@ -23837,7 +23844,14 @@ class Exchange { * @description safely extract a dictionary from dictionary or list * @returns {object | undefined} */ - return this.safeDictN(dictionary, [key], defaultValue); + const value = this.safeValue(dictionary, key, defaultValue); + if (value === undefined) { + return defaultValue; + } + if ((typeof value === 'object') && !Array.isArray(value)) { + return value; + } + return defaultValue; } safeDict2(dictionary, key1, key2, defaultValue = undefined) { /** @@ -23880,7 +23894,14 @@ class Exchange { * @description safely extract an Array from dictionary or list * @returns {Array | undefined} */ - return this.safeListN(dictionaryOrList, [key], defaultValue); + const value = this.safeValue(dictionaryOrList, key, defaultValue); + if (value === undefined) { + return defaultValue; + } + if (Array.isArray(value)) { + return value; + } + return defaultValue; } handleDeltas(orderbook, deltas) { for (let i = 0; i < deltas.length; i++) { @@ -29089,7 +29110,8 @@ class Exchange { uniqueResults = this.removeRepeatedElementsFromArray(result); } const key = (method === 'fetchOHLCV') ? 0 : 'timestamp'; - return this.filterBySinceLimit(uniqueResults, since, limit, key); + const sortedRes = this.sortBy(uniqueResults, key); + return this.filterBySinceLimit(sortedRes, since, limit, key); } async safeDeterministicCall(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}) { let maxRetries = undefined; @@ -29854,6 +29876,32 @@ class Exchange { } } } + timeframeFromMilliseconds(ms) { + if (ms <= 0) { + return ''; + } + const second = 1000; + const minute = 60 * second; + const hour = 60 * minute; + const day = 24 * hour; + const week = 7 * day; + if (ms % week === 0) { + return (ms / week) + 'w'; + } + if (ms % day === 0) { + return (ms / day) + 'd'; + } + if (ms % hour === 0) { + return (ms / hour) + 'h'; + } + if (ms % minute === 0) { + return (ms / minute) + 'm'; + } + if (ms % second === 0) { + return (ms / second) + 's'; + } + return ''; + } } @@ -34889,7 +34937,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul parseOrder(order, market = undefined) { // // { - // "id": "42154072251", + // "id": "42154072252", // "asset_pair_name": "SOL-USDT", // "price": "20", // "amount": "0.5", @@ -50896,6 +50944,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'fetchDeposits': true, 'fetchDepositWithdrawFee': 'emulated', 'fetchDepositWithdrawFees': true, + 'fetchFundingHistory': true, 'fetchFundingRate': true, 'fetchFundingRateHistory': true, 'fetchFundingRates': true, @@ -52631,6 +52680,89 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'datetime': this.iso8601(timestamp), }; } + /** + * @method + * @name bingx#fetchFundingHistory + * @description fetches historical funding received + * @see https://bingx-api.github.io/docs-v3/#/en/Swap/Account%20Endpoints/Get%20Account%20Profit%20and%20Loss%20Fund%20Flow + * @param {string} symbol unified symbol of the market to fetch the funding history for + * @param {int} [since] timestamp in ms of the earliest funding to fetch + * @param {int} [limit] the maximum amount of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure} to fetch + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {int} [params.until] timestamp in ms of the latest funding to fetch + * @returns {object[]} a list of [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure} + */ + async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + let paginate = false; + [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate'); + if (paginate) { + return await this.fetchPaginatedCallDeterministic('fetchFundingHistory', symbol, since, limit, '24h', params); + } + const request = { + 'incomeType': 'FUNDING_FEE', + }; + let market = undefined; + if (symbol !== undefined) { + market = this.market(symbol); + request['symbol'] = market['id']; + } + if (since !== undefined) { + request['startTime'] = since; + } + if (limit !== undefined) { + request['limit'] = limit; + } + const until = this.safeInteger2(params, 'until', 'endTime'); + if (until !== undefined) { + params = this.omit(params, ['until']); + request['endTime'] = until; + } + const response = await this.swapV2PrivateGetUserIncome(this.extend(request, params)); + // { + // "code": 0, + // "msg": "", + // "data": [ + // { + // "symbol": "LDO-USDT", + // "incomeType": "FUNDING_FEE", + // "income": "-0.0292", + // "asset": "USDT", + // "info": "Funding Fee", + // "time": 1702713615000, + // "tranId": "170***6*2_3*9_20***97", + // "tradeId": "170***6*2_3*9_20***97" + // } + // ] + // } + const data = this.safeList(response, 'data', []); + return this.parseIncomes(data, market, since, limit); + } + parseIncome(income, market = undefined) { + // { + // "symbol": "LDO-USDT", + // "incomeType": "FUNDING_FEE", + // "income": "-0.0292", + // "asset": "USDT", + // "info": "Funding Fee", + // "time": 1702713615000, + // "tranId": "170***6*2_3*9_20***97", + // "tradeId": "170***6*2_3*9_20***97" + // } + const marketId = this.safeString(income, 'symbol'); + const currencyId = this.safeString(income, 'asset'); + const timestamp = this.safeInteger(income, 'time'); + return { + 'info': income, + 'symbol': this.safeSymbol(marketId, market, undefined, 'swap'), + 'code': this.safeCurrencyCode(currencyId), + 'timestamp': timestamp, + 'datetime': this.iso8601(timestamp), + 'id': this.safeString(income, 'tranId'), + 'amount': this.safeNumber(income, 'income'), + 'type': 'funding', + }; + } /** * @method * @name bingx#fetchOpenInterest @@ -69655,7 +69787,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul const marketId = this.safeString(ticker, 'symbol'); const close = this.safeString2(ticker, 'lastPr', 'lastPrice'); const timestamp = this.safeIntegerOmitZero(ticker, 'ts'); // exchange bitget provided 0 - const change = this.safeString(ticker, 'change24h'); const category = this.safeString(ticker, 'category'); const markPrice = this.safeString(ticker, 'markPrice'); let marketType; @@ -69667,7 +69798,8 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul } let percentage = this.safeString(ticker, 'price24hPcnt'); if (percentage === undefined) { - percentage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(change, '100'); + const change24h = this.safeString(ticker, 'change24h'); + percentage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(change24h, '100'); } return this.safeTicker({ 'symbol': this.safeSymbol(marketId, market, undefined, marketType), @@ -69684,7 +69816,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'close': close, 'last': close, 'previousClose': undefined, - 'change': change, + 'change': undefined, 'percentage': percentage, 'average': undefined, 'baseVolume': this.safeString2(ticker, 'baseVolume', 'volume24h'), @@ -91953,7 +92085,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // "code": "0", // "msg": "Success", // "data": { - // "orderId": 1690615847831143159 + // "orderId": 1690615847831143154 // } // } // @@ -114976,6 +115108,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" '170203': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder, '170204': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder, '170206': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder, + '170209': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.RestrictedLocation, '170210': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder, '170213': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.OrderNotFound, '170217': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder, @@ -116974,7 +117107,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" let paginate = false; [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate'); if (paginate) { - return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 200); + return await this.fetchPaginatedCallDynamic('fetchFundingRateHistory', symbol, since, limit, params, 200); } if (limit === undefined) { limit = 200; @@ -116987,6 +117120,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'limit': limit, // Limit for data size per page. [1, 200]. Default: 200 }; const market = this.market(symbol); + const fundingTimeFrameMins = this.safeInteger(market['info'], 'fundingInterval'); symbol = market['symbol']; request['symbol'] = market['id']; let type = undefined; @@ -117007,8 +117141,11 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" else { if (since !== undefined) { // end time is required when since is not empty - const fundingInterval = 60 * 60 * 8 * 1000; - request['endTime'] = since + limit * fundingInterval; + let fundingInterval = 60 * 60 * 8 * 1000; + if (fundingTimeFrameMins !== undefined) { + fundingInterval = fundingTimeFrameMins * 60 * 1000; + } + request['endTime'] = this.sum(since, limit * fundingInterval); } } const response = await this.publicGetV5MarketFundingHistory(this.extend(request, params)); @@ -123505,12 +123642,13 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" * @name bybit#fetchMarginMode * @description fetches the margin mode of the trading pair * @see https://bybit-exchange.github.io/docs/v5/account/account-info - * @param {string} [symbol] unified symbol of the market to fetch the margin mode for (not used by bybit) + * @param {string} [symbol] unified symbol of the market to fetch the margin mode for * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure} */ async fetchMarginMode(symbol, params = {}) { await this.loadMarkets(); + const market = this.market(symbol); const response = await this.privateGetV5AccountInfo(params); // // { @@ -123529,7 +123667,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" // } // const result = this.safeDict(response, 'result', {}); - return this.parseMarginMode(result); + return this.parseMarginMode(result, market); } parseMarginMode(marginMode, market = undefined) { const marginType = this.safeString(marginMode, 'marginMode'); @@ -132538,12 +132676,13 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de * @method * @name coinbase#withdraw * @description make a withdrawal - * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#send-money + * @see https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/send-crypto * @param {string} code unified currency code * @param {float} amount the amount to withdraw * @param {string} address the address to withdraw to * @param {string} [tag] an optional tag for the withdrawal * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.network] the cryptocurrency network to use for the withdrawal using the lowercase name like bitcoin, ethereum, solana, etc. * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure} */ async withdraw(code, amount, address, tag = undefined, params = {}) { @@ -158968,6 +159107,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* [" '219': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, '306': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds, '314': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + '315': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, '325': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, '415': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, '10001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, @@ -162800,7 +162940,7 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" } // // { - // "order_id": "01JEXAFCCC5ZVJPZAAHHDKQBNG" + // "order_id": "01JEXAFCCC5ZVJPZAAHHDKQBMG" // } // return this.parseOrder(response, market); @@ -213657,7 +213797,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // }, 'logo': 'https://user-images.githubusercontent.com/1294454/76137448-22748a80-604e-11ea-8069-6e389271911d.jpg', 'hostnames': { - 'contract': 'api.hbdm.com', + 'contract': 'api.hbdm.vn', 'spot': 'api.huobi.pro', 'status': { 'spot': 'status.huobigroup.com', @@ -224643,6 +224783,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'datetime': undefined, 'previousClose': this.safeNumber(ticker, 'prevDayPx'), 'close': this.safeNumber(ticker, 'midPx'), + 'last': this.safeNumber(ticker, 'price'), 'bid': this.safeNumber(bidAsk, 0), 'ask': this.safeNumber(bidAsk, 1), 'quoteVolume': this.safeNumber(ticker, 'dayNtlVlm'), @@ -235508,6 +235649,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_ * @param {int} [since] Timestamp (ms) of earliest order. * @param {int} [limit] How many orders to return. * @param {object} [params] Exchange specific parameters + * @param {bool} [params.trigger] set to true if you wish to fetch only trigger orders * @returns An array of [order structures]{@link https://docs.ccxt.com/?id=order-structure} */ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -235523,13 +235665,21 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_ if (since !== undefined) { request['from'] = since; } - const response = await this.historyGetOrders(this.extend(request, params)); + const isTrigger = this.safeBool2(params, 'trigger', 'stop', false); + let response = undefined; + if (isTrigger) { + params = this.omit(params, ['trigger', 'stop']); + response = await this.historyGetTriggers(this.extend(request, params)); + } + else { + response = await this.historyGetOrders(this.extend(request, params)); + } const allOrders = this.safeList(response, 'elements', []); const closedOrders = []; for (let i = 0; i < allOrders.length; i++) { const order = allOrders[i]; const event = this.safeDict(order, 'event', {}); - const orderPlaced = this.safeDict(event, 'OrderPlaced'); + const orderPlaced = this.safeDict2(event, 'OrderPlaced', 'OrderTriggerActivated'); if (orderPlaced !== undefined) { const innerOrder = this.safeDict(orderPlaced, 'order', {}); const filled = this.safeString(innerOrder, 'filled'); @@ -235550,6 +235700,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_ * @param {int} [since] Timestamp (ms) of earliest order. * @param {int} [limit] How many orders to return. * @param {object} [params] Exchange specific parameters + * @param {bool} [params.trigger] set to true if you wish to fetch only trigger orders * @returns An array of [order structures]{@link https://docs.ccxt.com/?id=order-structure} */ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -235565,17 +235716,26 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_ if (since !== undefined) { request['from'] = since; } - const response = await this.historyGetOrders(this.extend(request, params)); + let response = undefined; + const isTrigger = this.safeBool2(params, 'trigger', 'stop', false); + if (isTrigger) { + params = this.omit(params, ['trigger', 'stop']); + response = await this.historyGetTriggers(this.extend(request, params)); + } + else { + response = await this.historyGetOrders(this.extend(request, params)); + } const allOrders = this.safeList(response, 'elements', []); const canceledAndRejected = []; for (let i = 0; i < allOrders.length; i++) { const order = allOrders[i]; const event = this.safeDict(order, 'event', {}); - const orderPlaced = this.safeDict(event, 'OrderPlaced'); + const isCancelledTriggerOrder = ('OrderTriggerCancelled' in event); + const orderPlaced = this.safeDict2(event, 'OrderPlaced', 'OrderTriggerCancelled'); if (orderPlaced !== undefined) { const innerOrder = this.safeDict(orderPlaced, 'order', {}); const filled = this.safeString(innerOrder, 'filled'); - if (filled === '0') { + if (filled === '0' || isCancelledTriggerOrder) { innerOrder['status'] = 'canceled'; // status not available in the response canceledAndRejected.push(innerOrder); } @@ -236933,7 +237093,12 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_ body = postData; } else if (Object.keys(params).length) { - postData = this.urlencode(params); + if ('orderIds' in params) { + postData = this.urlencodeWithArrayRepeat(params); + } + else { + postData = this.urlencode(params); + } query += '?' + postData; } const url = this.urls['api'][api] + query; @@ -237595,7 +237760,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul '400370': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, '400400': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, '400401': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError, - '400500': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + '400500': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RestrictedLocation, '400600': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol, '400760': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, '401000': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, @@ -269141,8 +269306,10 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ maxLeverage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMax(maxLeverage, '1'); const maxSpotCost = this.safeNumber(market, 'maxMktSz'); const status = this.safeString(market, 'state'); + const instIdCode = this.safeInteger(market, 'instIdCode'); return this.extend(fees, { 'id': id, + 'instIdCode': instIdCode, 'symbol': symbol, 'base': base, 'quote': quote, @@ -304798,7 +304965,12 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ payload['symbol'] = market['id']; } } - const type = this.getMarketType('fetchPositionsWs', market, params); + let type = this.getMarketType('fetchPositionsWs', market, params); + if (symbols === undefined && (type === 'spot')) { + // when symbols aren't provide + // we shouldn't rely on the defaultType + type = 'future'; + } if (type !== 'future' && type !== 'delivery') { throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' fetchPositionsWs only supports swap markets'); } @@ -340259,13 +340431,13 @@ class dydx extends _dydx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { parseWsTrade(trade, market = undefined) { // // { - // "id": "02b6148d0000000200000005", + // "id": "02b6148d0000000200000003", // "side": "BUY", // "size": "0.024", // "price": "114581", // "type": "LIMIT", // "createdAt": "2025-08-04T00:42:07.118Z", - // "createdAtHeight": "45487245" + // "createdAtHeight": "45487244" // } // const timestamp = this.parse8601(this.safeString(trade, 'createdAt')); @@ -347460,22 +347632,22 @@ class htx extends _htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { }, 'future': { 'linear': { - 'public': 'wss://api.hbdm.com/linear-swap-ws', - 'private': 'wss://api.hbdm.com/linear-swap-notification', + 'public': 'wss://api.hbdm.vn/linear-swap-ws', + 'private': 'wss://api.hbdm.vn/linear-swap-notification', }, 'inverse': { - 'public': 'wss://api.hbdm.com/ws', - 'private': 'wss://api.hbdm.com/notification', + 'public': 'wss://api.hbdm.vn/ws', + 'private': 'wss://api.hbdm.vn/notification', }, }, 'swap': { 'inverse': { - 'public': 'wss://api.hbdm.com/swap-ws', - 'private': 'wss://api.hbdm.com/swap-notification', + 'public': 'wss://api.hbdm.vn/swap-ws', + 'private': 'wss://api.hbdm.vn/swap-notification', }, 'linear': { - 'public': 'wss://api.hbdm.com/linear-swap-ws', - 'private': 'wss://api.hbdm.com/linear-swap-notification', + 'public': 'wss://api.hbdm.vn/linear-swap-ws', + 'private': 'wss://api.hbdm.vn/linear-swap-notification', }, }, }, @@ -350334,6 +350506,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market * @param {string} symbol unified symbol of the market to fetch the ticker for * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.channel] 'webData2' or 'allMids', default is 'webData2' * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure} */ async watchTicker(symbol, params = {}) { @@ -350354,6 +350527,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions * @param {string[]} symbols unified symbol of the market to fetch the ticker for * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.channel] 'webData2' or 'allMids', default is 'webData2' * @param {string} [params.dex] for for hip3 tokens subscription, eg: 'xyz' or 'flx`, if symbols are provided we will infer it from the first symbol's market * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure} */ @@ -350362,10 +350536,12 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau symbols = this.marketSymbols(symbols, undefined, true); let messageHash = 'tickers'; const url = this.urls['api']['ws']['public']; + let channel = 'webData2'; + [channel, params] = this.handleOptionAndParams(params, 'watchTickers', 'channel', channel); const request = { 'method': 'subscribe', 'subscription': { - 'type': 'webData2', + 'type': channel, 'user': '0x0000000000000000000000000000000000000000', }, }; @@ -350397,18 +350573,21 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions * @param {string[]} symbols unified symbol of the market to fetch the ticker for * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.channel] 'webData2' or 'allMids', default is 'webData2' * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure} */ async unWatchTickers(symbols = undefined, params = {}) { await this.loadMarkets(); symbols = this.marketSymbols(symbols, undefined, true); const subMessageHash = 'tickers'; + let channel = 'webData2'; + [channel, params] = this.handleOptionAndParams(params, 'unWatchTickers', 'channel', channel); const messageHash = 'unsubscribe:' + subMessageHash; const url = this.urls['api']['ws']['public']; const request = { 'method': 'unsubscribe', 'subscription': { - 'type': 'webData2', + 'type': channel, 'user': '0x0000000000000000000000000000000000000000', }, }; @@ -350556,7 +350735,11 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau }, market); this.tickers[symbol] = ticker; } - const messageHash = 'tickers:' + this.safeString(data, 'dex'); + let messageHash = 'tickers'; + const dexMessage = this.safeString(data, 'dex'); + if (dexMessage !== undefined) { + messageHash += ':' + dexMessage; + } client.resolve(this.tickers, messageHash); return true; } @@ -358063,7 +358246,8 @@ class lbank extends _lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { }; const request = this.deepExtend(message, params); const trades = await this.watch(url, messageHash, request, messageHash, request); - return this.filterBySinceLimit(trades, since, limit, 'timestamp', true); + const result = this.filterBySinceLimit(trades, since, limit, 'timestamp', true); + return this.sortBy(result, 'timestamp'); // needed bcz of https://github.com/ccxt/ccxt/actions/runs/21364685870/job/61493905690?pr=27750#step:11:1067 } handleTrades(client, message) { // @@ -364985,6 +365169,12 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { let op = undefined; [op, params] = this.handleOptionAndParams(params, 'createOrderWs', 'op', 'batch-orders'); const args = this.createOrderRequest(symbol, type, side, amount, price, params); + const market = this.market(symbol); + const instIdCode = this.safeInteger(market, 'instIdCode'); + if (instIdCode !== undefined) { + delete args['instId']; + args['instIdCode'] = instIdCode; + } const ordType = this.safeString(args, 'ordType'); if ((ordType === 'trigger') || (ordType === 'conditional') || (type === 'oco') || (type === 'move_order_stop') || (type === 'iceberg') || (type === 'twap')) { throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest(this.id + ' createOrderWs() does not support algo trading. this.options["createOrderWs"]["op"] must be either order or batch-order'); @@ -365055,6 +365245,12 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { let op = undefined; [op, params] = this.handleOptionAndParams(params, 'editOrderWs', 'op', 'amend-order'); const args = this.editOrderRequest(id, symbol, type, side, amount, price, params); + const market = this.market(symbol); + const instIdCode = this.safeInteger(market, 'instIdCode'); + if (instIdCode !== undefined) { + delete args['instId']; + args['instIdCode'] = instIdCode; + } const request = { 'id': messageHash, 'op': op, @@ -365083,8 +365279,10 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { const messageHash = this.requestId(); const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId'); params = this.omit(params, ['clientOrderId', 'clOrdId']); + const market = this.market(symbol); + const instIdCode = this.safeInteger(market, 'instIdCode'); const arg = { - 'instId': this.marketId(symbol), + 'instIdCode': instIdCode, }; if (clientOrderId !== undefined) { arg['clOrdId'] = clientOrderId; @@ -365122,11 +365320,15 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { const url = this.getUrl('private', 'private'); const messageHash = this.requestId(); const args = []; + const market = this.market(symbol); + const instIdCode = this.safeInteger(market, 'instIdCode'); + const instParams = { + 'instIdCode': instIdCode, + }; for (let i = 0; i < idsLength; i++) { - const arg = { - 'instId': this.marketId(symbol), + const arg = this.extend(instParams, { 'ordId': ids[i], - }; + }); args.push(arg); } const request = { @@ -373651,7 +373853,7 @@ class toobit extends _toobit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A return; } // whether or not to schedule another listenKey keepAlive request - const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000); + const listenKeyRefreshRate = this.safeInteger(this.options['ws'], 'listenKeyRefreshRate', 1200000); this.delay(listenKeyRefreshRate, this.keepAliveListenKey, params); } getUserStreamUrl() { @@ -435896,8 +436098,8 @@ class xt extends _abstract_xt_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ . 'change': this.safeNumber(ticker, 'cv'), 'percentage': this.parseNumber(percentage), 'average': undefined, - 'baseVolume': undefined, - 'quoteVolume': this.safeNumber2(ticker, 'a', 'v'), + 'baseVolume': this.safeNumber(ticker, 'a'), + 'quoteVolume': this.safeNumber(ticker, 'v'), 'info': ticker, }, market); } @@ -437735,7 +437937,7 @@ class xt extends _abstract_xt_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ . // "hasNext": false, // "items": [ // { - // "id": "207260567109387524", + // "id": "207260567109387525", // "coin": "usdt", // "symbol": "btc_usdt", // "type": "FEE", diff --git a/dist/ccxt.browser.min.js b/dist/ccxt.browser.min.js index 0ce2c4835019f..d12458e1dd3c7 100644 --- a/dist/ccxt.browser.min.js +++ b/dist/ccxt.browser.min.js @@ -1,4 +1,4 @@ -(()=>{var __webpack_modules__={8045:e=>{"use strict";e.exports=function(e,t){var i=new Array(arguments.length-1),s=0,r=2,a=!0;for(;r{"use strict";var i=t;i.length=function(e){var t=e.length;if(!t)return 0;for(var i=0;--t%4>1&&"="===e.charAt(t);)++i;return Math.ceil(3*e.length)/4-i};for(var s=new Array(64),r=new Array(123),a=0;a<64;)r[s[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;i.encode=function(e,t,i){for(var r,a=null,o=[],n=0,d=0;t>2],r=(3&c)<<4,d=1;break;case 1:o[n++]=s[r|c>>4],r=(15&c)<<2,d=2;break;case 2:o[n++]=s[r|c>>6],o[n++]=s[63&c],d=0}n>8191&&((a||(a=[])).push(String.fromCharCode.apply(String,o)),n=0)}return d&&(o[n++]=s[r],o[n++]=61,1===d&&(o[n++]=61)),a?(n&&a.push(String.fromCharCode.apply(String,o.slice(0,n))),a.join("")):String.fromCharCode.apply(String,o.slice(0,n))};var o="invalid encoding";i.decode=function(e,t,i){for(var s,a=i,n=0,d=0;d1)break;if(void 0===(c=r[c]))throw Error(o);switch(n){case 0:s=c,n=1;break;case 1:t[i++]=s<<2|(48&c)>>4,s=c,n=2;break;case 2:t[i++]=(15&s)<<4|(60&c)>>2,s=c,n=3;break;case 3:t[i++]=(3&s)<<6|c,n=0}}if(1===n)throw Error(o);return i-a},i.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},4358:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,i){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:i||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var i=this._listeners[e],s=0;s{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),i=new Uint8Array(t.buffer),s=128===i[3];function r(e,s,r){t[0]=e,s[r]=i[0],s[r+1]=i[1],s[r+2]=i[2],s[r+3]=i[3]}function a(e,s,r){t[0]=e,s[r]=i[3],s[r+1]=i[2],s[r+2]=i[1],s[r+3]=i[0]}function o(e,s){return i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],i[3]=e[s+3],t[0]}function n(e,s){return i[3]=e[s],i[2]=e[s+1],i[1]=e[s+2],i[0]=e[s+3],t[0]}e.writeFloatLE=s?r:a,e.writeFloatBE=s?a:r,e.readFloatLE=s?o:n,e.readFloatBE=s?n:o}():function(){function t(e,t,i,s){var r=t<0?1:0;if(r&&(t=-t),0===t)e(1/t>0?0:2147483648,i,s);else if(isNaN(t))e(2143289344,i,s);else if(t>34028234663852886e22)e((r<<31|2139095040)>>>0,i,s);else if(t<11754943508222875e-54)e((r<<31|Math.round(t/1401298464324817e-60))>>>0,i,s);else{var a=Math.floor(Math.log(t)/Math.LN2);e((r<<31|a+127<<23|8388607&Math.round(t*Math.pow(2,-a)*8388608))>>>0,i,s)}}function o(e,t,i){var s=e(t,i),r=2*(s>>31)+1,a=s>>>23&255,o=8388607&s;return 255===a?o?NaN:r*(1/0):0===a?1401298464324817e-60*r*o:r*Math.pow(2,a-150)*(o+8388608)}e.writeFloatLE=t.bind(null,i),e.writeFloatBE=t.bind(null,s),e.readFloatLE=o.bind(null,r),e.readFloatBE=o.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),i=new Uint8Array(t.buffer),s=128===i[7];function r(e,s,r){t[0]=e,s[r]=i[0],s[r+1]=i[1],s[r+2]=i[2],s[r+3]=i[3],s[r+4]=i[4],s[r+5]=i[5],s[r+6]=i[6],s[r+7]=i[7]}function a(e,s,r){t[0]=e,s[r]=i[7],s[r+1]=i[6],s[r+2]=i[5],s[r+3]=i[4],s[r+4]=i[3],s[r+5]=i[2],s[r+6]=i[1],s[r+7]=i[0]}function o(e,s){return i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],i[3]=e[s+3],i[4]=e[s+4],i[5]=e[s+5],i[6]=e[s+6],i[7]=e[s+7],t[0]}function n(e,s){return i[7]=e[s],i[6]=e[s+1],i[5]=e[s+2],i[4]=e[s+3],i[3]=e[s+4],i[2]=e[s+5],i[1]=e[s+6],i[0]=e[s+7],t[0]}e.writeDoubleLE=s?r:a,e.writeDoubleBE=s?a:r,e.readDoubleLE=s?o:n,e.readDoubleBE=s?n:o}():function(){function t(e,t,i,s,r,a){var o=s<0?1:0;if(o&&(s=-s),0===s)e(0,r,a+t),e(1/s>0?0:2147483648,r,a+i);else if(isNaN(s))e(0,r,a+t),e(2146959360,r,a+i);else if(s>17976931348623157e292)e(0,r,a+t),e((o<<31|2146435072)>>>0,r,a+i);else{var n;if(s<22250738585072014e-324)e((n=s/5e-324)>>>0,r,a+t),e((o<<31|n/4294967296)>>>0,r,a+i);else{var d=Math.floor(Math.log(s)/Math.LN2);1024===d&&(d=1023),e(4503599627370496*(n=s*Math.pow(2,-d))>>>0,r,a+t),e((o<<31|d+1023<<20|1048576*n&1048575)>>>0,r,a+i)}}}function o(e,t,i,s,r){var a=e(s,r+t),o=e(s,r+i),n=2*(o>>31)+1,d=o>>>20&2047,c=4294967296*(1048575&o)+a;return 2047===d?c?NaN:n*(1/0):0===d?5e-324*n*c:n*Math.pow(2,d-1075)*(c+4503599627370496)}e.writeDoubleLE=t.bind(null,i,0,4),e.writeDoubleBE=t.bind(null,s,4,0),e.readDoubleLE=o.bind(null,r,0,4),e.readDoubleBE=o.bind(null,a,4,0)}(),e}function i(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}function s(e,t,i){t[i]=e>>>24,t[i+1]=e>>>16&255,t[i+2]=e>>>8&255,t[i+3]=255&e}function r(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},4153:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},9390:e=>{"use strict";e.exports=function(e,t,i){var s=i||8192,r=s>>>1,a=null,o=s;return function(i){if(i<1||i>r)return e(i);o+i>s&&(a=e(s),o=0);var n=t.call(a,o,o+=i);return 7&o&&(o=1+(7|o)),n}}},1447:(e,t)=>{"use strict";var i=t;i.length=function(e){for(var t=0,i=0,s=0;s191&&s<224?a[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,a[o++]=55296+(s>>10),a[o++]=56320+(1023&s)):a[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,a)),o=0);return r?(o&&r.push(String.fromCharCode.apply(String,a.slice(0,o))),r.join("")):String.fromCharCode.apply(String,a.slice(0,o))},i.write=function(e,t,i){for(var s,r,a=i,o=0;o>6|192,t[i++]=63&s|128):55296==(64512&s)&&56320==(64512&(r=e.charCodeAt(o+1)))?(s=65536+((1023&s)<<10)+(1023&r),++o,t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=63&s|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=63&s|128);return i-a}},6946:(e,t,i)=>{"use strict";e.exports=i(4394)},4394:(e,t,i)=>{"use strict";var s=t;function r(){s.util._configure(),s.Writer._configure(s.BufferWriter),s.Reader._configure(s.BufferReader)}s.build="minimal",s.Writer=i(3449),s.BufferWriter=i(818),s.Reader=i(6237),s.BufferReader=i(3158),s.util=i(3610),s.rpc=i(5047),s.roots=i(4529),s.configure=r,r()},6237:(e,t,i)=>{"use strict";e.exports=d;var s,r=i(3610),a=r.LongBits,o=r.utf8;function n(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function d(e){this.buf=e,this.pos=0,this.len=e.length}var c,h="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new d(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new d(e);throw Error("illegal buffer")},l=function(){return r.Buffer?function(e){return(d.create=function(e){return r.Buffer.isBuffer(e)?new s(e):h(e)})(e)}:h};function u(){var e=new a(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw n(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw n(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function p(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw n(this,8);return new a(p(this.buf,this.pos+=4),p(this.buf,this.pos+=4))}d.create=l(),d.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice,d.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return c;if((this.pos+=5)>this.len)throw this.pos=this.len,n(this,10);return c}),d.prototype.int32=function(){return 0|this.uint32()},d.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},d.prototype.bool=function(){return 0!==this.uint32()},d.prototype.fixed32=function(){if(this.pos+4>this.len)throw n(this,4);return p(this.buf,this.pos+=4)},d.prototype.sfixed32=function(){if(this.pos+4>this.len)throw n(this,4);return 0|p(this.buf,this.pos+=4)},d.prototype.float=function(){if(this.pos+4>this.len)throw n(this,4);var e=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},d.prototype.double=function(){if(this.pos+8>this.len)throw n(this,4);var e=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},d.prototype.bytes=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw n(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,i);if(t===i){var s=r.Buffer;return s?s.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,i)},d.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},d.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw n(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw n(this)}while(128&this.buf[this.pos++]);return this},d.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},d._configure=function(e){s=e,d.create=l(),s._configure();var t=r.Long?"toLong":"toNumber";r.merge(d.prototype,{int64:function(){return u.call(this)[t](!1)},uint64:function(){return u.call(this)[t](!0)},sint64:function(){return u.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},3158:(e,t,i)=>{"use strict";e.exports=a;var s=i(6237);(a.prototype=Object.create(s.prototype)).constructor=a;var r=i(3610);function a(e){s.call(this,e)}a._configure=function(){r.Buffer&&(a.prototype._slice=r.Buffer.prototype.slice)},a.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},a._configure()},4529:e=>{"use strict";e.exports={}},5047:(e,t,i)=>{"use strict";t.Service=i(7595)},7595:(e,t,i)=>{"use strict";e.exports=r;var s=i(3610);function r(e,t,i){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");s.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(i)}(r.prototype=Object.create(s.EventEmitter.prototype)).constructor=r,r.prototype.rpcCall=function e(t,i,r,a,o){if(!a)throw TypeError("request must be specified");var n=this;if(!o)return s.asPromise(e,n,t,i,r,a);if(n.rpcImpl)try{return n.rpcImpl(t,i[n.requestDelimited?"encodeDelimited":"encode"](a).finish(),(function(e,i){if(e)return n.emit("error",e,t),o(e);if(null!==i){if(!(i instanceof r))try{i=r[n.responseDelimited?"decodeDelimited":"decode"](i)}catch(e){return n.emit("error",e,t),o(e)}return n.emit("data",i,t),o(null,i)}n.end(!0)}))}catch(e){return n.emit("error",e,t),void setTimeout((function(){o(e)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},r.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},2239:(e,t,i)=>{"use strict";e.exports=r;var s=i(3610);function r(e,t){this.lo=e>>>0,this.hi=t>>>0}var a=r.zero=new r(0,0);a.toNumber=function(){return 0},a.zzEncode=a.zzDecode=function(){return this},a.length=function(){return 1};var o=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(e){if(0===e)return a;var t=e<0;t&&(e=-e);var i=e>>>0,s=(e-i)/4294967296>>>0;return t&&(s=~s>>>0,i=~i>>>0,++i>4294967295&&(i=0,++s>4294967295&&(s=0))),new r(i,s)},r.from=function(e){if("number"==typeof e)return r.fromNumber(e);if(s.isString(e)){if(!s.Long)return r.fromNumber(parseInt(e,10));e=s.Long.fromString(e)}return e.low||e.high?new r(e.low>>>0,e.high>>>0):a},r.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,i=~this.hi>>>0;return t||(i=i+1>>>0),-(t+4294967296*i)}return this.lo+4294967296*this.hi},r.prototype.toLong=function(e){return s.Long?new s.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var n=String.prototype.charCodeAt;r.fromHash=function(e){return e===o?a:new r((n.call(e,0)|n.call(e,1)<<8|n.call(e,2)<<16|n.call(e,3)<<24)>>>0,(n.call(e,4)|n.call(e,5)<<8|n.call(e,6)<<16|n.call(e,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},r.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},r.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0===i?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10}},3610:function(e,t,i){"use strict";var s=t;function r(e,t,i){for(var s=Object.keys(t),r=0;r0)},s.Buffer=function(){try{var e=s.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),s._Buffer_from=null,s._Buffer_allocUnsafe=null,s.newBuffer=function(e){return"number"==typeof e?s.Buffer?s._Buffer_allocUnsafe(e):new s.Array(e):s.Buffer?s._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},s.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,s.Long=s.global.dcodeIO&&s.global.dcodeIO.Long||s.global.Long||s.inquire("long"),s.key2Re=/^true|false|0|1$/,s.key32Re=/^-?(?:0|[1-9][0-9]*)$/,s.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,s.longToHash=function(e){return e?s.LongBits.from(e).toHash():s.LongBits.zeroHash},s.longFromHash=function(e,t){var i=s.LongBits.fromHash(e);return s.Long?s.Long.fromBits(i.lo,i.hi,t):i.toNumber(Boolean(t))},s.merge=r,s.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},s.newError=a,s.ProtocolError=a("ProtocolError"),s.oneOfGetter=function(e){for(var t={},i=0;i-1;--i)if(1===t[e[i]]&&void 0!==this[e[i]]&&null!==this[e[i]])return e[i]}},s.oneOfSetter=function(e){return function(t){for(var i=0;i{"use strict";e.exports=l;var s,r=i(3610),a=r.LongBits,o=r.base64,n=r.utf8;function d(e,t,i){this.fn=e,this.len=t,this.next=void 0,this.val=i}function c(){}function h(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function l(){this.len=0,this.head=new d(c,0,0),this.tail=this.head,this.states=null}var u=function(){return r.Buffer?function(){return(l.create=function(){return new s})()}:function(){return new l}};function p(e,t,i){t[i]=255&e}function f(e,t){this.len=e,this.next=void 0,this.val=t}function m(e,t,i){for(;e.hi;)t[i++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[i++]=127&e.lo|128,e.lo=e.lo>>>7;t[i++]=e.lo}function g(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}l.create=u(),l.alloc=function(e){return new r.Array(e)},r.Array!==Array&&(l.alloc=r.pool(l.alloc,r.Array.prototype.subarray)),l.prototype._push=function(e,t,i){return this.tail=this.tail.next=new d(e,t,i),this.len+=t,this},f.prototype=Object.create(d.prototype),f.prototype.fn=function(e,t,i){for(;e>127;)t[i++]=127&e|128,e>>>=7;t[i]=e},l.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new f((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},l.prototype.int32=function(e){return e<0?this._push(m,10,a.fromNumber(e)):this.uint32(e)},l.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},l.prototype.uint64=function(e){var t=a.from(e);return this._push(m,t.length(),t)},l.prototype.int64=l.prototype.uint64,l.prototype.sint64=function(e){var t=a.from(e).zzEncode();return this._push(m,t.length(),t)},l.prototype.bool=function(e){return this._push(p,1,e?1:0)},l.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},l.prototype.sfixed32=l.prototype.fixed32,l.prototype.fixed64=function(e){var t=a.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},l.prototype.sfixed64=l.prototype.fixed64,l.prototype.float=function(e){return this._push(r.float.writeFloatLE,4,e)},l.prototype.double=function(e){return this._push(r.float.writeDoubleLE,8,e)};var v=r.Array.prototype.set?function(e,t,i){t.set(e,i)}:function(e,t,i){for(var s=0;s>>0;if(!t)return this._push(p,1,0);if(r.isString(e)){var i=l.alloc(t=o.length(e));o.decode(e,i,0),e=i}return this.uint32(t)._push(v,t,e)},l.prototype.string=function(e){var t=n.length(e);return t?this.uint32(t)._push(n.write,t,e):this._push(p,1,0)},l.prototype.fork=function(){return this.states=new h(this),this.head=this.tail=new d(c,0,0),this.len=0,this},l.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new d(c,0,0),this.len=0),this},l.prototype.ldelim=function(){var e=this.head,t=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=e.next,this.tail=t,this.len+=i),this},l.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),i=0;e;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t},l._configure=function(e){s=e,l.create=u(),s._configure()}},818:(e,t,i)=>{"use strict";e.exports=a;var s=i(3449);(a.prototype=Object.create(s.prototype)).constructor=a;var r=i(3610);function a(){s.call(this)}function o(e,t,i){e.length<40?r.utf8.write(e,t,i):t.utf8Write?t.utf8Write(e,i):t.write(e,i)}a._configure=function(){a.alloc=r._Buffer_allocUnsafe,a.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&"set"===r.Buffer.prototype.set.name?function(e,t,i){t.set(e,i)}:function(e,t,i){if(e.copy)e.copy(t,i,0,e.length);else for(var s=0;s>>0;return this.uint32(t),t&&this._push(a.writeBytesBuffer,t,e),this},a.prototype.string=function(e){var t=r.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},a._configure()},4242:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4523:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1185:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2975:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},566:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6510:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5475:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3971:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},335:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4619:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3885:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2308:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5625:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9332:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1578:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9152:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3974:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1466:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8186:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7202:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8800:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9656:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5223:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8535:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7754:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8716:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5254:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1769:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3829:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2317:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8430:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7198:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1293:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5439:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5465:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5661:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1552:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2609:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5769:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2938:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5277:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8109:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1671:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6658:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4935:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9360:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4295:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3037:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1786:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9872:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7227:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4012:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},970:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9420:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8918:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1352:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2597:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7418:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3434:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9722:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5825:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},706:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1180:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8617:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9023:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},359:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4558:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2459:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1359:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3548:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3942:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(1397);class r extends s.A{}const a=r},121:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},575:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7533:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6928:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9174:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5362:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3414:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1426:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5531:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3800:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9401:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7849:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2134:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8563:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4158:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7733:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},995:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},334:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7999:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3016:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6405:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5317:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3965:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7246:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5308:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3521:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3578:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8291:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4456:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5517:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5569:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(4242),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"alp",name:"Alp",countries:["US"],version:"v1",rateLimit:10,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL2OrderBook:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1},timeframes:{"5m":"5","15m":"15","30m":"30","1h":"60","4h":"240","1d":"D"},urls:{logo:"https://github.com/user-attachments/assets/dce49f3a-61e5-4ba0-a2fe-41d192fd0e5d",api:{rest:"https://alp.com/api"},www:"https://alp.com",doc:"https://alpcomdev.github.io/alp-api-docs/",fees:"https://alp.com/fees/",referral:"https://alp.com/?r=123788"},api:{public:{get:{"currencies/":1,"pairs/":1,"orderbook/{pair_name}":1,"exchanges/":1,"charts/{pair}/{type}/chart/":1,"ticker/":1}},private:{get:{"wallets/":50,"orders/own/":50,"order/{id}/":50,"exchanges/own/":50,"deposits/":50,"withdraws/":50},post:{"order/":50,"order-cancel/":50}}},fees:{trading:{maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")},funding:{withdraw:{}}},commonCurrencies:{CBC:"Cashbery"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:2e3,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:2e3,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:2e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:720}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{},broad:{"Out of balance":r.InsufficientFunds}}})}async fetchMarkets(e={}){const t=await this.publicGetPairs(e);return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"name"),i=this.safeString(e,"currency1"),s=this.safeString(e,"currency2"),r=this.safeCurrencyCode(i),o=this.safeCurrencyCode(s),n=this.safeString(e,"price_precision"),d=this.parsePrecision(n),c=this.safeString(e,"minimum_order_size");return{id:t,symbol:r+"/"+o,base:r,quote:o,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:!0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(e,"amount_precision"))),price:this.parseNumber(this.parsePrecision(n))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(c),max:this.safeNumber(e,"maximum_order_size")},price:{min:this.parseNumber(d),max:void 0},cost:{min:this.parseNumber(a.Y.stringMul(d,c)),max:void 0}},created:void 0,info:e}}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.publicGetTicker(t);return this.parseTickers(i,e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={pair:i.id},r=await this.publicGetTicker(this.extend(s,t));return this.parseTicker(r,i)}parseTicker(e,t=void 0){const i=this.safeString(e,"timestamp"),s=parseInt(a.Y.stringMul(i,"1000000")),r=this.safeString(e,"pair");t=this.safeMarket(r,t,"_");const o=this.safeString(e,"last");return this.safeTicker({info:e,symbol:t.symbol,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:o,last:o,previousClose:void 0,change:this.safeString(e,"diff"),percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:this.safeString(e,"vol")},t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={pair_name:s.id};t&&(r.limit_sell=t,r.limit_buy=t);const a=await this.publicGetOrderbookPairName(this.extend(r,i));return this.parseOrderBook(a,s.symbol,void 0,"buy","sell","price","amount")}parseBidsAsks(e,t=0,i=1,s=2){const r=[];for(let s=0;s{"use strict";i.d(t,{A:()=>n});var s=i(4523),r=i(5147),a=i(2079),o=i(1579);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"alpaca",name:"Alpaca",countries:["US"],rateLimit:333,hostname:"alpaca.markets",pro:!0,urls:{logo:"https://github.com/user-attachments/assets/e9476df8-a450-4c3e-ab9a-1a7794219e1b",www:"https://alpaca.markets",api:{broker:"https://broker-api.{hostname}",trader:"https://api.{hostname}",market:"https://data.{hostname}"},test:{broker:"https://broker-api.sandbox.{hostname}",trader:"https://paper-api.{hostname}",market:"https://data.{hostname}"},doc:"https://alpaca.markets/docs/",fees:"https://docs.alpaca.markets/docs/crypto-fees"},has:{CORS:!1,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!0,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,createStopOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL1OrderBook:!0,fetchL2OrderBook:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},api:{broker:{},trader:{private:{get:["v2/account","v2/orders","v2/orders/{order_id}","v2/positions","v2/positions/{symbol_or_asset_id}","v2/account/portfolio/history","v2/watchlists","v2/watchlists/{watchlist_id}","v2/watchlists:by_name","v2/account/configurations","v2/account/activities","v2/account/activities/{activity_type}","v2/calendar","v2/clock","v2/assets","v2/assets/{symbol_or_asset_id}","v2/corporate_actions/announcements/{id}","v2/corporate_actions/announcements","v2/wallets","v2/wallets/transfers"],post:["v2/orders","v2/watchlists","v2/watchlists/{watchlist_id}","v2/watchlists:by_name","v2/wallets/transfers"],put:["v2/orders/{order_id}","v2/watchlists/{watchlist_id}","v2/watchlists:by_name"],patch:["v2/orders/{order_id}","v2/account/configurations"],delete:["v2/orders","v2/orders/{order_id}","v2/positions","v2/positions/{symbol_or_asset_id}","v2/watchlists/{watchlist_id}","v2/watchlists:by_name","v2/watchlists/{watchlist_id}/{symbol}"]}},market:{public:{get:["v1beta3/crypto/{loc}/bars","v1beta3/crypto/{loc}/latest/bars","v1beta3/crypto/{loc}/latest/orderbooks","v1beta3/crypto/{loc}/latest/quotes","v1beta3/crypto/{loc}/latest/trades","v1beta3/crypto/{loc}/quotes","v1beta3/crypto/{loc}/snapshots","v1beta3/crypto/{loc}/trades"]},private:{get:["v1beta1/corporate-actions","v1beta1/forex/latest/rates","v1beta1/forex/rates","v1beta1/logos/{symbol}","v1beta1/news","v1beta1/screener/stocks/most-actives","v1beta1/screener/{market_type}/movers","v2/stocks/auctions","v2/stocks/bars","v2/stocks/bars/latest","v2/stocks/meta/conditions/{ticktype}","v2/stocks/meta/exchanges","v2/stocks/quotes","v2/stocks/quotes/latest","v2/stocks/snapshots","v2/stocks/trades","v2/stocks/trades/latest","v2/stocks/{symbol}/auctions","v2/stocks/{symbol}/bars","v2/stocks/{symbol}/bars/latest","v2/stocks/{symbol}/quotes","v2/stocks/{symbol}/quotes/latest","v2/stocks/{symbol}/snapshot","v2/stocks/{symbol}/trades","v2/stocks/{symbol}/trades/latest"]}}},timeframes:{"1m":"1min","3m":"3min","5m":"5min","15m":"15min","30m":"30min","1h":"1H","2h":"2H","4h":"4H","6h":"6H","8h":"8H","12h":"12H","1d":"1D","3d":"3D","1w":"1W","1M":"1M"},precisionMode:o.kb,requiredCredentials:{apiKey:!0,secret:!0},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0015"),taker:this.parseNumber("0.0025"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0025")],[this.parseNumber("100000"),this.parseNumber("0.0022")],[this.parseNumber("500000"),this.parseNumber("0.0020")],[this.parseNumber("1000000"),this.parseNumber("0.0018")],[this.parseNumber("10000000"),this.parseNumber("0.0015")],[this.parseNumber("25000000"),this.parseNumber("0.0013")],[this.parseNumber("50000000"),this.parseNumber("0.0012")],[this.parseNumber("100000000"),this.parseNumber("0.001")]],maker:[[this.parseNumber("0"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.0012")],[this.parseNumber("500000"),this.parseNumber("0.001")],[this.parseNumber("1000000"),this.parseNumber("0.0008")],[this.parseNumber("10000000"),this.parseNumber("0.0005")],[this.parseNumber("25000000"),this.parseNumber("0.0002")],[this.parseNumber("50000000"),this.parseNumber("0.0002")],[this.parseNumber("100000000"),this.parseNumber("0.00")]]}}},headers:{"APCA-PARTNER-ID":"ccxt"},options:{defaultExchange:"CBSE",exchanges:["CBSE","FTX","GNSS","ERSX"],defaultTimeInForce:"gtc",clientOrderId:"ccxt_{id}"},features:{spot:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!0,index:!0},price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:1e5,daysBackCanceled:void 0,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"forbidden.":a.PermissionDenied,4041e4:a.InvalidOrder,40010001:a.BadRequest,4011e4:a.PermissionDenied,4031e4:a.InsufficientFunds,4291e4:a.RateLimitExceeded},broad:{"Invalid format for parameter":a.BadRequest,"Invalid symbol":a.BadSymbol}}})}async fetchTime(e={}){const t=await this.traderPrivateGetV2Clock(e),i=this.safeString(t,"timestamp"),s=i.slice(0,23),r=i.length-6,a=i.length-3,o=i.slice(r,a);return this.parse8601(s)-3600*this.parseToNumeric(o)*1e3}async fetchMarkets(e={}){const t=await this.traderPrivateGetV2Assets(this.extend({asset_class:"crypto",status:"active"},e));return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"symbol"),i=t.split("/"),s=this.safeString(e,"class"),r=this.safeString(i,0),a=this.safeString(i,1),o=this.safeCurrencyCode(r);let n=this.safeCurrencyCode(a);void 0===n&&"us_equity"===s&&(n="USD");const d=o+"/"+n,c="active"===this.safeString(e,"status"),h=this.safeNumber(e,"min_order_size");return{id:t,symbol:d,base:o,quote:n,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:void 0,swap:!1,future:!1,option:!1,active:c,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"min_trade_increment"),price:this.safeNumber(e,"price_increment")},limits:{leverage:{min:void 0,max:void 0},amount:{min:h,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),o=r.id,n=this.safeString(s,"loc","us"),d=this.safeString(s,"method","marketPublicGetV1beta3CryptoLocTrades"),c={symbols:o,loc:n};let h;if(s=this.omit(s,["loc","method"]),"marketPublicGetV1beta3CryptoLocTrades"===d){void 0!==t&&(c.start=this.iso8601(t)),void 0!==i&&(c.limit=i);const e=await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(c,s)),r=this.safeDict(e,"trades",{});h=this.safeList(r,o,[])}else{if("marketPublicGetV1beta3CryptoLocLatestTrades"!==d)throw new a.NotSupported(this.id+" fetchTrades() does not support "+d+", marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported");{const e=await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(c,s)),t=this.safeDict(e,"trades",{});h=this.safeDict(t,o,{}),h=[h]}}return this.parseTrades(h,r,t,i)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r=s.id,a={symbols:r,loc:this.safeString(i,"loc","us")},o=await this.marketPublicGetV1beta3CryptoLocLatestOrderbooks(this.extend(a,i)),n=this.safeDict(o,"orderbooks",{}),d=this.safeDict(n,r,{}),c=this.parse8601(this.safeString(d,"t"));return this.parseOrderBook(d,s.symbol,c,"b","a","p","s")}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const o=this.market(e),n=o.id,d=this.safeString(r,"loc","us"),c=this.safeString(r,"method","marketPublicGetV1beta3CryptoLocBars"),h={symbols:n,loc:d};let l;if(r=this.omit(r,["loc","method"]),"marketPublicGetV1beta3CryptoLocBars"===c){void 0!==s&&(h.limit=s),void 0!==i&&(h.start=this.yyyymmdd(i)),h.timeframe=this.safeString(this.timeframes,t,t);const e=await this.marketPublicGetV1beta3CryptoLocBars(this.extend(h,r)),a=this.safeDict(e,"bars",{});l=this.safeList(a,n,[])}else{if("marketPublicGetV1beta3CryptoLocLatestBars"!==c)throw new a.NotSupported(this.id+" fetchOHLCV() does not support "+c+", marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported");{const e=await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(h,r)),t=this.safeDict(e,"bars",{});l=this.safeDict(t,n,{}),l=[l]}}return this.parseOHLCVs(l,o,t,i,s)}parseOHLCV(e,t=void 0){const i=this.safeString(e,"t");return[this.parse8601(i),this.safeNumber(e,"o"),this.safeNumber(e,"h"),this.safeNumber(e,"l"),this.safeNumber(e,"c"),this.safeNumber(e,"v")]}async fetchTicker(e,t={}){await this.loadMarkets(),e=this.symbol(e);const i=await this.fetchTickers([e],t);return this.safeDict(i,e)}async fetchTickers(e=void 0,t={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchTickers() requires a symbols argument");await this.loadMarkets(),e=this.marketSymbols(e);const i=this.safeString(t,"loc","us"),s={symbols:this.marketIds(e).join(","),loc:i};t=this.omit(t,"loc");const r=await this.marketPublicGetV1beta3CryptoLocSnapshots(this.extend(s,t)),o=[],n=this.safeDict(r,"snapshots",{}),d=Object.keys(n);for(let e=0;e=0))throw new a.NotSupported(this.id+" createOrder() does not support stop orders for "+t+" orders, only stop_limit orders are supported");i="stop_limit",d.stop_price=this.priceToPrecision(e,c),d.type=i}t.indexOf("limit")>=0&&(d.limit_price=this.priceToPrecision(e,r));const h=this.safeString(o,"cost");void 0!==h?(o=this.omit(o,"cost"),d.notional=this.costToPrecision(e,h)):d.qty=this.amountToPrecision(e,s);const l=this.safeString(this.options,"defaultTimeInForce");d.time_in_force=this.safeString(o,"timeInForce",l),o=this.omit(o,["timeInForce","triggerPrice"]),d.client_order_id=this.generateClientOrderId(o),o=this.omit(o,["clientOrderId"]);const u=await this.traderPrivatePostV2Orders(this.extend(d,o));return this.parseOrder(u,n)}async cancelOrder(e,t=void 0,i={}){const s={order_id:e},r=await this.traderPrivateDeleteV2OrdersOrderId(this.extend(s,i));return this.parseOrder(r)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i=await this.traderPrivateDeleteV2Orders(t);return Array.isArray(i)?this.parseOrders(i,void 0):[this.safeOrder({info:i})]}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={order_id:e},r=await this.traderPrivateGetV2OrdersOrderId(this.extend(s,i)),a=this.safeString(r,"symbol"),o=this.safeMarket(a);return this.parseOrder(r,o)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={status:"all"};let a;void 0!==e&&(a=this.market(e),r.symbols=a.id);const o=this.safeInteger(s,"until");void 0!==o&&(s=this.omit(s,"until"),r.endTime=this.iso8601(o)),void 0!==t&&(r.after=this.iso8601(t)),void 0!==i&&(r.limit=i);const n=await this.traderPrivateGetV2Orders(this.extend(r,s));return this.parseOrders(n,a,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({status:"open"},s))}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({status:"closed"},s))}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets();const n={order_id:e};let d;void 0!==t&&(d=this.market(t)),void 0!==r&&(n.qty=this.amountToPrecision(t,r));const c=this.safeStringN(o,["triggerPrice","stop_price"]);let h;void 0!==c&&(n.stop_price=this.priceToPrecision(t,c),o=this.omit(o,"triggerPrice")),void 0!==a&&(n.limit_price=this.priceToPrecision(t,a)),[h,o]=this.handleOptionAndParams2(o,"editOrder","timeInForce","defaultTimeInForce"),void 0!==h&&(n.time_in_force=h),n.client_order_id=this.generateClientOrderId(o),o=this.omit(o,["clientOrderId"]);const l=await this.traderPrivatePatchV2OrdersOrderId(this.extend(n,o));return this.parseOrder(l,d)}parseOrder(e,t=void 0){const i=this.safeString(e,"symbol"),s=(t=this.safeMarket(i,t)).symbol,r=this.safeString(e,"status"),a=this.parseOrderStatus(r),o=this.safeString(e,"commission");let n;void 0!==o&&(n={cost:o,currency:"USD"});let d=this.safeString(e,"order_type");void 0!==d&&d.indexOf("limit")>=0&&(d="limit");const c=this.safeString(e,"submitted_at"),h=this.parse8601(c);return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:this.safeString(e,"client_order_id"),timestamp:h,datetime:c,lastTradeTimeStamp:void 0,status:a,symbol:s,type:d,timeInForce:this.parseTimeInForce(this.safeString(e,"time_in_force")),postOnly:void 0,side:this.safeString(e,"side"),price:this.safeNumber(e,"limit_price"),triggerPrice:this.safeNumber(e,"stop_price"),cost:void 0,average:this.safeNumber(e,"filled_avg_price"),amount:this.safeNumber(e,"qty"),filled:this.safeNumber(e,"filled_qty"),remaining:void 0,trades:void 0,fee:n,info:e},t)}parseOrderStatus(e){return this.safeString({pending_new:"open",accepted:"open",new:"open",partially_filled:"open",activated:"open",filled:"closed"},e,e)}parseTimeInForce(e){return this.safeString({day:"Day"},e,e)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();let a={activity_type:"FILL"};void 0!==e&&(r=this.market(e));const o=this.safeInteger(s,"until");void 0!==o&&(s=this.omit(s,"until"),a.until=this.iso8601(o)),void 0!==t&&(a.after=this.iso8601(t)),void 0!==i&&(a.page_size=i),[a,s]=this.handleUntilOption("until",a,s);const n=await this.traderPrivateGetV2AccountActivitiesActivityType(this.extend(a,s));return this.parseTrades(n,r,t,i)}parseTrade(e,t=void 0){const i=this.safeString2(e,"S","symbol"),s=this.safeSymbol(i,t),r=this.safeString2(e,"t","transaction_time"),a=this.parse8601(r),o=this.safeString(e,"tks");let n=this.safeString(e,"side");"B"===o?n="buy":"S"===o&&(n="sell");const d=this.safeString2(e,"p","price"),c=this.safeString2(e,"s","qty");return this.safeTrade({info:e,id:this.safeString2(e,"i","id"),timestamp:a,datetime:this.iso8601(a),symbol:s,order:this.safeString(e,"order_id"),type:void 0,side:n,takerOrMaker:"taker",price:d,amount:c,cost:void 0,fee:void 0},t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={asset:i.id},r=await this.traderPrivateGetV2Wallets(this.extend(s,t));return this.parseDepositAddress(r,i)}parseDepositAddress(e,t=void 0){let i;return void 0!==t&&(i=t.id),{info:e,currency:i,network:void 0,address:this.safeString(e,"address"),tag:void 0}}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const a=this.currency(e);s&&(i=i+":"+s);const o={asset:a.id,address:i,amount:this.numberToString(t)},n=await this.traderPrivatePostV2WalletsTransfers(this.extend(o,r));return this.parseTransaction(n,a)}async fetchTransactionsHelper(e,t,i,s,r){let a;await this.loadMarkets(),void 0!==t&&(a=this.currency(t));const o=await this.traderPrivateGetV2WalletsTransfers(r),n=[];for(let t=0;t{"use strict";i.d(t,{A:()=>d});var s=i(5147),r=i(1185),a=i(1579),o=i(4852),n=i(2079);class d extends r.A{describe(){return this.deepExtend(super.describe(),{id:"apex",name:"Apex",countries:[],version:"v3",rateLimit:20,certified:!1,pro:!0,dex:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelOrdersForSymbols:!1,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!1,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchAccounts:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledAndClosedOrders:!1,fetchCanceledOrders:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDeposits:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!1,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginMode:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransfer:!0,fetchTransfers:!0,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!0,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","2h":"120","4h":"240","6h":"360","12h":"720","1d":"D","1w":"W","1M":"M"},hostname:"omni.apex.exchange",urls:{logo:"https://github.com/user-attachments/assets/fef8f2f7-4265-46aa-965e-33a91881cb00",api:{public:"https://{hostname}/api",private:"https://{hostname}/api"},test:{public:"https://testnet.omni.apex.exchange/api",private:"https://testnet.omni.apex.exchange/api"},www:"https://apex.exchange/",doc:"https://api-docs.pro.apex.exchange",fees:"https://apex-pro.gitbook.io/apex-pro/apex-omni-live-now/trading-perpetual-contracts/trading-fees",referral:"https://omni.apex.exchange/trade"},api:{public:{get:{"v3/symbols":1,"v3/history-funding":1,"v3/ticker":1,"v3/klines":1,"v3/trades":1,"v3/depth":1,"v3/time":1,"v3/data/all-ticker-info":1}},private:{get:{"v3/account":1,"v3/account-balance":1,"v3/fills":1,"v3/order-fills":1,"v3/order":1,"v3/history-orders":1,"v3/order-by-client-order-id":1,"v3/funding":1,"v3/historical-pnl":1,"v3/open-orders":1,"v3/transfers":1,"v3/transfer":1},post:{"v3/delete-open-orders":1,"v3/delete-client-order-id":1,"v3/delete-order":1,"v3/order":1,"v3/set-initial-margin-rate":1,"v3/transfer-out":1,"v3/contract-transfer-out":1}}},httpExceptions:{403:n.RateLimitExceeded},exceptions:{exact:{20006:"apikey sign error",20016:"request para error",10001:n.BadRequest},broad:{ORDER_PRICE_MUST_GREETER_ZERO:n.InvalidOrder,ORDER_POSSIBLE_LEAD_TO_ACCOUNT_LIQUIDATED:n.InvalidOrder,ORDER_WITH_THIS_PRICE_CANNOT_REDUCE_POSITION_ONLY:n.InvalidOrder}},fees:{swap:{taker:this.parseNumber("0.0005"),maker:this.parseNumber("0.0002")}},requiredCredentials:{apiKey:!0,secret:!0,walletAddress:!1,privateKey:!1,password:!0},precisionMode:a.kb,commonCurrencies:{},options:{defaultType:"swap",defaultSlippage:.05,brokerId:"6956"},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,selfTradePrevention:!1,trailing:!0,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:void 0,fetchOHLCV:{limit:200}},swap:{linear:{extends:"default"},inverse:void 0}}})}async fetchTime(e={}){const t=await this.publicGetV3Time(e),i=this.safeDict(t,"data",{});return this.safeInteger(i,"time")}parseBalance(e){const t=this.milliseconds(),i={info:e,timestamp:t,datetime:this.iso8601(t)},s=this.account();return s.free=this.safeString(e,"availableBalance"),s.total=this.safeString(e,"totalEquityValue"),i.USDT=s,this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.privateGetV3AccountBalance(e),i=this.safeDict(t,"data",{});return this.parseBalance(i)}parseAccount(e){return{id:this.safeString(e,"id","0"),type:void 0,code:void 0,info:e}}async fetchAccount(e={}){await this.loadMarkets();const t=await this.privateGetV3Account(e),i=this.safeDict(t,"data",{});return this.parseAccount(i)}async fetchCurrencies(e={}){const t=await this.publicGetV3Symbols(e),i=this.safeDict(t,"data",{}),s=this.safeDict(i,"spotConfig",{}),r=this.safeDict(s,"multiChain",{}),a=this.safeList(s,"assets",[]),o=this.safeList(r,"chains",[]),n={};for(let e=0;e0&&this.markets_by_id[i][0].id2===e&&(t=this.markets_by_id[i][0])}}return super.safeMarket(e,t,i,s)}generateRandomClientIdOmni(e){return"apexomni-"+(e||this.randNumber(12).toString())+"-"+this.milliseconds().toString()+"-"+this.randNumber(6).toString()}addHyphenBeforeUsdt(e){const t=e.toUpperCase().indexOf("USDT"),i=this.safeString(e,t-1);return t>0&&"-"!==i?e.slice(0,t)+"-"+e.slice(t):e}getSeeds(){const e=this.safeString(this.options,"seeds");if(void 0===e)throw new n.ArgumentsRequired(this.id+' the "seeds" key is required in the options to access private endpoints. You can find it in API Management > Omni Key, and then set it as exchange.options["seeds"] = XXXX');return e}async getAccountId(){if("0"===this.safeString(this.options,"accountId","0")){const e=await this.fetchAccount();this.options.accountId=this.safeString(e,"id","0")}return this.options.accountId}async createOrder(e,t,i,r,o=void 0,d={}){await this.loadMarkets();const c=this.market(e);let h=t.toUpperCase();const l=i.toUpperCase(),u=this.amountToPrecision(e,r);let p="0";void 0!==o&&(p=this.priceToPrecision(e,o));const f=this.safeDict(this.fees,"swap",{}),m=this.safeString(f,"taker","0.0005"),g=this.safeString(f,"maker","0.0002"),v=this.decimalToPrecision(s.Y.stringAdd(s.Y.stringMul(s.Y.stringMul(p,u),m),this.numberToString(c.precision.price)),a.R3,c.precision.price,this.precisionMode,this.paddingMode),y=this.milliseconds();let b=this.safeString(d,"triggerPrice");const w=this.safeString(d,"stopLossPrice"),k=this.safeString(d,"takeProfitPrice");void 0!==w?(h="MARKET"===h?"STOP_MARKET":"STOP_LIMIT",b=w):void 0!==k&&(h="MARKET"===h?"TAKE_PROFIT_MARKET":"TAKE_PROFIT_LIMIT",b=k);const S="MARKET"===h;if(S&&void 0===o)throw new n.ArgumentsRequired(this.id+" createOrder() requires a price argument for market orders");let O=this.safeStringUpper(d,"timeInForce");const T=this.isPostOnly(S,void 0,d);void 0===O&&(O="GOOD_TIL_CANCEL"),S||(T?O="POST_ONLY":"ioc"===O&&(O="IMMEDIATE_OR_CANCEL")),d=this.omit(d,"timeInForce"),d=this.omit(d,"postOnly");let P=this.safeStringN(d,["clientId","clientOrderId","client_order_id"]);const I=await this.getAccountId();void 0===P&&(P=this.generateRandomClientIdOmni(I)),d=this.omit(d,["clientId","clientOrderId","client_order_id","stopLossPrice","takeProfitPrice","triggerPrice"]);const M={accountId:I,slotId:P,nonce:P,pairId:c.quoteId,size:u,price:p,direction:l,makerFeeRate:g,takerFeeRate:m};void 0!==b&&(M.triggerPrice=this.priceToPrecision(e,b));const A=await this.getZKContractSignatureObj(this.remove0xPrefix(this.getSeeds()),M),x={symbol:c.id,side:l,type:h,size:u,price:p,limitFee:v,expiration:Math.floor(y/1e3+2592e3),timeInForce:O,clientId:P,brokerId:this.safeString(this.options,"brokerId","6956")};void 0!==b&&(x.triggerPrice=this.priceToPrecision(e,b)),x.signature=A;const _=await this.privatePostV3Order(this.extend(x,d)),C=this.safeDict(_,"data",{});return this.parseOrder(C,c)}async transfer(e,t,i,r,a={}){await this.loadMarkets();const o=await this.publicGetV3Symbols(a),n=this.safeDict(o,"data",{}),d=this.safeDict(n,"contractConfig",{}),c=this.safeList(d,"assets",[]),h=this.safeDict(n,"spotConfig",{}),l=this.safeList(h,"assets",[]),u=this.safeDict(h,"global",{}),p=this.safeString(u,"contractAssetPoolEthAddress",""),f=this.safeString(u,"contractAssetPoolZkAccountId",""),m=this.safeString(u,"contractAssetPoolSubAccount",""),g=this.safeString(u,"contractAssetPoolAccountId",""),v=await this.privateGetV3Account(a),y=this.safeDict(v,"data",{}),b=this.safeDict(y,"spotAccount",{}),w=this.safeString(b,"zkAccountId",""),k=this.safeString(b,"defaultSubAccountId","0"),S=this.safeList(b,"subAccounts",[]);let O="0";S.length>0&&(O=this.safeString(S[0],"nonce","0"));const T=this.safeString(y,"ethereumAddress",""),P=this.safeString(y,"id","");let I={},M=[];M=void 0!==i&&"contract"===i.toLowerCase()?c:l;for(let t=0;t{"use strict";i.d(t,{A:()=>d});var s=i(2975),r=i(5147),a=i(2079),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"arkham",name:"ARKHAM",countries:["US"],version:"v1",rateLimit:20/3,certified:!1,pro:!0,has:{CORS:!1,spot:!0,margin:!1,swap:!0,future:!1,option:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,createDepositAddress:!0,createOrder:!0,fetchAccounts:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchFundingHistory:!0,fetchGreeks:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!0,fetchLeverageTiers:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPositions:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFees:!0,fetchVolatilityHistory:!1,fetchWithdrawals:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!1,setLeverage:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","6h":"6h","1d":"24h"},urls:{logo:"https://github.com/user-attachments/assets/5cefdcfb-2c10-445b-835c-fa21317bf5ac",api:{v1:"https://arkm.com/api"},www:"https://arkm.com/",referral:{url:"https://arkm.com/register?ref=ccxt",discount:0},doc:["https://arkm.com/limits-api","https://info.arkm.com/api-platform"],fees:"https://arkm.com/fees"},api:{v1:{public:{get:{alerts:1,announcements:1,assets:1,book:1,candles:1,chains:1,contracts:1,"index-price":1,"index-prices":1,"margin-schedules":1,marketcapchart:1,marketcaps:1,pair:1,pairs:1,"server-time":1,ticker:1,tickers:1,trades:1}},private:{get:{user:7.5,orders:7.5,"orders/by-client-order-id":7.5,"orders/history":7.5,"orders/history/by-client-order-id":7.5,"orders/history_offset":7.5,"orders/{id}":7.5,trades:7.5,"trades/history":7.5,"trades/time":7.5,"trigger-orders":7.5,"account/airdrops":7.5,"account/balance-updates":7.5,"account/balances":7.5,"account/balances/ll":7.5,"account/balances/history":7.5,"account/balances/commissions":7.5,"account/deposit/addresses":7.5,"account/deposits":7.5,"account/fees":7.5,"account/funding-rate-payments":7.5,"account/leverage":7.5,"account/lsp-assignments":7.5,"account/margin":7.5,"account/margin/all":7.5,"account/notifications":7.5,"account/position-updates":7.5,"account/positions":7.5,"account/realized-pnl":7.5,"account/rebates":7.5,"account/referral-links":7.5,"account/sessions":7.5,"account/settings":7.5,"account/settings/price-alert":7.5,"account/transfers":7.5,"account/unsubscribe":7.5,"account/watchlist":7.5,"account/withdrawal/addresses":7.5,"account/withdrawal/addresses/{id}":7.5,"account/withdrawals":7.5,subaccounts:7.5,airdrop:7.5,"airdrop/claim":7.5,"affiliate-dashboard/commission-earned":7.5,"affiliate-dashboard/min-arkm-last-30d":7.5,"affiliate-dashboard/points":7.5,"affiliate-dashboard/points-season-1":7.5,"affiliate-dashboard/points-season-2":7.5,"affiliate-dashboard/realized-pnl":7.5,"affiliate-dashboard/rebate-balance":7.5,"affiliate-dashboard/referral-count":7.5,"affiliate-dashboard/referrals-season-1":7.5,"affiliate-dashboard/referrals-season-2":7.5,"affiliate-dashboard/trading-volume-stats":7.5,"affiliate-dashboard/volume-season-1":7.5,"affiliate-dashboard/volume-season-2":7.5,"affiliate-dashboard/api-key":7.5,"competitions/opt-in-status":7.5,"rewards/info":7.5,"rewards/vouchers":7.5},post:{"orders/new":7.5,"trigger-orders/new":7.5,"orders/cancel":7.5,"trigger-orders/cancel":7.5,"orders/cancel/all":7.5,"trigger-orders/cancel/all":7.5,"orders/new/simple":7.5,"account/deposit/addresses/new":7.5,"account/leverage":7.5,"account/notifications/read":7.5,"account/referral-links":7.5,"account/sessions/delete":7.5,"account/sessions/terminate-all":7.5,"account/settings/update":7.5,"account/watchlist/add":7.5,"account/watchlist/remove":7.5,"account/withdraw":7.5,"account/withdrawal/addresses/confirm":7.5,subaccounts:7.5,"subaccounts/transfer":7.5,"subaccounts/perp-transfer":7.5,"subaccounts/update-settings":7.5,airdrop:7.5,"api-key/create":7.5,authenticate:7.5,"competitions/opt-in":7.5,"rewards/vouchers/claim":7.5},put:{"account/referral-links/{id}/slug":7.5,"account/settings/price-alert":7.5,"account/withdrawal/addresses/{id}":7.5,subaccounts:7.5,"api-key/update/{id}":7.5},delete:{"account/settings/price-alert":7.5,"account/withdrawal/addresses/{id}":7.5,"subaccounts/{subaccountId}":7.5,"api-key/{id}":7.5}}}},options:{networks:{ETH:"ETH",ERC20:"ETH",BTC:"BTC",SOL:"SOL",TON:"TON",DOGE:"DOGE",SUI:"SUI",XRP:"XRP",OP:"OP",AVAXC:"AVAX",ARBONE:"ARB"},networksById:{ETH:"ERC20",ERC20:"ERC20"},requestExpiration:5e3,timeframeDurations:{"1m":6e7,"5m":3e8,"15m":9e8,"30m":18e8,"1h":36e8,"6h":216e8,"1d":864e8}},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{mark:!0,index:!0,last:!0},triggerDirection:!0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:1,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:365}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:{extends:"default"},inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{1e4:a.OperationFailed,10001:a.BadRequest,10002:a.AuthenticationError,10003:a.BadSymbol,10004:a.ArgumentsRequired,10005:a.RateLimitExceeded,10006:a.PermissionDenied,10007:a.PermissionDenied,10008:a.RateLimitExceeded,10009:a.PermissionDenied,10010:a.PermissionDenied,10011:a.AuthenticationError,10012:a.PermissionDenied,10013:a.PermissionDenied,10014:a.AuthenticationError,10015:a.PermissionDenied,10016:a.PermissionDenied,10017:a.PermissionDenied,10018:a.AuthenticationError,10019:a.AuthenticationError,10020:a.PermissionDenied,10021:a.PermissionDenied,10022:a.ExchangeError,10023:a.BadRequest,10024:a.ExchangeError,10025:a.BadRequest,20001:a.BadRequest,20002:a.ArgumentsRequired,20003:a.BadRequest,20004:a.ArgumentsRequired,20005:a.BadRequest,30001:a.InvalidOrder,30002:a.InvalidOrder,30003:a.InvalidOrder,30004:a.InvalidOrder,30005:a.InvalidOrder,30006:a.InvalidOrder,30007:a.BadSymbol,30008:a.OperationRejected,30009:a.OperationRejected,30010:a.InsufficientFunds,30011:a.BadSymbol,30012:a.OperationRejected,30013:a.OperationRejected,30014:a.InvalidOrder,30015:a.OrderNotFound,30016:a.InvalidOrder,30017:a.InvalidOrder,30018:a.InvalidOrder,30019:a.OperationRejected,30020:a.InvalidOrder,30021:a.InvalidOrder,30022:a.InvalidOrder,30023:a.InvalidOrder,30024:a.InvalidOrder,30025:a.BadRequest,30026:a.PermissionDenied,30027:a.PermissionDenied,30028:a.OrderNotFound,40001:a.OperationRejected,40002:a.BadRequest,40003:a.InvalidAddress,40004:a.OperationRejected,40005:a.BadRequest,40006:a.PermissionDenied,40007:a.OperationRejected,40008:a.OperationRejected,40009:a.OperationRejected,40010:a.BadRequest,40011:a.OperationRejected,40012:a.BadRequest,40013:a.BadRequest,90001:a.BadRequest,90002:a.BadRequest,90003:a.OperationRejected,90004:a.BadRequest,90005:a.BadRequest,90006:a.RateLimitExceeded,90007:a.AuthenticationError,90008:a.RateLimitExceeded,90009:a.PermissionDenied,90010:a.BadRequest,90011:a.RateLimitExceeded},broad:{"less than min withdrawal ":a.OperationRejected}}})}async fetchCurrencies(e={}){const t=await this.v1PublicGetAssets(e),i={};for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(566),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"ascendex",name:"AscendEX",countries:["SG"],rateLimit:400,certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!0,cancelAllOrders:!0,cancelOrder:!0,createOrder:!0,createOrders:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowRate:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingRate:"emulated",fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:"emulated",fetchLeverages:!0,fetchLeverageTiers:!0,fetchMarginMode:"emulated",fetchMarginModes:!0,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMySettlementHistory:!1,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:"emulated",fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!0,sandbox:!0,setLeverage:!0,setMarginMode:!0,setPositionMode:!1,transfer:!0},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","2h":"120","4h":"240","6h":"360","12h":"720","1d":"1d","1w":"1w","1M":"1m"},version:"v2",urls:{logo:"https://github.com/user-attachments/assets/55bab6b9-d4ca-42a8-a0e6-fac81ae557f1",api:{rest:"https://ascendex.com"},test:{rest:"https://api-test.ascendex-sandbox.com"},www:"https://ascendex.com",doc:["https://ascendex.github.io/ascendex-pro-api/#ascendex-pro-api-documentation"],fees:"https://ascendex.com/en/feerate/transactionfee-traderate",referral:{url:"https://ascendex.com/en-us/register?inviteCode=EL6BXBQM",discount:.25}},api:{v1:{public:{get:{assets:1,products:1,ticker:1,"barhist/info":1,barhist:1,depth:1,trades:1,"cash/assets":1,"cash/products":1,"margin/assets":1,"margin/products":1,"futures/collateral":1,"futures/contracts":1,"futures/ref-px":1,"futures/market-data":1,"futures/funding-rates":1,"risk-limit-info":1,"exchange-info":1}},private:{get:{info:1,"wallet/transactions":1,"wallet/deposit/address":1,"data/balance/snapshot":1,"data/balance/history":1},accountCategory:{get:{balance:1,"order/open":1,"order/status":1,"order/hist/current":1,risk:1},post:{order:1,"order/batch":1},delete:{order:1,"order/all":1,"order/batch":1}},accountGroup:{get:{"cash/balance":1,"margin/balance":1,"margin/risk":1,"futures/collateral-balance":1,"futures/position":1,"futures/risk":1,"futures/funding-payments":1,"order/hist":1,"spot/fee":1},post:{transfer:1,"futures/transfer/deposit":1,"futures/transfer/withdraw":1}}}},v2:{public:{get:{assets:1,"futures/contract":1,"futures/collateral":1,"futures/pricing-data":1,"futures/ticker":1,"risk-limit-info":1}},private:{data:{get:{"order/hist":1}},get:{"account/info":1},accountGroup:{get:{"order/hist":1,"futures/position":1,"futures/free-margin":1,"futures/order/hist/current":1,"futures/funding-payments":1,"futures/order/open":1,"futures/order/status":1},post:{"futures/isolated-position-margin":1,"futures/margin-type":1,"futures/leverage":1,"futures/transfer/deposit":1,"futures/transfer/withdraw":1,"futures/order":1,"futures/order/batch":1,"futures/order/open":1,"subuser/subuser-transfer":1,"subuser/subuser-transfer-hist":1},delete:{"futures/order":1,"futures/order/batch":1,"futures/order/all":1}}}}},fees:{trading:{feeSide:"get",tierBased:!0,percentage:!0,taker:this.parseNumber("0.002"),maker:this.parseNumber("0.002")}},precisionMode:o.kb,options:{"account-category":"cash","account-group":void 0,fetchClosedOrders:{method:"v2PrivateDataGetOrderHist"},defaultType:"spot",accountsByType:{spot:"cash",swap:"futures",margin:"margin"},transfer:{fillResponseFromRequest:!0},networks:{BSC:"BEP20 (BSC)",ARB:"arbitrum",SOL:"Solana",AVAX:"avalanche C chain",OMNI:"Omni",TRC20:"TRC20",ERC20:"ERC20",GO20:"GO20",BEP2:"BEP2",BTC:"Bitcoin",BCH:"Bitcoin ABC",LTC:"Litecoin",MATIC:"Matic Network",AKT:"Akash"}},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:{max:10},fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,marketType:!0,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,marketType:!0,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:500}},spot:{extends:"default",fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1}},forDerivatives:{extends:"default",createOrder:{attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!1,index:!1},price:!1}},fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1}},swap:{linear:{extends:"forDerivatives"},inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{1900:r.BadRequest,2100:r.AuthenticationError,5002:r.BadSymbol,6001:r.BadSymbol,6010:r.InsufficientFunds,60060:r.InvalidOrder,600503:r.InvalidOrder,100001:r.BadRequest,100002:r.BadRequest,100003:r.BadRequest,100004:r.BadRequest,100005:r.BadRequest,100006:r.BadRequest,100007:r.BadRequest,100008:r.BadSymbol,100009:r.AuthenticationError,100010:r.BadRequest,100011:r.BadRequest,100012:r.BadRequest,100013:r.BadRequest,100101:r.ExchangeError,150001:r.BadRequest,200001:r.AuthenticationError,200002:r.ExchangeError,200003:r.ExchangeError,200004:r.ExchangeError,200005:r.ExchangeError,200006:r.ExchangeError,200007:r.ExchangeError,200008:r.ExchangeError,200009:r.ExchangeError,200010:r.AuthenticationError,200011:r.ExchangeError,200012:r.ExchangeError,200013:r.ExchangeError,200014:r.PermissionDenied,200015:r.PermissionDenied,300001:r.InvalidOrder,300002:r.InvalidOrder,300003:r.InvalidOrder,300004:r.InvalidOrder,300005:r.InvalidOrder,300006:r.InvalidOrder,300007:r.InvalidOrder,300008:r.InvalidOrder,300009:r.InvalidOrder,300011:r.InsufficientFunds,300012:r.BadSymbol,300013:r.InvalidOrder,300014:r.InvalidOrder,300020:r.InvalidOrder,300021:r.AccountSuspended,300031:r.InvalidOrder,310001:r.InsufficientFunds,310002:r.InvalidOrder,310003:r.InvalidOrder,310004:r.BadSymbol,310005:r.InvalidOrder,510001:r.ExchangeError,900001:r.ExchangeError},broad:{}},commonCurrencies:{XBT:"XBT",BOND:"BONDED",BTCBEAR:"BEAR",BTCBULL:"BULL",BYN:"BeyondFi",PLN:"Pollen"}})}getAccount(e={}){const t=this.safeValue(e,"account",this.options.account).toLowerCase();return this.capitalize(t)}async fetchCurrencies(e={}){const t=await this.v2PublicGetAssets(e),i=this.safeList(t,"data",[]),s={};for(let e=0;e=0)continue;const i=c[t],s=this.safeString(i,"status"),r=this.safeString(i,"domain");let a=!1;"Normal"!==s&&"InternalTrading"!==s||"LeveragedETF"===r||(a=!0);const o=this.safeNumber(i,"minQty"),n=this.safeNumber(i,"maxQty"),d=this.safeNumber(i,"tickSize"),u=void 0,p=this.safeString2(i,"underlying","symbol").split("/"),f=this.safeString(p,0),m=this.safeString(p,1),g=this.safeCurrencyCode(f),v=this.safeCurrencyCode(m),y=this.safeNumber(i,"commissionReserveRate"),b=this.safeBool(i,"marginTradable",!1);l.push({id:t,symbol:g+"/"+v,base:g,baseId:f,quote:v,quoteId:m,settle:void 0,settleId:void 0,type:"spot",spot:!0,margin:b,swap:!1,future:!1,option:!1,active:a,contract:!1,linear:void 0,inverse:void 0,taker:y,maker:y,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(i,"lotSize"),price:this.safeNumber(i,"tickSize")},limits:{leverage:{min:void 0,max:void 0},amount:{min:o,max:n},price:{min:d,max:u},cost:{min:this.safeNumber(i,"minNotional"),max:this.safeNumber(i,"maxNotional")}},created:this.safeInteger(i,"tradingStartTime"),info:i})}return l}async fetchContractMarkets(e={}){const t=await this.v2PublicGetFuturesContract(e),i=this.safeList(t,"data",[]),s=[];for(let e=0;e1){const e=this.indexBy(c,"chainName");if(void 0===a){const t=Object.keys(e).join(", ");throw new r.ArgumentsRequired(this.id+" fetchDepositAddress() returned more than one address, a chainName parameter is required, one of "+t)}h=this.safeDict(e,a,{})}else h=this.safeDict(c,0,{});const l=this.parseDepositAddress(h,i);return this.extend(l,{info:n})}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactions(e,t,i,this.extend({txType:"deposit"},s))}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactions(e,t,i,this.extend({txType:"withdrawal"},s))}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.asset=a.id),void 0!==t&&(r.startTs=t),void 0!==i&&(r.pageSize=i);const o=await this.v1PrivateGetWalletTransactions(this.extend(r,s)),n=this.safeDict(o,"data",{}),d=this.safeList(n,"data",[]);return this.parseTransactions(d,a,t,i)}parseTransactionStatus(e){return this.safeString({reviewing:"pending",pending:"pending",confirmed:"ok",rejected:"rejected"},e,e)}parseTransaction(e,t=void 0){const i=this.safeDict(e,"destAddress",{}),s=this.safeString(i,"address"),r=this.safeString(i,"destTag"),o=this.safeInteger(e,"time"),n=this.safeString(e,"asset");let d=this.safeString(e,"amount");const c=this.safeString(e,"commission");d=a.Y.stringSub(d,c);const h=this.safeCurrencyCode(n,t);return{info:e,id:this.safeString(e,"requestId"),txid:this.safeString(e,"networkTransactionId"),type:this.safeString(e,"transactionType"),currency:h,network:void 0,amount:this.parseNumber(d),status:this.parseTransactionStatus(this.safeString(e,"status")),timestamp:o,datetime:this.iso8601(o),address:s,addressFrom:void 0,addressTo:s,tag:r,tagFrom:void 0,tagTo:r,updated:void 0,comment:void 0,fee:{currency:h,cost:this.parseNumber(c),rate:void 0},internal:!1}}async fetchPositions(e=void 0,t={}){await this.loadMarkets(),await this.loadAccounts();const i=this.safeDict(this.accounts,0,{}),s={"account-group":this.safeString(i,"id")},r=await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(s,t)),a=this.safeDict(r,"data",{}),o=this.safeList(a,"contracts",[]),n=[];for(let e=0;e100)throw new r.BadRequest(this.id+" leverage should be between 1 and 100");await this.loadMarkets(),await this.loadAccounts();const s=this.market(t);if(!s.swap)throw new r.BadSymbol(this.id+" setLeverage() supports swap contracts only");const a=this.safeDict(this.accounts,0,{}),o={"account-group":this.safeString(a,"id"),symbol:s.id,leverage:e};return await this.v2PrivateAccountGroupPostFuturesLeverage(this.extend(o,i))}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");if("cross"===(e=e.toLowerCase())&&(e="crossed"),"isolated"!==e&&"crossed"!==e)throw new r.BadRequest(this.id+" setMarginMode() marginMode argument should be isolated or cross");await this.loadMarkets(),await this.loadAccounts();const s=this.market(t),a=this.safeDict(this.accounts,0,{}),o={"account-group":this.safeString(a,"id"),symbol:s.id,marginType:e};if(!s.swap)throw new r.BadSymbol(this.id+" setMarginMode() supports swap contracts only");return await this.v2PrivateAccountGroupPostFuturesMarginType(this.extend(o,i))}async fetchLeverageTiers(e=void 0,t={}){await this.loadMarkets();const i=await this.v2PublicGetFuturesContract(t),s=this.safeList(i,"data",[]);return e=this.marketSymbols(e),this.parseLeverageTiers(s,e,"symbol")}parseMarketLeverageTiers(e,t=void 0){const i=this.safeList(e,"marginRequirements",[]),s=this.safeString(e,"symbol");t=this.safeMarket(s,t);const r=[];for(let e=0;e=0){const e=u.split("/");u=e[2]}if(s=this.omit(s,this.extractParams(e)),"public"===d)Object.keys(s).length&&(h+="?"+this.urlencode(s));else{this.checkRequiredCredentials();const e=this.milliseconds().toString(),t=e+"+"+u,o=this.hmac(this.encode(t),this.encode(this.secret),n.s,"base64");r={"x-auth-key":this.apiKey,"x-auth-timestamp":e,"x-auth-signature":o},"GET"===i?Object.keys(s).length&&(h+="?"+this.urlencode(s)):(r["Content-Type"]="application/json",a=this.json(s))}return h=this.urls.api.rest+h,{url:h,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.safeString(n,"code"),l=this.safeString(n,"message");if(void 0!==h&&"0"!==h||void 0!==l){const e=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,h,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwBroadlyMatchedException(this.exceptions.broad,l,e),new r.ExchangeError(e)}}}},4521:(e,t,i)=>{"use strict";i.d(t,{A:()=>l});var s=i(6510),r=i(2079),a=i(1579),o=i(5147),n=i(4852),d=i(8283),c=i(8432),h=i(987);class l extends s.A{describe(){return this.deepExtend(super.describe(),{id:"aster",name:"Aster",countries:["US"],rateLimit:333,hostname:"aster.markets",certified:!1,pro:!0,dex:!0,urls:{logo:"https://github.com/user-attachments/assets/4982201b-73cd-4d7a-8907-e69e239e9609",www:"https://www.asterdex.com/en",api:{fapiPublic:"https://fapi.asterdex.com/fapi",fapiPrivate:"https://fapi.asterdex.com/fapi",sapiPublic:"https://sapi.asterdex.com/api",sapiPrivate:"https://sapi.asterdex.com/api"},doc:"https://github.com/asterdex/api-docs",fees:"https://docs.asterdex.com/product/asterex-simple/fees-and-slippage",referral:{url:"https://www.asterdex.com/en/referral/aA1c2B",discount:.1}},has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,addMargin:!0,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createLimitBuyOrder:!1,createLimitSellOrder:!1,createMarketBuyOrder:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrder:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!1,createOrderWithTakeProfitAndStopLoss:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopLossOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!1,editOrder:!1,editOrders:!1,fetchAccounts:void 0,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:"emulated",fetchCanceledOrders:"emulated",fetchClosedOrder:!1,fetchClosedOrders:"emulated",fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingInterval:"emulated",fetchFundingIntervals:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:"emulated",fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!1,fetchLastPrices:!1,fetchLedger:!0,fetchLedgerEntry:!1,fetchLeverage:"emulated",fetchLeverages:!0,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!0,fetchMarginMode:"emulated",fetchMarginModes:!0,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!0,fetchPositions:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!0,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTradingLimits:"emulated",fetchTransactionFee:"emulated",fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawAddresses:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,fetchWithdrawalWhitelist:!1,reduceMargin:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!1,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!0,signIn:!1,transfer:!0,withdraw:!0},api:{fapiPublic:{get:["v1/ping","v1/time","v1/exchangeInfo","v1/depth","v1/trades","v1/historicalTrades","v1/aggTrades","v1/klines","v1/indexPriceKlines","v1/markPriceKlines","v1/premiumIndex","v1/fundingRate","v1/fundingInfo","v1/ticker/24hr","v1/ticker/price","v1/ticker/bookTicker","v1/adlQuantile","v1/forceOrders"]},fapiPrivate:{get:["v1/positionSide/dual","v1/multiAssetsMargin","v1/order","v1/openOrder","v1/openOrders","v1/allOrders","v2/balance","v3/balance","v3/account","v4/account","v1/positionMargin/history","v2/positionRisk","v3/positionRisk","v1/userTrades","v1/income","v1/leverageBracket","v1/commissionRate"],post:["v1/positionSide/dual","v1/multiAssetsMargin","v1/order","v1/order/test","v1/batchOrders","v1/asset/wallet/transfer","v1/countdownCancelAll","v1/leverage","v1/marginType","v1/positionMargin","v1/listenKey"],put:["v1/listenKey"],delete:["v1/order","v1/allOpenOrders","v1/batchOrders","v1/listenKey"]},sapiPublic:{get:["v1/ping","v1/time","v1/exchangeInfo","v1/depth","v1/trades","v1/historicalTrades","v1/aggTrades","v1/klines","v1/ticker/24hr","v1/ticker/price","v1/ticker/bookTicker","v1/aster/withdraw/estimateFee"]},sapiPrivate:{get:["v1/commissionRate","v1/order","v1/openOrders","v1/allOrders","v1/transactionHistory","v1/account","v1/userTrades"],post:["v1/order","v1/asset/wallet/transfer","v1/asset/sendToAddress","v1/aster/user-withdraw","v1/listenKey"],put:["v1/listenKey"],delete:["v1/order","v1/allOpenOrders","v1/listenKey"]}},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},precisionMode:a.kb,requiredCredentials:{apiKey:!0,secret:!0},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0001"),taker:this.parseNumber("0.00035")}},options:{defaultType:"spot",recvWindow:1e4,defaultTimeInForce:"GTC",zeroAddress:"0x0000000000000000000000000000000000000000",quoteOrderQty:!0,accountsByType:{spot:"SPOT",future:"FUTURE",linear:"FUTURE",swap:"FUTURE"},networks:{ERC20:"ETH",BEP20:"BSC",ARB:"Arbitrum"},networksToChainId:{ETH:1,BSC:56,Arbitrum:42161}},exceptions:{exact:{"-1000":r.OperationFailed,"-1001":r.NetworkError,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.DuplicateOrderId,"-1005":r.BadRequest,"-1006":r.BadResponse,"-1007":r.RequestTimeout,"-1010":r.OperationFailed,"-1011":r.PermissionDenied,"-1013":r.BadRequest,"-1014":r.OrderNotFillable,"-1015":r.RateLimitExceeded,"-1016":r.ExchangeClosedByUser,"-1020":r.NotSupported,"-1021":r.InvalidNonce,"-1022":r.AuthenticationError,"-1023":r.BadRequest,"-1100":r.BadRequest,"-1101":r.BadRequest,"-1102":r.ArgumentsRequired,"-1103":r.BadRequest,"-1104":r.BadRequest,"-1105":r.ArgumentsRequired,"-1106":r.BadRequest,"-1108":r.BadRequest,"-1109":r.BadRequest,"-1110":r.BadSymbol,"-1111":r.BadRequest,"-1112":r.BadRequest,"-1113":r.BadRequest,"-1114":r.BadRequest,"-1115":r.InvalidOrder,"-1116":r.InvalidOrder,"-1117":r.InvalidOrder,"-1118":r.InvalidOrder,"-1119":r.InvalidOrder,"-1120":r.BadRequest,"-1121":r.BadSymbol,"-1125":r.AuthenticationError,"-1127":r.BadRequest,"-1128":r.BadRequest,"-1130":r.BadRequest,"-1136":r.InvalidOrder,"-2010":r.InvalidOrder,"-2011":r.OrderNotFound,"-2013":r.OrderNotFound,"-2014":r.AuthenticationError,"-2015":r.AuthenticationError,"-2016":r.MarketClosed,"-2018":r.InsufficientFunds,"-2019":r.InsufficientFunds,"-2020":r.OrderNotFillable,"-2021":r.OrderImmediatelyFillable,"-2022":r.OperationRejected,"-2023":r.AccountSuspended,"-2024":r.InsufficientFunds,"-2025":r.RateLimitExceeded,"-2026":r.NotSupported,"-2027":r.BadRequest,"-2028":r.BadRequest,"-4000":r.InvalidOrder,"-4001":r.InvalidOrder,"-4002":r.InvalidOrder,"-4003":r.InvalidOrder,"-4004":r.InvalidOrder,"-4005":r.InvalidOrder,"-4006":r.InvalidOrder,"-4007":r.InvalidOrder,"-4008":r.InvalidOrder,"-4009":r.InvalidOrder,"-4010":r.InvalidOrder,"-4011":r.InvalidOrder,"-4012":r.RateLimitExceeded,"-4013":r.InvalidOrder,"-4014":r.InvalidOrder,"-4015":r.InvalidOrder,"-4016":r.InvalidOrder,"-4017":r.InvalidOrder,"-4018":r.InvalidOrder,"-4019":r.BadRequest,"-4020":r.BadRequest,"-4021":r.BadRequest,"-4022":r.MarketClosed,"-4023":r.InvalidOrder,"-4024":r.InvalidOrder,"-4025":r.BadRequest,"-4026":r.BadRequest,"-4027":r.BadRequest,"-4028":r.BadRequest,"-4029":r.BadRequest,"-4030":r.BadRequest,"-4031":r.BadRequest,"-4032":r.RateLimitExceeded,"-4033":r.AccountNotEnabled,"-4044":r.BadRequest,"-4045":r.RateLimitExceeded,"-4046":r.NoChange,"-4047":r.OperationRejected,"-4048":r.OperationRejected,"-4049":r.OperationRejected,"-4050":r.InsufficientFunds,"-4051":r.InsufficientFunds,"-4052":r.NoChange,"-4053":r.OperationRejected,"-4054":r.OperationRejected,"-4055":r.ArgumentsRequired,"-4056":r.AuthenticationError,"-4057":r.AuthenticationError,"-4058":r.InvalidOrder,"-4059":r.NoChange,"-4060":r.InvalidOrder,"-4061":r.InvalidOrder,"-4062":r.OperationRejected,"-4063":r.BadRequest,"-4064":r.BadRequest,"-4065":r.BadRequest,"-4066":r.BadRequest,"-4067":r.OperationRejected,"-4068":r.OperationRejected,"-4069":r.BadRequest,"-4070":r.InvalidOrder,"-4071":r.InvalidOrder,"-4072":r.NoChange,"-4073":r.BadRequest,"-4074":r.InvalidOrder,"-4075":r.OperationRejected,"-4076":r.OperationRejected,"-4077":r.RateLimitExceeded,"-4078":r.BadRequest,"-4079":r.BadRequest,"-4080":r.BadRequest,"-4081":r.BadRequest,"-4082":r.RateLimitExceeded,"-4083":r.OperationFailed,"-4084":r.NotSupported,"-4085":r.BadRequest,"-4086":r.BadRequest,"-4087":r.PermissionDenied,"-4088":r.PermissionDenied,"-4104":r.BadSymbol,"-4114":r.InvalidOrder,"-4115":r.DuplicateOrderId,"-4118":r.InsufficientFunds,"-4131":r.InvalidOrder,"-4135":r.InvalidOrder,"-4137":r.InvalidOrder,"-4138":r.OperationRejected,"-4139":r.InvalidOrder,"-4140":r.OperationRejected,"-4141":r.MarketClosed,"-4142":r.InvalidOrder,"-4144":r.BadSymbol,"-4161":r.OperationRejected,"-4164":r.InvalidOrder,"-4165":r.BadRequest,"-4183":r.InvalidOrder,"-4184":r.InvalidOrder,"-5060":r.OperationRejected,"-5076":r.OperationRejected},broad:{}}})}isInverse(e,t=void 0){return void 0===t?"delivery"===e:"inverse"===t}isLinear(e,t=void 0){return void 0===t?"future"===e||"swap"===e:"linear"===t}async fetchCurrencies(e={}){const t=[this.sapiPublicGetV1ExchangeInfo(e),this.fapiPublicGetV1ExchangeInfo(e)],i=await Promise.all(t),s=this.safeDict(i,0,{}),r=this.safeList(s,"assets",[]),a=this.safeDict(i,1,{}),o=this.safeList(a,"assets",[]),n=this.arrayConcat(r,o),d={};for(let e=0;e1500&&(s=1500),n.limit=s),[n,a]=this.handleUntilOption("endTime",n,a),n.interval=this.safeString(this.timeframes,t,t);const d=this.safeString(a,"price"),c="mark"===d,h="index"===d;let l;return a=this.omit(a,"price"),c?(n.symbol=o.id,l=await this.fapiPublicGetV1MarkPriceKlines(this.extend(n,a))):h?(n.pair=o.id,l=await this.fapiPublicGetV1IndexPriceKlines(this.extend(n,a))):(n.symbol=o.id,l=o.linear?await this.fapiPublicGetV1Klines(this.extend(n,a)):await this.sapiPublicGetV1Klines(this.extend(n,a))),this.parseOHLCVs(l,o,t,i,s)}parseTrade(e,t=void 0){const i=this.safeString(e,"id"),s=t.symbol,r=this.safeString(e,"commissionAsset"),a=this.safeCurrencyCode(r),n=this.safeString(e,"qty"),d=this.safeString(e,"price"),c=this.safeString2(e,"quoteQty","baseQty"),h=this.safeInteger(e,"time");let l=this.safeStringLower(e,"side");const u=this.safeBool(e,"maker");let p;void 0!==u&&(p=u?"maker":"taker");const f=this.safeBool(e,"isBuyerMaker");return void 0!==f&&(l=f?"sell":"buy"),this.safeTrade({id:i,info:e,timestamp:h,datetime:this.iso8601(h),symbol:s,order:this.safeString(e,"orderId"),type:void 0,side:l,takerOrMaker:p,price:d,amount:n,cost:c,fee:{cost:this.parseNumber(o.A.stringAbs(this.safeString(e,"commission"))),currency:a}},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={symbol:a.id};let n;return void 0!==i&&(i>1e3&&(i=1e3),o.limit=i),n=a.swap?await this.fapiPublicGetV1Trades(this.extend(o,s)):await this.sapiPublicGetV1Trades(this.extend(o,s)),this.parseTrades(n,a,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e);let o,n={symbol:a.id};return void 0!==t&&(n.startTime=t),void 0!==i&&(i>1e3&&(i=1e3),n.limit=i),[n,s]=this.handleUntilOption("endTime",n,s),o=a.swap?await this.fapiPrivateGetV1UserTrades(this.extend(n,s)):await this.sapiPrivateGetV1UserTrades(this.extend(n,s)),this.parseTrades(o,a,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOrderBook() requires a symbol argument");await this.loadMarkets();const s=this.market(e),a={symbol:s.id};let o;void 0!==t&&(t>1e3&&(t=1e3),a.limit=t),o=s.swap?await this.fapiPublicGetV1Depth(this.extend(a,i)):await this.sapiPublicGetV1Depth(this.extend(a,i));const n=this.safeInteger(o,"T");return this.parseOrderBook(o,e,n,"bids","asks")}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r={};if(void 0!==e){const t=this.market(e);r.symbol=t.id}void 0!==t&&(r.startTime=t),void 0!==i&&(i>1e3&&(i=1e3),r.limit=i),[r,s]=this.handleUntilOption("endTime",r,s);const a=await this.fapiPublicGetV1FundingRate(this.extend(r,s)),o=[];for(let e=0;e1e3&&(i=1e3),n.limit=i),[n,s]=this.handleUntilOption("endTime",n,s),o=a.swap?await this.fapiPrivateGetV1AllOrders(this.extend(n,s)):await this.sapiPrivateGetV1AllOrders(this.extend(n,s)),this.parseOrders(o,a,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const a={};let o,n,d,c;if([d,s]=this.handleSubTypeAndParams("fetchOpenOrders",o,s),void 0!==e&&(o=this.market(e),a.symbol=o.id),[n,s]=this.handleMarketTypeAndParams("fetchOpenOrders",o,s),this.isLinear(n,d))c=await this.fapiPrivateGetV1OpenOrders(this.extend(a,s));else{if("spot"!==n)throw new r.NotSupported(this.id+" fetchOpenOrders() does not support "+n+" markets yet");c=await this.sapiPrivateGetV1OpenOrders(this.extend(a,s))}return this.parseOrders(c,o,t,i)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.safeBool(a,"test",!1);a=this.omit(a,"test");const d=this.createOrderRequest(e,t,i,s,r,a);let c;return c=o.swap?n?await this.fapiPrivatePostV1OrderTest(d):await this.fapiPrivatePostV1Order(d):await this.sapiPrivatePostV1Order(d),this.parseOrder(c,o)}async createOrders(e,t={}){await this.loadMarkets();const i=[];let s=[];if(e.length>5)throw new r.InvalidOrder(this.id+" createOrders() order list max 5 orders");for(let t=0;t125)throw new r.BadRequest(this.id+" leverage should be between 1 and 125");await this.loadMarkets();const s={symbol:this.market(t).id,leverage:e};return await this.fapiPrivatePostV1Leverage(this.extend(s,i))}async fetchLeverages(e=void 0,t={}){await this.loadMarkets();const i=await this.fapiPrivateGetV2PositionRisk(t);return this.parseLeverages(i,e,"symbol")}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeStringLower(e,"marginType"),r=this.safeStringLower(e,"positionSide");let a,o;const n=this.safeInteger(e,"leverage");return void 0===r||"both"===r?(a=n,o=n):"long"===r?a=n:"short"===r&&(o=n),{info:e,symbol:this.safeSymbol(i,t),marginMode:s,longLeverage:a,shortLeverage:o}}async fetchMarginModes(e=void 0,t={}){await this.loadMarkets();const i=await this.fapiPrivateGetV2PositionRisk(t);return this.parseMarginModes(i,e,"symbol","swap")}parseMarginMode(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:(t=this.safeMarket(i,t)).symbol,marginMode:this.safeStringLower(e,"marginType")}}async fetchMarginAdjustmentHistory(e=void 0,t=void 0,i=void 0,s=void 0,a={}){if(await this.loadMarkets(),void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMarginAdjustmentHistory () requires a symbol argument");const o=this.market(e),n=this.safeInteger(a,"until");a=this.omit(a,"until");const d={symbol:o.id};void 0!==t&&(d.type="add"===t?1:2),void 0!==i&&(d.startTime=i),void 0!==s&&(d.limit=s),void 0!==n&&(d.endTime=n);const c=await this.fapiPrivateGetV1PositionMarginHistory(this.extend(d,a)),h=this.parseMarginModifications(c);return this.filterBySymbolSinceLimit(h,e,i,s)}parseMarginModification(e,t=void 0){const i=this.safeInteger(e,"type"),s=this.safeString(e,"code"),r=this.safeString(e,"symbol"),a=this.safeInteger(e,"time"),o=void 0===s,n="200"===s;return{info:e,symbol:(t=this.safeMarket(r,t,void 0,"swap")).symbol,type:1===i?"add":"reduce",marginMode:"isolated",amount:this.safeNumber(e,"amount"),code:this.safeString(e,"asset"),total:void 0,status:n||o?"ok":"failed",timestamp:a,datetime:this.iso8601(a)}}async modifyMarginHelper(e,t,i,s={}){await this.loadMarkets();const r=this.market(e);t=this.amountToPrecision(e,t);const a={type:i,symbol:r.id,amount:t},o=r.quote,n=await this.fapiPrivatePostV1PositionMargin(this.extend(a,s));return this.extend(this.parseMarginModification(n,r),{code:o})}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,2,i)}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,1,i)}parseIncome(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeString(e,"asset"),r=this.safeInteger(e,"time");return{info:e,symbol:this.safeSymbol(i,t,void 0,"swap"),code:this.safeCurrencyCode(s),timestamp:r,datetime:this.iso8601(r),id:this.safeString(e,"tranId"),amount:this.safeNumber(e,"income")}}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();let a={incomeType:"FUNDING_FEE"};void 0!==e&&(r=this.market(e),a.symbol=r.id),[a,s]=this.handleUntilOption("endTime",a,s),void 0!==t&&(a.startTime=t),void 0!==i&&(a.limit=Math.min(i,1e3));const o=await this.fapiPrivateGetV1Income(this.extend(a,s));return this.parseIncomes(o,r,t,i)}parseLedgerEntry(e,t=void 0){let i,s=this.safeString(e,"income");o.A.stringLe(s,"0")?(i="out",s=o.A.stringMul("-1",s)):i="in";const r=this.safeString(e,"asset"),a=this.safeCurrencyCode(r,t);t=this.safeCurrency(r,t);const n=this.safeInteger(e,"time"),d=this.safeString(e,"incomeType");return this.safeLedgerEntry({info:e,id:this.safeString(e,"tranId"),direction:i,account:void 0,referenceAccount:void 0,referenceId:this.safeString(e,"tradeId"),type:this.parseLedgerEntryType(d),currency:a,amount:this.parseNumber(s),timestamp:n,datetime:this.iso8601(n),before:void 0,after:void 0,status:void 0,fee:void 0},t)}parseLedgerEntryType(e){return this.safeString({TRANSFER:"transfer",WELCOME_BONUS:"cashback",REALIZED_PNL:"trade",FUNDING_FEE:"fee",COMMISSION:"commission",INSURANCE_CLEAR:"settlement",MARKET_MERCHANT_RETURN_REWARD:"cashback"},e,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a={};void 0!==t&&(a.startTime=t),void 0!==i&&(a.limit=Math.min(i,1e3));const o=this.safeInteger(s,"until");void 0!==o&&(s=this.omit(s,"until"),a.endTime=o);const n=await this.fapiPrivateGetV1Income(this.extend(a,s));return this.parseLedger(n,r,t,i)}parsePositionRisk(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t,void 0,"contract");const s=this.safeString(t,"symbol"),r=this.safeString(e,"isolatedMargin"),a=this.safeDict(this.options,"leverageBrackets",{}),n=this.safeList(a,s,[]),d=this.safeString2(e,"notional","notionalValue"),c=o.A.stringAbs(d);let h;for(let e=0;e0&&(f=f+"&orderidlist=%5B"+e.join("%2C")+"%5D"),s>0&&(f=f+"&origclientorderidlist=%5B"+t.join("%2C")+"%5D")}else f=this.rawencode(u);let m="";if(e.indexOf("v3")>=0){const e=this.options.signerAddress;if(void 0===e)throw new r.ArgumentsRequired(this.id+" requires signerAddress in options when use v3 api");const t=Object.keys(u),i=this.sort(t),s={};for(let e=0;e{"use strict";i.d(t,{A:()=>c});var s=i(5475),r=i(2079),a=i(1579),o=i(5147),n=i(6414),d=i(8283);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"backpack",name:"Backpack",countries:["JP"],rateLimit:50,version:"v1",certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelWithdraw:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createLimitBuyOrder:!0,createLimitOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!0,createMarketSellOrder:!0,createMarketSellOrderWithCost:!0,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLossOrder:!1,createTakeProfitOrder:!1,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,fetchAccounts:!1,fetchAllGreeks:!1,fetchBalance:!0,fetchCanceledAndClosedOrders:!1,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!0,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!0,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m",15:"15m",30:"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1month"},urls:{logo:"https://github.com/user-attachments/assets/cc04c278-679f-4554-9f72-930dd632b80f",api:{public:"https://api.backpack.exchange",private:"https://api.backpack.exchange"},www:"https://backpack.exchange/",doc:"https://docs.backpack.exchange/",referral:"https://backpack.exchange/join/ccxt"},api:{public:{get:{"api/v1/assets":1,"api/v1/collateral":1,"api/v1/borrowLend/markets":1,"api/v1/borrowLend/markets/history":1,"api/v1/markets":1,"api/v1/market":1,"api/v1/ticker":1,"api/v1/tickers":1,"api/v1/depth":1,"api/v1/klines":1,"api/v1/markPrices":1,"api/v1/openInterest":1,"api/v1/fundingRates":1,"api/v1/status":1,"api/v1/ping":1,"api/v1/time":1,"api/v1/wallets":1,"api/v1/trades":1,"api/v1/trades/history":1}},private:{get:{"api/v1/account":1,"api/v1/account/limits/borrow":1,"api/v1/account/limits/order":1,"api/v1/account/limits/withdrawal":1,"api/v1/borrowLend/positions":1,"api/v1/capital":1,"api/v1/capital/collateral":1,"wapi/v1/capital/deposits":1,"wapi/v1/capital/deposit/address":1,"wapi/v1/capital/withdrawals":1,"api/v1/position":1,"wapi/v1/history/borrowLend":1,"wapi/v1/history/interest":1,"wapi/v1/history/borrowLend/positions":1,"wapi/v1/history/dust":1,"wapi/v1/history/fills":1,"wapi/v1/history/funding":1,"wapi/v1/history/orders":1,"wapi/v1/history/rfq":1,"wapi/v1/history/quote":1,"wapi/v1/history/settlement":1,"wapi/v1/history/strategies":1,"api/v1/order":1,"api/v1/orders":1},post:{"api/v1/account/convertDust":1,"api/v1/borrowLend":1,"wapi/v1/capital/withdrawals":1,"api/v1/order":1,"api/v1/orders":1,"api/v1/rfq":1,"api/v1/rfq/accept":1,"api/v1/rfq/refresh":1,"api/v1/rfq/cancel":1,"api/v1/rfq/quote":1},delete:{"api/v1/order":1,"api/v1/orders":1},patch:{"api/v1/account":1}}},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{GTC:!0,IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:{EXPIRE_MAKER:!0,EXPIRE_TAKER:!0,EXPIRE_BOTH:!0,NONE:!1},iceberg:!1},createOrders:{max:20},fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:1e3,daysBack:void 0,untilDays:void 0,trigger:!0,trailing:!1,symbolRequired:!0},fetchClosedOrders:void 0,fetchOHLCV:{paginate:!1,limit:1e3}},spot:{extends:"default"},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},requiredCredentials:{apiKey:!0,secret:!0},precisionMode:a.kb,options:{instructions:{"api/v1/account":{GET:"accountQuery",PATCH:"accountUpdate"},"api/v1/capital":{GET:"balanceQuery"},"api/v1/account/limits/borrow":{GET:"maxBorrowQuantity"},"api/v1/account/limits/order":{GET:"maxOrderQuantity"},"api/v1/account/limits/withdrawal":{GET:"maxWithdrawalQuantity"},"api/v1/borrowLend/positions":{GET:"borrowLendPositionQuery"},"api/v1/borrowLend":{POST:"borrowLendExecute"},"wapi/v1/history/borrowLend/positions":{GET:"borrowPositionHistoryQueryAll"},"wapi/v1/history/borrowLend":{GET:"borrowHistoryQueryAll"},"wapi/v1/history/dust":{GET:"dustHistoryQueryAll"},"api/v1/capital/collateral":{GET:"collateralQuery"},"wapi/v1/capital/deposit/address":{GET:"depositAddressQuery"},"wapi/v1/capital/deposits":{GET:"depositQueryAll"},"wapi/v1/history/fills":{GET:"fillHistoryQueryAll"},"wapi/v1/history/funding":{GET:"fundingHistoryQueryAll"},"wapi/v1/history/interest":{GET:"interestHistoryQueryAll"},"api/v1/order":{GET:"orderQuery",POST:"orderExecute",DELETE:"orderCancel"},"api/v1/orders":{GET:"orderQueryAll",POST:"orderExecute",DELETE:"orderCancelAll"},"wapi/v1/history/orders":{GET:"orderHistoryQueryAll"},"wapi/v1/history/pnl":{GET:"pnlHistoryQueryAll"},"wapi/v1/history/rfq":{GET:"rfqHistoryQueryAll"},"wapi/v1/history/quote":{GET:"quoteHistoryQueryAll"},"wapi/v1/history/settlement":{GET:"settlementHistoryQueryAll"},"api/v1/position":{GET:"positionQuery"},"api/v1/rfq/quote":{POST:"quoteSubmit"},"wapi/v1/history/strategies":{GET:"strategyHistoryQueryAll"},"wapi/v1/capital/withdrawals":{GET:"withdrawalQueryAll",POST:"withdraw"}},recvWindow:5e3,brokerId:"",currencyIdsListForParseMarket:void 0,broker:"",timeDifference:0,adjustForTimeDifference:!1,networks:{APT:"Aptos",ARB:"Arbitrum",AVAX:"Avalanche",BASE:"Base",BERA:"Berachain",BTC:"Bitcoin",BCH:"BitcoinCash",BSC:"Bsc",ADA:"Cardano",DOGE:"Dogecoin",ECLIPSE:"Eclipse",EQUALSMONEY:"EqualsMoney",ERC20:"Ethereum",HYP:"Hyperliquid",LTC:"Litecoin",OPTIMISM:"Optimism",MATIC:"Polygon",SEI:"Sei",SUI:"Sui",SOL:"Solana",STORY:"Story",TRC20:"Tron",XRP:"XRP"},networksById:{aptos:"APT",arbitrum:"ARB",avalanche:"AVAX",base:"BASE",berachain:"BERA",bitcoin:"BTC",bitcoincash:"BCH",bsc:"BSC",cardano:"ADA",dogecoin:"DOGE",eclipse:"ECLIPSE",equalsmoney:"EQUALSMONEY",ethereum:"ERC20",hyperliquid:"HYP",litecoin:"LTC",optimism:"OPTIMISM",polygon:"MATIC",sei:"SEI",sui:"SUI",solana:"SOL",story:"STORY",tron:"TRC20",xrp:"XRP"}},commonCurrencies:{},exceptions:{exact:{INVALID_CLIENT_REQUEST:r.BadRequest,INVALID_ORDER:r.InvalidOrder,ACCOUNT_LIQUIDATING:r.BadRequest,BORROW_LIMIT:r.BadRequest,BORROW_REQUIRES_LEND_REDEEM:r.BadRequest,FORBIDDEN:r.OperationRejected,INSUFFICIENT_FUNDS:r.InsufficientFunds,INSUFFICIENT_MARGIN:r.InsufficientFunds,INSUFFICIENT_SUPPLY:r.InsufficientFunds,INVALID_ASSET:r.BadRequest,INVALID_MARKET:r.BadSymbol,INVALID_PRICE:r.BadRequest,INVALID_POSITION_ID:r.BadRequest,INVALID_QUANTITY:r.BadRequest,INVALID_RANGE:r.BadRequest,INVALID_SIGNATURE:r.AuthenticationError,INVALID_SOURCE:r.BadRequest,INVALID_SYMBOL:r.BadSymbol,INVALID_TWO_FACTOR_CODE:r.BadRequest,LEND_LIMIT:r.BadRequest,LEND_REQUIRES_BORROW_REPAY:r.BadRequest,MAINTENANCE:r.ExchangeError,MAX_LEVERAGE_REACHED:r.InsufficientFunds,NOT_IMPLEMENTED:r.OperationFailed,ORDER_LIMIT:r.OperationRejected,POSITION_LIMIT:r.OperationRejected,PRECONDITION_FAILED:r.OperationFailed,RESOURCE_NOT_FOUND:r.ExchangeNotAvailable,SERVER_ERROR:r.NetworkError,TIMEOUT:r.RequestTimeout,TOO_MANY_REQUESTS:r.RateLimitExceeded,TRADING_PAUSED:r.ExchangeNotAvailable,UNAUTHORIZED:r.AuthenticationError},broad:{}}})}async fetchCurrencies(e={}){const t=await this.publicGetApiV1Assets(e),i={};for(let e=0;e0&&(e+="&"),u="instruction="+l+"&"+e+"timestamp="+t+"&window="+s}const p=this.base64ToBinary(this.secret),f=this.arraySlice(p,0,32),m=(0,d.q4)(this.encode(u),f,n.ev);r={"X-Timestamp":t,"X-Window":s,"X-API-Key":this.apiKey,"X-Signature":m,"X-Broker-Id":"1400"},"GET"!==i&&(a=this.json(h),r["Content-Type"]="application/json")}if("GET"===i){const e=this.urlencode(h);0!==e.length&&(o+="?"+e)}return c+=o,{url:c,method:i,body:a,headers:r}}generateBatchPayload(e,t,i,s){let r="";for(let a=0;a{"use strict";i.d(t,{k:()=>Lt});var s=i(5095),r=i(7437),a=i(6238),o=i(2079),n=i(5147),d=i(7288),c=i(3206),h=i(3828),l=i(8283),u=i(8995),p=i(5897),f=i(4380),m=i(987),g=i(8432),v=i(447),y=i(3187),b=i(7661),w=i(6907),k=i(9793),S=i(9491),O=i(1878),T=i(4852),P=i(3466),I=i(9187),M=i(1291),A=i.n(M);const{isNode:x,selfIsDefined:_,deepExtend:C,extend:B,clone:E,flatten:R,unique:L,indexBy:N,sortBy:D,sortBy2:q,safeFloat2:V,groupBy:F,aggregate:H,uuid:G,unCamelCase:U,precisionFromString:W,Throttler:j,capitalize:K,now:z,decimalToPrecision:Y,safeValue:X,safeValue2:Q,safeString:Z,safeString2:$,seconds:J,milliseconds:ee,binaryToBase16:te,numberToBE:ie,base16ToBinary:se,iso8601:re,omit:ae,isJsonEncodedObject:oe,safeInteger:ne,sum:de,omitZero:ce,implodeParams:he,extractParams:le,json:ue,merge:pe,binaryConcat:fe,hash:me,arrayConcat:ge,encode:ve,urlencode:ye,hmac:be,numberToString:we,roundTimeframe:ke,parseTimeframe:Se,safeInteger2:Oe,safeStringLower:Te,parse8601:Pe,yyyymmdd:Ie,safeStringUpper:Me,safeTimestamp:Ae,binaryConcatArray:xe,uuidv1:_e,numberToLE:Ce,ymdhms:Be,stringToBase64:Ee,decode:Re,uuid22:Le,safeIntegerProduct2:Ne,safeIntegerProduct:De,safeStringLower2:qe,yymmdd:Ve,base58ToBinary:Fe,binaryToBase58:He,safeTimestamp2:Ge,rawencode:Ue,keysort:We,sort:je,inArray:Ke,isEmpty:ze,ordered:Ye,filterBy:Xe,uuid16:Qe,safeFloat:Ze,base64ToBinary:$e,safeStringUpper2:Je,urlencodeWithArrayRepeat:et,microseconds:tt,binaryToBase64:it,strip:st,toArray:rt,safeFloatN:at,safeIntegerN:ot,safeIntegerProductN:nt,safeTimestampN:dt,safeValueN:ct,safeStringN:ht,safeStringLowerN:lt,safeStringUpperN:ut,urlencodeNested:pt,urlencodeBase64:ft,parseDate:mt,ymd:gt,base64ToString:vt,crc32:yt,packb:bt,TRUNCATE:wt,ROUND:kt,DECIMAL_PLACES:St,NO_PADDING:Ot,TICK_SIZE:Tt,SIGNIFICANT_DIGITS:Pt,sleep:It}=s;let Mt,At,xt,_t,Ct,Bt,Et,Rt;(async()=>{try{Mt=await Promise.resolve().then(i.t.bind(i,2373,23))}catch(e){}})();class Lt{constructor(e={}){this.isSandboxModeEnabled=!1,this.api=void 0,this.certified=!1,this.pro=!1,this.countries=void 0,this.userAgent=void 0,this.user_agent=void 0,this.userAgents={chrome:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",chrome39:"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36",chrome100:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"},this.headers={},this.returnResponseHeaders=!1,this.origin="*",this.MAX_VALUE=Number.MAX_VALUE,this.agent=void 0,this.nodeHttpModuleLoaded=!1,this.httpAgent=void 0,this.httpsAgent=void 0,this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.quoteJsonNumbers=!0,this.number=Number,this.handleContentTypeApplicationZip=!1,this.reduceFees=!0,this.validateServerSsl=!0,this.validateClientSsl=!1,this.timeout=1e4,this.verbose=!1,this.twofa=void 0,this.balance={},this.liquidations={},this.orderbooks={},this.tickers={},this.fundingRates={},this.bidsasks={},this.orders=void 0,this.triggerOrders=void 0,this.transactions={},this.myLiquidations={},this.requiresWeb3=!1,this.requiresEddsa=!1,this.precision=void 0,this.enableLastJsonResponse=!1,this.enableLastHttpResponse=!0,this.enableLastResponseHeaders=!0,this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.last_request_headers=void 0,this.last_request_body=void 0,this.last_request_url=void 0,this.last_request_path=void 0,this.id="Exchange",this.markets=void 0,this.features=void 0,this.status=void 0,this.rateLimit=void 0,this.tokenBucket=void 0,this.throttler=void 0,this.enableRateLimit=void 0,this.rollingWindowSize=0,this.rateLimiterAlgorithm="leakyBucket",this.httpExceptions=void 0,this.limits=void 0,this.markets_by_id=void 0,this.symbols=void 0,this.ids=void 0,this.currencies={},this.baseCurrencies=void 0,this.quoteCurrencies=void 0,this.currencies_by_id=void 0,this.codes=void 0,this.reloadingMarkets=void 0,this.marketsLoading=void 0,this.accounts=void 0,this.accountsById=void 0,this.commonCurrencies=void 0,this.hostname=void 0,this.precisionMode=void 0,this.paddingMode=void 0,this.exceptions={},this.timeframes={},this.version=void 0,this.marketsByAltname=void 0,this.name=void 0,this.targetAccount=void 0,this.stablePairs={},this.httpProxyAgentModule=void 0,this.httpsProxyAgentModule=void 0,this.socksProxyAgentModule=void 0,this.socksProxyAgentModuleChecked=!1,this.proxyDictionaries={},this.proxiesModulesLoading=void 0,this.alias=!1,this.clients={},this.newUpdates=!0,this.streaming={},this.sleep=It,this.deepExtend=C,this.deepExtendSafe=C,this.isNode=x,this.keys=r.HP,this.values=r.zu,this.extend=B,this.clone=E,this.flatten=R,this.unique=L,this.indexBy=N,this.indexBySafe=N,this.roundTimeframe=ke,this.sortBy=D,this.sortBy2=q,this.groupBy=F,this.aggregate=H,this.uuid=G,this.unCamelCase=U,this.precisionFromString=W,this.capitalize=K,this.now=z,this.decimalToPrecision=Y,this.safeValue=X,this.safeValue2=Q,this.safeString=Z,this.safeString2=$,this.safeFloat=Ze,this.safeFloat2=V,this.seconds=J,this.milliseconds=ee,this.binaryToBase16=te,this.numberToBE=ie,this.base16ToBinary=se,this.iso8601=re,this.omit=ae,this.isJsonEncodedObject=oe,this.safeInteger=ne,this.sum=de,this.omitZero=ce,this.implodeParams=he,this.extractParams=le,this.json=ue,this.vwap=a.ru,this.merge=pe,this.binaryConcat=fe,this.hash=me,this.arrayConcat=ge,this.encode=ve,this.urlencode=ye,this.hmac=be,this.numberToString=we,this.parseTimeframe=Se,this.safeInteger2=Oe,this.safeStringLower=Te,this.parse8601=Pe,this.yyyymmdd=Ie,this.safeStringUpper=Me,this.safeTimestamp=Ae,this.binaryConcatArray=xe,this.uuidv1=_e,this.numberToLE=Ce,this.ymdhms=Be,this.yymmdd=Ve,this.stringToBase64=Ee,this.decode=Re,this.uuid22=Le,this.safeIntegerProduct2=Ne,this.safeIntegerProduct=De,this.binaryToBase58=He,this.base58ToBinary=Fe,this.base64ToBinary=$e,this.safeTimestamp2=Ge,this.rawencode=Ue,this.keysort=We,this.sort=je,this.inArray=Ke,this.safeStringLower2=qe,this.safeStringUpper2=Je,this.isEmpty=ze,this.ordered=Ye,this.filterBy=Xe,this.uuid16=Qe,this.urlencodeWithArrayRepeat=et,this.microseconds=tt,this.binaryToBase64=it,this.strip=st,this.toArray=rt,this.safeFloatN=at,this.safeIntegerN=ot,this.safeIntegerProductN=nt,this.safeTimestampN=dt,this.safeValueN=ct,this.safeStringN=ht,this.safeStringLowerN=lt,this.safeStringUpperN=ut,this.urlencodeNested=pt,this.parseDate=mt,this.ymd=gt,this.base64ToString=vt,this.crc32=yt,this.packb=bt,this.urlencodeBase64=ft,Object.assign(this,s),this.options=this.getDefaultOptions(),this.headers={},this.origin="*",this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.quoteJsonNumbers=!0,this.number=Number,this.handleContentTypeApplicationZip=!1,this.reduceFees=!0,this.fetchImplementation=void 0,this.validateServerSsl=!0,this.validateClientSsl=!1,this.timeout=1e4,this.verbose=!1,this.twofa=void 0,this.apiKey=void 0,this.secret=void 0,this.uid=void 0,this.login=void 0,this.password=void 0,this.privateKey=void 0,this.walletAddress=void 0,this.token=void 0,this.balance={},this.bidsasks={},this.orderbooks={},this.tickers={},this.liquidations={},this.orders=void 0,this.trades={},this.transactions={},this.ohlcvs={},this.myLiquidations={},this.myTrades=void 0,this.positions=void 0,this.requiresWeb3=!1,this.requiresEddsa=!1,this.lastRestRequestTimestamp=0,this.enableLastJsonResponse=!1,this.enableLastHttpResponse=!0,this.enableLastResponseHeaders=!0,this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.last_request_headers=void 0,this.last_request_body=void 0,this.last_request_url=void 0,this.last_request_path=void 0;const t=(e=this)=>{if(null!==e){const i=Object.getOwnPropertyNames(e);for(let e=0;eparseInt(e,16))),s=(new TextEncoder).encode(t),r=new Uint8Array([...i,...s]),a=(0,P.e)(r);a[6]=15&a[6]|80,a[8]=63&a[8]|128;const o=[...a.slice(0,16)].map((e=>e.toString(16).padStart(2,"0"))).join("");return[o.substring(0,8),o.substring(8,12),o.substring(12,16),o.substring(16,20),o.substring(20,32)].join("-")}encodeURIComponent(...e){return encodeURIComponent(...e)}checkRequiredVersion(e,t=!0){let i=!0;const[s,r,a]=e.split("."),[n,d,c]=Lt.ccxtVersion.split("."),h=this.parseToInt(s),l=this.parseToInt(r),u=this.parseToInt(a),p=this.parseToInt(n),f=this.parseToInt(d),m=this.parseToInt(c);if(h>p&&(i=!1),h===p&&(l>f||l===f&&u>m)&&(i=!1),!i){if(t)throw new o.NotSupported("Your current version of CCXT is "+Lt.ccxtVersion+", a newer version "+e+" is required, please, upgrade your version of CCXT");return t}return i}throttle(e=void 0){return this.throttler.throttle(e)}initThrottler(){this.throttler=new j(this.tokenBucket)}defineRestApiEndpoint(e,t,i,s,r,a,o={}){const n=r.split(/[^a-zA-Z0-9]/),d=n.map(this.capitalize).join(""),c=n.map((e=>e.trim().toLowerCase())).filter((e=>e.length>0)).join("_"),h=[a[0]].concat(a.slice(1).map(this.capitalize)).join(""),l=[a[0]].concat(a.slice(1).map((e=>e.trim())).filter((e=>e.length>0))).join("_"),u=h+s+this.capitalize(d),p=l+"_"+i+"_"+c,f=a.length>1?a:a[0],m=async(i={},s={})=>this[e](r,f,t,i,void 0,void 0,o,s);this[u]=m,this[p]=m}defineRestApi(e,t,i=[]){const s=Object.keys(e);for(let r=0;r{try{this.httpProxyAgentModule=await import("../static_dependencies/proxies/http-proxy-agent/index.js"),this.httpsProxyAgentModule=await import("../static_dependencies/proxies/https-proxy-agent/index.js")}catch(e){try{this.httpProxyAgentModule=await import("http-proxy-agent"),this.httpsProxyAgentModule=await import("https-proxy-agent")}catch(e){}}if(!1===this.socksProxyAgentModuleChecked){try{this.socksProxyAgentModule=await import("socks-proxy-agent")}catch(e){}this.socksProxyAgentModuleChecked=!0}})()),await this.proxiesModulesLoading}setProxyAgents(e,t,i){let s;if(!x&&(e||t||i))throw new o.NotSupported(this.id+' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');if(e){if(void 0===this.httpProxyAgentModule)throw new o.NotSupported(this.id+" you need to load JS proxy modules with `await instance.loadProxyModules()` method at first to use proxies");e in this.proxyDictionaries||(this.proxyDictionaries[e]=new this.httpProxyAgentModule.HttpProxyAgent(e)),s=this.proxyDictionaries[e]}else if(t){if(void 0===this.httpsProxyAgentModule)throw new o.NotSupported(this.id+" you need to load JS proxy modules with `await instance.loadProxyModules()` method at first to use proxies");t in this.proxyDictionaries||(this.proxyDictionaries[t]=new this.httpsProxyAgentModule.HttpsProxyAgent(t)),s=this.proxyDictionaries[t],s.keepAlive=!0}else if(i){if(void 0===this.socksProxyAgentModule)throw new o.NotSupported(this.id+' - to use SOCKS proxy with ccxt, at first you need install module "npm i socks-proxy-agent" and then initialize proxies with `await instance.loadProxyModules()` method');i in this.proxyDictionaries||(this.proxyDictionaries[i]=new this.socksProxyAgentModule.SocksProxyAgent(i)),s=this.proxyDictionaries[i]}return s}async loadHttpProxyAgent(){if(!this.httpAgent){const e=await import("node:http");this.httpAgent=new e.Agent}return this.httpAgent}getHttpAgentIfNeeded(e){if(x&&"ws://"===e.substring(0,5)){if(void 0===this.httpAgent)throw new o.NotSupported(this.id+" to use proxy with non-ssl ws:// urls, at first run `await exchange.loadHttpProxyAgent()` method");return this.httpAgent}}isBinaryMessage(e){return e instanceof Uint8Array||e instanceof ArrayBuffer}decodeProtoMsg(e){if(!Mt)throw new o.NotSupported(this.id+" requires protobuf to decode messages, please install it with `npm install protobufjs`");if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Uint8Array){return Mt.default.PushDataV3ApiWrapper.decode(e).toJSON()}return e}async fetch(e,t="GET",i=void 0,s=void 0){if(x&&!this.nodeHttpModuleLoaded){this.nodeHttpModuleLoaded=!0;const e=await import("node:https");this.httpsAgent=new e.Agent({keepAlive:!0})}i=this.extend(this.headers,i);const r=this.checkProxyUrlSettings(e,t,i,s);let a=!1;void 0!==r&&(x&&(i=this.extend({Origin:this.origin},i),"http:"===r.substring(0,5)&&(await this.loadHttpProxyAgent(),a=this.httpAgent)),e=r+this.urlEncoderForProxyUrl(e));const[n,d,c]=this.checkProxySettings(e,t,i,s);this.checkConflictingProxies(n||d||c,r),x&&await this.loadProxyModules();const h=this.setProxyAgents(n,d,c),l=void 0!==this.userAgent?this.userAgent:this.user_agent;if(l&&x&&("string"==typeof l?i=this.extend({"User-Agent":l},i):"object"==typeof l&&"User-Agent"in l&&(i=this.extend(l,i))),i=this.setHeaders(i),this.verbose&&this.log("fetch Request:\n",this.id,t,e,"\nRequestHeaders:\n",i,"\nRequestBody:\n",s,"\n"),void 0===this.fetchImplementation)if(x){void 0===this.agent&&(this.agent=this.httpsAgent);try{const e=await import("../static_dependencies/node-fetch/index.js");this.AbortError=e.AbortError,this.fetchImplementation=e.default,this.FetchError=e.FetchError}catch(e){if("function"!=typeof fetch)throw new Error('Seems, "fetch" function is not available in your node-js version, please use latest node-js version');this.fetchImplementation=fetch,this.AbortError=DOMException,this.FetchError=TypeError}}else this.fetchImplementation=_()?self.fetch:fetch,this.AbortError=DOMException,this.FetchError=TypeError;const u=this.fetchImplementation,p={method:t,headers:i,body:s,timeout:this.timeout};this.agent&&(p.agent=this.agent),a?p.agent=a:h&&(p.agent=h);const f=new AbortController;p.signal=f.signal;const m=setTimeout((()=>{f.abort()}),this.timeout);try{const r=await u(e,p);return clearTimeout(m),this.handleRestResponse(r,e,t,i,s)}catch(i){if(i instanceof this.AbortError)throw new o.RequestTimeout(this.id+" "+t+" "+e+" request timed out ("+this.timeout+" ms)");if(i instanceof this.FetchError)throw new o.NetworkError(this.id+" "+t+" "+e+" fetch failed");throw i}}parseJson(e){try{if(this.isJsonEncodedObject(e))return JSON.parse(this.onJsonResponse(e))}catch(e){return}}getResponseHeaders(e){const t={};return e.headers.forEach(((e,i)=>{i=i.split("-").map((e=>this.capitalize(e))).join("-"),t[i]=e})),t}handleRestResponse(e,t,i="GET",s=void 0,r=void 0){const a=this.getResponseHeaders(e);if(this.handleContentTypeApplicationZip&&"application/zip"===a["Content-Type"]){const s=e.buffer();return this.enableLastResponseHeaders&&(this.last_response_headers=a),this.enableLastHttpResponse&&(this.last_http_response=s),this.verbose&&this.log("handleRestResponse:\n",this.id,i,t,e.status,e.statusText,"\nResponseHeaders:\n",a,"ZIP redacted","\n"),s}return e.text().then((o=>{const n=this.onRestResponse(e.status,e.statusText,t,i,a,o,s,r),d=this.parseJson(n);this.enableLastResponseHeaders&&(this.last_response_headers=a),this.enableLastHttpResponse&&(this.last_http_response=o),this.enableLastJsonResponse&&(this.last_json_response=d),this.verbose&&this.log("handleRestResponse:\n",this.id,i,t,e.status,e.statusText,"\nResponseHeaders:\n",a,"\nResponseBody:\n",o,"\n");return this.handleErrors(e.status,e.statusText,t,i,a,o,d,s,r)||this.handleHttpStatusCode(e.status,e.statusText,t,i,o),d&&!Array.isArray(d)&&this.returnResponseHeaders&&(d.responseHeaders=a),d||o}))}onRestResponse(e,t,i,s,r,a,o,n){return a.trim()}onJsonResponse(e){return this.quoteJsonNumbers?e.replace(/":([+.0-9eE-]+)([,}])/g,'":"$1"$2'):e}async loadMarketsHelper(e=!1,t={}){if(!e&&this.markets)return this.markets_by_id?this.markets:this.setMarkets(this.markets);let i;!0===this.has.fetchCurrencies&&(i=await this.fetchCurrencies(),this.options.cachedCurrencies=i);const s=await this.fetchMarkets(t);return"cachedCurrencies"in this.options&&delete this.options.cachedCurrencies,this.setMarkets(s,i)}async loadMarkets(e=!1,t={}){return(e&&!this.reloadingMarkets||!this.marketsLoading)&&(this.reloadingMarkets=!0,this.marketsLoading=this.loadMarketsHelper(e,t).then((e=>(this.reloadingMarkets=!1,e)),(e=>{throw this.reloadingMarkets=!1,e}))),this.marketsLoading}async fetchCurrencies(e={}){return new Promise(((e,t)=>{e(this.currencies)}))}async fetchCurrenciesWs(e={}){return new Promise(((e,t)=>{e(this.currencies)}))}async fetchMarkets(e={}){return new Promise(((e,t)=>{e(Object.values(this.markets))}))}async fetchMarketsWs(e={}){return new Promise(((e,t)=>{e(Object.values(this.markets))}))}checkRequiredDependencies(){}parseNumber(e,t=void 0){if(void 0===e)return t;try{const i=this.numberToString(e);if(i.indexOf("e-")>-1)return this.number(we(parseFloat(i)));const s=this.number(i);return Number.isNaN(s)?t:s}catch(e){return t}}checkOrderArguments(e,t,i,s,r,a){if(void 0===r&&"limit"===t)throw new o.ArgumentsRequired(this.id+" createOrder() requires a price argument for a limit order");if(s<=0)throw new o.ArgumentsRequired(this.id+" createOrder() amount should be above 0")}handleHttpStatusCode(e,t,i,s,r){const a=e.toString();if(a in this.httpExceptions){throw new(0,this.httpExceptions[a])(this.id+" "+s+" "+i+" "+a+" "+t+" "+r)}}remove0xPrefix(e){return"0x"===e.slice(0,2)?e.slice(2):e}mapToSafeMap(e){return e}safeMapToMap(e){return e}spawn(e,...t){const i=(0,c.K)();return setTimeout((()=>{e.apply(this,t).then(i.resolve).catch(i.reject)}),0),i}delay(e,t,...i){setTimeout((()=>{this.spawn(t,...i)}),e)}orderBook(e={},t=Number.MAX_SAFE_INTEGER){return new h.Mi(e,t)}indexedOrderBook(e={},t=Number.MAX_SAFE_INTEGER){return new h.nS(e,t)}countedOrderBook(e={},t=Number.MAX_SAFE_INTEGER){return new h.if(e,t)}handleMessage(e,t){}ping(e){}client(e){if(this.clients=this.clients||{},!this.clients[e]){const t=this.handleMessage.bind(this),i=this.onError.bind(this),s=this.onClose.bind(this),r=this.onConnected.bind(this),a=this.safeValue(this.options,"ws",{}),[o,n,c]=this.checkWsProxySettings(),h=this.setProxyAgents(o,n,c),l=this.getHttpAgentIfNeeded(e),u=h||(l||this.agent),p=this.deepExtend(this.streaming,{log:this.log?this.log.bind(this):this.log,ping:this.ping?this.ping.bind(this):this.ping,verbose:this.verbose,throttler:new j(this.tokenBucket),options:{agent:u},decompressBinary:this.safeBool(this.options,"decompressBinary",!0)},a);this.clients[e]=new d.A(e,t,i,s,r,p)}return this.clients[e]}watchMultiple(e,t,i=void 0,s=void 0,r=void 0){const a=this.client(e),o=c.K.race(t.map((e=>a.future(e)))),n=[];if(void 0!==s)for(let e=0;e{const e=this.safeValue(this.options,"ws"),t=this.safeValue(e,"cost",1);i&&(this.enableRateLimit&&a.throttle?a.throttle(t).then((()=>{a.send(i)})).catch((e=>{for(let e=0;e{for(let e=0;e{for(let e=0;e{const e=this.safeValue(this.options,"ws"),t=this.safeValue(e,"cost",1);i&&(this.enableRateLimit&&a.throttle?a.throttle(t).then((()=>{a.send(i)})).catch((e=>{a.onError(e)})):a.send(i).catch((e=>{a.onError(e)})))})).catch((e=>{delete a.subscriptions[s],o.reject(e)})),o}onConnected(e,t=void 0){}onError(e,t){e.url in this.clients&&this.clients[e.url].error&&delete this.clients[e.url]}onClose(e,t){e.error||this.clients[e.url]&&delete this.clients[e.url]}async close(){await this.sleep(0);const e=Object.values(this.clients||{}),t=[];for(let i=0;i=0)return d.reset(o),this.handleDeltas(d,a.slice(c)),d.cache.length=0,void e.resolve(d,t);n++}e.reject(new o.ExchangeError(this.id+" nonce is behind the cache after "+a.toString()+" tries."),t),delete this.clients[e.url],this.orderbooks[i]=this.orderBook()}catch(a){e.reject(a,t),await this.loadOrderBook(e,t,i,s,r)}}convertToBigInt(e){return BigInt(e)}stringToCharsArray(e){return e.split("")}valueIsDefined(e){return null!=e}arraySlice(e,t,i=void 0){return void 0===i?e.slice(t):e.slice(t,i)}getProperty(e,t,i=void 0){return t in e?e[t]:i}setProperty(e,t,i=void 0){e[t]=i}exceptionMessage(e,t=!0){const i="["+e.constructor.name+"] "+(t?e.stack:e.message),s=Math.min(1e5,i.length);return i.slice(0,s)}axolotl(e,t,i){return(0,l.Sw)(e,t,i)}fixStringifiedJsonMembers(e){let t=e.replaceAll("\\","");return t=t.replaceAll('"{',"{"),t=t.replaceAll('}"',"}"),t}ethAbiEncode(e,t){return this.base16ToBinary(p.Ay.encode(e,t).slice(2))}ethEncodeStructuredData(e,t,i){return this.base16ToBinary(f.z.encode(e,t,i).slice(-132))}ethGetAddressFromPrivateKey(e){const t=this.remove0xPrefix(e),i=m.bI.getPublicKey(t),s=m.bI.ProjectivePoint.fromHex(i).toRawBytes(!1).slice(1),r=(0,g.lY)(s).slice(-20);return"0x"+this.binaryToBase16(r)}retrieveStarkAccount(e,t,i){const s=(0,y.b)(e),r=(0,y.$u)(s),a=w.fP.compile({implementation:t,selector:k.BK("initialize"),calldata:w.fP.compile({signer:r,guardian:"0"})});return{privateKey:s,publicKey:r,address:S.r4(r,i,a,0)}}starknetEncodeStructuredData(e,t,i,s){const r=Object.keys(t);if(r.length>1)throw new o.NotSupported(this.id+" starknetEncodeStructuredData only support single type");const a={domain:e,primaryType:r[0],types:this.extend({StarkNetDomain:[{name:"name",type:"felt"},{name:"chainId",type:"felt"},{name:"version",type:"felt"}]},t),message:i};return O.E(a,s)}starknetSign(e,t){const i=(0,y._S)(e.replace("0x",""),t.replace("0x",""));return this.json([i.r.toString(),i.s.toString()])}async getZKContractSignatureObj(e,t={}){const i=BigInt("0x"+this.remove0xPrefix(this.hash(this.encode(this.safeString(t,"slotId")),T.s,"hex"))).toString(),s=BigInt("0x"+this.remove0xPrefix(this.hash(this.encode(this.safeString(t,"nonce")),T.s,"hex"))).toString(),r="4294967295",a=parseInt(n.Y.stringMod(this.safeString(t,"accountId"),r),10),o=parseInt(n.Y.stringDiv(n.Y.stringMod(i,"18446744073709551615"),r),10),d=parseInt(n.Y.stringMod(s,r),10);await(0,b.Ay)();const c=b.$s({});await c.initZklinkSigner(e);const h=new b.KR(a,0,o,d,this.safeInteger(t,"pairId"),n.Y.stringMul(this.safeString(t,"size"),"1e18"),n.Y.stringMul(this.safeString(t,"price"),"1e18"),"BUY"===this.safeString(t,"direction"),parseInt(n.Y.stringMul(this.safeString(t,"makerFeeRate"),"10000")),parseInt(n.Y.stringMul(this.safeString(t,"takerFeeRate"),"10000")),!1),l=b.JF(h);l?.sign(c?.getZkLinkSigner());const u=l.jsValue(),p=u?.signature?.signature;return p}async getZKTransferSignatureObj(e,t={}){await(0,b.Ay)();const i=b.$s({});await i.initZklinkSigner(e);let s=this.safeString(t,"nonce","0");if(!0===this.safeBool(t,"isContract")){const e="4294967295",t=BigInt("0x"+this.remove0xPrefix(this.hash(this.encode(s),T.s,"hex"))).toString();s=n.Y.stringMod(t,e)}const r=new b.H3(this.safeNumber(t,"zkAccountId",0),this.safeString(t,"receiverAddress"),this.safeNumber(t,"subAccountId",0),this.safeNumber(t,"receiverSubAccountId",0),this.safeNumber(t,"tokenId",0),this.safeString(t,"fee","0"),this.safeString(t,"amount","0"),this.parseToInt(s),this.safeNumber(t,"timestampSeconds",0)),a=b.qj(r);a?.sign(i?.getZkLinkSigner());const o=a.jsValue(),d=o?.signature?.signature;return d}async loadDydxProtos(){const e=[Promise.resolve().then(i.bind(i,1173)),Promise.resolve().then(i.bind(i,7171)),Promise.resolve().then(i.bind(i,5928))],t=await Promise.all(e);At=t[0].encodeAsAny,xt=t[1].AuthInfo,_t=t[1].Tx,Ct=t[1].TxBody,Bt=t[1].TxRaw,Et=t[1].SignDoc,Rt=t[2].SignMode}toDydxLong(e){return A().fromString(e)}retrieveDydxCredentials(e){let t;return e.indexOf(" ")>0?(t=(0,I.t)(e),t.mnemonic=e,t):(t=(0,I.e)(this.base16ToBinary(e)),t)}encodeDydxTxForSimulation(e,t,i,s){if(!At)throw new o.NotSupported(this.id+" requires protobuf to encode messages, please install it with `npm install protobufjs`");if(!s)throw new Error("Public key cannot be undefined");const r=[e].map((e=>At(e))),a=_t.fromPartial({body:Ct.fromPartial({messages:r,memo:t}),authInfo:xt.fromPartial({fee:{},signerInfos:[{publicKey:At({typeUrl:"/cosmos.crypto.secp256k1.PubKey",value:s}),sequence:i,modeInfo:{single:{mode:Rt.SIGN_MODE_UNSPECIFIED}}}]}),signatures:[new Uint8Array]});return this.binaryToBase64(_t.encode(a).finish())}encodeDydxTxForSigning(e,t,i,s,r,a=void 0){if(!At)throw new o.NotSupported(this.id+" requires protobuf to encode messages, please install it with `npm install protobufjs`");if(!s.pub_key)throw new Error("Public key cannot be undefined");const n=[e],d=this.milliseconds();void 0===a&&(a={amount:[],gasLimit:1e6});const c=n.map((e=>At(e))),h=[At({typeUrl:"/dydxprotocol.accountplus.TxExtension",value:{selectedAuthenticators:r??[]}})],l=Ct.encode(Ct.fromPartial({messages:c,memo:t,extensionOptions:[],nonCriticalExtensionOptions:h})).finish(),u=xt.encode(xt.fromPartial({fee:a,signerInfos:[{publicKey:At({typeUrl:"/cosmos.crypto.secp256k1.PubKey",value:s.pub_key}),sequence:d,modeInfo:{single:{mode:Rt.SIGN_MODE_DIRECT}}}]})).finish(),p=Et.fromPartial({accountNumber:s.account_number,authInfoBytes:u,bodyBytes:l,chainId:i});return[this.hash(Et.encode(p).finish(),T.s,"hex"),p]}encodeDydxTxRaw(e,t){if(!At)throw new o.NotSupported(this.id+" requires protobuf to encode messages, please install it with `npm install protobufjs`");return"0x"+this.binaryToBase16(Bt.encode(Bt.fromPartial({bodyBytes:e.bodyBytes,authInfoBytes:e.authInfoBytes,signatures:[this.base16ToBinary(t)]})).finish())}intToBase16(e){return e.toString(16)}extendExchangeOptions(e){this.options=this.extend(this.options,e)}createSafeDictionary(){return{}}convertToSafeDictionary(e){return e}randomBytes(e){const t=new v.D,i=[];return i.length=e,t.nextBytes(i),Buffer.from(i).toString("hex")}randNumber(e){let t="";for(let i=0;i1){const e=r.join(",");throw new o.InvalidProxySettings(this.id+" you have multiple conflicting proxy settings ("+e+"), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback")}return a}urlEncoderForProxyUrl(e){return e.indexOf("?")>=0?this.encodeURIComponent(e):e}checkProxySettings(e=void 0,t=void 0,i=void 0,s=void 0){const r=[];let a,n,d;const c=this.valueIsDefined(this.httpProxy),h=this.valueIsDefined(this.http_proxy);(c||h)&&(r.push("httpProxy"),a=c?this.httpProxy:this.http_proxy);const l=this.valueIsDefined(this.httpProxyCallback),u=this.valueIsDefined(this.http_proxy_callback);(l||u)&&(r.push("httpProxyCallback"),a=l?this.httpProxyCallback(e,t,i,s):this.http_proxy_callback(e,t,i,s));const p=this.valueIsDefined(this.httpsProxy),f=this.valueIsDefined(this.https_proxy);(p||f)&&(r.push("httpsProxy"),n=p?this.httpsProxy:this.https_proxy);const m=this.valueIsDefined(this.httpsProxyCallback),g=this.valueIsDefined(this.https_proxy_callback);(m||g)&&(r.push("httpsProxyCallback"),n=m?this.httpsProxyCallback(e,t,i,s):this.https_proxy_callback(e,t,i,s));const v=this.valueIsDefined(this.socksProxy),y=this.valueIsDefined(this.socks_proxy);(v||y)&&(r.push("socksProxy"),d=v?this.socksProxy:this.socks_proxy);const b=this.valueIsDefined(this.socksProxyCallback),w=this.valueIsDefined(this.socks_proxy_callback);(b||w)&&(r.push("socksProxyCallback"),d=b?this.socksProxyCallback(e,t,i,s):this.socks_proxy_callback(e,t,i,s));if(r.length>1){const e=r.join(",");throw new o.InvalidProxySettings(this.id+" you have multiple conflicting proxy settings ("+e+"), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback")}return[a,n,d]}checkWsProxySettings(){const e=[];let t,i,s;const r=this.valueIsDefined(this.wsProxy),a=this.valueIsDefined(this.ws_proxy);(r||a)&&(e.push("wsProxy"),t=r?this.wsProxy:this.ws_proxy);const n=this.valueIsDefined(this.wssProxy),d=this.valueIsDefined(this.wss_proxy);(n||d)&&(e.push("wssProxy"),i=n?this.wssProxy:this.wss_proxy);const c=this.valueIsDefined(this.wsSocksProxy),h=this.valueIsDefined(this.ws_socks_proxy);(c||h)&&(e.push("wsSocksProxy"),s=c?this.wsSocksProxy:this.ws_socks_proxy);if(e.length>1){const t=e.join(",");throw new o.InvalidProxySettings(this.id+" you have multiple conflicting proxy settings ("+t+"), please use only one from: wsProxy, wssProxy, wsSocksProxy")}return[t,i,s]}checkConflictingProxies(e,t){if(e&&t)throw new o.InvalidProxySettings(this.id+" you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy")}checkAddress(e=void 0){if(void 0===e)throw new o.InvalidAddress(this.id+" address is undefined");if(1===this.unique(this.stringToCharsArray(e)).length||e.length-1)throw new o.InvalidAddress(this.id+" address is invalid or has less than "+this.minFundingAddressLength.toString()+' characters: "'+e.toString()+'"');return e}findMessageHashes(e,t){const i=[],s=Object.keys(e.futures);for(let e=0;e=0&&i.push(r)}return i}filterByLimit(e,t=void 0,i="timestamp",s=!1){if(this.valueIsDefined(t)){const r=e.length;if(r>0){let a=!0;if(i in e[0]){const t=e[0][i],s=e[r-1][i];void 0!==t&&void 0!==s&&(a=t<=s)}s?(t>r&&(t=r),e=a?this.arraySlice(e,0,t):this.arraySlice(e,-t)):e=a?this.arraySlice(e,-t):this.arraySlice(e,0,t)}}return e}filterBySinceLimit(e,t=void 0,i=void 0,s="timestamp",r=!1){const a=this.valueIsDefined(t),o=this.toArray(e);let n=o;if(a){n=[];for(let e=0;e=t&&n.push(i)}}if(r&&void 0!==i)return this.arraySlice(n,-i);const d=!r&&a;return this.filterByLimit(n,i,s,d)}filterByValueSinceLimit(e,t,i=void 0,s=void 0,r=void 0,a="timestamp",o=!1){const n=this.valueIsDefined(i),d=this.valueIsDefined(s),c=this.toArray(e);let h=c;if(n||d){h=[];for(let e=0;e=s)&&h.push(r)}}return o&&void 0!==r?this.arraySlice(h,-r):this.filterByLimit(h,r,a,d)}setSandboxMode(e){if(e){if(!("test"in this.urls))throw new o.NotSupported(this.id+" does not have a sandbox URL");"string"==typeof this.urls.api?(this.urls.apiBackup=this.urls.api,this.urls.api=this.urls.test):(this.urls.apiBackup=this.clone(this.urls.api),this.urls.api=this.clone(this.urls.test)),this.isSandboxModeEnabled=!0}else if("apiBackup"in this.urls){"string"==typeof this.urls.api?this.urls.api=this.urls.apiBackup:this.urls.api=this.clone(this.urls.apiBackup);const e=this.omit(this.urls,"apiBackup");this.urls=e,this.isSandboxModeEnabled=!1}}enableDemoTrading(e){if(this.isSandboxModeEnabled)throw new o.NotSupported(this.id+" demo trading does not support in sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences");if(e)this.urls.apiBackupDemoTrading=this.urls.api,this.urls.api=this.urls.demo;else if("apiBackupDemoTrading"in this.urls){this.urls.api=this.urls.apiBackupDemoTrading;const e=this.omit(this.urls,"apiBackupDemoTrading");this.urls=e}this.options.enableDemoTrading=e}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){return{}}async fetchAccounts(e={}){throw new o.NotSupported(this.id+" fetchAccounts() is not supported yet")}async fetchTrades(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchTrades() is not supported yet")}async fetchTradesWs(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchTradesWs() is not supported yet")}async watchLiquidations(e,t=void 0,i=void 0,s={}){if(this.has.watchLiquidationsForSymbols)return await this.watchLiquidationsForSymbols([e],t,i,s);throw new o.NotSupported(this.id+" watchLiquidations() is not supported yet")}async watchLiquidationsForSymbols(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchLiquidationsForSymbols() is not supported yet")}async watchMyLiquidations(e,t=void 0,i=void 0,s={}){if(this.has.watchMyLiquidationsForSymbols)return this.watchMyLiquidationsForSymbols([e],t,i,s);throw new o.NotSupported(this.id+" watchMyLiquidations() is not supported yet")}async watchMyLiquidationsForSymbols(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchMyLiquidationsForSymbols() is not supported yet")}async watchTrades(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchTrades() is not supported yet")}async unWatchOrders(e=void 0,t={}){throw new o.NotSupported(this.id+" unWatchOrders() is not supported yet")}async unWatchTrades(e,t={}){throw new o.NotSupported(this.id+" unWatchTrades() is not supported yet")}async watchTradesForSymbols(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchTradesForSymbols() is not supported yet")}async unWatchTradesForSymbols(e,t={}){throw new o.NotSupported(this.id+" unWatchTradesForSymbols() is not supported yet")}async watchMyTradesForSymbols(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchMyTradesForSymbols() is not supported yet")}async watchOrdersForSymbols(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchOrdersForSymbols() is not supported yet")}async watchOHLCVForSymbols(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchOHLCVForSymbols() is not supported yet")}async unWatchOHLCVForSymbols(e,t={}){throw new o.NotSupported(this.id+" unWatchOHLCVForSymbols() is not supported yet")}async watchOrderBookForSymbols(e,t=void 0,i={}){throw new o.NotSupported(this.id+" watchOrderBookForSymbols() is not supported yet")}async unWatchOrderBookForSymbols(e,t={}){throw new o.NotSupported(this.id+" unWatchOrderBookForSymbols() is not supported yet")}async unWatchPositions(e=void 0,t={}){throw new o.NotSupported(this.id+" unWatchPositions() is not supported yet")}async unWatchTicker(e,t={}){throw new o.NotSupported(this.id+" unWatchTicker() is not supported yet")}async unWatchMarkPrice(e,t={}){throw new o.NotSupported(this.id+" unWatchMarkPrice() is not supported yet")}async unWatchMarkPrices(e=void 0,t={}){throw new o.NotSupported(this.id+" unWatchMarkPrices() is not supported yet")}async fetchDepositAddresses(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchDepositAddresses() is not supported yet")}async fetchOrderBook(e,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchOrderBook() is not supported yet")}async fetchOrderBookWs(e,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchOrderBookWs() is not supported yet")}async fetchMarginMode(e,t={}){if(this.has.fetchMarginModes){const i=await this.fetchMarginModes([e],t);return this.safeDict(i,e)}throw new o.NotSupported(this.id+" fetchMarginMode() is not supported yet")}async fetchMarginModes(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchMarginModes () is not supported yet")}async fetchRestOrderBookSafe(e,t=void 0,i={}){const s=this.handleOption("watchOrderBook","maxRetries",3);for(let r=0;r=0?parseFloat(t):parseInt(t)}isRoundNumber(e){return 0===this.parseToNumeric(e%1)}safeNumberOmitZero(e,t,i=void 0){const s=this.safeString(e,t),r=this.parseNumber(this.omitZero(s));return void 0===r?i:r}safeIntegerOmitZero(e,t,i=void 0){const s=this.safeInteger(e,t,i);if(void 0!==s&&0!==s)return s}afterConstruct(){this.createNetworksByIdObject(),this.featuresGenerator(),this.markets&&this.setMarkets(this.markets),this.initRestRateLimiter();const e=this.safeBool2(this.options,"sandbox","testnet",!1);e&&this.setSandboxMode(e)}initRestRateLimiter(){if(void 0===this.rateLimit||void 0!==this.id&&-1===this.rateLimit)throw new o.ExchangeError(this.id+".rateLimit property is not configured");let e=this.MAX_VALUE;this.rateLimit>0&&(e=1/this.rateLimit);const t={delay:.001,capacity:1,cost:1,refillRate:e,algorithm:0===this.rollingWindowSize||"leakyBucket"===this.rateLimiterAlgorithm?"leakyBucket":"rollingWindow",windowSize:this.rollingWindowSize,rateLimit:this.rateLimit},i=void 0===this.tokenBucket?{}:this.tokenBucket;this.tokenBucket=this.extend(t,i),this.initThrottler()}featuresGenerator(){if(void 0===this.features)return;const e=this.features;this.features={};const t=["spot","swap","future","option"],i=["linear","inverse"];for(let s=0;s0)this.currencies=this.mapToSafeMap(this.deepExtend(this.currencies,t));else{let e=[],t=[];for(let s=0;ss.precision?t:s}o.push(s)}const n=this.sortBy(o,"code");this.currencies=this.mapToSafeMap(this.deepExtend(this.currencies,this.indexBy(n,"code")))}this.currencies_by_id=this.indexBySafe(this.currencies,"id");const n=this.keysort(this.currencies);return this.codes=Object.keys(n),this.markets}setMarketsFromExchange(e){if(this.id!==e.id)throw new o.ArgumentsRequired(this.id+" shareMarkets() can only share markets with exchanges of the same type (got "+e.id+")");if(!e.markets)throw new o.ExchangeError("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function");this.markets=e.markets,this.markets_by_id=e.markets_by_id,this.symbols=e.symbols,this.ids=e.ids,this.currencies=e.currencies,this.currencies_by_id=e.currencies_by_id,this.baseCurrencies=e.baseCurrencies,this.quoteCurrencies=e.quoteCurrencies,this.codes=e.codes;const t=this.safeList(e.options,"marketHelperProps",[]);for(let i=0;i0){void 0===e.symbol&&(e.symbol=O[0].symbol),void 0===e.side&&(e.side=O[0].side),void 0===e.type&&(e.type=O[0].type),void 0===e.id&&(e.id=O[0].order),p&&(r="0"),f&&(a="0");for(let e=0;e0)&&!(n<0))continue;-1===h||d>=this.sum(a[h][0],r)?a.push([d,n,n,n,n,s.amount,1]):(a[h][2]=Math.max(a[h][2],n),a[h][3]=Math.min(a[h][3],n),a[h][4]=n,a[h][5]=this.sum(a[h][5],s.amount),a[h][6]=this.sum(a[h][6],1))}return a}parseTradingViewOHLCV(e,t=void 0,i="1m",s=void 0,r=void 0){const a=this.convertTradingViewToOHLCV(e);return this.parseOHLCVs(a,t,i,s,r)}async editLimitBuyOrder(e,t,i,s=void 0,r={}){return await this.editLimitOrder(e,t,"buy",i,s,r)}async editLimitSellOrder(e,t,i,s=void 0,r={}){return await this.editLimitOrder(e,t,"sell",i,s,r)}async editLimitOrder(e,t,i,s,r=void 0,a={}){return await this.editOrder(e,t,"limit",i,s,r,a)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){return await this.cancelOrder(e,t),await this.createOrder(t,i,s,r,a,o)}async editOrderWithClientOrderId(e,t,i,s,r=void 0,a=void 0,o={}){return await this.editOrder("",t,i,s,r,a,this.extend({clientOrderId:e},o))}async editOrderWs(e,t,i,s,r=void 0,a=void 0,o={}){return await this.cancelOrderWs(e,t),await this.createOrderWs(t,i,s,r,a,o)}async fetchPosition(e,t={}){throw new o.NotSupported(this.id+" fetchPosition() is not supported yet")}async fetchPositionWs(e,t={}){throw new o.NotSupported(this.id+" fetchPositionWs() is not supported yet")}async watchPosition(e=void 0,t={}){throw new o.NotSupported(this.id+" watchPosition() is not supported yet")}async watchPositions(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchPositions() is not supported yet")}async watchPositionForSymbols(e=void 0,t=void 0,i=void 0,s={}){return await this.watchPositions(e,t,i,s)}async fetchPositionsForSymbol(e,t={}){throw new o.NotSupported(this.id+" fetchPositionsForSymbol() is not supported yet")}async fetchPositionsForSymbolWs(e,t={}){throw new o.NotSupported(this.id+" fetchPositionsForSymbol() is not supported yet")}async fetchPositions(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchPositions() is not supported yet")}async fetchPositionsWs(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchPositions() is not supported yet")}async fetchPositionsRisk(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchPositionsRisk() is not supported yet")}async fetchBidsAsks(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchBidsAsks() is not supported yet")}async fetchBorrowInterest(e=void 0,t=void 0,i=void 0,s=void 0,r={}){throw new o.NotSupported(this.id+" fetchBorrowInterest() is not supported yet")}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchLedger() is not supported yet")}async fetchLedgerEntry(e,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchLedgerEntry() is not supported yet")}parseBidAsk(e,t=0,i=1,s=2){const r=this.safeFloat(e,t),a=this.safeFloat(e,i),o=this.safeInteger(e,s),n=[r,a];return void 0!==o&&n.push(o),n}safeCurrency(e,t=void 0){if(void 0===e&&void 0!==t)return t;if(void 0!==this.currencies_by_id&&e in this.currencies_by_id&&void 0!==this.currencies_by_id[e])return this.currencies_by_id[e];let i=e;return void 0!==e&&(i=this.commonCurrencyCode(e.toUpperCase())),this.safeCurrencyStructure({id:e,code:i,precision:void 0})}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){if(void 0!==e)if(void 0!==this.markets_by_id&&e in this.markets_by_id){const i=this.markets_by_id[e];if(1===i.length)return i[0];if(void 0===s){if(void 0===t)throw new o.ArgumentsRequired(this.id+" safeMarket() requires a fourth argument for "+e+" to disambiguate between different markets with the same market id");s=t.type}for(let e=0;e=0)return s}}handleErrors(e,t,i,s,r,a,o,n,d){}calculateRateLimiterCost(e,t,i,s,r={}){return this.safeValue(r,"cost",1)}async fetchTicker(e,t={}){if(this.has.fetchTickers){await this.loadMarkets();e=this.market(e).symbol;const i=await this.fetchTickers([e],t),s=this.safeDict(i,e);if(void 0===s)throw new o.NullResponse(this.id+" fetchTickers() could not find a ticker for "+e);return s}throw new o.NotSupported(this.id+" fetchTicker() is not supported yet")}async fetchMarkPrice(e,t={}){if(this.has.fetchMarkPrices){await this.loadMarkets();e=this.market(e).symbol;const i=await this.fetchMarkPrices([e],t),s=this.safeDict(i,e);if(void 0===s)throw new o.NullResponse(this.id+" fetchMarkPrices() could not find a ticker for "+e);return s}throw new o.NotSupported(this.id+" fetchMarkPrices() is not supported yet")}async fetchTickerWs(e,t={}){if(this.has.fetchTickersWs){await this.loadMarkets();e=this.market(e).symbol;const i=await this.fetchTickersWs([e],t),s=this.safeDict(i,e);if(void 0===s)throw new o.NullResponse(this.id+" fetchTickerWs() could not find a ticker for "+e);return s}throw new o.NotSupported(this.id+" fetchTickerWs() is not supported yet")}async watchTicker(e,t={}){throw new o.NotSupported(this.id+" watchTicker() is not supported yet")}async fetchTickers(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchTickers() is not supported yet")}async fetchMarkPrices(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchMarkPrices() is not supported yet")}async fetchTickersWs(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchTickers() is not supported yet")}async fetchOrderBooks(e=void 0,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchOrderBooks() is not supported yet")}async watchBidsAsks(e=void 0,t={}){throw new o.NotSupported(this.id+" watchBidsAsks() is not supported yet")}async watchTickers(e=void 0,t={}){throw new o.NotSupported(this.id+" watchTickers() is not supported yet")}async unWatchTickers(e=void 0,t={}){throw new o.NotSupported(this.id+" unWatchTickers() is not supported yet")}async fetchOrder(e,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchOrder() is not supported yet")}async fetchOrderWithClientOrderId(e,t=void 0,i={}){const s=this.extend(i,{clientOrderId:e});return await this.fetchOrder("",t,s)}async fetchOrderWs(e,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchOrderWs() is not supported yet")}async fetchOrderStatus(e,t=void 0,i={}){return(await this.fetchOrder(e,t,i)).status}async fetchUnifiedOrder(e,t={}){return await this.fetchOrder(this.safeString(e,"id"),this.safeString(e,"symbol"),t)}async createOrder(e,t,i,s,r=void 0,a={}){throw new o.NotSupported(this.id+" createOrder() is not supported yet")}async createConvertTrade(e,t,i,s=void 0,r={}){throw new o.NotSupported(this.id+" createConvertTrade() is not supported yet")}async fetchConvertTrade(e,t=void 0,i={}){throw new o.NotSupported(this.id+" fetchConvertTrade() is not supported yet")}async fetchConvertTradeHistory(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchConvertTradeHistory() is not supported yet")}async fetchPositionMode(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchPositionMode() is not supported yet")}async createTrailingAmountOrder(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTrailingAmountOrder() requires a trailingAmount argument");if(d.trailingAmount=a,void 0!==n&&(d.trailingTriggerPrice=n),this.has.createTrailingAmountOrder)return await this.createOrder(e,t,i,s,r,d);throw new o.NotSupported(this.id+" createTrailingAmountOrder() is not supported yet")}async createTrailingAmountOrderWs(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTrailingAmountOrderWs() requires a trailingAmount argument");if(d.trailingAmount=a,void 0!==n&&(d.trailingTriggerPrice=n),this.has.createTrailingAmountOrderWs)return await this.createOrderWs(e,t,i,s,r,d);throw new o.NotSupported(this.id+" createTrailingAmountOrderWs() is not supported yet")}async createTrailingPercentOrder(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingPercent argument");if(d.trailingPercent=a,void 0!==n&&(d.trailingTriggerPrice=n),this.has.createTrailingPercentOrder)return await this.createOrder(e,t,i,s,r,d);throw new o.NotSupported(this.id+" createTrailingPercentOrder() is not supported yet")}async createTrailingPercentOrderWs(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTrailingPercentOrderWs() requires a trailingPercent argument");if(d.trailingPercent=a,void 0!==n&&(d.trailingTriggerPrice=n),this.has.createTrailingPercentOrderWs)return await this.createOrderWs(e,t,i,s,r,d);throw new o.NotSupported(this.id+" createTrailingPercentOrderWs() is not supported yet")}async createMarketOrderWithCost(e,t,i,s={}){if(this.has.createMarketOrderWithCost||this.has.createMarketBuyOrderWithCost&&this.has.createMarketSellOrderWithCost)return await this.createOrder(e,"market",t,i,1,s);throw new o.NotSupported(this.id+" createMarketOrderWithCost() is not supported yet")}async createMarketBuyOrderWithCost(e,t,i={}){if(this.options.createMarketBuyOrderRequiresPrice||this.has.createMarketBuyOrderWithCost)return await this.createOrder(e,"market","buy",t,1,i);throw new o.NotSupported(this.id+" createMarketBuyOrderWithCost() is not supported yet")}async createMarketSellOrderWithCost(e,t,i={}){if(this.options.createMarketSellOrderRequiresPrice||this.has.createMarketSellOrderWithCost)return await this.createOrder(e,"market","sell",t,1,i);throw new o.NotSupported(this.id+" createMarketSellOrderWithCost() is not supported yet")}async createMarketOrderWithCostWs(e,t,i,s={}){if(this.has.createMarketOrderWithCostWs||this.has.createMarketBuyOrderWithCostWs&&this.has.createMarketSellOrderWithCostWs)return await this.createOrderWs(e,"market",t,i,1,s);throw new o.NotSupported(this.id+" createMarketOrderWithCostWs() is not supported yet")}async createTriggerOrder(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTriggerOrder() requires a triggerPrice argument");if(n.triggerPrice=a,this.has.createTriggerOrder)return await this.createOrder(e,t,i,s,r,n);throw new o.NotSupported(this.id+" createTriggerOrder() is not supported yet")}async createTriggerOrderWs(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTriggerOrderWs() requires a triggerPrice argument");if(n.triggerPrice=a,this.has.createTriggerOrderWs)return await this.createOrderWs(e,t,i,s,r,n);throw new o.NotSupported(this.id+" createTriggerOrderWs() is not supported yet")}async createStopLossOrder(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createStopLossOrder() requires a stopLossPrice argument");if(n.stopLossPrice=a,this.has.createStopLossOrder)return await this.createOrder(e,t,i,s,r,n);throw new o.NotSupported(this.id+" createStopLossOrder() is not supported yet")}async createStopLossOrderWs(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createStopLossOrderWs() requires a stopLossPrice argument");if(n.stopLossPrice=a,this.has.createStopLossOrderWs)return await this.createOrderWs(e,t,i,s,r,n);throw new o.NotSupported(this.id+" createStopLossOrderWs() is not supported yet")}async createTakeProfitOrder(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTakeProfitOrder() requires a takeProfitPrice argument");if(n.takeProfitPrice=a,this.has.createTakeProfitOrder)return await this.createOrder(e,t,i,s,r,n);throw new o.NotSupported(this.id+" createTakeProfitOrder() is not supported yet")}async createTakeProfitOrderWs(e,t,i,s,r=void 0,a=void 0,n={}){if(void 0===a)throw new o.ArgumentsRequired(this.id+" createTakeProfitOrderWs() requires a takeProfitPrice argument");if(n.takeProfitPrice=a,this.has.createTakeProfitOrderWs)return await this.createOrderWs(e,t,i,s,r,n);throw new o.NotSupported(this.id+" createTakeProfitOrderWs() is not supported yet")}async createOrderWithTakeProfitAndStopLoss(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(d=this.setTakeProfitAndStopLossParams(e,t,i,s,r,a,n,d),this.has.createOrderWithTakeProfitAndStopLoss)return await this.createOrder(e,t,i,s,r,d);throw new o.NotSupported(this.id+" createOrderWithTakeProfitAndStopLoss() is not supported yet")}setTakeProfitAndStopLossParams(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(void 0===a&&void 0===n)throw new o.ArgumentsRequired(this.id+" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument");void 0!==a&&(d.takeProfit={triggerPrice:a}),void 0!==n&&(d.stopLoss={triggerPrice:n});const c=this.safeString(d,"takeProfitType"),h=this.safeString(d,"takeProfitPriceType"),l=this.safeString(d,"takeProfitLimitPrice"),u=this.safeString(d,"takeProfitAmount"),p=this.safeString(d,"stopLossType"),f=this.safeString(d,"stopLossPriceType"),m=this.safeString(d,"stopLossLimitPrice"),g=this.safeString(d,"stopLossAmount");return void 0!==c&&(d.takeProfit.type=c),void 0!==h&&(d.takeProfit.priceType=h),void 0!==l&&(d.takeProfit.price=this.parseToNumeric(l)),void 0!==u&&(d.takeProfit.amount=this.parseToNumeric(u)),void 0!==p&&(d.stopLoss.type=p),void 0!==f&&(d.stopLoss.priceType=f),void 0!==m&&(d.stopLoss.price=this.parseToNumeric(m)),void 0!==g&&(d.stopLoss.amount=this.parseToNumeric(g)),d=this.omit(d,["takeProfitType","takeProfitPriceType","takeProfitLimitPrice","takeProfitAmount","stopLossType","stopLossPriceType","stopLossLimitPrice","stopLossAmount"])}async createOrderWithTakeProfitAndStopLossWs(e,t,i,s,r=void 0,a=void 0,n=void 0,d={}){if(d=this.setTakeProfitAndStopLossParams(e,t,i,s,r,a,n,d),this.has.createOrderWithTakeProfitAndStopLossWs)return await this.createOrderWs(e,t,i,s,r,d);throw new o.NotSupported(this.id+" createOrderWithTakeProfitAndStopLossWs() is not supported yet")}async createOrders(e,t={}){throw new o.NotSupported(this.id+" createOrders() is not supported yet")}async editOrders(e,t={}){throw new o.NotSupported(this.id+" editOrders() is not supported yet")}async createOrderWs(e,t,i,s,r=void 0,a={}){throw new o.NotSupported(this.id+" createOrderWs() is not supported yet")}async cancelOrder(e,t=void 0,i={}){throw new o.NotSupported(this.id+" cancelOrder() is not supported yet")}async cancelOrderWithClientOrderId(e,t=void 0,i={}){const s=this.extend(i,{clientOrderId:e});return await this.cancelOrder("",t,s)}async cancelOrderWs(e,t=void 0,i={}){throw new o.NotSupported(this.id+" cancelOrderWs() is not supported yet")}async cancelOrders(e,t=void 0,i={}){throw new o.NotSupported(this.id+" cancelOrders() is not supported yet")}async cancelOrdersWithClientOrderIds(e,t=void 0,i={}){const s=this.extend(i,{clientOrderIds:e});return await this.cancelOrders([],t,s)}async cancelOrdersWs(e,t=void 0,i={}){throw new o.NotSupported(this.id+" cancelOrdersWs() is not supported yet")}async cancelAllOrders(e=void 0,t={}){throw new o.NotSupported(this.id+" cancelAllOrders() is not supported yet")}async cancelAllOrdersAfter(e,t={}){throw new o.NotSupported(this.id+" cancelAllOrdersAfter() is not supported yet")}async cancelOrdersForSymbols(e,t={}){throw new o.NotSupported(this.id+" cancelOrdersForSymbols() is not supported yet")}async cancelAllOrdersWs(e=void 0,t={}){throw new o.NotSupported(this.id+" cancelAllOrdersWs() is not supported yet")}async cancelUnifiedOrder(e,t={}){return this.cancelOrder(this.safeString(e,"id"),this.safeString(e,"symbol"),t)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){if(this.has.fetchOpenOrders&&this.has.fetchClosedOrders)throw new o.NotSupported(this.id+" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead");throw new o.NotSupported(this.id+" fetchOrders() is not supported yet")}async fetchOrdersWs(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchOrdersWs() is not supported yet")}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){throw new o.NotSupported(this.id+" fetchOrderTrades() is not supported yet")}async watchOrders(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchOrders() is not supported yet")}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){if(this.has.fetchOrders){const r=await this.fetchOrders(e,t,i,s);return this.filterBy(r,"status","open")}throw new o.NotSupported(this.id+" fetchOpenOrders() is not supported yet")}async fetchOpenOrdersWs(e=void 0,t=void 0,i=void 0,s={}){if(this.has.fetchOrdersWs){const r=await this.fetchOrdersWs(e,t,i,s);return this.filterBy(r,"status","open")}throw new o.NotSupported(this.id+" fetchOpenOrdersWs() is not supported yet")}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){if(this.has.fetchOrders){const r=await this.fetchOrders(e,t,i,s);return this.filterBy(r,"status","closed")}throw new o.NotSupported(this.id+" fetchClosedOrders() is not supported yet")}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchCanceledOrders() is not supported yet")}async fetchCanceledAndClosedOrders(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchCanceledAndClosedOrders() is not supported yet")}async fetchClosedOrdersWs(e=void 0,t=void 0,i=void 0,s={}){if(this.has.fetchOrdersWs){const r=await this.fetchOrdersWs(e,t,i,s);return this.filterBy(r,"status","closed")}throw new o.NotSupported(this.id+" fetchClosedOrdersWs() is not supported yet")}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchMyTrades() is not supported yet")}async fetchMyLiquidations(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchMyLiquidations() is not supported yet")}async fetchLiquidations(e,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchLiquidations() is not supported yet")}async fetchMyTradesWs(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchMyTradesWs() is not supported yet")}async watchMyTrades(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" watchMyTrades() is not supported yet")}async fetchGreeks(e,t={}){throw new o.NotSupported(this.id+" fetchGreeks() is not supported yet")}async fetchAllGreeks(e=void 0,t={}){throw new o.NotSupported(this.id+" fetchAllGreeks() is not supported yet")}async fetchOptionChain(e,t={}){throw new o.NotSupported(this.id+" fetchOptionChain() is not supported yet")}async fetchOption(e,t={}){throw new o.NotSupported(this.id+" fetchOption() is not supported yet")}async fetchConvertQuote(e,t,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchConvertQuote() is not supported yet")}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchDepositsWithdrawals() is not supported yet")}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchDeposits() is not supported yet")}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchWithdrawals() is not supported yet")}async fetchDepositsWs(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchDepositsWs() is not supported yet")}async fetchWithdrawalsWs(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchWithdrawalsWs() is not supported yet")}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchFundingRateHistory() is not supported yet")}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){throw new o.NotSupported(this.id+" fetchFundingHistory() is not supported yet")}async closePosition(e,t=void 0,i={}){throw new o.NotSupported(this.id+" closePosition() is not supported yet")}async closeAllPositions(e={}){throw new o.NotSupported(this.id+" closeAllPositions() is not supported yet")}async fetchL3OrderBook(e,t=void 0,i={}){throw new o.BadRequest(this.id+" fetchL3OrderBook() is not supported yet")}parseLastPrice(e,t=void 0){throw new o.NotSupported(this.id+" parseLastPrice() is not supported yet")}async fetchDepositAddress(e,t={}){if(this.has.fetchDepositAddresses){const i=await this.fetchDepositAddresses([e],t),s=this.safeValue(i,e);if(void 0===s)throw new o.InvalidAddress(this.id+" fetchDepositAddress() could not find a deposit address for "+e+", make sure you have created a corresponding deposit address in your wallet on the exchange website");return s}if(this.has.fetchDepositAddressesByNetwork){const i=this.safeString(t,"network");t=this.omit(t,"network");const s=await this.fetchDepositAddressesByNetwork(e,t);if(void 0!==i)return this.safeDict(s,i);{const e=Object.keys(s),t=this.safeString(e,0);return this.safeDict(s,t)}}throw new o.NotSupported(this.id+" fetchDepositAddress() is not supported yet")}account(){return{free:void 0,used:void 0,total:void 0}}commonCurrencyCode(e){return this.substituteCommonCurrencyCodes?this.safeString(this.commonCurrencies,e,e):e}currency(e){if(0===Object.keys(this.currencies).length)throw new o.ExchangeError(this.id+" currencies not loaded");if("string"==typeof e){if(e in this.currencies)return this.currencies[e];if(e in this.currencies_by_id)return this.currencies_by_id[e]}throw new o.ExchangeError(this.id+" does not have currency code "+e)}market(e){if(void 0===this.markets)throw new o.ExchangeError(this.id+" markets not loaded");if(e in this.markets)return this.markets[e];if(e in this.markets_by_id){const t=this.markets_by_id[e],i=this.safeString2(this.options,"defaultType","defaultSubType","spot");for(let e=0;e0){let e="0.";for(let i=0;i0&&!this.inArray(t,s)){const t=s.join(", ");let r=this.id+" "+e+"() requires a "+i+" argument";throw""!==t&&(r+=", one of ("+t+")"),new o.ArgumentsRequired(r)}}checkRequiredMarginArgument(e,t,i){if("isolated"===i&&void 0===t)throw new o.ArgumentsRequired(this.id+" "+e+"() requires a symbol argument for isolated margin");if("cross"===i&&void 0!==t)throw new o.ArgumentsRequired(this.id+" "+e+"() cannot have a symbol argument for cross margin")}parseDepositWithdrawFees(e,t=void 0,i=void 0){const s={},r=Array.isArray(e);let a=e;r||(a=Object.keys(e));for(let o=0;o=g)break}}catch(e){if(m+=1,m>c)throw e}}let v=f;u&&(v=this.removeRepeatedElementsFromArray(f));const y="fetchOHLCV"===e?0:"timestamp";return this.filterBySinceLimit(v,i,s,y)}async safeDeterministicCall(e,t=void 0,i=void 0,s=void 0,r=void 0,a={}){let n;[n,a]=this.handleOptionAndParams(a,e,"maxRetries",3);let d=0;for(;d<=n;)try{return r&&"fetchFundingRateHistory"!==e?await this[e](t,r,i,s,a):await this[e](t,i,s,a)}catch(e){if(e instanceof o.RateLimitExceeded)throw e;if(d+=1,d>n)throw e}return[]}async fetchPaginatedCallDeterministic(e,t=void 0,i=void 0,s=void 0,r=void 0,a={},n=void 0){let d;[d,a]=this.handleOptionAndParams(a,e,"paginationCalls",10),[n,a]=this.handleMaxEntriesPerRequestAndParams(e,n,a);const c=this.milliseconds(),h=[],l=1e3*this.parseTimeframe(r)*n;let u=c-d*l-1;u=void 0!==i?Math.max(u,i):Math.max(u,1241440531e3);const p=this.safeInteger2(a,"until","till");if(void 0!==p){const e=Math.ceil((p-i)/l);if(e>d)throw new o.BadRequest(this.id+" the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is "+d.toString()+" required calls is "+e.toString())}for(let i=0;i=p)&&!(u>=c);i++)h.push(this.safeDeterministicCall(e,t,u,n,r,a)),u=this.sum(u,l)-1;const f=await Promise.all(h);let m=[];for(let e=0;eh)throw e}u+=1}const g=this.sortCursorPaginatedResult(f),v="fetchOHLCV"===e?0:"timestamp";return this.filterBySinceLimit(g,i,s,v)}async fetchPaginatedCallIncremental(e,t=void 0,i=void 0,s=void 0,r={},a=void 0,o=void 0){let n,d;[n,r]=this.handleOptionAndParams(r,e,"paginationCalls",10),[d,r]=this.handleOptionAndParams(r,e,"maxRetries",3),[o,r]=this.handleMaxEntriesPerRequestAndParams(e,o,r);let c=0,h=0,l=[];for(;cd)throw e}c+=1}const u=this.sortCursorPaginatedResult(l),p="fetchOHLCV"===e?0:"timestamp";return this.filterBySinceLimit(u,i,s,p)}sortCursorPaginatedResult(e){const t=this.safeValue(e,0);if(void 0!==t){if("timestamp"in t)return this.sortBy(e,"timestamp",!0);if("id"in t)return this.sortBy(e,"id",!0)}return e}removeRepeatedElementsFromArray(e,t=!0){const i={},s=[];for(let r=0;r0?s:e}removeRepeatedTradesFromArray(e){const t={};for(let i=0;i0)for(let e=0;e{"use strict";i.d(t,{A:()=>n,Y:()=>o});const s=BigInt(0),r=BigInt(-1),a=BigInt(10);class o{constructor(e,t=void 0){if(this.base=void 0,void 0===t){let t=0;if((e=e.toLowerCase()).indexOf("e")>-1){let i="0";[e,i]=e.split("e"),t=parseInt(i)}const i=e.indexOf(".");this.decimals=i>-1?e.length-i-1:0;const s=e.replace(".","");this.integer=BigInt(s),this.decimals=this.decimals-t}else this.integer=e,this.decimals=t}mul(e){const t=this.integer*e.integer;return new o(t,this.decimals+e.decimals)}div(e,t=18){const i=t-this.decimals+e.decimals;let s;if(0===i)s=this.integer;else if(i<0){const e=a**BigInt(-i);s=this.integer/e}else{const e=a**BigInt(i);s=this.integer*e}const r=s/e.integer;return new o(r,t)}add(e){if(this.decimals===e.decimals){const t=this.integer+e.integer;return new o(t,this.decimals)}{const[t,i]=this.decimals>e.decimals?[e,this]:[this,e],s=i.decimals-t.decimals,r=t.integer*a**BigInt(s)+i.integer;return new o(r,i.decimals)}}mod(e){const t=Math.max(-this.decimals+e.decimals,0),i=this.integer*a**BigInt(t),s=Math.max(-e.decimals+this.decimals,0),r=e.integer*a**BigInt(s);return new o(i%r,s+e.decimals)}sub(e){const t=new o(-e.integer,e.decimals);return this.add(t)}abs(){return new o(this.integer<0?this.integer*r:this.integer,this.decimals)}neg(){return new o(-this.integer,this.decimals)}or(e){const t=this.integer|e.integer;return new o(t,this.decimals)}min(e){return this.lt(e)?this:e}max(e){return this.gt(e)?this:e}gt(e){return this.sub(e).integer>0}ge(e){return this.sub(e).integer>=0}lt(e){return e.gt(this)}le(e){return e.ge(this)}reduce(){const e=this.integer.toString(),t=e.length-1;if(0===t)return"0"===e&&(this.decimals=0),this;let i;for(i=t;i>=0&&"0"===e.charAt(i);i--);const s=t-i;if(0===s)return this;this.decimals-=s,this.integer=BigInt(e.slice(0,i+1))}equals(e){return this.reduce(),e.reduce(),this.decimals===e.decimals&&this.integer===e.integer}toString(){let e,t;this.reduce(),this.integer<0?(e="-",t=-this.integer):(e="",t=this.integer);const i=Array.from(t.toString(Number(a)).padStart(this.decimals,"0")),s=i.length-this.decimals;let r;return r=0===s?"0.":this.decimals<0?"0".repeat(-this.decimals):0===this.decimals?"":".",i.splice(s,0,r),e+i.join("")}static stringMul(e,t){if(void 0!==e&&void 0!==t)return new o(e).mul(new o(t)).toString()}static stringDiv(e,t,i=18){if(void 0===e||void 0===t)return;const r=new o(t);return r.integer!==s?new o(e).div(r,i).toString():void 0}static stringAdd(e,t){if(void 0!==e||void 0!==t)return void 0===e?t:void 0===t?e:new o(e).add(new o(t)).toString()}static stringSub(e,t){if(void 0!==e&&void 0!==t)return new o(e).sub(new o(t)).toString()}static stringAbs(e){if(void 0!==e)return new o(e).abs().toString()}static stringNeg(e){if(void 0!==e)return new o(e).neg().toString()}static stringMod(e,t){if(void 0!==e&&void 0!==t)return new o(e).mod(new o(t)).toString()}static stringOr(e,t){if(void 0!==e&&void 0!==t)return new o(e).or(new o(t)).toString()}static stringEquals(e,t){if(void 0!==e&&void 0!==t)return new o(e).equals(new o(t))}static stringEq(e,t){if(void 0!==e&&void 0!==t)return new o(e).equals(new o(t))}static stringMin(e,t){if(void 0!==e&&void 0!==t)return new o(e).min(new o(t)).toString()}static stringMax(e,t){if(void 0!==e&&void 0!==t)return new o(e).max(new o(t)).toString()}static stringGt(e,t){if(void 0!==e&&void 0!==t)return new o(e).gt(new o(t))}static stringGe(e,t){if(void 0!==e&&void 0!==t)return new o(e).ge(new o(t))}static stringLt(e,t){if(void 0!==e&&void 0!==t)return new o(e).lt(new o(t))}static stringLe(e,t){if(void 0!==e&&void 0!==t)return new o(e).le(new o(t))}}const n=o},2079:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AccountNotEnabled:()=>n,AccountSuspended:()=>d,AddressPending:()=>w,ArgumentsRequired:()=>c,AuthenticationError:()=>a,BadRequest:()=>h,BadResponse:()=>F,BadSymbol:()=>l,BaseError:()=>s,CancelPending:()=>G,ChecksumError:()=>q,ContractUnavailable:()=>M,DDoSProtection:()=>E,DuplicateOrderId:()=>I,ExchangeClosedByUser:()=>_,ExchangeError:()=>r,ExchangeNotAvailable:()=>L,InsufficientFunds:()=>y,InvalidAddress:()=>b,InvalidNonce:()=>D,InvalidOrder:()=>k,InvalidProxySettings:()=>x,ManualInteractionNeeded:()=>g,MarginModeAlreadySet:()=>f,MarketClosed:()=>m,NetworkError:()=>B,NoChange:()=>p,NotSupported:()=>A,NullResponse:()=>H,OnMaintenance:()=>N,OperationFailed:()=>C,OperationRejected:()=>u,OrderImmediatelyFillable:()=>T,OrderNotCached:()=>O,OrderNotFillable:()=>P,OrderNotFound:()=>S,PermissionDenied:()=>o,RateLimitExceeded:()=>R,RequestTimeout:()=>V,RestrictedLocation:()=>v,UnsubscribeError:()=>U,default:()=>W});class s extends Error{constructor(e){super(e),this.name="BaseError"}}class r extends s{constructor(e){super(e),this.name="ExchangeError"}}class a extends r{constructor(e){super(e),this.name="AuthenticationError"}}class o extends a{constructor(e){super(e),this.name="PermissionDenied"}}class n extends o{constructor(e){super(e),this.name="AccountNotEnabled"}}class d extends a{constructor(e){super(e),this.name="AccountSuspended"}}class c extends r{constructor(e){super(e),this.name="ArgumentsRequired"}}class h extends r{constructor(e){super(e),this.name="BadRequest"}}class l extends h{constructor(e){super(e),this.name="BadSymbol"}}class u extends r{constructor(e){super(e),this.name="OperationRejected"}}class p extends u{constructor(e){super(e),this.name="NoChange"}}class f extends p{constructor(e){super(e),this.name="MarginModeAlreadySet"}}class m extends u{constructor(e){super(e),this.name="MarketClosed"}}class g extends u{constructor(e){super(e),this.name="ManualInteractionNeeded"}}class v extends u{constructor(e){super(e),this.name="RestrictedLocation"}}class y extends r{constructor(e){super(e),this.name="InsufficientFunds"}}class b extends r{constructor(e){super(e),this.name="InvalidAddress"}}class w extends b{constructor(e){super(e),this.name="AddressPending"}}class k extends r{constructor(e){super(e),this.name="InvalidOrder"}}class S extends k{constructor(e){super(e),this.name="OrderNotFound"}}class O extends k{constructor(e){super(e),this.name="OrderNotCached"}}class T extends k{constructor(e){super(e),this.name="OrderImmediatelyFillable"}}class P extends k{constructor(e){super(e),this.name="OrderNotFillable"}}class I extends k{constructor(e){super(e),this.name="DuplicateOrderId"}}class M extends k{constructor(e){super(e),this.name="ContractUnavailable"}}class A extends r{constructor(e){super(e),this.name="NotSupported"}}class x extends r{constructor(e){super(e),this.name="InvalidProxySettings"}}class _ extends r{constructor(e){super(e),this.name="ExchangeClosedByUser"}}class C extends s{constructor(e){super(e),this.name="OperationFailed"}}class B extends C{constructor(e){super(e),this.name="NetworkError"}}class E extends B{constructor(e){super(e),this.name="DDoSProtection"}}class R extends B{constructor(e){super(e),this.name="RateLimitExceeded"}}class L extends B{constructor(e){super(e),this.name="ExchangeNotAvailable"}}class N extends L{constructor(e){super(e),this.name="OnMaintenance"}}class D extends B{constructor(e){super(e),this.name="InvalidNonce"}}class q extends D{constructor(e){super(e),this.name="ChecksumError"}}class V extends B{constructor(e){super(e),this.name="RequestTimeout"}}class F extends C{constructor(e){super(e),this.name="BadResponse"}}class H extends F{constructor(e){super(e),this.name="NullResponse"}}class G extends C{constructor(e){super(e),this.name="CancelPending"}}class U extends s{constructor(e){super(e),this.name="UnsubscribeError"}}const W={BaseError:s,ExchangeError:r,AuthenticationError:a,PermissionDenied:o,AccountNotEnabled:n,AccountSuspended:d,ArgumentsRequired:c,BadRequest:h,BadSymbol:l,OperationRejected:u,NoChange:p,MarginModeAlreadySet:f,MarketClosed:m,ManualInteractionNeeded:g,RestrictedLocation:v,InsufficientFunds:y,InvalidAddress:b,AddressPending:w,InvalidOrder:k,OrderNotFound:S,OrderNotCached:O,OrderImmediatelyFillable:T,OrderNotFillable:P,DuplicateOrderId:I,ContractUnavailable:M,NotSupported:A,InvalidProxySettings:x,ExchangeClosedByUser:_,OperationFailed:C,NetworkError:B,DDoSProtection:E,RateLimitExceeded:R,ExchangeNotAvailable:L,OnMaintenance:N,InvalidNonce:D,ChecksumError:q,RequestTimeout:V,BadResponse:F,NullResponse:H,CancelPending:G,UnsubscribeError:U}},5095:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DECIMAL_PLACES:()=>n.fv,NO_PADDING:()=>n.w1,PAD_WITH_ZERO:()=>n.ex,ROUND:()=>n.D_,ROUND_DOWN:()=>n._g,ROUND_UP:()=>n.Tz,SIGNIFICANT_DIGITS:()=>n.v,TICK_SIZE:()=>n.kb,TRUNCATE:()=>n.R3,Throttler:()=>l.x,TimedOut:()=>h.GA,aggregate:()=>u.QD,arrayConcat:()=>r.ax,asFloat:()=>o.Pf,asInteger:()=>o.JU,axolotl:()=>c.Sw,base16ToBinary:()=>d.FF,base58ToBinary:()=>d.Ry,base64ToBase64Url:()=>d.xg,base64ToBinary:()=>d.cg,base64ToString:()=>d.QM,binaryConcat:()=>d.qo,binaryConcatArray:()=>d.Vw,binaryToBase16:()=>d.t7,binaryToBase58:()=>d.bj,binaryToBase64:()=>d.sQ,binaryToString:()=>d.kn,capitalize:()=>a.ZH,clone:()=>r.o8,crc32:()=>c.QR,decimalToPrecision:()=>n.fq,decode:()=>d.D4,deepExtend:()=>r.zw,ecdsa:()=>c.h1,eddsa:()=>c.q4,encode:()=>d.lF,extend:()=>r.X$,extractParams:()=>u.um,filterBy:()=>r.WP,flatten:()=>r.Bq,groupBy:()=>r.$z,hasProps:()=>o.dl,hash:()=>c.tW,hmac:()=>c.w8,implodeParams:()=>u.Hp,inArray:()=>r.RV,index:()=>r.Pe,indexBy:()=>r.wQ,isArray:()=>o.cy,isBrowser:()=>s.Bd,isDeno:()=>s.N6,isDictionary:()=>o.Hf,isElectron:()=>s.b8,isEmpty:()=>r.Im,isInteger:()=>o.Fq,isJsonEncodedObject:()=>d.mC,isNode:()=>s.Ll,isNumber:()=>o.Et,isObject:()=>o.Gv,isString:()=>o.Kg,isStringCoercible:()=>o.KL,isWebWorker:()=>s.p7,isWindows:()=>s.uF,iso8601:()=>h.LC,json:()=>d.Pq,keys:()=>r.HP,keysort:()=>r.CA,mdy:()=>h.rE,merge:()=>r.h1,microseconds:()=>h.EZ,milliseconds:()=>h.Rz,now:()=>h.tB,numberToBE:()=>d.qE,numberToLE:()=>d.aN,numberToString:()=>n.um,omit:()=>r.cJ,omitZero:()=>n.Ye,ordered:()=>r.Sj,packb:()=>d.Am,parse8601:()=>h.Dj,parseDate:()=>h._U,parseTimeframe:()=>u.ce,pluck:()=>r.Ey,precisionConstants:()=>n.S2,precisionFromString:()=>n.Iu,prop:()=>o._w,rawencode:()=>d.rO,rfc2616:()=>h.D9,roundTimeframe:()=>u.jG,safeFloat:()=>o.w,safeFloat2:()=>o.Cw,safeFloatN:()=>o.Q7,safeInteger:()=>o.Y2,safeInteger2:()=>o.mU,safeIntegerN:()=>o.At,safeIntegerProduct:()=>o.lu,safeIntegerProduct2:()=>o.J0,safeIntegerProductN:()=>o.hO,safeString:()=>o.nr,safeString2:()=>o.d0,safeStringLower:()=>o.gw,safeStringLower2:()=>o.uS,safeStringLowerN:()=>o.I9,safeStringN:()=>o.Rc,safeStringUpper:()=>o.RH,safeStringUpper2:()=>o.F7,safeStringUpperN:()=>o.fu,safeTimestamp:()=>o.q0,safeTimestamp2:()=>o.ww,safeTimestampN:()=>o.Y_,safeValue:()=>o.pI,safeValue2:()=>o.Dj,safeValueN:()=>o.DR,seconds:()=>h.YA,selfIsDefined:()=>u.Se,setTimeout_safe:()=>h.k4,sleep:()=>h.yy,sort:()=>r.di,sortBy:()=>r.Ul,sortBy2:()=>r.sy,stringToBase64:()=>d.q3,stringToBinary:()=>d.wN,strip:()=>a.bB,sum:()=>r.cz,timeout:()=>h.wR,toArray:()=>r.$r,truncate:()=>n.xv,truncate_to_string:()=>n.NZ,unCamelCase:()=>a.Qd,unique:()=>r.Am,urlencode:()=>d.mu,urlencodeBase64:()=>d.LI,urlencodeNested:()=>d.Dy,urlencodeWithArrayRepeat:()=>d.ev,uuid:()=>a.uR,uuid16:()=>a.tg,uuid22:()=>a._n,uuidv1:()=>h.nm,values:()=>r.zu,vwap:()=>u.ru,ymd:()=>h.Th,ymdhms:()=>h.RR,yymmdd:()=>h.x_,yyyymmdd:()=>h.Rn});var s=i(7597),r=i(7437),a=i(3503),o=i(6834),n=i(1579),d=i(9560),c=i(8283),h=i(8403),l=i(7618),u=i(6238)},8283:(e,t,i)=>{"use strict";i.d(t,{QR:()=>v,Sw:()=>m,h1:()=>f,q4:()=>g,tW:()=>u,w8:()=>p});var s=i(712),r=i(4710),a=i(5268),o=i(890),n=i(987),d=i(8342),c=i(191);const h={binary:e=>e,hex:r.xn.encode,base64:r.K3.encode},l={"1.3.132.0.10":n.bI,"1.2.840.10045.3.1.7":d.Qj},u=(e,t,i="hex")=>{const s=t(e);return h[i](s)},p=(e,t,i,r="hex")=>{const a=(0,s.w)(i,t,e);return h[r](a)};function f(e,t,i,s=null,r=!1){if(s&&(e=u(e,s,"hex")),"string"==typeof t&&t.length>64){if(!t.startsWith("-----BEGIN EC PRIVATE KEY-----"))throw new Error("Unsupported key format");{const e=a.o.unarmor(t);let s=o.Ge.decode(e);if(4!==s.sub.length)throw new Error("Unsupported key format");if(null!==typeof s.sub[2].sub&&s.sub[2].sub.length>0){const e=s.sub[2].sub[0].content(void 0);if(void 0===l[e])throw new Error("Unsupported curve");i=l[e]}t=s.sub[1].getHexStringValue()}}let n=i.sign(e,t,{lowS:!0});const d=(BigInt(1)<h||n.r<=d||n.s<=d);)n=i.sign(e,t,{lowS:!0,extraEntropy:(0,c.z)(BigInt(p),32)}),p+=1;return{r:n.r.toString(16),s:n.s.toString(16),v:n.recovery}}function m(e,t,i){const s=i.signModified(e,t);return r.tw.encode(s)}function g(e,t,i){let s;32===t.length?s=t:"string"==typeof t&&(s=new Uint8Array(a.o.unarmor(t).slice(16)));const o=i.sign(e,s);return r.K3.encode(o)}function v(e,t=!1){void 0===v.table&&(v.table="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D".split(" ").map((e=>parseInt(e,16))));let i=-1;for(let t=0;t>>8^v.table[255&(i^e.charCodeAt(t))];const s=~i>>>0;return t&&s>=2147483648?s-4294967296:s}},9560:(e,t,i)=>{"use strict";i.d(t,{Am:()=>_,D4:()=>I,Dy:()=>S,FF:()=>m,LI:()=>M,Pq:()=>n,QM:()=>u,Ry:()=>v,Vw:()=>w,aN:()=>A,bj:()=>y,cg:()=>p,ev:()=>O,kn:()=>c,lF:()=>P,mC:()=>d,mu:()=>k,q3:()=>l,qE:()=>x,qo:()=>b,rO:()=>T,sQ:()=>f,t7:()=>g,wN:()=>h,xg:()=>C});var s=i(4710),r=i(191),a=i(917),o=i(3649);const n=(e,t=void 0)=>JSON.stringify(e),d=e=>"string"==typeof e&&e.length>=2&&("{"===e[0]||"["===e[0]),c=s.As.encode,h=s.As.decode,l=e=>s.K3.encode(s.As.decode(e)),u=e=>s.As.encode(s.K3.decode(e)),p=s.K3.decode,f=s.K3.encode,m=s.xn.decode,g=s.xn.encode,v=s.tw.decode,y=s.tw.encode,b=r.Id,w=e=>(0,r.Id)(...e),k=(e,t=!1)=>o.Ay.stringify(e),S=e=>o.Ay.stringify(e),O=e=>o.Ay.stringify(e,{arrayFormat:"repeat"}),T=(e,t=!1)=>o.Ay.stringify(e,{encode:!1}),P=s.As.decode,I=s.As.encode,M=e=>("string"==typeof e?l(e):f(e)).replace(/[=]+$/,"").replace(/\+/g,"-").replace(/\//g,"_"),A=(e,t)=>(0,r.z)(BigInt(e),t),x=(e,t)=>(0,r.lq)(BigInt(e),t);function _(e){return(0,a.l)(e)}function C(e,t=!0){let i=e.replace(/\+/g,"-").replace(/\//g,"_");return t&&(i=i.replace(/=+$/,"")),i}},7437:(e,t,i)=>{"use strict";i.d(t,{$r:()=>p,$z:()=>v,Am:()=>h,Bq:()=>S,CA:()=>m,Ey:()=>O,HP:()=>r,Im:()=>f,Pe:()=>o,RV:()=>u,Sj:()=>c,Ul:()=>w,WP:()=>b,X$:()=>n,ax:()=>l,cJ:()=>T,cz:()=>P,di:()=>g,h1:()=>M,o8:()=>d,sy:()=>k,wQ:()=>y,zu:()=>a,zw:()=>I});var s=i(6834);const r=Object.keys,a=e=>(0,s.cy)(e)?e:Object.values(e),o=e=>new Set(a(e)),n=(...e)=>Object.assign({},...e),d=e=>(0,s.cy)(e)?Array.from(e):n(e),c=e=>e,h=e=>Array.from(o(e)),l=(e,t)=>e.concat(t),u=(e,t)=>t.includes(e),p=e=>Object.values(e),f=e=>!e||(Array.isArray(e)?e:Object.keys(e)).length<1,m=(e,t={})=>{for(const i of r(e).sort())t[i]=e[i];return t},g=e=>{const t=e.slice();return t.sort(),t},v=(e,t,i={})=>{for(const s of a(e))if(t in s){const e=s[t];i[e]=i[e]||[],i[e].push(s)}return i},y=(e,t,i={})=>{for(const s of a(e))t in s&&(i[s[t]]=s);return i},b=(e,t,i=void 0,s=[])=>{for(const r of a(e))r[t]===i&&s.push(r);return s},w=(e,t,i=!1,s=0,r=(i?-1:1))=>e.sort(((e,i)=>{const a=t in e?e[t]:s,o=t in i?i[t]:s;return ao?r:0})),k=(e,t,i,s=!1,r=(s?-1:1))=>e.sort(((e,s)=>e[t]s[t]?r:e[i]s[i]?r:0)),S=function e(t,i=[]){for(const r of t)(0,s.cy)(r)?e(r,i):i.push(r);return i},O=(e,t)=>a(e).filter((e=>t in e)).map((e=>e[t])),T=(e,...t)=>{if(!Array.isArray(e)){const i=d(e);for(const e of t)if((0,s.cy)(e))for(const t of e)delete i[t];else delete i[e];return i}return e},P=(...e)=>{const t=e.filter(s.Et);return t.length>0?t.reduce(((e,t)=>e+t),0):void 0},I=function e(...t){let i;for(const r of t)if((0,s.Hf)(r)){(0,s.Hf)(i)||(i={});for(const t in r)i[t]=e(i[t],r[t])}else i=r;return i},M=(e,...t)=>{const i={},s=Object.assign({},...t),r=Object.keys(s);for(let t=0;t{"use strict";i.d(t,{Hp:()=>c,QD:()=>l,Se:()=>u,ce:()=>o,jG:()=>n,ru:()=>h,um:()=>d});var s=i(1579),r=i(6834),a=i(2079);const o=e=>{const t=(0,r.Pf)(e.slice(0,-1)),i=e.slice(-1);let s;if("y"===i)s=31536e3;else if("M"===i)s=2592e3;else if("w"===i)s=604800;else if("d"===i)s=86400;else if("h"===i)s=3600;else if("m"===i)s=60;else{if("s"!==i)throw new a.NotSupported("timeframe unit "+i+" is not supported");s=1}return t*s},n=(e,t,i=s._g)=>{const r=1e3*o(e);return t-t%r+(i===s.Tz?r:0)},d=e=>{const t=/{([\w-]+)}/g,i=[];let s=t.exec(e);for(;s;)i.push(s[1]),s=t.exec(e);return i},c=(e,t)=>{if(!Array.isArray(t)){const i=Object.keys(t);for(let s=0;s0?t/e:void 0}function l(e){const t={};for(let i=0;i0&&(t[s]=(t[s]||0)+r)}return Object.keys(t).map((e=>[parseFloat(e),parseFloat(t[e])]))}function u(){let e=!1;try{e=void 0!==self}catch(t){e=!1}return e}},1579:(e,t,i)=>{"use strict";i.d(t,{D_:()=>r,Iu:()=>y,NZ:()=>g,R3:()=>s,S2:()=>u,Tz:()=>a,Ye:()=>k,_g:()=>o,ex:()=>l,fq:()=>b,fv:()=>n,kb:()=>c,um:()=>f,v:()=>d,w1:()=>h,xv:()=>v});const s=0,r=1,a=2,o=3,n=2,d=3,c=4,h=5,l=6,u={ROUND:r,TRUNCATE:s,ROUND_UP:a,ROUND_DOWN:o,DECIMAL_PLACES:n,SIGNIFICANT_DIGITS:d,TICK_SIZE:c,NO_PADDING:h,PAD_WITH_ZERO:l},p=(e,t)=>{if(!e)throw new Error(t||"assertion failed")};function f(e){if(void 0===e)return;if("number"!=typeof e)return e.toString();const t=e.toString();if(Math.abs(e)<1){const i=t.split("e-"),s=i[0].replace(".",""),r=parseInt(i[1]),a="-"===t[0];if(r)return e=(a?"-":"")+"0."+new Array(r).join("0")+s.substring(a)}else{const e=t.split("e");if(e[1]){let t=parseInt(e[1]);const i=e[0].split(".");let s="";return i[1]&&(t-=i[1].length,s=i[1]),i[0]+s+new Array(t+1).join("0")}}return t}const m=[],g=(e,t=0)=>{if(e=f(e),t>0){const i=m[t]||(m[t]=new RegExp("([-]*\\d+\\.\\d{"+t+"})(\\d)")),[,s]=e.toString().match(i)||[null,e];return s.toString()}return parseInt(e).toString()},v=(e,t=0)=>parseFloat(g(e,t));function y(e){if(e.indexOf("e")>-1||e.indexOf("E")>-1){const t=e.replace(/\d\.?\d*[eE]/,"");return-1*parseInt(t)}const t=e.replace(/0+$/g,"").split(".");return t.length>1?t[1].length:0}const b=(e,t,i,s=n,r=h)=>w(e,t,i,s,r),w=(e,t,i,a=n,o=h)=>{if(p(void 0!==i,"numPrecisionDigits should not be undefined"),"string"==typeof i&&(i=parseFloat(i)),p(Number.isFinite(i),"numPrecisionDigits has an invalid number"),a===c?p(i>0,"negative or zero numPrecisionDigits can not be used with TICK_SIZE precisionMode"):p(Number.isInteger(i),"numPrecisionDigits must be an integer with DECIMAL_PLACES or SIGNIFICANT_DIGITS precisionMode"),p(t===r||t===s,"invalid roundingMode provided"),p(a===n||a===d||a===c,"invalid countingMode provided"),p(o===h||o===l,"invalid paddingMode provided"),i<0){const n=Math.pow(10,-i);if(t===r)return(n*w(e/n,t,0,a,o)).toString();if(t===s)return(e-e%n).toString()}if(a===c){const a=y(w(i,r,22,n,h));if(t===s){const t=f(e),s=g(t,Math.max(0,a)),d=Number(s),c=Math.pow(10,a),l=Math.round(d*c),u=Math.round(i*c);return e=Math.trunc(l/u)*u/c,o===h?String(Number(e.toFixed(a))):w(e,r,a,n,o)}let d=e%i;d=Number(w(d,r,8,n,h));return 0!==y(w(d/i,r,Math.max(a,8),n,h))&&t===r&&(e>0?d>=i/2?e=e-d+i:e-=d:e=d>=i/2?Number(e)-d:Number(e)-d-i),w(e,r,a,n,o)}const u=f(e),m="-"===u[0],v=m?1:0,b=u.length;for(var k=0;k57)throw new Error(`${u}: invalid number (contains an illegal character '${u[A-1]}')`);T[A]=e,e!==O&&I<0&&(I=A)}}I<0&&(I=1);let _=a===n?P:I,C=_+i;M=-1;let B=!0,E=m;for(let e=T.length-1,s=0;e>=0;e--){let a=T[e];if(0!==e){if(a+=s,e>=_+i){a=t===r&&a>=53&&!(53===a&&s)?58:O}a>57?(a=O,s=1):s=0}else s&&(a=49);T[e]=a,a!==O&&(B=!1,I=e,M=M<0?e+1:M)}a===d&&(_=I,C=_+i),B&&(E=!1);const R=I>=P||B?P-1:I,L=M{"use strict";i.d(t,{Bd:()=>s,Ll:()=>d,N6:()=>n,b8:()=>r,p7:()=>a,uF:()=>o});const s="undefined"!=typeof window,r="undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.electron,a="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,o="undefined"!=typeof process&&"win32"===process.platform,n="undefined"!=typeof Deno,d=!(s||a||n)},5354:(e,t,i)=>{"use strict";i.d(t,{a:()=>h,n:()=>c});var s=i(5944),r=i(4710),a=i(9560),o=i(8283),n=i(8342),d=i(6414);function c(e,t,i){const a=new s.v;a.setPrivateKey(t);const o=i.create().constructor.name.toLowerCase();return a.sign(e,(e=>r.xn.encode(i(e))),o)}function h(e,t,i,s=!1,h={}){let l=(s?"RS":"HS")+8*i.outputLen;h.alg&&(l=h.alg.toUpperCase());const u=Object.assign({alg:l,typ:"JWT"},h);void 0!==u.iat&&(e.iat=u.iat,delete u.iat);let p=[(0,a.LI)(JSON.stringify(u)),(0,a.LI)(JSON.stringify(e))].join(".");const f=l.slice(0,2);let m;if("HS"===f)m=(0,a.LI)((0,o.w8)(p,t,i,"binary"));else if(s||"RS"===f)m=(0,a.LI)((0,a.cg)(c(p,r.As.encode(t),i)));else if("ES"===f){const e=(0,o.h1)(p,r.As.encode(t),n.Qj,i),s=e.r.padStart(64,"0"),d=e.s.padStart(64,"0");m=(0,a.LI)((0,a.FF)(s+d))}else if("ED"===f){const e=(0,o.q4)(function(e){for(var t="",i=0;i{"use strict";i.d(t,{Qd:()=>s,ZH:()=>r,_n:()=>d,bB:()=>a,tg:()=>n,uR:()=>o});const s=e=>{const t={fetchOHLCVWs:"fetch_ohlcv_ws"};return t[e]?t[e]:e.match(/[A-Z]/)?e.replace(/[a-z0-9][A-Z]/g,(e=>e[0]+"_"+e[1])).replace(/[A-Z0-9][A-Z0-9][a-z][^$]/g,(e=>e[0]+"_"+e[1]+e[2]+e[3])).replace(/[a-z][0-9]$/g,(e=>e[0]+"_"+e[1])).toLowerCase():e},r=e=>e.length?e.charAt(0).toUpperCase()+e.slice(1):e,a=e=>e.replace(/^\s+|\s+$/g,""),o=e=>e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o),n=e=>e?(e^16*Math.random()>>e/4).toString(16):([1e5]+100+400+8e3).replace(/[018]/g,n),d=e=>e?(e^16*Math.random()>>e/4).toString(16):([1e7]+1e3+4e3+8e5).replace(/[018]/g,d)},7618:(e,t,i)=>{"use strict";i.d(t,{x:()=>r});var s=i(8403);class r{constructor(e){this.config={refillRate:1,delay:.001,capacity:1,tokens:0,cost:1,algorithm:"leakyBucket",windowSize:6e4,maxWeight:void 0},Object.assign(this.config,e),"leakyBucket"!==this.config.algorithm&&(this.config.maxWeight=this.config.windowSize/this.config.rateLimit),this.queue=[],this.running=!1,this.timestamps=[]}async leakyBucketLoop(){let e=(0,s.tB)();for(;this.running;){const{resolver:t,cost:i}=this.queue[0];if(this.config.tokens>=0)this.config.tokens-=i,t(),this.queue.shift(),await Promise.resolve(),0===this.queue.length&&(this.running=!1);else{await(0,s.yy)(1e3*this.config.delay);const t=(0,s.tB)(),i=t-e;e=t;const r=this.config.tokens+this.config.refillRate*i;this.config.tokens=Math.min(r,this.config.capacity)}}}async rollingWindowLoop(){for(;this.running;){const{resolver:e,cost:t}=this.queue[0],i=(0,s.tB)(),r=i-this.config.windowSize;let a=0;const o=[];for(let e=0;er&&(a+=t.cost,o.push(t))}if(this.timestamps=o,a+t<=this.config.maxWeight)this.timestamps.push({timestamp:i,cost:t}),e(),this.queue.shift(),await Promise.resolve(),0===this.queue.length&&(this.running=!1);else{const e=this.timestamps[0].timestamp+this.config.windowSize-i;e>0&&await(0,s.yy)(e)}}}async loop(){"leakyBucket"===this.config.algorithm?await this.leakyBucketLoop():await this.rollingWindowLoop()}throttle(e=void 0){let t;const i=new Promise(((e,i)=>{t=e}));return e=void 0===e?this.config.cost:e,this.queue.push({resolver:t,cost:e}),this.running||(this.running=!0,this.loop()),i}}},8403:(e,t,i)=>{"use strict";i.d(t,{D9:()=>f,Dj:()=>u,EZ:()=>r,GA:()=>h,LC:()=>l,RR:()=>b,Rn:()=>y,Rz:()=>a,Th:()=>g,YA:()=>o,_U:()=>p,k4:()=>c,nm:()=>n,rE:()=>m,tB:()=>s,wR:()=>k,x_:()=>v,yy:()=>w});const s=Date.now,r=()=>1e3*s(),a=s,o=()=>Math.floor(s()/1e3),n=()=>{const e=(10*r()+122192928e9).toString(16);return e.slice(7,15)+e.slice(3,7)+"1"+e.slice(0,3)+"9696"+"ff".repeat(6)},d=setTimeout,c=(e,t,i=d,r=s()+t)=>{if(t>=2147483647)throw new Error("setTimeout() function was called with unrealistic value of "+t.toString());let a=()=>{},o=!0;const n=i((()=>{o=!0;const t=r-s();t>0?a=c(e,t,i,r):e()}),t);return function(){o&&(o=!1,clearTimeout(n)),a()}};class h extends Error{constructor(){const e="timed out";super(e),this.constructor=h,this.__proto__=h.prototype,this.message=e}}const l=e=>{let t;if(t="number"==typeof e?Math.floor(e):parseInt(e,10),!(Number.isNaN(t)||t<0))try{return new Date(t).toISOString()}catch(e){return}},u=e=>{if("string"==typeof e&&e&&!e.match(/^[0-9]+$/)&&!(e.indexOf("-")<0||e.indexOf(":")<0))try{const t=Date.parse(e.indexOf("+")>=0||"Z"===e.slice(-1)?e:(e+"Z").replace(/\s(\d\d):/,"T$1:"));if(Number.isNaN(t))return;return t}catch(e){return}},p=e=>{if("string"==typeof e&&e){if(e.indexOf("GMT")>=0)try{return Date.parse(e)}catch(e){return}return u(e)}},f=(e=void 0)=>new Date(e).toUTCString(),m=(e,t="-")=>{t=t||"";const i=new Date(e),s=i.getUTCFullYear().toString();let r=i.getUTCMonth()+1,a=i.getUTCDate();return r=r<10?"0"+r:r.toString(),a=a<10?"0"+a:a.toString(),r+t+a+t+s},g=(e,t,i=!0)=>{t=t||"";const s=new Date(e),r=s.getUTCFullYear(),a=(i?r:r-2e3).toString();let o=s.getUTCMonth()+1,n=s.getUTCDate();return o=o<10?"0"+o:o.toString(),n=n<10?"0"+n:n.toString(),a+t+o+t+n},v=(e,t="")=>g(e,t,!1),y=(e,t="-")=>g(e,t,!0),b=(e,t=" ")=>{const i=new Date(e),s=i.getUTCFullYear();let r=i.getUTCMonth()+1,a=i.getUTCDate(),o=i.getUTCHours(),n=i.getUTCMinutes(),d=i.getUTCSeconds();return r=r<10?"0"+r:r,a=a<10?"0"+a:a,o=o<10?"0"+o:o,n=n<10?"0"+n:n,d=d<10?"0"+d:d,s+"-"+r+"-"+a+t+o+":"+n+":"+d},w=e=>new Promise((t=>c(t,e))),k=async(e,t)=>{let i=()=>{};const s=new Promise((t=>i=c(t,e)));try{return await Promise.race([t,s.then((()=>{throw new h}))])}finally{i()}}},8995:(e,t,i)=>{"use strict";i.d(t,{O:()=>o});var s=i(4710),r=i(3466),a=i(8283);function o(e){const t=e=>parseInt(e,16);e=e.replace(" ","");const i=Math.round((new Date).getTime()/1e3),o=((e,t)=>(t+e).slice(-t.length))(((n=Math.floor(i/30))<15.5?"0":"")+Math.round(n).toString(16),"0000000000000000");var n;const d=(0,a.w8)(s.xn.decode(o),s.RG.decode(e),r.e,"hex"),c=t(d.substring(d.length-1));let h=(t(d.substr(2*c,8))&t("7fffffff"))+"";return h.substring(h.length-6,h.length)}},6834:(e,t,i)=>{"use strict";i.d(t,{At:()=>E,Cw:()=>T,DR:()=>N,Dj:()=>A,Et:()=>s,F7:()=>C,Fq:()=>r,Gv:()=>d,Hf:()=>c,I9:()=>q,J0:()=>I,JU:()=>m,KL:()=>h,Kg:()=>n,Pf:()=>f,Q7:()=>B,RH:()=>O,Rc:()=>D,Y2:()=>v,Y_:()=>L,_w:()=>l,cy:()=>a,d0:()=>x,dl:()=>o,fu:()=>V,gw:()=>S,hO:()=>R,lu:()=>y,mU:()=>P,nr:()=>k,pI:()=>w,q0:()=>b,uS:()=>_,w:()=>g,ww:()=>M});const s=Number.isFinite,r=Number.isInteger,a=Array.isArray,o=e=>null!=e,n=e=>"string"==typeof e,d=e=>null!==e&&"object"==typeof e,c=e=>d(e)&&Object.getPrototypeOf(e)===Object.prototype&&!a(e)&&!(e=>e instanceof RegExp)(e),h=e=>o(e)&&e.toString||s(e),l=(e,t)=>d(e)&&""!==e[t]&&null!==e[t]?e[t]:void 0,u=(e,t,i)=>d(e)?void 0!==e[t]&&""!==e[t]&&null!==e[t]?e[t]:""!==e[i]&&null!==e[i]?e[i]:void 0:void 0,p=(e,t)=>d(e)?e[t.find((t=>void 0!==l(e,t)))]:void 0,f=e=>s(e)||n(e)&&0!==e.length?parseFloat(e):NaN,m=e=>s(e)||n(e)&&0!==e.length?Math.trunc(Number(e)):NaN,g=(e,t,i)=>{const r=f(l(e,t));return s(r)?r:i},v=(e,t,i)=>{const r=m(l(e,t));return s(r)?r:i},y=(e,t,i,r)=>{const a=f(l(e,t));return s(a)?parseInt(a*i):r},b=(e,t,i)=>{const r=f(l(e,t));return s(r)?parseInt(1e3*r):i},w=(e,t,i)=>{const s=l(e,t);return o(s)?s:i},k=(e,t,i)=>{const s=l(e,t);return h(s)?String(s):i},S=(e,t,i)=>{const s=l(e,t);return h(s)?String(s).toLowerCase():h(i)?String(i).toLowerCase():i},O=(e,t,i)=>{const s=l(e,t);return h(s)?String(s).toUpperCase():h(i)?String(i).toUpperCase():i},T=(e,t,i,r)=>{const a=f(u(e,t,i));return s(a)?a:r},P=(e,t,i,r)=>{const a=m(u(e,t,i));return s(a)?a:r},I=(e,t,i,r,a)=>{const o=f(u(e,t,i));return s(o)?parseInt(o*r):a},M=(e,t,i,r)=>{const a=f(u(e,t,i));return s(a)?parseInt(1e3*a):r},A=(e,t,i,s)=>{const r=u(e,t,i);return o(r)?r:s},x=(e,t,i,s)=>{const r=u(e,t,i);return h(r)?String(r):s},_=(e,t,i,s)=>{const r=u(e,t,i);return h(r)?String(r).toLowerCase():h(s)?String(s).toLowerCase():s},C=(e,t,i,s)=>{const r=u(e,t,i);return h(r)?String(r).toUpperCase():h(s)?String(s).toUpperCase():s},B=(e,t,i)=>{const r=f(p(e,t));return s(r)?r:i},E=(e,t,i)=>{if(void 0===e)return i;const r=m(p(e,t));return s(r)?r:i},R=(e,t,i,r)=>{const a=f(p(e,t));return s(a)?parseInt(a*i):r},L=(e,t,i)=>{const r=f(p(e,t));return s(r)?parseInt(1e3*r):i},N=(e,t,i)=>{if(void 0===e)return i;const s=p(e,t);return o(s)?s:i},D=(e,t,i)=>{if(void 0===e)return i;const s=p(e,t);return h(s)?String(s):i},q=(e,t,i)=>{const s=p(e,t);return h(s)?String(s).toLowerCase():h(i)?String(i).toLowerCase():i},V=(e,t,i)=>{const s=p(e,t);return h(s)?String(s).toUpperCase():h(i)?String(i).toUpperCase():i}},2931:(e,t,i)=>{"use strict";i.d(t,{Hk:()=>n,I3:()=>r,Pt:()=>o,TG:()=>a});class s extends Array{constructor(e=void 0){super(),Object.defineProperty(this,"maxSize",{__proto__:null,value:e,writable:!0})}clear(){this.length=0}}class r extends s{constructor(e=void 0){super(e),this.hashmap={},Object.defineProperty(this,"nestedNewUpdatesBySymbol",{__proto__:null,value:!1,writable:!0}),Object.defineProperty(this,"newUpdatesBySymbol",{__proto__:null,value:{},writable:!0}),Object.defineProperty(this,"clearUpdatesBySymbol",{__proto__:null,value:{},writable:!0}),Object.defineProperty(this,"allNewUpdates",{__proto__:null,value:0,writable:!0}),Object.defineProperty(this,"clearAllUpdates",{__proto__:null,value:!1,writable:!0}),Object.defineProperty(this,"hashmap",{__proto__:null,value:{},writable:!0,enumerable:!1})}getLimit(e,t){let i;return void 0===e?(i=this.allNewUpdates,this.clearAllUpdates=!0):(i=this.newUpdatesBySymbol[e],void 0!==i&&this.nestedNewUpdatesBySymbol&&(i=i.size),this.clearUpdatesBySymbol[e]=!0),void 0===i?t:void 0!==t?Math.min(i,t):i}append(e){this.maxSize&&this.length===this.maxSize&&this.shift(),this.push(e),this.clearAllUpdates&&(this.clearAllUpdates=!1,this.clearUpdatesBySymbol={},this.allNewUpdates=0,this.newUpdatesBySymbol={}),this.clearUpdatesBySymbol[e.symbol]&&(this.clearUpdatesBySymbol[e.symbol]=!1,this.newUpdatesBySymbol[e.symbol]=0),this.newUpdatesBySymbol[e.symbol]=(this.newUpdatesBySymbol[e.symbol]||0)+1,this.allNewUpdates=(this.allNewUpdates||0)+1}}class a extends s{constructor(e=void 0){super(e),Object.defineProperty(this,"hashmap",{__proto__:null,value:{},writable:!0}),Object.defineProperty(this,"sizeTracker",{__proto__:null,value:new Set,writable:!0}),Object.defineProperty(this,"newUpdates",{__proto__:null,value:0,writable:!0}),Object.defineProperty(this,"clearUpdates",{__proto__:null,value:!1,writable:!0})}getLimit(e,t){return this.clearUpdates=!0,void 0===t?this.newUpdates:Math.min(this.newUpdates,t)}append(e){if(e[0]in this.hashmap){const t=this.hashmap[e[0]];if(t!==e)for(const i in e)t[i]=e[i]}else{if(this.hashmap[e[0]]=e,this.maxSize&&this.length===this.maxSize){const e=this.shift();delete this.hashmap[e[0]]}this.push(e)}this.clearUpdates&&(this.clearUpdates=!1,this.sizeTracker.clear()),this.sizeTracker.add(e[0]),this.newUpdates=this.sizeTracker.size}}class o extends r{constructor(e=void 0){super(e),this.nestedNewUpdatesBySymbol=!0}append(e){const t=this.hashmap[e.symbol]=this.hashmap[e.symbol]||{};if(e.id in t){const i=t[e.id];if(i!==e)for(const t in e)i[t]=e[t];e=i;const s=this.findIndex((t=>t.id===e.id));this.splice(s,1)}else t[e.id]=e;if(this.maxSize&&this.length===this.maxSize){const e=this.shift();delete this.hashmap[e.symbol][e.id]}this.push(e),this.clearAllUpdates&&(this.clearAllUpdates=!1,this.clearUpdatesBySymbol={},this.allNewUpdates=0,this.newUpdatesBySymbol={}),void 0===this.newUpdatesBySymbol[e.symbol]&&(this.newUpdatesBySymbol[e.symbol]=new Set),this.clearUpdatesBySymbol[e.symbol]&&(this.clearUpdatesBySymbol[e.symbol]=!1,this.newUpdatesBySymbol[e.symbol].clear());const i=this.newUpdatesBySymbol[e.symbol],s=i.size;i.add(e.id);const r=i.size;this.allNewUpdates=(this.allNewUpdates||0)+(r-s)}}class n extends r{constructor(){super(),this.nestedNewUpdatesBySymbol=!0,Object.defineProperty(this,"hashmap",{__proto__:null,value:{},writable:!0})}append(e){const t=this.hashmap[e.symbol]=this.hashmap[e.symbol]||{};if(e.side in t){const i=t[e.side];if(i!==e)for(const t in e)i[t]=e[t];e=i;const s=this.findIndex((t=>t.symbol===e.symbol&&t.side===e.side));this.splice(s,1)}else t[e.side]=e;this.push(e),this.clearAllUpdates&&(this.clearAllUpdates=!1,this.clearUpdatesBySymbol={},this.allNewUpdates=0,this.newUpdatesBySymbol={}),void 0===this.newUpdatesBySymbol[e.symbol]&&(this.newUpdatesBySymbol[e.symbol]=new Set),this.clearUpdatesBySymbol[e.symbol]&&(this.clearUpdatesBySymbol[e.symbol]=!1,this.newUpdatesBySymbol[e.symbol].clear());const i=this.newUpdatesBySymbol[e.symbol],s=i.size;i.add(e.side);const r=i.size;this.allNewUpdates=(this.allNewUpdates||0)+(r-s)}}},934:(e,t,i)=>{"use strict";i.d(t,{A:()=>l});var s=i(2079),r=i(4350),a=i(3206),o=i(7437),n=i(8403),d=i(7597),c=i(9560),h=i(4710);class l{constructor(e,t,i,s,r,n={}){this.verbose=!1,this.decompressBinary=!0;const d={url:e,onMessageCallback:t,onErrorCallback:i,onCloseCallback:s,onConnectedCallback:r,verbose:!1,protocols:void 0,options:void 0,futures:{},subscriptions:{},rejections:{},connected:void 0,error:void 0,connectionStarted:void 0,connectionEstablished:void 0,isConnected:!1,connectionTimer:void 0,connectionTimeout:1e4,pingInterval:void 0,ping:void 0,keepAlive:3e4,maxPingPongMisses:2,connection:void 0,startedConnecting:!1,gunzip:!1,inflate:!1};Object.assign(this,(0,o.zw)(d,n)),this.connected=(0,a.K)()}reusableFuture(e){return this.future(e)}future(e){e in this.futures||(this.futures[e]=(0,a.K)());const t=this.futures[e];return e in this.rejections&&(t.reject(this.rejections[e]),delete this.rejections[e]),t}resolve(e,t){if(this.verbose&&void 0===t&&this.log(new Date,"resolve received undefined messageHash"),void 0!==t&&t in this.futures){this.futures[t].resolve(e),delete this.futures[t]}return e}reject(e,t=void 0){if(t)if(t in this.futures){this.futures[t].reject(e),delete this.futures[t]}else this.rejections[t]=e;else{const t=Object.keys(this.futures);for(let i=0;i{this.onError(e)})):d.Ll?this.connection.ping():this.lastPong=e}}}onOpen(){this.verbose&&this.log(new Date,"onOpen","|",this.url),this.connectionEstablished=(0,n.Rz)(),this.isConnected=!0,this.connected.resolve(this.url),this.clearConnectionTimeout(),this.setPingInterval(),this.onConnectedCallback(this)}onPing(){this.verbose&&this.log(new Date,"onPing","|",this.url)}onPong(){this.lastPong=(0,n.Rz)(),this.verbose&&this.log(new Date,"onPong","|",this.url)}onError(e){this.verbose&&this.log(new Date,"onError",e.message,"|",this.url),e instanceof s.BaseError||(e=new s.NetworkError(e.message)),this.error=e,this.reset(this.error),this.onErrorCallback(this,this.error)}onClose(e){this.verbose&&this.log(new Date,"onClose",e,"|",this.url),this.error||this.reset(new s.NetworkError("connection closed by remote server, closing code "+String(e.code))),this.error instanceof s.ExchangeClosedByUser&&this.reset(this.error),void 0!==this.disconnected&&this.disconnected.resolve(!0),this.onCloseCallback(this,e)}onUpgrade(e){this.verbose&&this.log(new Date,"onUpgrade","|",this.url)}async send(e){this.verbose&&this.log(new Date,"sending",e),e="string"==typeof e?e:JSON.stringify(e);const t=(0,a.K)();if(d.Ll){function i(e){e?t.reject(e):t.resolve(null)}this.connection.send(e,{},i)}else this.connection.send(e),t.resolve(null);return t}close(){throw new s.NotSupported("close() not implemented yet")}onMessage(e){let t,i=e.data;"string"!=typeof i&&(this.gunzip||this.inflate?(t=new Uint8Array(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)),this.gunzip?t=(0,r.Wt)(t):this.inflate&&(t=(0,r.HM)(t)),i=h.As.encode(t)):this.decompressBinary&&(i=i.toString()));try{(0,c.mC)(i)&&(i=i.toString(),i=JSON.parse(i.replace(/:(\d{15,}),/g,':"$1",'))),this.verbose&&this.log(new Date,"onMessage",i)}catch(e){this.log(new Date,"onMessage JSON.parse",e,"|",this.url)}try{this.onMessageCallback(this,i)}catch(e){this.reject(e)}}}},3206:(e,t,i)=>{"use strict";i.d(t,{K:()=>r});var s=i(2634);function r(){let e,t;const i=new Promise(((i,s)=>{e=i,t=s}));return i.resolve=function(){queueMicrotask((()=>{e.apply(this,arguments)}))},i.reject=function(){queueMicrotask((()=>{t.apply(this,arguments)}))},i}r.race=e=>function(e){const t=r();return e.then(t.resolve,t.reject),t}(s.V.race(e))},3828:(e,t,i)=>{"use strict";i.d(t,{Mi:()=>o,if:()=>n,nS:()=>d});var s=i(8403),r=i(7437),a=i(975);class o{constructor(e={},t=void 0){this.cache=[],Object.defineProperty(this,"cache",{__proto__:null,value:[],writable:!0,enumerable:!1}),t=t||Number.MAX_SAFE_INTEGER;const i={bids:[],asks:[],timestamp:void 0,datetime:void 0,nonce:void 0,symbol:void 0},o=Object.entries((0,r.X$)(i,e));for(let e=0;e{"use strict";function s(e,t){let i=0,s=e.length-1;for(;i<=s;){const r=i+s>>>1;e[r]-t<0?i=r+1:s=r-1}return i}i.d(t,{$w:()=>d,PB:()=>c,eB:()=>p,f_:()=>h,jR:()=>l,o5:()=>u});const r=new Float64Array(new Array(1024).fill(Number.MAX_VALUE));class a extends Array{constructor(e=[],t=void 0){super(),Object.defineProperty(this,"index",{__proto__:null,value:new Float64Array(r),writable:!0}),Object.defineProperty(this,"depth",{__proto__:null,value:t||Number.MAX_SAFE_INTEGER,writable:!0}),this.length=0;for(let t=0;tthis.index.length-1){const e=Array.from(this.index);e.length=2*this.length,e.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(e)}}else this.index[a]===r&&(this.index.copyWithin(a,a+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(a,a+1,this.length),this.length--)}store(e,t){this.storeArray([e,t])}limit(){if(this.length>this.depth){for(let e=this.depth;ethis.index.length-1){const e=Array.from(this.index);e.length=2*this.length,e.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(e)}}else this.index[o]===a&&(this.index.copyWithin(o,o+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(o,o+1,this.length),this.length--)}}class n extends Array{constructor(e=[],t=Number.MAX_SAFE_INTEGER){super(e.length),Object.defineProperty(this,"hashmap",{__proto__:null,value:new Map,writable:!0}),Object.defineProperty(this,"index",{__proto__:null,value:new Float64Array(r),writable:!0}),Object.defineProperty(this,"depth",{__proto__:null,value:t||Number.MAX_SAFE_INTEGER,writable:!0});for(let t=0;tthis.index.length-1){const e=Array.from(this.index);e.length=2*this.length,e.fill(Number.MAX_VALUE,this.index.length),this.index=new Float64Array(e)}}else if(this.hashmap.has(r)){const e=this.hashmap.get(r);let t=s(this.index,e);for(;this[t][2]!==r;)t++;this.index.copyWithin(t,t+1,this.index.length),this.index[this.length-1]=Number.MAX_VALUE,this.copyWithin(t,t+1,this.length),this.length--,this.hashmap.delete(r)}}limit(){if(this.length>this.depth){for(let e=this.depth;e{"use strict";i.d(t,{A:()=>l});var s=i(1591),r=i.n(s),a=i(934),o=i(7597),n=i(6238),d=i(8403),c=i(3206);const h=o.Ll||!(0,n.Se)()?r():self.WebSocket;class l extends a.A{constructor(){super(...arguments),this.startedConnecting=!1}createConnection(){this.verbose&&this.log(new Date,"connecting to",this.url),this.connectionStarted=(0,d.Rz)(),this.setConnectionTimeout();const e={};if(void 0!==this.cookies){let t="";const i=Object.keys(this.cookies);for(let e=0;e{"use strict";i.d(t,{A:()=>r});var s=i(7996);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bequant",name:"Bequant",pro:!0,countries:["MT"],urls:{logo:"https://github.com/user-attachments/assets/0583ef1f-29fe-4b7c-8189-63565a0e2867",api:{public:"https://api.bequant.io/api/3",private:"https://api.bequant.io/api/3"},www:"https://bequant.io",doc:["https://api.bequant.io/"],fees:["https://bequant.io/fees-and-limits"],referral:"https://bequant.io/referral/dd104e3bee7634ec"}})}}},8698:(e,t,i)=>{"use strict";i.d(t,{A:()=>c});var s=i(3971),r=i(2079),a=i(1579),o=i(5354),n=i(4852),d=i(5147);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bigone",name:"BigONE",countries:["CN"],version:"v3",rateLimit:20,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:void 0,option:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchMarkets:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"min1","5m":"min5","15m":"min15","30m":"min30","1h":"hour1","3h":"hour3","4h":"hour4","6h":"hour6","12h":"hour12","1d":"day1","1w":"week1","1M":"month1"},hostname:"big.one",urls:{logo:"https://github.com/user-attachments/assets/4e5cfd53-98cc-4b90-92cd-0d7b512653d1",api:{public:"https://{hostname}/api/v3",private:"https://{hostname}/api/v3/viewer",contractPublic:"https://{hostname}/api/contract/v2",contractPrivate:"https://{hostname}/api/contract/v2",webExchange:"https://{hostname}/api/"},www:"https://big.one",doc:"https://open.big.one/docs/api.html",fees:"https://bigone.zendesk.com/hc/en-us/articles/115001933374-BigONE-Fee-Policy",referral:"https://b1.run/users/new?code=D3LLBVFT"},api:{public:{get:["ping","asset_pairs","asset_pairs/{asset_pair_name}/depth","asset_pairs/{asset_pair_name}/trades","asset_pairs/{asset_pair_name}/ticker","asset_pairs/{asset_pair_name}/candles","asset_pairs/tickers"]},private:{get:["accounts","fund/accounts","assets/{asset_symbol}/address","orders","orders/{id}","orders/multi","trades","withdrawals","deposits"],post:["orders","orders/{id}/cancel","orders/cancel","withdrawals","transfer"]},contractPublic:{get:["symbols","instruments","depth@{symbol}/snapshot","instruments/difference","instruments/prices"]},contractPrivate:{get:["accounts","orders/{id}","orders","orders/opening","orders/count","orders/opening/count","trades","trades/count"],post:["orders","orders/batch"],put:["positions/{symbol}/margin","positions/{symbol}/risk-limit"],delete:["orders/{id}","orders/batch"]},webExchange:{get:["v3/assets"]}},fees:{trading:{maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")},funding:{withdraw:{}}},options:{createMarketBuyOrderRequiresPrice:!0,accountsByType:{spot:"SPOT",fund:"FUND",funding:"FUND",future:"CONTRACT",swap:"CONTRACT"},transfer:{fillResponseFromRequest:!0},exchangeMillisecondsCorrection:-100,fetchCurrencies:{webApiEnable:!0,webApiRetries:5,webApiMuteFailure:!0},defaultNetwork:"ERC20",defaultNetworks:{USDT:"TRC20"},networks:{ABBC:"ABBC",ACA:"Acala",AE:"Aeternity",ALGO:"Algorand",APT:"Aptos",AR:"Arweave",ASTR:"Astar",AVAXC:"Avax",AVAXX:"AvaxChain",BEAM:"Beam",BEP20:"BinanceSmartChain",BITCI:"BitciChain",BTC:"Bitcoin",BCH:"BitcoinCash",BSV:"BitcoinSV",CELO:"Celo",CKKB:"CKB",ATOM:"Cosmos",CRC20:"CRO",DASH:"Dash",DOGE:"Dogecoin",XEC:"ECash",EOS:"EOS",ETH:"Ethereum",ETC:"EthereumClassic",ETHW:"EthereumPow",FTM:"Fantom",FIL:"Filecoin",FSN:"Fusion",GRIN:"Grin",ONE:"Harmony",HRC20:"Hecochain",HBAR:"Hedera",HNT:"Helium",ZEN:"Horizen",IOST:"IOST",IRIS:"IRIS",KLAY:"Klaytn",KSM:"Kusama",LTC:"Litecoin",XMR:"Monero",GLMR:"Moonbeam",NEAR:"Near",NEO:"Neo",NEON3:"NeoN3",OASIS:"Oasis",OKC:"Okexchain",ONT:"Ontology",OPTIMISM:"Optimism",DOT:"Polkadot",MATIC:"Polygon",QTUM:"Qtum",REI:"REI",XRP:"Ripple",SGB:"SGB",SDN:"Shiden",SOL:"Solana",XLM:"Stellar",TERA:"Tera",XTZ:"Tezos",TRC20:"Tron",VET:"Vechain",VSYS:"VSystems",WAX:"WAX",ZEC:"Zcash"}},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!0,marketBuyByCost:!0,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:200,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:200,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:200,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:200,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:500}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{triggerPriceType:{mark:!0,index:!0,last:!0}},fetchOrders:{daysBack:1e5,untilDays:1e5},fetchClosedOrders:{daysBack:1e5,untilDays:1e5}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:void 0,inverse:void 0}},precisionMode:a.kb,exceptions:{exact:{10001:r.BadRequest,10005:r.ExchangeError,"Amount's scale must greater than AssetPair's base scale":r.InvalidOrder,"Price mulit with amount should larger than AssetPair's min_quote_value":r.InvalidOrder,10007:r.BadRequest,10011:r.ExchangeError,10013:r.BadSymbol,10014:r.InsufficientFunds,10403:r.PermissionDenied,10429:r.RateLimitExceeded,40004:r.AuthenticationError,40103:r.AuthenticationError,40104:r.AuthenticationError,40301:r.PermissionDenied,40302:r.ExchangeError,40601:r.ExchangeError,40602:r.ExchangeError,40603:r.InsufficientFunds,40604:r.InvalidOrder,40605:r.InvalidOrder,40120:r.InvalidOrder,40121:r.InvalidOrder,60100:r.BadSymbol},broad:{}},commonCurrencies:{CRE:"Cybereits",FXT:"FXTTOKEN",FREE:"FreeRossDAO",MBN:"Mobilian Coin",ONE:"BigONE Token"}})}async fetchCurrencies(e={}){const t=await this.fetchWebEndpoint("fetchCurrencies","webExchangeGetV3Assets",!0);if(void 0===t)return{};const i=this.safeList(t,"data",[]),s={};for(let e=0;e{"use strict";i.d(t,{A:()=>l});var s=i(335),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(5354),c=i(8283),h=i(6414);class l extends s.A{describe(){return this.deepExtend(super.describe(),{id:"binance",name:"Binance",countries:[],rateLimit:50,certified:!0,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!0,option:!0,addMargin:!0,borrowCrossMargin:!0,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createConvertTrade:!0,createDepositAddress:!1,createLimitBuyOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!0,createMarketSellOrder:!0,createMarketSellOrderWithCost:!0,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!1,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!0,createTakeProfitOrder:!0,createTrailingPercentOrder:!0,createTriggerOrder:!0,editOrder:!0,editOrders:!0,fetchAccounts:void 0,fetchAllGreeks:!0,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!0,fetchCanceledAndClosedOrders:"emulated",fetchCanceledOrders:"emulated",fetchClosedOrder:!1,fetchClosedOrders:"emulated",fetchConvertCurrencies:!0,fetchConvertQuote:!0,fetchConvertTrade:!0,fetchConvertTradeHistory:!0,fetchCrossBorrowRate:!0,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingInterval:"emulated",fetchFundingIntervals:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!0,fetchIndexOHLCV:!0,fetchIsolatedBorrowRate:"emulated",fetchIsolatedBorrowRates:!0,fetchL3OrderBook:!1,fetchLastPrices:!0,fetchLedger:!0,fetchLedgerEntry:!0,fetchLeverage:"emulated",fetchLeverages:!0,fetchLeverageTiers:!0,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!0,fetchMarginAdjustmentHistory:!0,fetchMarginMode:!0,fetchMarginModes:!0,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMarkPrice:!0,fetchMarkPrices:!0,fetchMyLiquidations:!0,fetchMySettlementHistory:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!0,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!0,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!0,fetchPositions:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!0,fetchPremiumIndexOHLCV:!0,fetchSettlementHistory:!0,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTradingLimits:"emulated",fetchTransactionFee:"emulated",fetchTransactionFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawAddresses:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!0,repayCrossMargin:!0,repayIsolatedMargin:!0,sandbox:!0,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!0,signIn:!1,transfer:!0,withdraw:!0},timeframes:{"1s":"1s","1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://github.com/user-attachments/assets/e9419b93-ccb0-46aa-9bff-c883f096274b",test:{dapiPublic:"https://testnet.binancefuture.com/dapi/v1",dapiPrivate:"https://testnet.binancefuture.com/dapi/v1",dapiPrivateV2:"https://testnet.binancefuture.com/dapi/v2",fapiPublic:"https://testnet.binancefuture.com/fapi/v1",fapiPublicV2:"https://testnet.binancefuture.com/fapi/v2",fapiPublicV3:"https://testnet.binancefuture.com/fapi/v3",fapiPrivate:"https://testnet.binancefuture.com/fapi/v1",fapiPrivateV2:"https://testnet.binancefuture.com/fapi/v2",fapiPrivateV3:"https://testnet.binancefuture.com/fapi/v3",public:"https://testnet.binance.vision/api/v3",private:"https://testnet.binance.vision/api/v3",v1:"https://testnet.binance.vision/api/v1"},demo:{dapiPublic:"https://demo-dapi.binance.com/dapi/v1",dapiPrivate:"https://demo-dapi.binance.com/dapi/v1",dapiPrivateV2:"https://demo-dapi.binance.com/dapi/v2",fapiPublic:"https://demo-fapi.binance.com/fapi/v1",fapiPublicV2:"https://demo-fapi.binance.com/fapi/v2",fapiPublicV3:"https://demo-fapi.binance.com/fapi/v3",fapiPrivate:"https://demo-fapi.binance.com/fapi/v1",fapiPrivateV2:"https://demo-fapi.binance.com/fapi/v2",fapiPrivateV3:"https://demo-fapi.binance.com/fapi/v3",public:"https://demo-api.binance.com/api/v3",private:"https://demo-api.binance.com/api/v3",v1:"https://demo-api.binance.com/api/v1"},api:{sapi:"https://api.binance.com/sapi/v1",sapiV2:"https://api.binance.com/sapi/v2",sapiV3:"https://api.binance.com/sapi/v3",sapiV4:"https://api.binance.com/sapi/v4",dapiPublic:"https://dapi.binance.com/dapi/v1",dapiPrivate:"https://dapi.binance.com/dapi/v1",eapiPublic:"https://eapi.binance.com/eapi/v1",eapiPrivate:"https://eapi.binance.com/eapi/v1",dapiPrivateV2:"https://dapi.binance.com/dapi/v2",dapiData:"https://dapi.binance.com/futures/data",fapiPublic:"https://fapi.binance.com/fapi/v1",fapiPublicV2:"https://fapi.binance.com/fapi/v2",fapiPublicV3:"https://fapi.binance.com/fapi/v3",fapiPrivate:"https://fapi.binance.com/fapi/v1",fapiPrivateV2:"https://fapi.binance.com/fapi/v2",fapiPrivateV3:"https://fapi.binance.com/fapi/v3",fapiData:"https://fapi.binance.com/futures/data",public:"https://api.binance.com/api/v3",private:"https://api.binance.com/api/v3",v1:"https://api.binance.com/api/v1",papi:"https://papi.binance.com/papi/v1",papiV2:"https://papi.binance.com/papi/v2"},www:"https://www.binance.com",referral:{url:"https://accounts.binance.com/register?ref=CCXTCOM",discount:.1},doc:["https://developers.binance.com/en"],api_management:"https://www.binance.com/en/usercenter/settings/api-management",fees:"https://www.binance.com/en/fee/schedule"},api:{sapi:{get:{"copyTrading/futures/userStatus":2,"copyTrading/futures/leadSymbol":2,"system/status":.1,accountSnapshot:240,"account/info":.1,"margin/asset":1,"margin/pair":1,"margin/allAssets":.1,"margin/allPairs":.1,"margin/priceIndex":1,"spot/delist-schedule":10,"asset/assetDividend":1,"asset/dribblet":.1,"asset/transfer":.1,"asset/assetDetail":.1,"asset/tradeFee":.1,"asset/ledger-transfer/cloud-mining/queryByPage":4.0002,"asset/convert-transfer/queryByPage":.033335,"asset/wallet/balance":6,"asset/custody/transfer-history":6,"margin/borrow-repay":1,"margin/loan":1,"margin/repay":1,"margin/account":1,"margin/transfer":.1,"margin/interestHistory":.1,"margin/forceLiquidationRec":.1,"margin/order":1,"margin/openOrders":1,"margin/allOrders":20,"margin/myTrades":1,"margin/maxBorrowable":5,"margin/maxTransferable":5,"margin/tradeCoeff":1,"margin/isolated/transfer":.1,"margin/isolated/account":1,"margin/isolated/pair":1,"margin/isolated/allPairs":1,"margin/isolated/accountLimit":.1,"margin/interestRateHistory":.1,"margin/orderList":1,"margin/allOrderList":20,"margin/openOrderList":1,"margin/crossMarginData":{cost:.1,noCoin:.5},"margin/isolatedMarginData":{cost:.1,noCoin:1},"margin/isolatedMarginTier":.1,"margin/rateLimit/order":2,"margin/dribblet":.1,"margin/dust":20.001,"margin/crossMarginCollateralRatio":10,"margin/exchange-small-liability":.6667,"margin/exchange-small-liability-history":.6667,"margin/next-hourly-interest-rate":.6667,"margin/capital-flow":10,"margin/delist-schedule":10,"margin/available-inventory":.3334,"margin/leverageBracket":.1,"loan/vip/loanable/data":40,"loan/vip/collateral/data":40,"loan/vip/request/data":2.6668,"loan/vip/request/interestRate":2.6668,"loan/income":40.002,"loan/ongoing/orders":40,"loan/ltv/adjustment/history":40,"loan/borrow/history":40,"loan/repay/history":40,"loan/loanable/data":40,"loan/collateral/data":40,"loan/repay/collateral/rate":600,"loan/flexible/ongoing/orders":30,"loan/flexible/borrow/history":40,"loan/flexible/repay/history":40,"loan/flexible/ltv/adjustment/history":40,"loan/vip/ongoing/orders":40,"loan/vip/repay/history":40,"loan/vip/collateral/account":600,"fiat/orders":600.03,"fiat/payments":.1,"futures/transfer":1,"futures/histDataLink":.1,"rebate/taxQuery":80.004,"capital/config/getall":1,"capital/deposit/address":1,"capital/deposit/address/list":1,"capital/deposit/hisrec":.1,"capital/deposit/subAddress":.1,"capital/deposit/subHisrec":.1,"capital/withdraw/history":2,"capital/withdraw/address/list":10,"capital/contract/convertible-coins":4.0002,"convert/tradeFlow":20.001,"convert/exchangeInfo":50,"convert/assetInfo":10,"convert/orderStatus":.6667,"convert/limit/queryOpenOrders":20.001,"account/status":.1,"account/apiTradingStatus":.1,"account/apiRestrictions/ipRestriction":.1,bnbBurn:.1,"sub-account/futures/account":1,"sub-account/futures/accountSummary":.1,"sub-account/futures/positionRisk":1,"sub-account/futures/internalTransfer":.1,"sub-account/list":.1,"sub-account/margin/account":1,"sub-account/margin/accountSummary":1,"sub-account/spotSummary":.1,"sub-account/status":1,"sub-account/sub/transfer/history":.1,"sub-account/transfer/subUserHistory":.1,"sub-account/universalTransfer":.1,"sub-account/apiRestrictions/ipRestriction/thirdPartyList":1,"sub-account/transaction-statistics":.40002,"sub-account/subAccountApi/ipRestriction":20.001,"managed-subaccount/asset":.1,"managed-subaccount/accountSnapshot":240,"managed-subaccount/queryTransLogForInvestor":.1,"managed-subaccount/queryTransLogForTradeParent":.40002,"managed-subaccount/fetch-future-asset":.40002,"managed-subaccount/marginAsset":.1,"managed-subaccount/info":.40002,"managed-subaccount/deposit/address":.006667,"managed-subaccount/query-trans-log":.40002,"lending/daily/product/list":.1,"lending/daily/userLeftQuota":.1,"lending/daily/userRedemptionQuota":.1,"lending/daily/token/position":.1,"lending/union/account":.1,"lending/union/purchaseRecord":.1,"lending/union/redemptionRecord":.1,"lending/union/interestHistory":.1,"lending/project/list":.1,"lending/project/position/list":.1,"eth-staking/eth/history/stakingHistory":15,"eth-staking/eth/history/redemptionHistory":15,"eth-staking/eth/history/rewardsHistory":15,"eth-staking/eth/quota":15,"eth-staking/eth/history/rateHistory":15,"eth-staking/account":15,"eth-staking/wbeth/history/wrapHistory":15,"eth-staking/wbeth/history/unwrapHistory":15,"eth-staking/eth/history/wbethRewardsHistory":15,"sol-staking/sol/history/stakingHistory":15,"sol-staking/sol/history/redemptionHistory":15,"sol-staking/sol/history/bnsolRewardsHistory":15,"sol-staking/sol/history/rateHistory":15,"sol-staking/account":15,"sol-staking/sol/quota":15,"mining/pub/algoList":.1,"mining/pub/coinList":.1,"mining/worker/detail":.5,"mining/worker/list":.5,"mining/payment/list":.5,"mining/statistics/user/status":.5,"mining/statistics/user/list":.5,"mining/payment/uid":.5,"bswap/pools":.1,"bswap/liquidity":{cost:.1,noPoolId:1},"bswap/liquidityOps":20.001,"bswap/quote":1.00005,"bswap/swap":20.001,"bswap/poolConfigure":1.00005,"bswap/addLiquidityPreview":1.00005,"bswap/removeLiquidityPreview":1.00005,"bswap/unclaimedRewards":6.667,"bswap/claimedHistory":6.667,"blvt/tokenInfo":.1,"blvt/subscribe/record":.1,"blvt/redeem/record":.1,"blvt/userLimit":.1,"apiReferral/ifNewUser":1,"apiReferral/customization":1,"apiReferral/userCustomization":1,"apiReferral/rebate/recentRecord":1,"apiReferral/rebate/historicalRecord":1,"apiReferral/kickback/recentRecord":1,"apiReferral/kickback/historicalRecord":1,"broker/subAccountApi":1,"broker/subAccount":1,"broker/subAccountApi/commission/futures":1,"broker/subAccountApi/commission/coinFutures":1,"broker/info":1,"broker/transfer":1,"broker/transfer/futures":1,"broker/rebate/recentRecord":1,"broker/rebate/historicalRecord":1,"broker/subAccount/bnbBurn/status":1,"broker/subAccount/depositHist":1,"broker/subAccount/spotSummary":1,"broker/subAccount/marginSummary":1,"broker/subAccount/futuresSummary":1,"broker/rebate/futures/recentRecord":1,"broker/subAccountApi/ipRestriction":1,"broker/universalTransfer":1,"account/apiRestrictions":.1,"c2c/orderMatch/listUserOrderHistory":.1,"nft/history/transactions":20.001,"nft/history/deposit":20.001,"nft/history/withdraw":20.001,"nft/user/getAsset":20.001,"pay/transactions":20.001,"giftcard/verify":.1,"giftcard/cryptography/rsa-public-key":.1,"giftcard/buyCode/token-limit":.1,"algo/spot/openOrders":.1,"algo/spot/historicalOrders":.1,"algo/spot/subOrders":.1,"algo/futures/openOrders":.1,"algo/futures/historicalOrders":.1,"algo/futures/subOrders":.1,"portfolio/account":.1,"portfolio/collateralRate":5,"portfolio/pmLoan":3.3335,"portfolio/interest-history":.6667,"portfolio/asset-index-price":.1,"portfolio/repay-futures-switch":3,"portfolio/margin-asset-leverage":5,"portfolio/balance":2,"portfolio/negative-balance-exchange-record":2,"portfolio/pmloan-history":5,"portfolio/earn-asset-balance":150,"portfolio/delta-mode":150,"staking/productList":.1,"staking/position":.1,"staking/stakingRecord":.1,"staking/personalLeftQuota":.1,"lending/auto-invest/target-asset/list":.1,"lending/auto-invest/target-asset/roi/list":.1,"lending/auto-invest/all/asset":.1,"lending/auto-invest/source-asset/list":.1,"lending/auto-invest/plan/list":.1,"lending/auto-invest/plan/id":.1,"lending/auto-invest/history/list":.1,"lending/auto-invest/index/info":.1,"lending/auto-invest/index/user-summary":.1,"lending/auto-invest/one-off/status":.1,"lending/auto-invest/redeem/history":.1,"lending/auto-invest/rebalance/history":.1,"simple-earn/flexible/list":15,"simple-earn/locked/list":15,"simple-earn/flexible/personalLeftQuota":15,"simple-earn/locked/personalLeftQuota":15,"simple-earn/flexible/subscriptionPreview":15,"simple-earn/locked/subscriptionPreview":15,"simple-earn/flexible/history/rateHistory":15,"simple-earn/flexible/position":15,"simple-earn/locked/position":15,"simple-earn/account":15,"simple-earn/flexible/history/subscriptionRecord":15,"simple-earn/locked/history/subscriptionRecord":15,"simple-earn/flexible/history/redemptionRecord":15,"simple-earn/locked/history/redemptionRecord":15,"simple-earn/flexible/history/rewardsRecord":15,"simple-earn/locked/history/rewardsRecord":15,"simple-earn/flexible/history/collateralRecord":.1,"dci/product/list":.1,"dci/product/positions":.1,"dci/product/accounts":.1},post:{"asset/dust":.06667,"asset/dust-btc":.1,"asset/transfer":6.0003,"asset/get-funding-asset":.1,"asset/convert-transfer":.033335,"account/disableFastWithdrawSwitch":.1,"account/enableFastWithdrawSwitch":.1,"capital/withdraw/apply":4.0002,"capital/contract/convertible-coins":4.0002,"capital/deposit/credit-apply":.1,"margin/borrow-repay":20.001,"margin/transfer":4.0002,"margin/loan":20.001,"margin/repay":20.001,"margin/order":.040002,"margin/order/oco":.040002,"margin/dust":20.001,"margin/exchange-small-liability":20.001,"margin/isolated/transfer":4.0002,"margin/isolated/account":2.0001,"margin/max-leverage":300,bnbBurn:.1,"sub-account/virtualSubAccount":.1,"sub-account/margin/transfer":4.0002,"sub-account/margin/enable":.1,"sub-account/futures/enable":.1,"sub-account/futures/transfer":.1,"sub-account/futures/internalTransfer":.1,"sub-account/transfer/subToSub":.1,"sub-account/transfer/subToMaster":.1,"sub-account/universalTransfer":.1,"sub-account/options/enable":.1,"managed-subaccount/deposit":.1,"managed-subaccount/withdraw":.1,userDataStream:.1,"userDataStream/isolated":.1,"futures/transfer":.1,"lending/customizedFixed/purchase":.1,"lending/daily/purchase":.1,"lending/daily/redeem":.1,"bswap/liquidityAdd":60,"bswap/liquidityRemove":60,"bswap/swap":60,"bswap/claimRewards":6.667,"blvt/subscribe":.1,"blvt/redeem":.1,"apiReferral/customization":1,"apiReferral/userCustomization":1,"apiReferral/rebate/historicalRecord":1,"apiReferral/kickback/historicalRecord":1,"broker/subAccount":1,"broker/subAccount/margin":1,"broker/subAccount/futures":1,"broker/subAccountApi":1,"broker/subAccountApi/permission":1,"broker/subAccountApi/commission":1,"broker/subAccountApi/commission/futures":1,"broker/subAccountApi/commission/coinFutures":1,"broker/transfer":1,"broker/transfer/futures":1,"broker/rebate/historicalRecord":1,"broker/subAccount/bnbBurn/spot":1,"broker/subAccount/bnbBurn/marginInterest":1,"broker/subAccount/blvt":1,"broker/subAccountApi/ipRestriction":1,"broker/subAccountApi/ipRestriction/ipList":1,"broker/universalTransfer":1,"broker/subAccountApi/permission/universalTransfer":1,"broker/subAccountApi/permission/vanillaOptions":1,"giftcard/createCode":.1,"giftcard/redeemCode":.1,"giftcard/buyCode":.1,"algo/spot/newOrderTwap":20.001,"algo/futures/newOrderVp":20.001,"algo/futures/newOrderTwap":20.001,"staking/purchase":.1,"staking/redeem":.1,"staking/setAutoStaking":.1,"eth-staking/eth/stake":15,"eth-staking/eth/redeem":15,"eth-staking/wbeth/wrap":15,"sol-staking/sol/stake":15,"sol-staking/sol/redeem":15,"mining/hash-transfer/config":.5,"mining/hash-transfer/config/cancel":.5,"portfolio/repay":20.001,"loan/vip/renew":40.002,"loan/vip/borrow":40.002,"loan/borrow":40.002,"loan/repay":40.002,"loan/adjust/ltv":40.002,"loan/customize/margin_call":40.002,"loan/flexible/repay":40.002,"loan/flexible/adjust/ltv":40.002,"loan/vip/repay":40.002,"convert/getQuote":1.3334,"convert/acceptQuote":3.3335,"convert/limit/placeOrder":3.3335,"convert/limit/cancelOrder":1.3334,"portfolio/auto-collection":150,"portfolio/asset-collection":6,"portfolio/bnb-transfer":150,"portfolio/repay-futures-switch":150,"portfolio/repay-futures-negative-balance":150,"portfolio/mint":20,"portfolio/redeem":20,"portfolio/earn-asset-transfer":150,"portfolio/delta-mode":150,"lending/auto-invest/plan/add":.1,"lending/auto-invest/plan/edit":.1,"lending/auto-invest/plan/edit-status":.1,"lending/auto-invest/one-off":.1,"lending/auto-invest/redeem":.1,"simple-earn/flexible/subscribe":.1,"simple-earn/locked/subscribe":.1,"simple-earn/flexible/redeem":.1,"simple-earn/locked/redeem":.1,"simple-earn/flexible/setAutoSubscribe":15,"simple-earn/locked/setAutoSubscribe":15,"simple-earn/locked/setRedeemOption":5,"dci/product/subscribe":.1,"dci/product/auto_compound/edit":.1},put:{userDataStream:.1,"userDataStream/isolated":.1},delete:{"margin/openOrders":.1,"margin/order":.006667,"margin/orderList":.006667,"margin/isolated/account":2.0001,userDataStream:.1,"userDataStream/isolated":.1,"broker/subAccountApi":1,"broker/subAccountApi/ipRestriction/ipList":1,"algo/spot/order":.1,"algo/futures/order":.1,"sub-account/subAccountApi/ipRestriction/ipList":20.001}},sapiV2:{get:{"eth-staking/account":15,"sub-account/futures/account":.1,"sub-account/futures/accountSummary":1,"sub-account/futures/positionRisk":.1,"loan/flexible/ongoing/orders":30,"loan/flexible/borrow/history":40,"loan/flexible/repay/history":40,"loan/flexible/ltv/adjustment/history":40,"loan/flexible/loanable/data":40,"loan/flexible/collateral/data":40,"portfolio/account":2},post:{"eth-staking/eth/stake":15,"sub-account/subAccountApi/ipRestriction":20.001,"loan/flexible/borrow":40.002,"loan/flexible/repay":40.002,"loan/flexible/adjust/ltv":40.002}},sapiV3:{get:{"sub-account/assets":.40002},post:{"asset/getUserAsset":.5}},sapiV4:{get:{"sub-account/assets":.40002}},dapiPublic:{get:{ping:1,time:1,exchangeInfo:1,depth:{cost:2,byLimit:[[50,2],[100,5],[500,10],[1e3,20]]},trades:5,historicalTrades:20,aggTrades:20,premiumIndex:10,fundingRate:1,klines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},continuousKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},indexPriceKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},markPriceKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},premiumIndexKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},"ticker/24hr":{cost:1,noSymbol:40},"ticker/price":{cost:1,noSymbol:2},"ticker/bookTicker":{cost:2,noSymbol:5},constituents:2,openInterest:1,fundingInfo:1}},dapiData:{get:{"delivery-price":1,openInterestHist:1,topLongShortAccountRatio:1,topLongShortPositionRatio:1,globalLongShortAccountRatio:1,takerBuySellVol:1,basis:1}},dapiPrivate:{get:{"positionSide/dual":30,orderAmendment:1,order:1,openOrder:1,openOrders:{cost:1,noSymbol:5},allOrders:{cost:20,noSymbol:40},balance:1,account:5,"positionMargin/history":1,positionRisk:1,userTrades:{cost:20,noSymbol:40},income:20,leverageBracket:1,forceOrders:{cost:20,noSymbol:50},adlQuantile:5,commissionRate:20,"income/asyn":5,"income/asyn/id":5,"trade/asyn":.5,"trade/asyn/id":.5,"order/asyn":.5,"order/asyn/id":.5,pmExchangeInfo:.5,pmAccountInfo:.5},post:{"positionSide/dual":1,order:4,batchOrders:5,countdownCancelAll:10,leverage:1,marginType:1,positionMargin:1,listenKey:1},put:{listenKey:1,order:1,batchOrders:5},delete:{order:1,allOpenOrders:1,batchOrders:5,listenKey:1}},dapiPrivateV2:{get:{leverageBracket:1}},fapiPublic:{get:{ping:1,time:1,exchangeInfo:1,depth:{cost:2,byLimit:[[50,2],[100,5],[500,10],[1e3,20]]},rpiDepth:20,trades:5,historicalTrades:20,aggTrades:20,klines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},continuousKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},markPriceKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},indexPriceKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},premiumIndexKlines:{cost:1,byLimit:[[99,1],[499,2],[1e3,5],[1e4,10]]},fundingRate:1,fundingInfo:1,premiumIndex:1,"ticker/24hr":{cost:1,noSymbol:40},"ticker/price":{cost:1,noSymbol:2},"ticker/bookTicker":{cost:1,noSymbol:2},openInterest:1,indexInfo:1,assetIndex:{cost:1,noSymbol:10},constituents:2,apiTradingStatus:{cost:1,noSymbol:10},lvtKlines:1,"convert/exchangeInfo":4,insuranceBalance:1,symbolAdlRisk:1,tradingSchedule:5}},fapiData:{get:{"delivery-price":1,openInterestHist:1,topLongShortAccountRatio:1,topLongShortPositionRatio:1,globalLongShortAccountRatio:1,takerlongshortRatio:1,basis:1}},fapiPrivate:{get:{forceOrders:{cost:20,noSymbol:50},allOrders:5,openOrder:1,openOrders:{cost:1,noSymbol:40},order:1,account:5,balance:5,leverageBracket:1,"positionMargin/history":1,positionRisk:5,"positionSide/dual":30,userTrades:5,income:30,commissionRate:20,"rateLimit/order":1,apiTradingStatus:1,multiAssetsMargin:30,"apiReferral/ifNewUser":1,"apiReferral/customization":1,"apiReferral/userCustomization":1,"apiReferral/traderNum":1,"apiReferral/overview":1,"apiReferral/tradeVol":1,"apiReferral/rebateVol":1,"apiReferral/traderSummary":1,adlQuantile:5,pmAccountInfo:5,orderAmendment:1,"income/asyn":1e3,"income/asyn/id":10,"order/asyn":1e3,"order/asyn/id":10,"trade/asyn":1e3,"trade/asyn/id":10,feeBurn:1,symbolConfig:5,accountConfig:5,"convert/orderStatus":5,algoOrder:1,openAlgoOrders:{cost:1,noSymbol:40},allAlgoOrders:5,"stock/contract":50},post:{batchOrders:5,"positionSide/dual":1,positionMargin:1,marginType:1,order:4,"order/test":1,leverage:1,listenKey:1,countdownCancelAll:10,multiAssetsMargin:1,"apiReferral/customization":1,"apiReferral/userCustomization":1,feeBurn:1,"convert/getQuote":200,"convert/acceptQuote":20,algoOrder:1},put:{listenKey:1,order:1,batchOrders:5},delete:{batchOrders:1,order:1,allOpenOrders:1,listenKey:1,algoOrder:1,algoOpenOrders:1}},fapiPublicV2:{get:{"ticker/price":0}},fapiPrivateV2:{get:{account:1,balance:1,positionRisk:1}},fapiPublicV3:{get:{}},fapiPrivateV3:{get:{account:1,balance:1,positionRisk:1}},eapiPublic:{get:{ping:1,time:1,exchangeInfo:1,index:1,ticker:5,mark:5,depth:1,klines:1,trades:5,historicalTrades:20,exerciseHistory:3,openInterest:3}},eapiPrivate:{get:{account:3,position:5,openOrders:{cost:1,noSymbol:40},historyOrders:3,userTrades:5,exerciseRecord:5,bill:1,"income/asyn":5,"income/asyn/id":5,marginAccount:3,mmp:1,countdownCancelAll:1,order:1,"block/order/orders":5,"block/order/execute":5,"block/user-trades":5,blockTrades:5,comission:5},post:{order:1,batchOrders:5,listenKey:1,mmpSet:1,mmpReset:1,countdownCancelAll:1,countdownCancelAllHeartBeat:10,"block/order/create":5,"block/order/execute":5},put:{listenKey:1,"block/order/create":5},delete:{order:1,batchOrders:1,allOpenOrders:1,allOpenOrdersByUnderlying:1,listenKey:1,"block/order/create":5}},public:{get:{ping:.2,time:.2,depth:{cost:1,byLimit:[[100,1],[500,5],[1e3,10],[5e3,50]]},trades:2,aggTrades:.4,historicalTrades:2,klines:.4,uiKlines:.4,"ticker/24hr":{cost:.4,noSymbol:16},ticker:{cost:.4,noSymbol:16},"ticker/tradingDay":.8,"ticker/price":{cost:.4,noSymbol:.8},"ticker/bookTicker":{cost:.4,noSymbol:.8},exchangeInfo:4,avgPrice:.4},put:{userDataStream:.4},post:{userDataStream:.4},delete:{userDataStream:.4}},private:{get:{allOrderList:4,openOrderList:1.2,orderList:.8,order:.8,openOrders:{cost:1.2,noSymbol:16},allOrders:4,account:4,myTrades:4,"rateLimit/order":8,myPreventedMatches:4,myAllocations:4,"account/commission":4},post:{"order/oco":.2,"orderList/oco":.2,"orderList/oto":.2,"orderList/otoco":.2,"orderList/opo":.2,"orderList/opoco":.2,"sor/order":.2,"sor/order/test":.2,order:.2,"order/cancelReplace":.2,"order/test":.2},delete:{openOrders:.2,orderList:.2,order:.2}},papi:{get:{ping:.2,"um/order":1,"um/openOrder":1,"um/openOrders":{cost:1,noSymbol:40},"um/allOrders":5,"cm/order":1,"cm/openOrder":1,"cm/openOrders":{cost:1,noSymbol:40},"cm/allOrders":20,"um/conditional/openOrder":1,"um/conditional/openOrders":{cost:1,noSymbol:40},"um/conditional/orderHistory":1,"um/conditional/allOrders":{cost:1,noSymbol:40},"cm/conditional/openOrder":1,"cm/conditional/openOrders":{cost:1,noSymbol:40},"cm/conditional/orderHistory":1,"cm/conditional/allOrders":40,"margin/order":10,"margin/openOrders":5,"margin/allOrders":100,"margin/orderList":5,"margin/allOrderList":100,"margin/openOrderList":5,"margin/myTrades":5,balance:4,account:4,"margin/maxBorrowable":1,"margin/maxWithdraw":1,"um/positionRisk":1,"cm/positionRisk":.2,"um/positionSide/dual":6,"cm/positionSide/dual":6,"um/userTrades":5,"cm/userTrades":20,"um/leverageBracket":.2,"cm/leverageBracket":.2,"margin/forceOrders":1,"um/forceOrders":{cost:20,noSymbol:50},"cm/forceOrders":{cost:20,noSymbol:50},"um/apiTradingStatus":{cost:.2,noSymbol:2},"um/commissionRate":4,"cm/commissionRate":4,"margin/marginLoan":2,"margin/repayLoan":2,"margin/marginInterestHistory":.2,"portfolio/interest-history":10,"um/income":6,"cm/income":6,"um/account":1,"cm/account":1,"repay-futures-switch":6,"um/adlQuantile":5,"cm/adlQuantile":5,"um/trade/asyn":300,"um/trade/asyn/id":2,"um/order/asyn":300,"um/order/asyn/id":2,"um/income/asyn":300,"um/income/asyn/id":2,"um/orderAmendment":1,"cm/orderAmendment":1,"um/feeBurn":30,"um/accountConfig":1,"um/symbolConfig":1,"cm/accountConfig":1,"cm/symbolConfig":1,"rateLimit/order":1},post:{"um/order":1,"um/conditional/order":1,"cm/order":1,"cm/conditional/order":1,"margin/order":1,marginLoan:100,repayLoan:100,"margin/order/oco":1,"um/leverage":.2,"cm/leverage":.2,"um/positionSide/dual":.2,"cm/positionSide/dual":.2,"auto-collection":150,"bnb-transfer":150,"repay-futures-switch":150,"repay-futures-negative-balance":150,listenKey:.2,"asset-collection":6,"margin/repay-debt":3e3,"um/feeBurn":1},put:{listenKey:.2,"um/order":1,"cm/order":1},delete:{"um/order":1,"um/conditional/order":1,"um/allOpenOrders":1,"um/conditional/allOpenOrders":1,"cm/order":1,"cm/conditional/order":1,"cm/allOpenOrders":1,"cm/conditional/allOpenOrders":1,"margin/order":2,"margin/allOpenOrders":5,"margin/orderList":2,listenKey:.2}},papiV2:{get:{"um/account":1}}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")},linear:{trading:{feeSide:"quote",tierBased:!0,percentage:!0,taker:this.parseNumber("0.000500"),maker:this.parseNumber("0.000200"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.000400")],[this.parseNumber("250"),this.parseNumber("0.000400")],[this.parseNumber("2500"),this.parseNumber("0.000350")],[this.parseNumber("7500"),this.parseNumber("0.000320")],[this.parseNumber("22500"),this.parseNumber("0.000300")],[this.parseNumber("50000"),this.parseNumber("0.000270")],[this.parseNumber("100000"),this.parseNumber("0.000250")],[this.parseNumber("200000"),this.parseNumber("0.000220")],[this.parseNumber("400000"),this.parseNumber("0.000200")],[this.parseNumber("750000"),this.parseNumber("0.000170")]],maker:[[this.parseNumber("0"),this.parseNumber("0.000200")],[this.parseNumber("250"),this.parseNumber("0.000160")],[this.parseNumber("2500"),this.parseNumber("0.000140")],[this.parseNumber("7500"),this.parseNumber("0.000120")],[this.parseNumber("22500"),this.parseNumber("0.000100")],[this.parseNumber("50000"),this.parseNumber("0.000080")],[this.parseNumber("100000"),this.parseNumber("0.000060")],[this.parseNumber("200000"),this.parseNumber("0.000040")],[this.parseNumber("400000"),this.parseNumber("0.000020")],[this.parseNumber("750000"),this.parseNumber("0")]]}}},inverse:{trading:{feeSide:"base",tierBased:!0,percentage:!0,taker:this.parseNumber("0.000500"),maker:this.parseNumber("0.000100"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.000500")],[this.parseNumber("250"),this.parseNumber("0.000450")],[this.parseNumber("2500"),this.parseNumber("0.000400")],[this.parseNumber("7500"),this.parseNumber("0.000300")],[this.parseNumber("22500"),this.parseNumber("0.000250")],[this.parseNumber("50000"),this.parseNumber("0.000240")],[this.parseNumber("100000"),this.parseNumber("0.000240")],[this.parseNumber("200000"),this.parseNumber("0.000240")],[this.parseNumber("400000"),this.parseNumber("0.000240")],[this.parseNumber("750000"),this.parseNumber("0.000240")]],maker:[[this.parseNumber("0"),this.parseNumber("0.000100")],[this.parseNumber("250"),this.parseNumber("0.000080")],[this.parseNumber("2500"),this.parseNumber("0.000050")],[this.parseNumber("7500"),this.parseNumber("0.0000030")],[this.parseNumber("22500"),this.parseNumber("0")],[this.parseNumber("50000"),this.parseNumber("-0.000050")],[this.parseNumber("100000"),this.parseNumber("-0.000060")],[this.parseNumber("200000"),this.parseNumber("-0.000070")],[this.parseNumber("400000"),this.parseNumber("-0.000080")],[this.parseNumber("750000"),this.parseNumber("-0.000090")]]}}},option:{}},currencies:{BNFCR:this.safeCurrencyStructure({id:"BNFCR",code:"BNFCR",precision:this.parseNumber("0.001")})},commonCurrencies:{BCC:"BCC",YOYO:"YOYOW"},precisionMode:o.kb,options:{sandboxMode:!1,fetchMargins:!0,fetchMarkets:{types:["spot","linear","inverse"]},loadAllOptions:!1,fetchCurrencies:!0,defaultTimeInForce:"GTC",defaultType:"spot",defaultSubType:void 0,hasAlreadyAuthenticatedSuccessfully:!1,warnOnFetchOpenOrdersWithoutSymbol:!0,currencyToPrecisionRoundingMode:o.R3,throwMarginModeAlreadySet:!1,fetchPositions:"positionRisk",recvWindow:1e4,timeDifference:0,adjustForTimeDifference:!1,newOrderRespType:{market:"FULL",limit:"FULL"},quoteOrderQty:!0,broker:{spot:"x-TKT5PX2F",margin:"x-TKT5PX2F",future:"x-cvBPrNm9",delivery:"x-xcKtGhcu",swap:"x-cvBPrNm9",option:"x-xcKtGhcu",inverse:"x-xcKtGhcu"},accountsByType:{main:"MAIN",spot:"MAIN",funding:"FUNDING",margin:"MARGIN",cross:"MARGIN",future:"UMFUTURE",delivery:"CMFUTURE",linear:"UMFUTURE",swap:"UMFUTURE",inverse:"CMFUTURE",option:"OPTION"},accountsById:{MAIN:"spot",FUNDING:"funding",MARGIN:"margin",UMFUTURE:"linear",CMFUTURE:"inverse",OPTION:"option"},networks:{ERC20:"ETH",TRC20:"TRX",BEP2:"BNB",BEP20:"BSC",OMNI:"OMNI",EOS:"EOS",SPL:"SOL",SOL:"SOL"},networksById:{SOL:"SOL"},impliedNetworks:{ETH:{ERC20:"ETH"},TRX:{TRC20:"TRX"}},legalMoney:{MXN:!0,UGX:!0,SEK:!0,CHF:!0,VND:!0,AED:!0,DKK:!0,KZT:!0,HUF:!0,PEN:!0,PHP:!0,USD:!0,TRY:!0,EUR:!0,NGN:!0,PLN:!0,BRL:!0,ZAR:!0,KES:!0,ARS:!0,RUB:!0,AUD:!0,NOK:!0,CZK:!0,GBP:!0,UAH:!0,GHS:!0,HKD:!0,CAD:!0,INR:!0,JPY:!0,NZD:!0},legalMoneyCurrenciesById:{BUSD:"USD"},defaultWithdrawPrecision:1e-8},features:{spot:{sandbox:!0,fetchCurrencies:{private:!0},createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!0,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:{EXPIRE_MAKER:!0,EXPIRE_TAKER:!0,EXPIRE_BOTH:!0,NONE:!0},trailing:!1,icebergAmount:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:void 0,untilDays:1,symbolRequired:!0},fetchOrder:{marginMode:!0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:1e3,daysBack:void 0,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!0,limit:1e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1e3}},forDerivatives:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{mark:!0,last:!0,index:!1},stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!0,selfTradePrevention:!0,trailing:!0,iceberg:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!0},createOrders:{max:5},fetchMyTrades:{marginMode:!1,daysBack:void 0,limit:1e3,untilDays:7,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,limit:500,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:1e3,daysBack:90,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!0,limit:1e3,daysBack:90,daysBackCanceled:3,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1500}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}}},exceptions:{spot:{exact:{"-1004":r.OperationFailed,"-1008":r.OperationFailed,"-1099":r.AuthenticationError,"-1108":r.BadRequest,"-1131":r.BadRequest,"-1134":r.BadRequest,"-1135":r.BadRequest,"-1145":r.BadRequest,"-1151":r.BadSymbol,"-2008":r.AuthenticationError,"-2016":r.OperationRejected,"-2021":r.BadResponse,"-2022":r.BadResponse,"-2026":r.InvalidOrder,"-3000":r.OperationFailed,"-3001":r.AuthenticationError,"-3002":r.BadSymbol,"-3003":r.BadRequest,"-3004":r.OperationRejected,"-3005":r.BadRequest,"-3006":r.BadRequest,"-3007":r.OperationFailed,"-3008":r.BadRequest,"-3009":r.OperationRejected,"-3010":r.BadRequest,"-3011":r.BadRequest,"-3012":r.OperationRejected,"-3013":r.BadRequest,"-3014":r.AccountSuspended,"-3015":r.BadRequest,"-3016":r.BadRequest,"-3017":r.OperationRejected,"-3018":r.AccountSuspended,"-3019":r.AccountSuspended,"-3020":r.BadRequest,"-3021":r.BadRequest,"-3022":r.AccountSuspended,"-3023":r.OperationRejected,"-3024":r.OperationRejected,"-3025":r.BadRequest,"-3026":r.BadRequest,"-3027":r.BadSymbol,"-3028":r.BadSymbol,"-3029":r.OperationFailed,"-3036":r.AccountSuspended,"-3037":r.OperationFailed,"-3038":r.BadRequest,"-3041":r.InsufficientFunds,"-3042":r.BadRequest,"-3043":r.PermissionDenied,"-3044":r.OperationFailed,"-3045":r.OperationRejected,"-3999":r.PermissionDenied,"-4000":r.ExchangeError,"-4001":r.BadRequest,"-4002":r.BadRequest,"-4003":r.BadRequest,"-4004":r.AuthenticationError,"-4005":r.RateLimitExceeded,"-4006":r.BadRequest,"-4007":r.PermissionDenied,"-4008":r.PermissionDenied,"-4009":r.ExchangeError,"-4010":r.PermissionDenied,"-4011":r.BadRequest,"-4012":r.PermissionDenied,"-4013":r.AuthenticationError,"-4014":r.OperationRejected,"-4015":r.PermissionDenied,"-4016":r.PermissionDenied,"-4017":r.PermissionDenied,"-4018":r.BadSymbol,"-4019":r.BadRequest,"-4020":r.ExchangeError,"-4021":r.BadRequest,"-4022":r.BadRequest,"-4023":r.OperationRejected,"-4024":r.InsufficientFunds,"-4025":r.InsufficientFunds,"-4026":r.InsufficientFunds,"-4027":r.OperationFailed,"-4028":r.BadRequest,"-4029":r.BadRequest,"-4030":r.BadResponse,"-4031":r.OperationFailed,"-4032":r.OperationRejected,"-4033":r.BadRequest,"-4034":r.OperationRejected,"-4035":r.PermissionDenied,"-4036":r.PermissionDenied,"-4037":r.OperationFailed,"-4038":r.OperationFailed,"-4039":r.PermissionDenied,"-4040":r.OperationRejected,"-4041":r.OperationFailed,"-4042":r.OperationRejected,"-4043":r.OperationRejected,"-4044":r.PermissionDenied,"-4045":r.OperationFailed,"-4046":r.AuthenticationError,"-4047":r.BadRequest,"-4048":r.ExchangeError,"-4049":r.ExchangeError,"-4050":r.ExchangeError,"-4051":r.ExchangeError,"-4052":r.ExchangeError,"-4053":r.ExchangeError,"-4054":r.ExchangeError,"-4055":r.ExchangeError,"-4056":r.ExchangeError,"-4057":r.ExchangeError,"-4058":r.ExchangeError,"-4059":r.ExchangeError,"-4060":r.OperationFailed,"-4061":r.ExchangeError,"-4062":r.ExchangeError,"-4063":r.ExchangeError,"-4064":r.ExchangeError,"-4065":r.ExchangeError,"-4066":r.ExchangeError,"-4067":r.ExchangeError,"-4068":r.ExchangeError,"-4069":r.ExchangeError,"-4070":r.ExchangeError,"-4071":r.ExchangeError,"-4072":r.ExchangeError,"-4073":r.ExchangeError,"-4074":r.ExchangeError,"-4075":r.ExchangeError,"-4076":r.ExchangeError,"-4077":r.ExchangeError,"-4078":r.ExchangeError,"-4079":r.ExchangeError,"-4080":r.ExchangeError,"-4081":r.ExchangeError,"-4082":r.ExchangeError,"-4083":r.ExchangeError,"-4084":r.ExchangeError,"-4085":r.ExchangeError,"-4086":r.ExchangeError,"-4087":r.ExchangeError,"-4088":r.ExchangeError,"-4089":r.ExchangeError,"-4091":r.ExchangeError,"-4092":r.ExchangeError,"-4093":r.ExchangeError,"-4094":r.ExchangeError,"-4095":r.ExchangeError,"-4096":r.ExchangeError,"-4097":r.ExchangeError,"-4098":r.ExchangeError,"-4099":r.ExchangeError,"-4101":r.ExchangeError,"-4102":r.ExchangeError,"-4103":r.ExchangeError,"-4104":r.ExchangeError,"-4105":r.ExchangeError,"-4106":r.ExchangeError,"-4107":r.ExchangeError,"-4108":r.ExchangeError,"-4109":r.ExchangeError,"-4110":r.ExchangeError,"-4112":r.ExchangeError,"-4113":r.ExchangeError,"-4114":r.ExchangeError,"-4115":r.ExchangeError,"-4116":r.ExchangeError,"-4117":r.ExchangeError,"-4118":r.ExchangeError,"-4119":r.ExchangeError,"-4120":r.ExchangeError,"-4121":r.ExchangeError,"-4122":r.ExchangeError,"-4123":r.ExchangeError,"-4124":r.ExchangeError,"-4125":r.ExchangeError,"-4126":r.ExchangeError,"-4127":r.ExchangeError,"-4128":r.ExchangeError,"-4129":r.ExchangeError,"-4130":r.ExchangeError,"-4131":r.ExchangeError,"-4132":r.ExchangeError,"-4133":r.ExchangeError,"-4134":r.ExchangeError,"-4135":r.ExchangeError,"-4136":r.ExchangeError,"-4137":r.ExchangeError,"-4138":r.ExchangeError,"-4139":r.ExchangeError,"-4141":r.ExchangeError,"-4142":r.ExchangeError,"-4143":r.ExchangeError,"-4144":r.ExchangeError,"-4145":r.ExchangeError,"-4146":r.ExchangeError,"-4147":r.ExchangeError,"-4148":r.ExchangeError,"-4149":r.ExchangeError,"-4150":r.ExchangeError,"-5001":r.BadRequest,"-5002":r.InsufficientFunds,"-5003":r.InsufficientFunds,"-5004":r.OperationRejected,"-5005":r.OperationRejected,"-5006":r.OperationRejected,"-5007":r.BadRequest,"-5008":r.OperationRejected,"-5009":r.BadSymbol,"-5010":r.OperationFailed,"-5011":r.BadRequest,"-5012":r.OperationFailed,"-5013":r.InsufficientFunds,"-5021":r.BadRequest,"-5022":r.BadRequest,"-6001":r.BadSymbol,"-6003":r.PermissionDenied,"-6004":r.BadRequest,"-6005":r.BadRequest,"-6006":r.BadRequest,"-6007":r.OperationRejected,"-6008":r.OperationRejected,"-6009":r.RateLimitExceeded,"-6011":r.OperationRejected,"-6012":r.InsufficientFunds,"-6013":r.BadResponse,"-6014":r.OperationRejected,"-6015":r.BadRequest,"-6016":r.BadRequest,"-6017":r.PermissionDenied,"-6018":r.InsufficientFunds,"-6019":r.OperationRejected,"-6020":r.BadRequest,"-7001":r.BadRequest,"-7002":r.BadRequest,"-10001":r.OperationFailed,"-10002":r.BadRequest,"-10005":r.BadResponse,"-10007":r.BadRequest,"-10008":r.BadRequest,"-10009":r.BadRequest,"-10010":r.BadRequest,"-10011":r.InsufficientFunds,"-10012":r.BadRequest,"-10013":r.InsufficientFunds,"-10015":r.OperationFailed,"-10016":r.OperationFailed,"-10017":r.OperationRejected,"-10018":r.BadRequest,"-10019":r.BadRequest,"-10020":r.BadRequest,"-10021":r.InvalidOrder,"-10022":r.BadRequest,"-10023":r.OperationFailed,"-10024":r.BadRequest,"-10025":r.OperationFailed,"-10026":r.BadRequest,"-10028":r.BadRequest,"-10029":r.OperationRejected,"-10030":r.OperationRejected,"-10031":r.OperationRejected,"-10032":r.OperationFailed,"-10034":r.OperationRejected,"-10039":r.OperationRejected,"-10040":r.OperationRejected,"-10041":r.OperationFailed,"-10042":r.BadSymbol,"-10043":r.OperationRejected,"-10044":r.OperationRejected,"-10045":r.OperationRejected,"-10046":r.OperationRejected,"-10047":r.PermissionDenied,"-11008":r.OperationRejected,"-12014":r.RateLimitExceeded,"-13000":r.OperationRejected,"-13001":r.OperationRejected,"-13002":r.OperationRejected,"-13003":r.PermissionDenied,"-13004":r.OperationRejected,"-13005":r.OperationRejected,"-13006":r.OperationRejected,"-13007":r.PermissionDenied,"-18002":r.OperationRejected,"-18003":r.OperationRejected,"-18004":r.OperationRejected,"-18005":r.PermissionDenied,"-18006":r.OperationRejected,"-18007":r.OperationRejected,"-21001":r.BadRequest,"-21002":r.BadRequest,"-21003":r.BadResponse,"-21004":r.OperationRejected,"-21005":r.InsufficientFunds,"-21006":r.OperationFailed,"-21007":r.OperationFailed,"-32603":r.BadRequest,400002:r.BadRequest,100001003:r.AuthenticationError,200003903:r.AuthenticationError}},linear:{exact:{"-1005":r.PermissionDenied,"-1008":r.OperationFailed,"-1011":r.PermissionDenied,"-1023":r.BadRequest,"-1099":r.AuthenticationError,"-1109":r.PermissionDenied,"-1110":r.BadRequest,"-1113":r.BadRequest,"-1122":r.BadRequest,"-1126":r.BadSymbol,"-1136":r.BadRequest,"-2012":r.OperationFailed,"-2016":r.OperationRejected,"-2017":r.PermissionDenied,"-2018":r.InsufficientFunds,"-2019":r.InsufficientFunds,"-2020":r.OperationFailed,"-2021":r.OrderImmediatelyFillable,"-2022":r.InvalidOrder,"-2023":r.OperationFailed,"-2024":r.InsufficientFunds,"-2025":r.OperationRejected,"-2026":r.InvalidOrder,"-2027":r.OperationRejected,"-2028":r.OperationRejected,"-4063":r.BadRequest,"-4064":r.BadRequest,"-4065":r.BadRequest,"-4066":r.BadRequest,"-4069":r.BadRequest,"-4070":r.BadRequest,"-4071":r.BadRequest,"-4072":r.OperationRejected,"-4073":r.BadRequest,"-4074":r.OperationRejected,"-4075":r.BadRequest,"-4076":r.OperationRejected,"-4077":r.OperationRejected,"-4078":r.OperationFailed,"-4079":r.BadRequest,"-4080":r.PermissionDenied,"-4081":r.BadRequest,"-4085":r.BadRequest,"-4087":r.PermissionDenied,"-4088":r.PermissionDenied,"-4114":r.BadRequest,"-4115":r.BadRequest,"-4116":r.InvalidOrder,"-4117":r.OperationRejected,"-4118":r.OperationRejected,"-4131":r.OperationRejected,"-4140":r.BadRequest,"-4141":r.OperationRejected,"-4144":r.BadSymbol,"-4164":r.InvalidOrder,"-4136":r.InvalidOrder,"-4165":r.BadRequest,"-4167":r.BadRequest,"-4168":r.BadRequest,"-4169":r.OperationRejected,"-4170":r.OperationRejected,"-4171":r.OperationRejected,"-4172":r.OperationRejected,"-4183":r.BadRequest,"-4184":r.BadRequest,"-4192":r.PermissionDenied,"-4202":r.PermissionDenied,"-4203":r.PermissionDenied,"-4205":r.PermissionDenied,"-4206":r.PermissionDenied,"-4208":r.OperationRejected,"-4209":r.OperationRejected,"-4210":r.BadRequest,"-4211":r.BadRequest,"-4400":r.PermissionDenied,"-4401":r.PermissionDenied,"-4402":r.PermissionDenied,"-4403":r.PermissionDenied,"-5021":r.OrderNotFillable,"-5022":r.OrderNotFillable,"-5024":r.OperationRejected,"-5025":r.OperationRejected,"-5026":r.OperationRejected,"-5027":r.OperationRejected,"-5028":r.BadRequest,"-5037":r.BadRequest,"-5038":r.BadRequest,"-5039":r.BadRequest,"-5040":r.BadRequest,"-5041":r.OperationFailed}},inverse:{exact:{"-1005":r.PermissionDenied,"-1011":r.PermissionDenied,"-1023":r.BadRequest,"-1109":r.AuthenticationError,"-1110":r.BadSymbol,"-1113":r.BadRequest,"-1128":r.BadRequest,"-1136":r.BadRequest,"-2016":r.OperationRejected,"-2018":r.InsufficientFunds,"-2019":r.InsufficientFunds,"-2020":r.OperationFailed,"-2021":r.OrderImmediatelyFillable,"-2022":r.InvalidOrder,"-2023":r.OperationFailed,"-2024":r.BadRequest,"-2025":r.OperationRejected,"-2026":r.InvalidOrder,"-2027":r.OperationRejected,"-2028":r.OperationRejected,"-4086":r.BadRequest,"-4087":r.BadSymbol,"-4088":r.BadRequest,"-4089":r.PermissionDenied,"-4090":r.PermissionDenied,"-4110":r.BadRequest,"-4111":r.BadRequest,"-4112":r.OperationRejected,"-4113":r.OperationRejected,"-4150":r.OperationRejected,"-4151":r.BadRequest,"-4152":r.BadRequest,"-4154":r.BadRequest,"-4155":r.BadRequest,"-4178":r.BadRequest,"-4188":r.BadRequest,"-4192":r.PermissionDenied,"-4194":r.PermissionDenied,"-4195":r.PermissionDenied,"-4196":r.BadRequest,"-4197":r.OperationRejected,"-4198":r.OperationRejected,"-4199":r.BadRequest,"-4200":r.PermissionDenied,"-4201":r.PermissionDenied,"-4202":r.OperationRejected}},option:{exact:{"-1003":r.ExchangeError,"-1004":r.ExchangeError,"-1006":r.ExchangeError,"-1007":r.ExchangeError,"-1008":r.RateLimitExceeded,"-1010":r.ExchangeError,"-1013":r.ExchangeError,"-1108":r.ExchangeError,"-1112":r.ExchangeError,"-1114":r.ExchangeError,"-1128":r.BadSymbol,"-1129":r.BadSymbol,"-1131":r.BadRequest,"-2011":r.ExchangeError,"-2018":r.InsufficientFunds,"-2027":r.InsufficientFunds,"-3029":r.OperationFailed,"-4006":r.ExchangeError,"-4007":r.ExchangeError,"-4008":r.ExchangeError,"-4009":r.ExchangeError,"-4010":r.ExchangeError,"-4011":r.ExchangeError,"-4012":r.ExchangeError,"-4014":r.ExchangeError,"-4015":r.ExchangeError,"-4016":r.ExchangeError,"-4017":r.ExchangeError,"-4018":r.ExchangeError,"-4019":r.ExchangeError,"-4020":r.ExchangeError,"-4021":r.ExchangeError,"-4022":r.ExchangeError,"-4023":r.ExchangeError,"-4024":r.ExchangeError,"-4025":r.ExchangeError,"-4026":r.ExchangeError,"-4027":r.ExchangeError,"-4028":r.ExchangeError,"-4031":r.ExchangeError,"-4032":r.ExchangeError,"-4033":r.ExchangeError,"-4034":r.ExchangeError,"-4035":r.ExchangeError,"-4036":r.ExchangeError,"-4037":r.ExchangeError,"-4038":r.ExchangeError,"-4039":r.ExchangeError,"-4040":r.ExchangeError,"-4041":r.ExchangeError,"-4042":r.ExchangeError,"-4043":r.ExchangeError,"-4044":r.ExchangeError,"-4045":r.ExchangeError,"-4046":r.ExchangeError,"-4047":r.ExchangeError,"-4048":r.ExchangeError,"-4049":r.ExchangeError,"-4050":r.ExchangeError,"-4051":r.ExchangeError,"-4052":r.ExchangeError,"-4053":r.ExchangeError,"-4054":r.ExchangeError,"-4056":r.ExchangeError,"-4057":r.ExchangeError,"-4058":r.ExchangeError,"-4059":r.ExchangeError,"-4060":r.ExchangeError,"-4061":r.ExchangeError,"-4062":r.ExchangeError,"-4063":r.ExchangeError,"-4064":r.ExchangeError,"-4065":r.ExchangeError,"-4066":r.ExchangeError,"-4067":r.ExchangeError,"-4068":r.ExchangeError,"-4069":r.ExchangeError,"-4070":r.ExchangeError,"-4071":r.ExchangeError,"-4072":r.ExchangeError,"-4073":r.ExchangeError,"-4074":r.ExchangeError,"-4075":r.ExchangeError,"-4076":r.ExchangeError,"-4077":r.ExchangeError,"-4078":r.ExchangeError,"-4079":r.ExchangeError,"-4080":r.ExchangeError,"-4081":r.ExchangeError,"-4082":r.ExchangeError,"-4083":r.ExchangeError,"-4084":r.ExchangeError,"-4085":r.ExchangeError,"-4086":r.ExchangeError,"-4087":r.ExchangeError,"-4088":r.ExchangeError,"-4089":r.ExchangeError,"-4091":r.ExchangeError,"-4092":r.ExchangeError,"-4093":r.ExchangeError,"-4094":r.ExchangeError,"-4095":r.ExchangeError,"-4096":r.ExchangeError,"-4097":r.ExchangeError,"-4098":r.ExchangeError,"-4099":r.ExchangeError,"-4101":r.ExchangeError,"-4102":r.ExchangeError,"-4103":r.ExchangeError,"-4104":r.ExchangeError,"-4105":r.ExchangeError,"-4106":r.ExchangeError,"-4107":r.ExchangeError,"-4108":r.ExchangeError,"-4109":r.ExchangeError,"-4110":r.ExchangeError,"-4112":r.ExchangeError,"-4113":r.ExchangeError,"-4114":r.ExchangeError,"-4115":r.ExchangeError,"-4116":r.ExchangeError,"-4117":r.ExchangeError,"-4118":r.ExchangeError,"-4119":r.ExchangeError,"-4120":r.ExchangeError,"-4121":r.ExchangeError,"-4122":r.ExchangeError,"-4123":r.ExchangeError,"-4124":r.ExchangeError,"-4125":r.ExchangeError,"-4126":r.ExchangeError,"-4127":r.ExchangeError,"-4128":r.ExchangeError,"-4129":r.ExchangeError,"-4130":r.ExchangeError,"-4131":r.ExchangeError,"-4132":r.ExchangeError,"-4133":r.ExchangeError,"-4134":r.ExchangeError,"-4135":r.ExchangeError,"-4136":r.ExchangeError,"-4137":r.ExchangeError,"-4138":r.ExchangeError,"-4139":r.ExchangeError,"-4141":r.ExchangeError,"-4142":r.ExchangeError,"-4143":r.ExchangeError,"-4144":r.ExchangeError,"-4145":r.ExchangeError,"-4146":r.ExchangeError,"-4147":r.ExchangeError,"-4148":r.ExchangeError,"-4149":r.ExchangeError,"-4150":r.ExchangeError,"-20121":r.ExchangeError,"-20124":r.ExchangeError,"-20130":r.ExchangeError,"-20132":r.ExchangeError,"-20194":r.ExchangeError,"-20195":r.ExchangeError,"-20196":r.ExchangeError,"-20198":r.ExchangeError,"-20204":r.ExchangeError}},portfolioMargin:{exact:{"-1000":r.OperationFailed,"-1001":r.ExchangeError,"-1002":r.PermissionDenied,"-1003":r.RateLimitExceeded,"-1004":r.BadRequest,"-1005":r.PermissionDenied,"-1006":r.BadResponse,"-1007":r.BadResponse,"-1008":r.OperationFailed,"-1010":r.ExchangeError,"-1011":r.PermissionDenied,"-1013":r.ExchangeError,"-1014":r.InvalidOrder,"-1015":r.InvalidOrder,"-1016":r.NotSupported,"-1020":r.NotSupported,"-1021":r.BadRequest,"-1022":r.BadRequest,"-1023":r.BadRequest,"-1099":r.OperationFailed,"-1100":r.BadRequest,"-1101":r.BadRequest,"-1102":r.BadRequest,"-1103":r.BadRequest,"-1104":r.BadRequest,"-1105":r.BadRequest,"-1106":r.BadRequest,"-1108":r.BadRequest,"-1109":r.BadRequest,"-1110":r.BadSymbol,"-1111":r.BadRequest,"-1112":r.BadRequest,"-1113":r.BadRequest,"-1114":r.BadRequest,"-1115":r.BadRequest,"-1116":r.BadRequest,"-1117":r.BadRequest,"-1118":r.BadRequest,"-1119":r.BadRequest,"-1120":r.BadRequest,"-1121":r.BadSymbol,"-1125":r.BadRequest,"-1127":r.BadRequest,"-1128":r.BadRequest,"-1130":r.BadRequest,"-1131":r.BadRequest,"-1134":r.BadRequest,"-1136":r.BadRequest,"-1145":r.BadRequest,"-1151":r.BadRequest,"-2010":r.InvalidOrder,"-2011":r.OperationRejected,"-2013":r.OrderNotFound,"-2014":r.OperationRejected,"-2015":r.OperationRejected,"-2016":r.OperationFailed,"-2018":r.OperationFailed,"-2019":r.OperationFailed,"-2020":r.OrderNotFillable,"-2021":r.OrderImmediatelyFillable,"-2022":r.InvalidOrder,"-2023":r.OperationFailed,"-2024":r.OperationRejected,"-2025":r.OperationRejected,"-2026":r.InvalidOrder,"-2027":r.OperationRejected,"-2028":r.OperationRejected,"-4000":r.BadRequest,"-4001":r.BadRequest,"-4002":r.BadRequest,"-4003":r.BadRequest,"-4004":r.BadRequest,"-4005":r.BadRequest,"-4006":r.BadRequest,"-4007":r.BadRequest,"-4008":r.BadRequest,"-4009":r.BadRequest,"-4010":r.BadRequest,"-4011":r.BadRequest,"-4012":r.BadRequest,"-4013":r.BadRequest,"-4014":r.BadRequest,"-4015":r.BadRequest,"-4016":r.BadRequest,"-4017":r.BadRequest,"-4018":r.BadRequest,"-4019":r.BadRequest,"-4020":r.BadRequest,"-4021":r.BadRequest,"-4022":r.BadRequest,"-4023":r.BadRequest,"-4024":r.BadRequest,"-4025":r.BadRequest,"-4026":r.BadRequest,"-4027":r.BadRequest,"-4028":r.BadRequest,"-4029":r.BadRequest,"-4030":r.BadRequest,"-4031":r.BadRequest,"-4032":r.BadRequest,"-4033":r.BadRequest,"-4044":r.BadRequest,"-4045":r.BadRequest,"-4046":r.BadRequest,"-4047":r.BadRequest,"-4048":r.BadRequest,"-4049":r.BadRequest,"-4050":r.BadRequest,"-4051":r.BadRequest,"-4052":r.BadRequest,"-4053":r.BadRequest,"-4054":r.BadRequest,"-4055":r.BadRequest,"-4056":r.PermissionDenied,"-4057":r.PermissionDenied,"-4058":r.BadRequest,"-4059":r.BadRequest,"-4060":r.BadRequest,"-4061":r.InvalidOrder,"-4062":r.BadRequest,"-4063":r.BadRequest,"-4064":r.BadRequest,"-4065":r.BadRequest,"-4066":r.BadRequest,"-4067":r.BadRequest,"-4068":r.BadRequest,"-4069":r.BadRequest,"-4070":r.BadRequest,"-4071":r.BadRequest,"-4072":r.OperationRejected,"-4073":r.BadRequest,"-4074":r.BadRequest,"-4075":r.BadRequest,"-4076":r.OperationRejected,"-4077":r.OperationRejected,"-4078":r.OperationFailed,"-4079":r.BadRequest,"-4080":r.PermissionDenied,"-4081":r.BadRequest,"-4082":r.BadRequest,"-4083":r.BadRequest,"-4084":r.NotSupported,"-4085":r.BadRequest,"-4086":r.BadRequest,"-4087":r.PermissionDenied,"-4088":r.PermissionDenied,"-4104":r.BadRequest,"-4114":r.BadRequest,"-4115":r.BadRequest,"-4118":r.OperationRejected,"-4131":r.OperationRejected,"-4135":r.BadRequest,"-4137":r.BadRequest,"-4138":r.BadRequest,"-4139":r.BadRequest,"-4140":r.OrderImmediatelyFillable,"-4141":r.BadRequest,"-4142":r.OrderImmediatelyFillable,"-4144":r.BadSymbol,"-4161":r.OperationRejected,"-4164":r.InvalidOrder,"-4165":r.BadRequest,"-4183":r.InvalidOrder,"-4184":r.InvalidOrder,"-4408":r.InvalidOrder,"-5021":r.OrderNotFillable,"-5022":r.OrderNotFillable,"-5028":r.OperationFailed,"-5041":r.RateLimitExceeded}},exact:{"-1000":r.OperationFailed,"-1001":r.OperationFailed,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.OperationRejected,"-1006":r.OperationFailed,"-1007":r.RequestTimeout,"-1010":r.OperationFailed,"-1013":r.BadRequest,"-1014":r.InvalidOrder,"-1015":r.RateLimitExceeded,"-1016":r.BadRequest,"-1020":r.BadRequest,"-1021":r.InvalidNonce,"-1022":r.AuthenticationError,"-1100":r.BadRequest,"-1101":r.BadRequest,"-1102":r.BadRequest,"-1103":r.BadRequest,"-1104":r.BadRequest,"-1105":r.BadRequest,"-1106":r.BadRequest,"-1108":r.BadSymbol,"-1111":r.BadRequest,"-1112":r.OperationFailed,"-1114":r.BadRequest,"-1115":r.BadRequest,"-1116":r.BadRequest,"-1117":r.BadRequest,"-1118":r.BadRequest,"-1119":r.BadRequest,"-1120":r.BadRequest,"-1121":r.BadSymbol,"-1125":r.AuthenticationError,"-1127":r.BadRequest,"-1128":r.BadRequest,"-1130":r.BadRequest,"-2010":r.InvalidOrder,"-2011":r.OrderNotFound,"-2013":r.OrderNotFound,"-2014":r.AuthenticationError,"-2015":r.AuthenticationError,"-4000":r.InvalidOrder,"-4001":r.BadRequest,"-4002":r.BadRequest,"-4003":r.BadRequest,"-4004":r.BadRequest,"-4005":r.BadRequest,"-4006":r.BadRequest,"-4007":r.BadRequest,"-4008":r.BadRequest,"-4009":r.BadRequest,"-4010":r.BadRequest,"-4011":r.BadRequest,"-4012":r.BadRequest,"-4013":r.BadRequest,"-4014":r.BadRequest,"-4015":r.BadRequest,"-4016":r.BadRequest,"-4017":r.BadRequest,"-4018":r.BadRequest,"-4019":r.OperationRejected,"-4020":r.BadRequest,"-4021":r.BadRequest,"-4022":r.BadRequest,"-4023":r.BadRequest,"-4024":r.BadRequest,"-4025":r.BadRequest,"-4026":r.BadRequest,"-4027":r.BadRequest,"-4028":r.BadRequest,"-4029":r.BadRequest,"-4030":r.BadRequest,"-4031":r.BadRequest,"-4032":r.OperationRejected,"-4033":r.BadRequest,"-4044":r.BadRequest,"-4045":r.OperationRejected,"-4046":r.OperationRejected,"-4047":r.OperationRejected,"-4048":r.OperationRejected,"-4049":r.BadRequest,"-4050":r.InsufficientFunds,"-4051":r.InsufficientFunds,"-4052":r.OperationRejected,"-4053":r.BadRequest,"-4054":r.OperationRejected,"-4055":r.BadRequest,"-4056":r.AuthenticationError,"-4057":r.AuthenticationError,"-4058":r.BadRequest,"-4059":r.OperationRejected,"-4060":r.BadRequest,"-4061":r.OperationRejected,"-4062":r.BadRequest,"-4067":r.OperationRejected,"-4068":r.OperationRejected,"-4082":r.BadRequest,"-4083":r.OperationRejected,"-4084":r.BadRequest,"-4086":r.BadRequest,"-4104":r.BadRequest,"-4135":r.BadRequest,"-4137":r.BadRequest,"-4138":r.BadRequest,"-4139":r.BadRequest,"-4142":r.OrderImmediatelyFillable,"-20121":r.BadSymbol,"-20124":r.BadRequest,"-20130":r.BadRequest,"-20132":r.BadRequest,"-20194":r.BadRequest,"-20195":r.BadRequest,"-20196":r.BadRequest,"-20198":r.OperationRejected,"-20204":r.BadRequest,"System is under maintenance.":r.OnMaintenance,"System abnormality":r.OperationFailed,"You are not authorized to execute this request.":r.PermissionDenied,"API key does not exist":r.AuthenticationError,"Order would trigger immediately.":r.OrderImmediatelyFillable,"Stop price would trigger immediately.":r.OrderImmediatelyFillable,"Order would immediately match and take.":r.OrderImmediatelyFillable,"Account has insufficient balance for requested action.":r.InsufficientFunds,"Rest API trading is not enabled.":r.PermissionDenied,"This account may not place or cancel orders.":r.PermissionDenied,"You don't have permission.":r.PermissionDenied,"Market is closed.":r.MarketClosed,"Too many requests. Please try again later.":r.RateLimitExceeded,"This action is disabled on this account.":r.AccountSuspended,"Limit orders require GTC for this phase.":r.BadRequest,"This order type is not possible in this trading phase.":r.BadRequest,"This type of sub-account exceeds the maximum number limit":r.OperationRejected,"This symbol is restricted for this account.":r.PermissionDenied,"This symbol is not permitted for this account.":r.PermissionDenied},broad:{"has no operation privilege":r.PermissionDenied,MAX_POSITION:r.BadRequest,PERCENT_PRICE_BY_SIDE:r.InvalidOrder}},rollingWindowSize:6e4})}isInverse(e,t=void 0){return void 0===t?"delivery"===e:"inverse"===t}isLinear(e,t=void 0){return void 0===t?"future"===e||"swap"===e:"linear"===t}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}createExpiredOptionMarket(e){const t="USDT",i=e.split("-"),s=e.split("/");let r;r=e.indexOf("/")>-1?this.safeString(s,0):this.safeString(i,0);const a=this.safeString(i,1),o=this.safeInteger(i,2),n=this.safeString(i,2),d=this.safeString(i,3),c=this.convertExpireDate(a);return{id:r+"-"+a+"-"+n+"-"+d,symbol:r+"/"+t+":"+t+"-"+a+"-"+n+"-"+d,base:r,quote:t,baseId:r,quoteId:t,active:void 0,type:"option",linear:void 0,inverse:void 0,spot:!1,swap:!1,future:!1,option:!0,margin:!1,contract:!0,contractSize:void 0,expiry:this.parse8601(c),expiryDatetime:c,optionType:"C"===d?"call":"put",strike:o,settle:t,settleId:t,precision:{amount:void 0,price:void 0},limits:{amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:void 0}}market(e){if(void 0===this.markets)throw new r.ExchangeError(this.id+" markets not loaded");let t=this.safeString(this.options,"defaultType");const i=this.safeString(this.options,"defaultSubType"),s="future"===t,a="delivery"===t,o=s||a;if("string"==typeof e)if(e in this.markets){const t=this.markets[e];if(!o||!t.spot)return t;{const i=e+":"+(s?t.quote:t.base);if(i in this.markets)return this.markets[i]}}else{if(e in this.markets_by_id){const r=this.markets_by_id[e];s?t="linear":a?t="inverse":void 0===t&&(t=i);for(let e=0;e-1&&e.indexOf(":")<0){if(void 0!==t&&"spot"!==t){const[t,i]=e.split("/"),s=e+":"+("USD"===i?t:i);if(s in this.markets)return this.markets[s]}}else if(e.indexOf("-C")>-1||e.indexOf("-P")>-1)return this.createExpiredOptionMarket(e)}throw new r.BadSymbol(this.id+" does not have market symbol "+e)}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return void 0!==e&&(e.indexOf("-C")>-1||e.indexOf("-P")>-1)&&!(e in this.markets_by_id)?this.createExpiredOptionMarket(e):super.safeMarket(e,t,i,s)}costToPrecision(e,t){return this.decimalToPrecision(t,o.R3,this.markets[e].precision.quote,this.precisionMode,this.paddingMode)}nonce(){return this.milliseconds()-this.options.timeDifference}enableDemoTrading(e){if(this.isSandboxModeEnabled)throw new r.NotSupported(this.id+" demo trading is not supported in the sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences");if(e)this.urls.apiBackupDemoTrading=this.urls.api,this.urls.api=this.urls.demo;else if("apiBackupDemoTrading"in this.urls){this.urls.api=this.urls.apiBackupDemoTrading;const e=this.omit(this.urls,"apiBackupDemoTrading");this.urls=e}this.options.enableDemoTrading=e}async fetchTime(e={}){const t=this.safeString2(this.options,"fetchTime","defaultType","spot"),i=this.safeString(e,"type",t),s=this.omit(e,"type");let r,a;return[r,e]=this.handleSubTypeAndParams("fetchTime",void 0,e),a=this.isLinear(i,r)?await this.fapiPublicGetTime(s):this.isInverse(i,r)?await this.dapiPublicGetTime(s):await this.publicGetTime(s),this.safeInteger(a,"serverTime")}async fetchCurrencies(e={}){if(!this.safeBool(this.options,"fetchCurrencies"))return{};if(!this.checkRequiredCredentials(!1))return{};if(void 0!==this.safeValue(this.urls,"apiBackup"))return{};if(this.safeBool(this.options,"enableDemoTrading",!1))return{};const t=[this.sapiGetCapitalConfigGetall(e)],i=this.safeBool(this.options,"fetchMargins",!1);i&&t.push(this.sapiGetMarginAllPairs(e));const s=await Promise.all(t),r=s[0];let o;if(i){const e=s[1];o=this.indexBy(e,"assetName")}const n={};for(let e=0;e0)){const e=this.parseTimeframe(t),r=this.sum(i,s*e*1e3-1),a=this.milliseconds();c.endTime=Math.min(a,r)}let l;void 0!==d&&(c.endTime=d),l=o.option?await this.eapiPublicGetKlines(this.extend(c,r)):"mark"===n?o.inverse?await this.dapiPublicGetMarkPriceKlines(this.extend(c,r)):await this.fapiPublicGetMarkPriceKlines(this.extend(c,r)):"index"===n?o.inverse?await this.dapiPublicGetIndexPriceKlines(this.extend(c,r)):await this.fapiPublicGetIndexPriceKlines(this.extend(c,r)):"premiumIndex"===n?o.inverse?await this.dapiPublicGetPremiumIndexKlines(this.extend(c,r)):await this.fapiPublicGetPremiumIndexKlines(this.extend(c,r)):o.linear?await this.fapiPublicGetKlines(this.extend(c,r)):o.inverse?await this.dapiPublicGetKlines(this.extend(c,r)):await this.publicGetKlines(this.extend(c,r));return this.parseOHLCVs(l,o,t,i,s)}parseTrade(e,t=void 0){if("isDustTrade"in e)return this.parseDustTrade(e,t);const i=this.safeInteger2(e,"T","time");let s=this.safeString2(e,"q","qty");s=this.safeString(e,"quantity",s);const r=this.safeString(e,"symbol"),o="isIsolated"in e||"M"in e||"orderListId"in e||"isMaker"in e?"spot":"contract",n=(t=this.safeMarket(r,t,void 0,o)).symbol;let d;const c=this.safeBool2(e,"m","isBuyerMaker");let h,l;if(void 0!==c?d=c?"sell":"buy":"side"in e?d=this.safeStringLower(e,"side"):"isBuyer"in e&&(d=e.isBuyer?"buy":"sell"),"commission"in e&&(l={cost:this.safeString(e,"commission"),currency:this.safeCurrencyCode(this.safeString(e,"commissionAsset"))}),"isMaker"in e&&(h=e.isMaker?"maker":"taker"),"maker"in e&&(h=e.maker?"maker":"taker"),"optionSide"in e||t.option){const t=this.safeCurrencyCode(this.safeString(e,"quoteAsset","USDT"));h=this.safeStringLower(e,"liquidity"),"fee"in e&&(l={cost:this.safeString(e,"fee"),currency:t}),"buy"!==d&&"sell"!==d&&(d="1"===d?"buy":"sell"),"optionSide"in e&&"buy"!==d&&(s=a.Y.stringMul("-1",s))}return this.safeTrade({info:e,timestamp:i,datetime:this.iso8601(i),symbol:n,id:this.safeStringN(e,["t","a","tradeId","id"]),order:this.safeString(e,"orderId"),type:this.safeStringLower(e,"type"),side:d,takerOrMaker:h,price:this.safeString2(e,"p","price"),amount:s,cost:this.safeString2(e,"quoteQty","baseQty"),fee:l},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchTrades","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchTrades",e,t,i,s);const a=this.market(e),o={symbol:a.id};if(!a.option){void 0!==t&&(o.startTime=t,o.endTime=this.sum(t,36e5));const e=this.safeInteger(s,"until");void 0!==e&&(o.endTime=e)}let n,d=this.safeString(this.options,"fetchTradesMethod");if(d=this.safeString2(s,"fetchTradesMethod","method",d),void 0!==i){const e=a.swap||a.future,t=void 0!==d&&d.indexOf("GetHistoricalTrades")>=0?500:1e3;o.limit=e?Math.min(i,t):i}return s=this.omit(s,["until","fetchTradesMethod"]),n=a.option||"eapiPublicGetTrades"===d?await this.eapiPublicGetTrades(this.extend(o,s)):a.linear||"fapiPublicGetAggTrades"===d?await this.fapiPublicGetAggTrades(this.extend(o,s)):a.inverse||"dapiPublicGetAggTrades"===d?await this.dapiPublicGetAggTrades(this.extend(o,s)):await this.publicGetAggTrades(this.extend(o,s)),this.parseTrades(n,a,t,i)}async editSpotOrder(e,t,i,s,a,o=void 0,n={}){await this.loadMarkets();const d=this.market(t);if(!d.spot)throw new r.NotSupported(this.id+" editSpotOrder() does not support "+d.type+" orders");const c=this.editSpotOrderRequest(e,t,i,s,a,o,n),h=await this.privatePostOrderCancelReplace(c),l=this.safeDict(h,"newOrderResponse");return this.parseOrder(l,d)}editSpotOrderRequest(e,t,i,s,n,d=void 0,c={}){const h=this.market(t),l=this.safeStringN(c,["newClientOrderId","clientOrderId","origClientOrderId"]),u={symbol:h.id,side:s.toUpperCase()},p=i.toUpperCase();let f=p;this.isPostOnly("MARKET"===p,"LIMIT_MAKER"===p,c)&&(f="LIMIT_MAKER");const m=this.safeNumber2(c,"stopPrice","triggerPrice");void 0!==m&&("MARKET"===f?f="STOP_LOSS":"LIMIT"===f&&(f="STOP_LOSS_LIMIT")),u.type=f;const g=this.safeList(h.info,"orderTypes");if(!this.inArray(f,g))throw p!==f?new r.InvalidOrder(this.id+" triggerPrice parameter is not allowed for "+t+" "+i+" orders"):new r.InvalidOrder(this.id+" "+i+" is not a valid order type for the "+t+" market");if(void 0===l){const e=this.safeDict(this.options,"broker");if(void 0!==e){const t=this.safeString(e,"spot");void 0!==t&&(u.newClientOrderId=t+this.uuid22())}}else u.newClientOrderId=l;u.newOrderRespType=this.safeValue(this.options.newOrderRespType,i,"RESULT");let v=!1,y=!1,b=!1,w=!1;if("MARKET"===f){if(this.safeBool(this.options,"quoteOrderQty",!0)){const e=this.safeValue2(c,"quoteOrderQty","cost"),t=h.precision.price;if(void 0!==e)u.quoteOrderQty=this.decimalToPrecision(e,o.R3,t,this.precisionMode);else if(void 0!==d){const e=this.numberToString(n),i=this.numberToString(d),s=a.Y.stringMul(e,i);u.quoteOrderQty=this.decimalToPrecision(s,o.R3,t,this.precisionMode)}else w=!0}else w=!0}else"LIMIT"===f?(y=!0,v=!0,w=!0):"STOP_LOSS"===f||"TAKE_PROFIT"===f?(b=!0,w=!0):"STOP_LOSS_LIMIT"===f||"TAKE_PROFIT_LIMIT"===f?(w=!0,b=!0,y=!0,v=!0):"LIMIT_MAKER"===f&&(y=!0,w=!0);if(w&&(u.quantity=this.amountToPrecision(t,n)),y){if(void 0===d)throw new r.InvalidOrder(this.id+" editOrder() requires a price argument for a "+i+" order");u.price=this.priceToPrecision(t,d)}if(v&&void 0===this.safeString(c,"timeInForce")&&(u.timeInForce=this.options.defaultTimeInForce),b){if(void 0===m)throw new r.InvalidOrder(this.id+" editOrder() requires a triggerPrice extra param for a "+i+" order");u.stopPrice=this.priceToPrecision(t,m)}u.cancelReplaceMode="STOP_ON_FAILURE";return void 0===this.safeString2(c,"cancelNewClientOrderId","cancelOrigClientOrderId")&&(u.cancelOrderId=e),"PO"===this.safeString(c,"timeInForce")&&(c=this.omit(c,["timeInForce"])),c=this.omit(c,["quoteOrderQty","cost","stopPrice","newClientOrderId","clientOrderId","postOnly"]),this.extend(u,c)}editContractOrderRequest(e,t,i,s,a,o=void 0,n={}){const d=this.market(t);if(!d.contract)throw new r.NotSupported(this.id+" editContractOrder() does not support "+d.type+" orders");const c={symbol:d.id,side:s.toUpperCase(),orderId:e,quantity:this.amountToPrecision(t,a)},h=this.safeStringN(n,["newClientOrderId","clientOrderId","origClientOrderId"]);return void 0!==o&&(c.price=this.priceToPrecision(t,o)),void 0!==h&&(c.origClientOrderId=h),n=this.omit(n,["clientOrderId","newClientOrderId"]),c}async editContractOrder(e,t,i,s,a,o=void 0,n={}){await this.loadMarkets();const d=this.market(t);let c;if([c,n]=this.handleOptionAndParams2(n,"editContractOrder","papi","portfolioMargin",!1),(d.linear||c)&&void 0===o&&!("priceMatch"in n))throw new r.ArgumentsRequired(this.id+" editOrder() requires a price argument for portfolio margin and linear orders");const h=this.editContractOrderRequest(e,t,i,s,a,o,n);let l;return d.linear?l=c?await this.papiPutUmOrder(this.extend(h,n)):await this.fapiPrivatePutOrder(this.extend(h,n)):d.inverse&&(l=c?await this.papiPutCmOrder(this.extend(h,n)):await this.dapiPrivatePutOrder(this.extend(h,n))),this.parseOrder(l,d)}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){await this.loadMarkets();const d=this.market(t);if(d.option)throw new r.NotSupported(this.id+" editOrder() does not support "+d.type+" orders");return d.spot?await this.editSpotOrder(e,t,i,s,a,o,n):await this.editContractOrder(e,t,i,s,a,o,n)}async editOrders(e,t={}){await this.loadMarkets();const i=[];let s=[];for(let t=0;t=s&&void 0===l&&n.linear&&(l=this.sum(e,s),l=Math.min(l,i))}if(void 0!==l&&(o.endTime=l,s=this.omit(s,["endTime","until"])),void 0!==i&&(("option"===d||n.contract)&&(i=Math.min(i,1e3)),o.limit=i),"option"===d)h=await this.eapiPrivateGetUserTrades(this.extend(o,s));else{if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");let t;[c,s]=this.handleMarginModeAndParams("fetchMyTrades",s),[t,s]=this.handleOptionAndParams2(s,"fetchMyTrades","papi","portfolioMargin",!1),"spot"===d||"margin"===d?t?h=await this.papiGetMarginMyTrades(this.extend(o,s)):"margin"===d||void 0!==c?("isolated"===c&&(o.isIsolated=!0),h=await this.sapiGetMarginMyTrades(this.extend(o,s))):h=await this.privateGetMyTrades(this.extend(o,s)):n.linear?h=t?await this.papiGetUmUserTrades(this.extend(o,s)):await this.fapiPrivateGetUserTrades(this.extend(o,s)):n.inverse&&(h=t?await this.papiGetCmUserTrades(this.extend(o,s)):await this.dapiPrivateGetUserTrades(this.extend(o,s)))}return this.parseTrades(h,n,t,i)}async fetchMyDustTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};void 0!==t&&(r.startTime=t,r.endTime=this.sum(t,7776e6));const a=this.safeStringUpper(s,"type");s=this.omit(s,"type"),void 0!==a&&(r.accountType=a);const o=await this.sapiGetAssetDribblet(this.extend(r,s)),n=this.safeList(o,"userAssetDribblets",[]),d=this.safeInteger(o,"total",0),c=[];for(let e=0;e=0&&(a=a.slice(18));const o=this.safeString2(e,"coin","fiatCurrency");let n,d=this.safeCurrencyCode(o,t);n=this.safeInteger2(e,"insertTime","createTime"),void 0===n&&(n=this.parse8601(this.safeString(e,"applyTime")));const c=this.safeInteger2(e,"successTime","updateTime");let h=this.safeString(e,"type");if(void 0===h){const t=this.safeString(e,"transactionType");void 0!==t&&(h="0"===t?"deposit":"withdrawal");const i=this.safeDict(this.options,"legalMoneyCurrenciesById");d=this.safeString(i,d,d)}const l=this.parseTransactionStatusByType(this.safeString(e,"status"),h),u=this.safeNumber(e,"amount"),p=this.safeNumber2(e,"transactionFee","totalFee");let f;void 0!==p&&(f={currency:d,cost:p});const m=this.safeInteger(e,"transferType");let g;void 0!==m&&(g=0!==m);const v=this.safeString(e,"network");return{info:e,id:i,txid:a,timestamp:n,datetime:this.iso8601(n),network:v,address:s,addressTo:s,addressFrom:void 0,tag:r,tagTo:r,tagFrom:void 0,type:h,amount:u,currency:d,status:l,updated:c,internal:g,comment:void 0,fee:f}}parseTransferStatus(e){return this.safeString({CONFIRMED:"ok"},e,e)}parseTransfer(e,t=void 0){const i=this.safeString2(e,"tranId","transactionId"),s=this.safeString2(e,"asset","currency"),r=this.safeCurrencyCode(s,t),a=this.safeNumber(e,"amount"),o=this.safeString(e,"type");let n,d;const c=this.safeDict(this.options,"accountsById",{});if(void 0!==o){const e=o.split("_");n=this.safeValue(e,0),d=this.safeValue(e,1),n=this.safeString(c,n,n),d=this.safeString(c,d,d)}if(void 0!==this.safeInteger(e,"walletType")){const t=this.safeDict(e,"payerInfo",{}),i=this.safeDict(e,"receiverInfo",{});n=this.safeString(t,"accountId"),d=this.safeString(i,"accountId")}const h=this.safeInteger2(e,"timestamp","transactionTime"),l=this.parseTransferStatus(this.safeString(e,"status"));return{info:e,id:i,timestamp:h,datetime:this.iso8601(h),currency:r,amount:a,fromAccount:n,toAccount:d,status:l}}parseIncome(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeString(e,"asset"),r=this.safeInteger(e,"time");return{info:e,symbol:this.safeSymbol(i,t,void 0,"swap"),code:this.safeCurrencyCode(s),timestamp:r,datetime:this.iso8601(r),id:this.safeString(e,"tranId"),amount:this.safeNumber(e,"income")}}async transfer(e,t,i,s,a={}){await this.loadMarkets();const o=this.currency(e),n={asset:o.id,amount:this.currencyToPrecision(e,t)};if(n.type=this.safeString(a,"type"),a=this.omit(a,"type"),void 0===n.type){const e=this.safeString(a,"symbol");let t;void 0!==e&&(t=this.market(e),a=this.omit(a,"symbol"));let o,d=this.convertTypeToAccount(i).toUpperCase(),c=this.convertTypeToAccount(s).toUpperCase();if(void 0!==t&&(o=t.id),"ISOLATED"===d&&void 0===e)throw new r.ArgumentsRequired(this.id+' transfer () requires params["symbol"] when fromAccount is '+i);if("ISOLATED"===c&&void 0===e)throw new r.ArgumentsRequired(this.id+' transfer () requires params["symbol"] when toAccount is '+s);const h=this.safeDict(this.options,"accountsById",{}),l=!(d in h),u=!(c in h);if(l&&void 0===t&&(o=d),u&&void 0===t&&(o=c),l||u){const e="MAIN"===d,t="MAIN"===c;if((l||u)&&("UMFUTURE"===d||"CMFUTURE"===d||("UMFUTURE"===c||"CMFUTURE"===c)||("FUNDING"===d||"FUNDING"===c)||("OPTION"===d||"OPTION"===c)))throw new r.BadRequest(this.id+" transfer () does not allow transfers between "+i+" and "+s);t&&l?(d="ISOLATED_MARGIN",n.fromSymbol=o):e&&u?(c="ISOLATED_MARGIN",n.toSymbol=o):l&&u?(n.fromSymbol=d,n.toSymbol=c,d="ISOLATEDMARGIN",c="ISOLATEDMARGIN"):(l&&(n.fromSymbol=o,d="ISOLATEDMARGIN"),u&&(n.toSymbol=o,c="ISOLATEDMARGIN")),n.type=d+"_"+c}else n.type=d+"_"+c}const d=await this.sapiPostAssetTransfer(this.extend(n,a));return this.parseTransfer(d,o)}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const a=this.safeBool(s,"internal");s=this.omit(s,"internal");let o,n=!1;if([n,s]=this.handleOptionAndParams(s,"fetchTransfers","paginate"),n&&!a)return await this.fetchPaginatedCallDynamic("fetchTransfers",e,t,i,s);void 0!==e&&(o=this.currency(e));const d={};let c="limit";if(!a){const e=this.safeString2(this.options,"fetchTransfers","defaultType","spot"),t=this.safeString(s,"fromAccount",e),i="future"===t?"spot":"future",a=this.safeString(s,"toAccount",i);let o=this.safeString(s,"type");const n=this.safeDict(this.options,"accountsByType",{}),h=this.safeString(n,t),l=this.safeString(n,a);if(void 0===o){if(void 0===h){const e=Object.keys(n);throw new r.ExchangeError(this.id+" fromAccount parameter must be one of "+e.join(", "))}if(void 0===l){const e=Object.keys(n);throw new r.ExchangeError(this.id+" toAccount parameter must be one of "+e.join(", "))}o=h+"_"+l}d.type=o,c="size"}void 0!==i&&(d[c]=i),void 0!==t&&(d.startTime=t);const h=this.safeInteger(s,"until");let l;void 0!==h&&(s=this.omit(s,"until"),d.endTime=h),l=a?await this.sapiGetPayTransactions(this.extend(d,s)):await this.sapiGetAssetTransfer(this.extend(d,s));const u=this.safeList2(l,"rows","data",[]);return this.parseTransfers(u,o,t,i)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={coin:i.id},r=this.safeDict(this.options,"networks",{});let a=this.safeStringUpper(t,"network");a=this.safeString(r,a,a),void 0!==a&&(s.network=a,t=this.omit(t,"network"));const o=await this.sapiGetCapitalDepositAddress(this.extend(s,t));return this.parseDepositAddress(o,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"url"),s=this.safeString(e,"address"),r=this.safeString(e,"currency"),a=this.safeCurrencyCode(r,t),o=this.getNetworkCodeByNetworkUrl(a,i);let n=this.safeString(e,"tag","");return 0===n.length&&(n=void 0),this.checkAddress(s),{info:e,currency:a,network:o,address:s,tag:n}}async fetchTransactionFees(e=void 0,t={}){await this.loadMarkets();const i=await this.sapiGetCapitalConfigGetall(t),s={};for(let e=0;e4)throw new r.ArgumentsRequired(this.id+" type must be between 1 and 4");await this.loadMarkets();const a=this.currency(e),o={asset:a.id,amount:t,type:i},n=await this.sapiPostFuturesTransfer(this.extend(o,s));return this.parseTransfer(n,a)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let a;if(i.linear)a=await this.fapiPublicGetPremiumIndex(this.extend(s,t));else{if(!i.inverse)throw new r.NotSupported(this.id+" fetchFundingRate() supports linear and inverse contracts only");a=await this.dapiPublicGetPremiumIndex(this.extend(s,t))}return i.inverse&&(a=a[0]),this.parseFundingRate(a,i)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const a={};let o=!1;if([o,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),o)return await this.fetchPaginatedCallDeterministic("fetchFundingRateHistory",e,t,i,"8h",s);const n=this.safeString2(this.options,"fetchFundingRateHistory","defaultType","future"),d=this.safeString(s,"type",n);let c,h;void 0!==e&&(c=this.market(e),e=c.symbol,a.symbol=c.id),[h,s]=this.handleSubTypeAndParams("fetchFundingRateHistory",c,s,"linear"),s=this.omit(s,"type"),void 0!==t&&(a.startTime=t);const l=this.safeInteger(s,"until"),u=this.safeInteger(s,"endTime",l);let p;if(s=this.omit(s,["endTime","until"]),void 0!==u&&(a.endTime=u),void 0!==i&&(a.limit=i),this.isLinear(d,h))p=await this.fapiPublicGetFundingRate(this.extend(a,s));else{if(!this.isInverse(d,h))throw new r.NotSupported(this.id+" fetchFundingRateHistory() is not supported for "+d+" markets");p=await this.dapiPublicGetFundingRate(this.extend(a,s))}return this.parseFundingRateHistories(p,c,t,i)}parseFundingRateHistory(e,t=void 0){const i=this.safeInteger(e,"fundingTime");return{info:e,symbol:this.safeSymbol(this.safeString(e,"symbol"),void 0,void 0,"swap"),fundingRate:this.safeNumber(e,"fundingRate"),timestamp:i,datetime:this.iso8601(i)}}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=this.safeString2(this.options,"fetchFundingRates","defaultType","future"),s=this.safeString(t,"type",i);let a;[a,t]=this.handleSubTypeAndParams("fetchFundingRates",void 0,t,"linear");const o=this.omit(t,"type");let n;if(this.isLinear(s,a))n=await this.fapiPublicGetPremiumIndex(o);else{if(!this.isInverse(s,a))throw new r.NotSupported(this.id+" fetchFundingRates() supports linear and inverse contracts only");n=await this.dapiPublicGetPremiumIndex(o)}return this.parseFundingRates(n,e)}parseFundingRate(e,t=void 0){const i=this.safeInteger(e,"time"),s=this.safeString(e,"symbol"),r=this.safeSymbol(s,t,void 0,"contract"),a=this.safeNumber(e,"markPrice"),o=this.safeNumber(e,"indexPrice"),n=this.safeNumber(e,"interestRate"),d=this.safeNumber(e,"estimatedSettlePrice"),c=this.safeNumber(e,"lastFundingRate"),h=this.safeInteger(e,"nextFundingTime"),l=this.safeString(e,"fundingIntervalHours");let u;return void 0!==l&&(u=l+"h"),{info:e,symbol:r,markPrice:a,indexPrice:o,interestRate:n,estimatedSettlePrice:d,timestamp:i,datetime:this.iso8601(i),fundingRate:c,fundingTimestamp:h,fundingDatetime:this.iso8601(h),nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:u}}parseAccountPositions(e,t=!1){const i=this.safeList(e,"positions"),s=this.safeList(e,"assets",[]),r={};for(let e=0;e1)throw new r.BadRequest(this.id+" fetchPositions() symbols argument cannot contain more than 1 symbol");t=e[0]}else t=e;s=this.market(t),i.symbol=s.id}const a=await this.eapiPrivateGetPosition(this.extend(i,t)),o=[];for(let e=0;e125)throw new r.BadRequest(this.id+" leverage should be between 1 and 125");await this.loadMarkets();const s=this.market(t),a={symbol:s.id,leverage:e};let o,n;if([o,i]=this.handleOptionAndParams2(i,"setLeverage","papi","portfolioMargin",!1),s.linear)n=o?await this.papiPostUmLeverage(this.extend(a,i)):await this.fapiPrivatePostLeverage(this.extend(a,i));else{if(!s.inverse)throw new r.NotSupported(this.id+" setLeverage() supports linear and inverse contracts only");n=o?await this.papiPostCmLeverage(this.extend(a,i)):await this.dapiPrivatePostLeverage(this.extend(a,i))}return n}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");if("CROSS"===(e=e.toUpperCase())&&(e="CROSSED"),"ISOLATED"!==e&&"CROSSED"!==e)throw new r.BadRequest(this.id+" marginMode must be either isolated or cross");await this.loadMarkets();const s=this.market(t),a={symbol:s.id,marginType:e};let o;try{if(s.linear)o=await this.fapiPrivatePostMarginType(this.extend(a,i));else{if(!s.inverse)throw new r.NotSupported(this.id+" setMarginMode() supports linear and inverse contracts only");o=await this.dapiPrivatePostMarginType(this.extend(a,i))}}catch(e){if(!(e instanceof r.MarginModeAlreadySet))throw e;if(this.safeBool(this.options,"throwMarginModeAlreadySet",!1))throw e;o={code:-4046,msg:"No need to change margin type."}}return o}async setPositionMode(e,t=void 0,i={}){let s,a,o,n,d;void 0!==t&&(s=this.market(t)),[a,i]=this.handleMarketTypeAndParams("setPositionMode",s,i),[o,i]=this.handleSubTypeAndParams("setPositionMode",s,i),[n,i]=this.handleOptionAndParams2(i,"setPositionMode","papi","portfolioMargin",!1),d=e?"true":"false";const c={dualSidePosition:d};let h;if(this.isInverse(a,o))h=n?await this.papiPostCmPositionSideDual(this.extend(c,i)):await this.dapiPrivatePostPositionSideDual(this.extend(c,i));else{if(!this.isLinear(a,o))throw new r.BadRequest(this.id+" setPositionMode() supports linear and inverse contracts only");h=n?await this.papiPostUmPositionSideDual(this.extend(c,i)):await this.fapiPrivatePostPositionSideDual(this.extend(c,i))}return h}async fetchLeverages(e=void 0,t={}){let i,s,a,o;if(await this.loadMarkets(),await this.loadLeverageBrackets(!1,t),[i,t]=this.handleMarketTypeAndParams("fetchLeverages",void 0,t),[s,t]=this.handleSubTypeAndParams("fetchLeverages",void 0,t,"linear"),[a,t]=this.handleOptionAndParams2(t,"fetchLeverages","papi","portfolioMargin",!1),this.isLinear(i,s))o=a?await this.papiGetUmAccount(t):await this.fapiPrivateGetSymbolConfig(t);else{if(!this.isInverse(i,s))throw new r.NotSupported(this.id+" fetchLeverages() supports linear and inverse contracts only");o=a?await this.papiGetCmAccount(t):await this.dapiPrivateGetAccount(t)}let n=this.safeList(o,"positions",[]);return Array.isArray(o)&&(n=o),this.parseLeverages(n,e,"symbol")}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeBool(e,"isolated");let r;void 0!==s&&(r=s?"isolated":"cross");const a=this.safeStringLower(e,"marginType");void 0!==a&&(r="crossed"===a?"cross":"isolated");const o=this.safeStringLower(e,"positionSide");let n,d;const c=this.safeInteger(e,"leverage");return void 0===o||"both"===o?(n=c,d=c):"long"===o?n=c:"short"===o&&(d=c),{info:e,symbol:this.safeSymbol(i,t),marginMode:r,longLeverage:n,shortLeverage:d}}async fetchSettlementHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const a=void 0===e?void 0:this.market(e);let o;if([o,s]=this.handleMarketTypeAndParams("fetchSettlementHistory",a,s),"option"!==o)throw new r.NotSupported(this.id+" fetchSettlementHistory() supports option markets only");const n={};void 0!==e&&(e=a.symbol,n.underlying=a.baseId+a.quoteId),void 0!==t&&(n.startTime=t),void 0!==i&&(n.limit=i);const d=await this.eapiPublicGetExerciseHistory(this.extend(n,s)),c=this.parseSettlements(d,a),h=this.sortBy(c,"timestamp");return this.filterBySymbolSinceLimit(h,e,t,i)}async fetchMySettlementHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const a=void 0===e?void 0:this.market(e);let o;if([o,s]=this.handleMarketTypeAndParams("fetchMySettlementHistory",a,s),"option"!==o)throw new r.NotSupported(this.id+" fetchMySettlementHistory() supports option markets only");const n={};void 0!==e&&(n.symbol=a.id,e=a.symbol),void 0!==t&&(n.startTime=t),void 0!==i&&(n.limit=i);const d=await this.eapiPrivateGetExerciseRecord(this.extend(n,s)),c=this.parseSettlements(d,a),h=this.sortBy(c,"timestamp");return this.filterBySymbolSinceLimit(h,e,t,i)}parseSettlement(e,t){const i=this.safeInteger2(e,"expiryDate","createDate"),s=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(s,t),price:this.safeNumber2(e,"realStrikePrice","exercisePrice"),timestamp:i,datetime:this.iso8601(i)}}parseSettlements(e,t){const i=[];for(let s=0;s-1&&this.isSandboxModeEnabled&&!this.safeBool(this.options,"disableFuturesSandboxWarning"))throw new r.NotSupported(this.id+" testnet/sandbox mode is not supported for futures anymore, please check the deprecation announcement https://t.me/ccxt_announcements/92 and consider using the demo trading instead.");if("POST"===i&&("order"===e||"sor/order"===e)){if(void 0===this.safeString(s,"newClientOrderId")){const e=t.indexOf("sapi")>-1||"private"===t,i=e?"spot":"future",r=e?"x-TKT5PX2F":"x-xcKtGhcu",a=this.safeDict(this.options,"broker",{}),o=this.safeString(a,i,r);s.newClientOrderId=o+this.uuid22()}}let u;if("batchOrders"===e&&("POST"===i||"PUT"===i)){const e=this.safeList(s,"batchOrders");let r=e;if("POST"===i&&"fapiPrivate"===t){r=[];for(let t=0;t=0||"capital/withdraw/apply"===e||e.indexOf("staking")>=0||e.indexOf("simple-earn")>=0)if("DELETE"===i&&"batchOrders"===e){const e=this.safeList(f,"orderidlist",[]),t=this.safeList2(f,"origclientorderidlist","origClientOrderIdList",[]);f=this.omit(f,["orderidlist","origclientorderidlist","origClientOrderIdList"]),"symbol"in f&&(f.symbol=this.encodeURIComponent(f.symbol)),u=this.rawencode(f);const i=e.length,s=t.length;if(i>0&&(u=u+"&orderidlist=%5B"+e.join("%2C")+"%5D"),s>0){const e=[];for(let i=0;i-1?this.secret.length>120?this.encodeURIComponent((0,d.n)(u,this.secret,n.s)):this.encodeURIComponent((0,c.q4)(this.encode(u),this.secret,h.ev)):this.hmac(this.encode(u),this.encode(this.secret),n.s),u+="&signature="+g,a={"X-MBX-APIKEY":this.apiKey},"GET"===i||"DELETE"===i?l+="?"+u:(o=u,a["Content-Type"]="application/x-www-form-urlencoded")}else Object.keys(s).length&&(l+="?"+this.urlencode(s));return{url:l,method:i,body:o,headers:a}}getExceptionsByUrl(e,t){let i;const s=void 0!==this.hostname?this.hostname:"binance.com";if(e.startsWith("https://api."+s+"/")||e.startsWith("https://demo-api")||e.startsWith("https://testnet.binance.vision")?i="spot":e.startsWith("https://dapi."+s+"/")||e.startsWith("https://demo-dapi")||e.startsWith("https://testnet.binancefuture.com/dapi")?i="inverse":e.startsWith("https://fapi."+s+"/")||e.startsWith("https://demo-fapi")||e.startsWith("https://testnet.binancefuture.com/fapi")?i="linear":e.startsWith("https://eapi."+s+"/")?i="option":e.startsWith("https://papi."+s+"/")&&(i="portfolioMargin"),void 0!==i){const e=this.safeDict(this.exceptions,i,{});return this.safeDict(e,t,{})}return{}}handleErrors(e,t,i,s,o,n,d,c,h){if(418===e||429===e)throw new r.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+n);if(e>=400){if(n.indexOf("Price * QTY is zero or less")>=0)throw new r.InvalidOrder(this.id+" order cost = amount * price is zero or less "+n);if(n.indexOf("LOT_SIZE")>=0)throw new r.InvalidOrder(this.id+" order amount should be evenly divisible by lot size "+n);if(n.indexOf("PRICE_FILTER")>=0)throw new r.InvalidOrder(this.id+" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) "+n)}if(void 0===d)return;const l=this.safeBool(d,"success",!0);if(!l){const e=this.safeString(d,"msg");let t;if(void 0!==e){try{t=JSON.parse(e)}catch(e){t=void 0}void 0!==t&&(d=t)}}const u=this.safeString(d,"msg");void 0!==u&&(this.throwExactlyMatchedException(this.getExceptionsByUrl(i,"exact"),u,this.id+" "+u),this.throwExactlyMatchedException(this.exceptions.exact,u,this.id+" "+u),this.throwBroadlyMatchedException(this.getExceptionsByUrl(i,"broad"),u,this.id+" "+u),this.throwBroadlyMatchedException(this.exceptions.broad,u,this.id+" "+u));const p=this.safeString(d,"code");if(void 0!==p){if("200"===p||a.Y.stringEquals(p,"0"))return;if("-2015"===p&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new r.DDoSProtection(this.id+" "+n);const e=this.id+" "+n;if("No need to change margin type."===u)throw new r.MarginModeAlreadySet(e);throw this.throwExactlyMatchedException(this.getExceptionsByUrl(i,"exact"),p,e),this.throwExactlyMatchedException(this.exceptions.exact,p,e),new r.ExchangeError(e)}if(!l)throw new r.ExchangeError(this.id+" "+n);if(Array.isArray(d)){if(1===d.length){const e=d[0],t=this.safeString(e,"code");void 0!==t&&(this.throwExactlyMatchedException(this.getExceptionsByUrl(i,"exact"),t,this.id+" "+n),this.throwExactlyMatchedException(this.exceptions.exact,t,this.id+" "+n))}}}calculateRateLimiterCost(e,t,i,s,r={}){if("noCoin"in r&&!("coin"in s))return r.noCoin;if("noSymbol"in r&&!("symbol"in s))return r.noSymbol;if("noPoolId"in r&&!("poolId"in s))return r.noPoolId;if("byLimit"in r&&"limit"in s){const e=s.limit,t=r.byLimit;for(let i=0;i93)throw new r.BadRequest(this.id+" fetchBorrowRateHistory() limit parameter cannot exceed 92");const a={asset:this.currency(e).id,limit:i};if(void 0!==t){a.startTime=t;const e=this.sum(t,864e5*i)-1,s=this.milliseconds();a.endTime=Math.min(e,s)}const o=await this.sapiGetMarginInterestRateHistory(this.extend(a,s));return this.parseBorrowRateHistory(o,e,t,i)}parseBorrowRate(e,t=void 0){const i=this.safeInteger(e,"timestamp"),s=this.safeString(e,"asset");return{currency:this.safeCurrencyCode(s,t),rate:this.safeNumber(e,"dailyInterestRate"),period:864e5,timestamp:i,datetime:this.iso8601(i),info:e}}parseIsolatedBorrowRate(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t,void 0,"spot");const s=this.safeList(e,"data"),r=this.safeDict(s,0),a=this.safeDict(s,1);return{info:e,symbol:this.safeString(t,"symbol"),base:this.safeString(r,"coin"),baseRate:this.safeNumber(r,"dailyInterest"),quote:this.safeString(a,"coin"),quoteRate:this.safeNumber(a,"dailyInterest"),period:864e5,timestamp:void 0,datetime:void 0}}async createGiftCode(e,t,i={}){await this.loadMarkets();const s={token:this.currency(e).id,amount:t},r=await this.sapiPostGiftcardCreateCode(this.extend(s,i)),a=this.safeDict(r,"data"),o=this.safeString(a,"code");return{info:r,id:this.safeString(a,"referenceNo"),code:o,currency:e,amount:t}}async redeemGiftCode(e,t={}){const i={code:e};return await this.sapiPostGiftcardRedeemCode(this.extend(i,t))}async verifyGiftCode(e,t={}){const i={referenceNo:e};return await this.sapiGetGiftcardVerify(this.extend(i,t))}async fetchBorrowInterest(e=void 0,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),[a,r]=this.handleOptionAndParams2(r,"fetchBorrowInterest","papi","portfolioMargin",!1);let o,n,d={};if(void 0!==e){const t=this.currency(e);d.asset=t.id}void 0!==i&&(d.startTime=i),void 0!==s&&(d.size=s),[d,r]=this.handleUntilOption("endTime",d,r),a?n=await this.papiGetMarginMarginInterestHistory(this.extend(d,r)):(void 0!==t&&(o=this.market(t),d.isolatedSymbol=o.id),n=await this.sapiGetMarginInterestHistory(this.extend(d,r)));const c=this.safeList(n,"rows"),h=this.parseBorrowInterests(c,o);return this.filterByCurrencySinceLimit(h,e,i,s)}parseBorrowInterest(e,t=void 0){const i=this.safeString(e,"isolatedSymbol"),s=this.safeInteger(e,"interestAccuredTime"),r=void 0===i?"cross":"isolated";return{info:e,symbol:i,currency:this.safeCurrencyCode(this.safeString(e,"asset")),interest:this.safeNumber(e,"interest"),interestRate:this.safeNumber(e,"interestRate"),amountBorrowed:this.safeNumber(e,"principal"),marginMode:r,timestamp:s,datetime:this.iso8601(s)}}async repayCrossMargin(e,t,i={}){await this.loadMarkets();const s=this.currency(e),r={asset:s.id,amount:this.currencyToPrecision(e,t)};let a,o;if([o,i]=this.handleOptionAndParams2(i,"repayCrossMargin","papi","portfolioMargin",!1),o){let e;[e,i]=this.handleOptionAndParams2(i,"repayCrossMargin","repayCrossMarginMethod","method"),a="papiPostMarginRepayDebt"===e?await this.papiPostMarginRepayDebt(this.extend(r,i)):await this.papiPostRepayLoan(this.extend(r,i))}else r.isIsolated="FALSE",r.type="REPAY",a=await this.sapiPostMarginBorrowRepay(this.extend(r,i));return this.parseMarginLoan(a,s)}async repayIsolatedMargin(e,t,i,s={}){await this.loadMarkets();const r=this.currency(t),a=this.market(e),o={asset:r.id,amount:this.currencyToPrecision(t,i),symbol:a.id,isIsolated:"TRUE",type:"REPAY"},n=await this.sapiPostMarginBorrowRepay(this.extend(o,s));return this.parseMarginLoan(n,r)}async borrowCrossMargin(e,t,i={}){await this.loadMarkets();const s=this.currency(e),r={asset:s.id,amount:this.currencyToPrecision(e,t)};let a,o;return[o,i]=this.handleOptionAndParams2(i,"borrowCrossMargin","papi","portfolioMargin",!1),o?a=await this.papiPostMarginLoan(this.extend(r,i)):(r.isIsolated="FALSE",r.type="BORROW",a=await this.sapiPostMarginBorrowRepay(this.extend(r,i))),this.parseMarginLoan(a,s)}async borrowIsolatedMargin(e,t,i,s={}){await this.loadMarkets();const r=this.currency(t),a=this.market(e),o={asset:r.id,amount:this.currencyToPrecision(t,i),symbol:a.id,isIsolated:"TRUE",type:"BORROW"},n=await this.sapiPostMarginBorrowRepay(this.extend(o,s));return this.parseMarginLoan(n,r)}parseMarginLoan(e,t=void 0){const i=this.safeString(e,"asset"),s=this.safeInteger(e,"updateTime");return{id:this.safeInteger(e,"tranId"),currency:this.safeCurrencyCode(i,t),amount:this.safeNumber(e,"amount"),symbol:void 0,timestamp:s,datetime:this.iso8601(s),info:e}}async fetchOpenInterestHistory(e,t="5m",i=void 0,s=void 0,a={}){if("1m"===t)throw new r.BadRequest(this.id+" fetchOpenInterestHistory cannot use the 1m timeframe");await this.loadMarkets();let o=!1;if([o,a]=this.handleOptionAndParams(a,"fetchOpenInterestHistory","paginate",!1),o)return await this.fetchPaginatedCallDeterministic("fetchOpenInterestHistory",e,i,s,t,a,500);const n=this.market(e),d={period:this.safeString(this.timeframes,t,t)};void 0!==s&&(d.limit=s);d[n.linear?"symbol":"pair"]=n.id,n.inverse&&(d.contractType=this.safeString(a,"contractType","CURRENT_QUARTER")),void 0!==i&&(d.startTime=i);const c=this.safeInteger(a,"until"),h=this.safeInteger(a,"endTime",c);if(a=this.omit(a,["endTime","until"]),h)d.endTime=h;else if(i){void 0===s&&(s=30);const e=this.parseTimeframe(t);d.endTime=this.sum(i,e*s*1e3)}let l;return l=n.inverse?await this.dapiDataGetOpenInterestHist(this.extend(d,a)):await this.fapiDataGetOpenInterestHist(this.extend(d,a)),this.parseOpenInterestsHistory(l,n,i,s)}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e),s={};if(i.option){if(s.underlyingAsset=i.baseId,void 0===i.expiry)throw new r.NotSupported(this.id+" fetchOpenInterest does not support "+e);s.expiration=this.yymmdd(i.expiry)}else s.symbol=i.id;let a;if(a=i.option?await this.eapiPublicGetOpenInterest(this.extend(s,t)):i.inverse?await this.dapiPublicGetOpenInterest(this.extend(s,t)):await this.fapiPublicGetOpenInterest(this.extend(s,t)),!i.option)return this.parseOpenInterest(a,i);{e=i.symbol;const t=this.parseOpenInterestsHistory(a,i);for(let i=0;io)throw new r.BadRequest(this.id+" fetchConvertTradeHistory () the max interval between startTime and endTime is 30 days.");void 0!==i&&(a.limit=i),l="fromAsset",u="toAsset",h="list",c=await this.sapiGetConvertTradeFlow(this.extend(a,s))}const p=this.safeList(c,h,[]);return this.parseConversions(p,e,l,u,t,i)}parseConversion(e,t=void 0,i=void 0){const s=this.safeIntegerN(e,["time","validTimestamp","createTime"]),r=this.safeString2(e,"deductedAsset","fromAsset"),a=this.safeCurrencyCode(r,t),o=this.safeString2(e,"targetAsset","toAsset"),n=this.safeCurrencyCode(o,i);return{info:e,timestamp:s,datetime:this.iso8601(s),id:this.safeStringN(e,["tranId","orderId","quoteId"]),fromCurrency:a,fromAmount:this.safeNumber2(e,"deductedAmount","fromAmount"),toCurrency:n,toAmount:this.safeNumber2(e,"targetAmount","toAmount"),price:void 0,fee:void 0}}async fetchFundingIntervals(e=void 0,t={}){let i;await this.loadMarkets(),void 0!==e&&(e=this.marketSymbols(e),i=this.market(e[0]));const s="swap";let a,o;if([a,t]=this.handleSubTypeAndParams("fetchFundingIntervals",i,t,"linear"),this.isLinear(s,a))o=await this.fapiPublicGetFundingInfo(t);else{if(!this.isInverse(s,a))throw new r.NotSupported(this.id+" fetchFundingIntervals() supports linear and inverse swap contracts only");o=await this.dapiPublicGetFundingInfo(t)}return this.parseFundingRates(o,e)}async fetchLongShortRatioHistory(e=void 0,t=void 0,i=void 0,s=void 0,a={}){await this.loadMarkets();const o=this.market(e);void 0===t&&(t="1d");let n,d,c={period:t};if([c,a]=this.handleUntilOption("endTime",c,a),void 0!==i&&(c.startTime=i),void 0!==s&&(c.limit=s),[n,a]=this.handleSubTypeAndParams("fetchLongShortRatioHistory",o,a),"linear"===n)c.symbol=o.id,d=await this.fapiDataGetGlobalLongShortAccountRatio(this.extend(c,a));else{if("inverse"!==n)throw new r.BadRequest(this.id+" fetchLongShortRatioHistory() supports linear and inverse subTypes only");c.pair=o.info.pair,d=await this.dapiDataGetGlobalLongShortAccountRatio(this.extend(c,a))}return this.parseLongShortRatioHistory(d,o)}parseLongShortRatio(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeIntegerOmitZero(e,"timestamp");return{info:e,symbol:this.safeSymbol(i,t,void 0,"contract"),timestamp:s,datetime:this.iso8601(s),timeframe:void 0,longShortRatio:this.safeNumber(e,"longShortRatio")}}}},1510:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var s=i(3192);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"binancecoinm",name:"Binance COIN-M",urls:{logo:"https://github.com/user-attachments/assets/387cfc4e-5f33-48cd-8f5c-cd4854dabf0c",doc:["https://binance-docs.github.io/apidocs/delivery/en/","https://binance-docs.github.io/apidocs/spot/en","https://developers.binance.com/en"]},has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!0,option:void 0,createStopMarketOrder:!0},options:{fetchMarkets:{types:["inverse"]},defaultSubType:"inverse",leverageBrackets:void 0}})}async transferIn(e,t,i={}){return await this.futuresTransfer(e,t,3,i)}async transferOut(e,t,i={}){return await this.futuresTransfer(e,t,4,i)}}},8228:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var s=i(3192);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"binanceus",name:"Binance US",countries:["US"],hostname:"binance.us",rateLimit:50,certified:!1,pro:!0,urls:{logo:"https://github.com/user-attachments/assets/a9667919-b632-4d52-a832-df89f8a35e8c",api:{web:"https://www.binance.us",public:"https://api.binance.us/api/v3",private:"https://api.binance.us/api/v3",sapi:"https://api.binance.us/sapi/v1",sapiV2:"https://api.binance.us/sapi/v2",sapiV3:"https://api.binance.us/sapi/v3"},www:"https://www.binance.us",referral:"https://www.binance.us/?ref=35005074",doc:"https://github.com/binance-us/binance-official-api-docs",fees:"https://www.binance.us/en/fee/schedule"},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},options:{fetchMarkets:{types:["spot"]},defaultType:"spot",fetchMargins:!1,quoteOrderQty:!1},has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,closeAllPositions:!1,closePosition:!1,createReduceOnlyOrder:!1,createStopLossOrder:!1,createTakeProfitOrder:!1,fetchAllGreeks:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMySettlementHistory:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOption:!1,fetchOptionChain:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1},api:{public:{get:{ping:1,time:1,exchangeInfo:10,trades:1,historicalTrades:5,aggTrades:1,depth:{cost:1,byLimit:[[100,1],[500,5],[1e3,10],[5e3,50]]},klines:1,"ticker/price":{cost:1,noSymbol:2},avgPrice:1,"ticker/bookTicker":{cost:1,noSymbol:2},"ticker/24hr":{cost:1,noSymbol:40},ticker:{cost:2,noSymbol:100}}},private:{get:{account:10,"rateLimit/order":20,order:2,openOrders:{cost:3,noSymbol:40},myTrades:10,myPreventedMatches:10,allOrders:10,orderList:2,allOrderList:10,openOrderList:3},post:{order:1,"order/test":1,"order/cancelReplace":1,"order/oco":1},delete:{order:1,openOrders:1,orderList:1}},sapi:{get:{"system/status":1,"asset/assetDistributionHistory":1,"asset/query/trading-fee":1,"asset/query/trading-volume":1,"sub-account/spotSummary":1,"sub-account/status":1,"otc/coinPairs":1,"otc/orders/{orderId}":1,"otc/orders":1,"ocbs/orders":1,"capital/config/getall":1,"capital/withdraw/history":1,"fiatpayment/query/withdraw/history":1,"capital/deposit/address":1,"capital/deposit/hisrec":1,"fiatpayment/query/deposit/history":1,"capital/sub-account/deposit/address":1,"capital/sub-account/deposit/history":1,"asset/query/dust-logs":1,"asset/query/dust-assets":1,"marketing/referral/reward/history":1,"staking/asset":1,"staking/stakingBalance":1,"staking/history":1,"staking/stakingRewardsHistory":1,"custodian/balance":1,"custodian/supportedAssetList":1,"custodian/walletTransferHistory":1,"custodian/custodianTransferHistory":1,"custodian/openOrders":1,"custodian/order":1,"custodian/orderHistory":1,"custodian/tradeHistory":1,"custodian/settlementSetting":1,"custodian/settlementHistory":1,"cl/transferHistory":1,"apipartner/checkEligibility":1,"apipartner/rebateHistory":1},post:{"otc/quotes":1,"otc/orders":1,"fiatpayment/withdraw/apply":1,"capital/withdraw/apply":1,"asset/dust":10,"staking/stake":1,"staking/unstake":1,"custodian/walletTransfer":1,"custodian/custodianTransfer":1,"custodian/undoTransfer":1,"custodian/order":1,"custodian/ocoOrder":1,"cl/transfer":1},delete:{"custodian/cancelOrder":1,"custodian/cancelOrdersBySymbol":1,"custodian/cancelOcoOrder":1}},sapiV2:{get:{"cl/account":10,"cl/alertHistory":1}},sapiV3:{get:{accountStatus:1,apiTradingStatus:1,"sub-account/list":1,"sub-account/transfer/history":1,"sub-account/assets":1},post:{"sub-account/transfer":1}}},features:{swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}}},2171:(e,t,i)=>{"use strict";i.d(t,{A:()=>a});var s=i(3192),r=i(2079);class a extends s.A{describe(){return this.deepExtend(super.describe(),{id:"binanceusdm",name:"Binance USDⓈ-M",urls:{logo:"https://github.com/user-attachments/assets/871cbea7-eebb-4b28-b260-c1c91df0487a",doc:["https://binance-docs.github.io/apidocs/futures/en/","https://binance-docs.github.io/apidocs/spot/en","https://developers.binance.com/en"]},has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!0,option:void 0,createStopMarketOrder:!0},options:{fetchMarkets:{types:["linear"]},defaultSubType:"linear",leverageBrackets:void 0,marginTypes:{},marginModes:{}},exceptions:{exact:{"-5021":r.InvalidOrder,"-5022":r.InvalidOrder,"-5028":r.InvalidOrder}}})}async transferIn(e,t,i={}){return await this.futuresTransfer(e,t,1,i)}async transferOut(e,t,i={}){return await this.futuresTransfer(e,t,2,i)}}},2480:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(4619),r=i(2079),a=i(5147),o=i(4852),n=i(1579);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bingx",name:"BingX",countries:["US"],rateLimit:100,version:"v1",certified:!0,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!1,addMargin:!0,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!0,closePosition:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!0,createMarketSellOrderWithCost:!0,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLossOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTrailingAmountOrder:!0,createTrailingPercentOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!0,fetchLiquidations:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMarkPrice:!0,fetchMarkPrices:!0,fetchMyLiquidations:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!0,fetchPositions:!0,fetchPositionsHistory:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTransfers:!0,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!0,setMargin:!0,setMarginMode:!0,setPositionMode:!0,transfer:!0},hostname:"bingx.com",urls:{logo:"https://github-production-user-asset-6210df.s3.amazonaws.com/1294454/253675376-6983b72e-4999-4549-b177-33b374c195e3.jpg",api:{fund:"https://open-api.{hostname}/openApi",spot:"https://open-api.{hostname}/openApi",swap:"https://open-api.{hostname}/openApi",contract:"https://open-api.{hostname}/openApi",wallets:"https://open-api.{hostname}/openApi",user:"https://open-api.{hostname}/openApi",subAccount:"https://open-api.{hostname}/openApi",account:"https://open-api.{hostname}/openApi",copyTrading:"https://open-api.{hostname}/openApi",cswap:"https://open-api.{hostname}/openApi",api:"https://open-api.{hostname}/openApi"},test:{swap:"https://open-api-vst.{hostname}/openApi"},www:"https://bingx.com/",doc:"https://bingx-api.github.io/docs/",referral:"https://bingx.com/invite/OHETOM"},fees:{tierBased:!0,spot:{feeSide:"get",maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")},swap:{feeSide:"quote",maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},requiredCredentials:{apiKey:!0,secret:!0},api:{fund:{v1:{private:{get:{"account/balance":1}}}},spot:{v1:{public:{get:{"server/time":1,"common/symbols":1,"market/trades":1,"market/depth":1,"market/kline":1,"ticker/24hr":1,"ticker/price":1,"ticker/bookTicker":1}},private:{get:{"trade/query":1,"trade/openOrders":1,"trade/historyOrders":1,"trade/myTrades":2,"user/commissionRate":5,"account/balance":2,"oco/orderList":5,"oco/openOrderList":5,"oco/historyOrderList":5},post:{"trade/order":2,"trade/cancel":2,"trade/batchOrders":5,"trade/order/cancelReplace":5,"trade/cancelOrders":5,"trade/cancelOpenOrders":5,"trade/cancelAllAfter":5,"oco/order":5,"oco/cancel":5}}},v2:{public:{get:{"market/depth":1,"market/kline":1,"ticker/price":1}}},v3:{private:{get:{"get/asset/transfer":1,"asset/transfer":1,"capital/deposit/hisrec":1,"capital/withdraw/history":1},post:{"post/asset/transfer":5}}}},swap:{v1:{public:{get:{"ticker/price":1,"market/historicalTrades":1,"market/markPriceKlines":1,"trade/multiAssetsRules":1,tradingRules:1}},private:{get:{"positionSide/dual":5,"trade/batchCancelReplace":5,"trade/fullOrder":2,maintMarginRatio:2,"trade/positionHistory":2,"positionMargin/history":2,"twap/openOrders":5,"twap/historyOrders":5,"twap/orderDetail":5,"trade/assetMode":5,"user/marginAssets":5},post:{"trade/amend":2,"trade/cancelReplace":2,"positionSide/dual":5,"trade/batchCancelReplace":5,"trade/closePosition":2,"trade/getVst":5,"twap/order":5,"twap/cancelOrder":5,"trade/assetMode":5,"trade/reverse":5,"trade/autoAddMargin":5}}},v2:{public:{get:{"server/time":1,"quote/contracts":1,"quote/price":1,"quote/depth":1,"quote/trades":1,"quote/premiumIndex":1,"quote/fundingRate":1,"quote/klines":1,"quote/openInterest":1,"quote/ticker":1,"quote/bookTicker":1}},private:{get:{"user/balance":2,"user/positions":2,"user/income":2,"trade/openOrders":2,"trade/openOrder":2,"trade/order":2,"trade/marginType":5,"trade/leverage":2,"trade/forceOrders":1,"trade/allOrders":2,"trade/allFillOrders":2,"trade/fillHistory":2,"user/income/export":2,"user/commissionRate":2,"quote/bookTicker":1},post:{"trade/getVst":5,"trade/order":2,"trade/batchOrders":2,"trade/closeAllPositions":2,"trade/cancelAllAfter":5,"trade/marginType":5,"trade/leverage":5,"trade/positionMargin":5,"trade/order/test":2},delete:{"trade/order":2,"trade/batchOrders":2,"trade/allOpenOrders":2}}},v3:{public:{get:{"quote/klines":1}},private:{get:{"user/balance":2}}}},cswap:{v1:{public:{get:{"market/contracts":1,"market/premiumIndex":1,"market/openInterest":1,"market/klines":1,"market/depth":1,"market/ticker":1}},private:{get:{"trade/leverage":2,"trade/forceOrders":2,"trade/allFillOrders":2,"trade/openOrders":2,"trade/orderDetail":2,"trade/orderHistory":2,"trade/marginType":2,"user/commissionRate":2,"user/positions":2,"user/balance":2},post:{"trade/order":2,"trade/leverage":2,"trade/allOpenOrders":2,"trade/closeAllPositions":2,"trade/marginType":2,"trade/positionMargin":2},delete:{"trade/allOpenOrders":2,"trade/cancelOrder":2}}}},contract:{v1:{private:{get:{allPosition:2,allOrders:2,balance:2}}}},wallets:{v1:{private:{get:{"capital/config/getall":5,"capital/deposit/address":5,"capital/innerTransfer/records":1,"capital/subAccount/deposit/address":5,"capital/deposit/subHisrec":2,"capital/subAccount/innerTransfer/records":1,"capital/deposit/riskRecords":5},post:{"capital/withdraw/apply":5,"capital/innerTransfer/apply":5,"capital/subAccountInnerTransfer/apply":2,"capital/deposit/createSubAddress":2}}}},subAccount:{v1:{private:{get:{list:10,assets:2,allAccountBalance:2},post:{create:10,"apiKey/create":2,"apiKey/edit":2,"apiKey/del":2,updateStatus:10}}}},account:{v1:{private:{get:{uid:1,"apiKey/query":2,"account/apiPermissions":5,allAccountBalance:2},post:{"innerTransfer/authorizeSubAccount":1}}},transfer:{v1:{private:{get:{"subAccount/asset/transferHistory":1},post:{"subAccount/transferAsset/supportCoins":1,"subAccount/transferAsset":1}}}}},user:{auth:{private:{post:{userDataStream:2},put:{userDataStream:2},delete:{userDataStream:2}}}},copyTrading:{v1:{private:{get:{"swap/trace/currentTrack":2,"PFutures/traderDetail":2,"PFutures/profitHistorySummarys":2,"PFutures/profitDetail":2,"PFutures/tradingPairs":2,"spot/traderDetail":2,"spot/profitHistorySummarys":2,"spot/profitDetail":2,"spot/historyOrder":2},post:{"swap/trace/closeTrackOrder":2,"swap/trace/setTPSL":2,"PFutures/setCommission":2,"spot/trader/sellOrder":10}}}},api:{v3:{private:{get:{"asset/transfer":1,"asset/transferRecord":5,"capital/deposit/hisrec":1,"capital/withdraw/history":1},post:{"post/asset/transfer":1}}},asset:{v1:{private:{post:{transfer:5}},public:{get:{"transfer/supportCoins":5}}}}},agent:{v1:{private:{get:{"account/inviteAccountList":5,"reward/commissionDataList":5,"account/inviteRelationCheck":5,"asset/depositDetailList":5,"reward/third/commissionDataList":5,"asset/partnerData":5,"commissionDataList/referralCode":5,"account/superiorCheck":5}}}}},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},precisionMode:n.kb,exceptions:{exact:{400:r.BadRequest,401:r.AuthenticationError,403:r.PermissionDenied,404:r.BadRequest,429:r.DDoSProtection,418:r.PermissionDenied,500:r.ExchangeError,504:r.ExchangeError,100001:r.AuthenticationError,100412:r.AuthenticationError,100202:r.InsufficientFunds,100204:r.BadRequest,100400:r.BadRequest,100410:r.OperationFailed,100421:r.BadSymbol,100440:r.ExchangeError,100500:r.OperationFailed,100503:r.ExchangeError,80001:r.BadRequest,80012:r.InsufficientFunds,80014:r.BadRequest,80016:r.OrderNotFound,80017:r.OrderNotFound,100414:r.AccountSuspended,100419:r.PermissionDenied,100437:r.BadRequest,101204:r.InsufficientFunds,110425:r.InvalidOrder,"Insufficient assets":r.InsufficientFunds,"illegal transferType":r.BadRequest},broad:{}},commonCurrencies:{SNOW:"Snowman",OMNI:"OmniCat",NAP:"$NAP",TRUMP:"TRUMPMAGA",TRUMPSOL:"TRUMP"},options:{defaultType:"spot",accountsByType:{funding:"fund",spot:"spot",future:"stdFutures",swap:"USDTMPerp",linear:"USDTMPerp",inverse:"coinMPerp"},accountsById:{fund:"funding",spot:"spot",stdFutures:"future",USDTMPerp:"linear",coinMPerp:"inverse"},recvWindow:5e3,broker:"CCXT",defaultNetworks:{ETH:"ETH",USDT:"ERC20",USDC:"ERC20",BTC:"BTC",LTC:"LTC"},networks:{ARBITRUM:"ARB",MATIC:"POLYGON",ZKSYNC:"ZKSYNCERA",AVAXC:"AVAX-C",HBAR:"HEDERA"}},features:{defaultForLinear:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!0,index:!0},price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!0,trailing:!0,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!0,selfTradePrevention:!1,iceberg:!1},createOrders:{max:5},fetchMyTrades:{marginMode:!1,limit:512,daysBack:30,untilDays:30,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:1e3,daysBack:2e4,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1440}},defaultForInverse:{extends:"defaultForLinear",fetchMyTrades:{limit:1e3,daysBack:void 0,untilDays:void 0},fetchOrders:void 0},spot:{extends:"defaultForLinear",fetchCurrencies:{private:!0},createOrder:{triggerPriceType:void 0,attachedStopLossTakeProfit:void 0,trailing:!1},fetchMyTrades:{limit:1e3,daysBack:1,untilDays:1},fetchOrders:void 0,fetchClosedOrders:{limit:100,untilDays:void 0}},swap:{linear:{extends:"defaultForLinear"},inverse:{extends:"defaultForInverse"}},defaultForFuture:{extends:"defaultForLinear",fetchOrders:void 0},future:{linear:{extends:"defaultForFuture"},inverse:{extends:"defaultForFuture"}}}})}async fetchTime(e={}){const t=await this.swapV2PublicGetServerTime(e),i=this.safeDict(t,"data");return this.safeInteger(i,"serverTime")}async fetchCurrencies(e={}){if(!this.checkRequiredCredentials(!1))return{};if(this.safeBool(this.options,"sandboxMode",!1))return{};const t=await this.walletsV1PrivateGetCapitalConfigGetall(e),i=this.safeList(t,"data",[]),s={};for(let e=0;e5)throw new r.InvalidOrder(this.id+" createOrders() can not create more than 5 orders at once for swap markets");d.batchOrders=this.json(i),c=await this.swapV2PrivatePostTradeBatchOrders(d)}else{this.safeBool(t,"sync",!1)&&(d.sync=!0),d.data=this.json(i),c=await this.spotV1PrivatePostTradeBatchOrders(d)}"string"==typeof c&&(c=this.fixStringifiedJsonMembers(c),c=this.parseJson(c));const h=this.safeDict(c,"data",{}),l=this.safeList(h,"orders",[]);return this.parseOrders(l,n)}parseOrderSide(e){return this.safeString({BUY:"buy",SELL:"sell",SHORT:"sell",LONG:"buy",ask:"sell",bid:"buy"},e,e)}parseOrderType(e){return this.safeString({trigger_market:"market",trigger_limit:"limit",stop_limit:"limit",stop_market:"market",take_profit_market:"market",stop:"limit"},e,e)}parseOrder(e,t=void 0){const i=e,s=this.safeDict2(e,"newOrderResponse","orderOpenResponse");void 0!==s&&(e=s);const r=void 0===this.safeString2(e,"positionSide","ps")?"spot":"swap",o=this.safeString2(e,"symbol","s");void 0===t&&(t=this.safeMarket(o,void 0,void 0,r));const n=this.safeStringLower2(e,"side","S"),d=this.safeIntegerN(e,["time","transactTime","E","createdTime"]),c=this.safeInteger2(e,"updateTime","T"),h=this.safeStringUpperN(e,["status","X","orderStatus"]);let l=this.safeString2(e,"feeAsset","N");const u=this.safeStringN(e,["fee","commission","n"]);void 0===l&&(l=t.spot&&"buy"===n?t.base:t.quote);let p,f=this.safeValue(e,"stopLoss");void 0!==f&&""!==f&&(p=this.omitZero(this.safeString(f,"stopLoss"))),void 0!==f&&"number"!=typeof f&&""!==f&&("string"==typeof f&&(f=this.parseJson(f)),p=this.omitZero(this.safeString(f,"stopPrice")));let m,g=this.safeValue(e,"takeProfit");void 0!==g&&""!==g&&(m=this.omitZero(this.safeString(g,"takeProfit"))),void 0!==g&&"number"!=typeof g&&""!==g&&("string"==typeof g&&(g=this.parseJson(g)),m=this.omitZero(this.safeString(g,"stopPrice")));const v=this.safeStringLower2(e,"type","o"),y=this.omitZero(this.safeString2(e,"StopPrice","stopPrice"));let b=y;return void 0!==y&&(v.indexOf("stop")>-1&&void 0===p&&(p=y,b=void 0),v.indexOf("take")>-1&&void 0===m&&(m=y,b=void 0)),this.safeOrder({info:i,id:this.safeStringN(e,["orderId","i","mainOrderId"]),clientOrderId:this.safeStringN(e,["clientOrderID","clientOrderId","origClientOrderId","c"]),symbol:this.safeSymbol(o,t,"-",r),timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:c,lastUpdateTimestamp:this.safeInteger(e,"updateTime"),type:this.parseOrderType(v),timeInForce:this.safeString(e,"timeInForce"),postOnly:void 0,side:this.parseOrderSide(n),price:this.safeString2(e,"price","p"),triggerPrice:b,stopLossPrice:p,takeProfitPrice:m,average:this.safeString2(e,"avgPrice","ap"),cost:this.safeString(e,"cummulativeQuoteQty"),amount:this.safeStringN(e,["origQty","q","quantity","totalAmount"]),filled:this.safeString2(e,"executedQty","z"),remaining:void 0,status:this.parseOrderStatus(h),fee:{currency:l,cost:a.Y.stringAbs(u)},trades:void 0,reduceOnly:this.safeBool2(e,"reduceOnly","ro")},t)}parseOrderStatus(e){return this.safeString({NEW:"open",PENDING:"open",PARTIALLY_FILLED:"open",RUNNING:"open",FILLED:"closed",CANCELED:"canceled",CANCELLED:"canceled",FAILED:"canceled"},e,e)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeBool(i,"twap",!1);let a,o;if(i=this.omit(i,"twap"),s){const t={mainOrderId:e};a=await this.swapV1PrivatePostTwapCancelOrder(this.extend(t,i))}else{if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");o=this.market(t);const s={symbol:o.id},n=this.safeString2(i,"clientOrderId","clientOrderID");let d,c;i=this.omit(i,["clientOrderId"]),void 0!==n?s.clientOrderID=n:s.orderId=e,[d,i]=this.handleMarketTypeAndParams("cancelOrder",o,i),[c,i]=this.handleSubTypeAndParams("cancelOrder",o,i),a="spot"===d?await this.spotV1PrivatePostTradeCancel(this.extend(s,i)):"inverse"===c?await this.cswapV1PrivateDeleteTradeCancelOrder(this.extend(s,i)):await this.swapV2PrivateDeleteTradeOrder(this.extend(s,i))}const n=this.safeDict(a,"data",{}),d=this.safeDict(n,"order",n);return this.parseOrder(d,o)}async cancelAllOrders(e=void 0,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" cancelAllOrders() requires a symbol argument");await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let a;if(i.spot)a=await this.spotV1PrivatePostTradeCancelOpenOrders(this.extend(s,t));else{if(!i.swap)throw new r.BadRequest(this.id+" cancelAllOrders is only supported for spot and swap markets.");a=i.inverse?await this.cswapV1PrivateDeleteTradeAllOpenOrders(this.extend(s,t)):await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(s,t))}const o=this.safeDict(a,"data",{}),n=this.safeList2(o,"success","orders",[]);return this.parseOrders(n)}async cancelOrders(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrders() requires a symbol argument");await this.loadMarkets();const s=this.market(t),a={symbol:s.id},o=this.safeValue(i,"clientOrderIds");i=this.omit(i,"clientOrderIds");let n=e;const d=void 0!==o;d&&(n=o);const c=[];for(let e=0;e0,s={type:i?"ACTIVATE":"CLOSE",timeOut:i?this.parseToInt(e/1e3):0};let a,o;if([o,t]=this.handleMarketTypeAndParams("cancelAllOrdersAfter",void 0,t),"spot"===o)a=await this.spotV1PrivatePostTradeCancelAllAfter(this.extend(s,t));else{if("swap"!==o)throw new r.NotSupported(this.id+" cancelAllOrdersAfter() is not supported for "+o+" markets");a=await this.swapV2PrivatePostTradeCancelAllAfter(this.extend(s,t))}return a}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeBool(i,"twap",!1);let a,o;if(i=this.omit(i,"twap"),s){const t={mainOrderId:e};a=await this.swapV1PrivateGetTwapOrderDetail(this.extend(t,i))}else{if(void 0===t)throw new r.ArgumentsRequired(this.id+" fetchOrder() requires a symbol argument");o=this.market(t);const s={symbol:o.id,orderId:e};let n,d;[n,i]=this.handleMarketTypeAndParams("fetchOrder",o,i),[d,i]=this.handleSubTypeAndParams("fetchOrder",o,i),a="spot"===n?await this.spotV1PrivateGetTradeQuery(this.extend(s,i)):"inverse"===d?await this.cswapV1PrivateGetTradeOrderDetail(this.extend(s,i)):await this.swapV2PrivateGetTradeOrder(this.extend(s,i))}const n=this.safeDict(a,"data",{}),d=this.safeDict(n,"order",n);return this.parseOrder(d,o)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let a,o,n={};if(void 0!==e&&(a=this.market(e),n.symbol=a.id),[o,s]=this.handleMarketTypeAndParams("fetchOrders",a,s),"swap"!==o)throw new r.NotSupported(this.id+" fetchOrders() is only supported for swap markets");void 0!==i&&(n.limit=i),void 0!==t&&(n.startTime=t),[n,s]=this.handleUntilOption("endTime",n,s);const d=await this.swapV1PrivateGetTradeFullOrder(this.extend(n,s)),c=this.safeDict(d,"data",{}),h=this.safeList(c,"orders",[]);return this.parseOrders(h,a,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};let o,n,d;if(void 0!==e&&(r=this.market(e),a.symbol=r.id),[o,s]=this.handleMarketTypeAndParams("fetchOpenOrders",r,s),[n,s]=this.handleSubTypeAndParams("fetchOpenOrders",r,s),"spot"===o)d=await this.spotV1PrivateGetTradeOpenOrders(this.extend(a,s));else{const e=this.safeBool(s,"twap",!1);s=this.omit(s,"twap"),d=e?await this.swapV1PrivateGetTwapOpenOrders(this.extend(a,s)):"inverse"===n?await this.cswapV1PrivateGetTradeOpenOrders(this.extend(a,s)):await this.swapV2PrivateGetTradeOpenOrders(this.extend(a,s))}const c=this.safeDict(d,"data",{}),h=this.safeList2(c,"orders","list",[]);return this.parseOrders(h,r,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=await this.fetchCanceledAndClosedOrders(e,t,i,s);return this.filterBy(r,"status","closed")}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=await this.fetchCanceledAndClosedOrders(e,t,i,s);return this.filterBy(r,"status","canceled")}async fetchCanceledAndClosedOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};let o,n,d,c;if(void 0!==e&&(r=this.market(e),a.symbol=r.id),[o,s]=this.handleMarketTypeAndParams("fetchClosedOrders",r,s),[n,s]=this.handleSubTypeAndParams("fetchClosedOrders",r,s),[d,s]=this.handleOptionAndParams(s,"fetchClosedOrders","standard",!1),d)c=await this.contractV1PrivateGetAllOrders(this.extend(a,s));else if("spot"===o)void 0!==i&&(a.pageSize=i),c=await this.spotV1PrivateGetTradeHistoryOrders(this.extend(a,s));else{const e=this.safeBool(s,"twap",!1);if(s=this.omit(s,"twap"),e){a.pageIndex=1,a.pageSize=void 0===i?100:i,a.startTime=void 0===t?1:t;const e=this.safeInteger(s,"until",this.milliseconds());s=this.omit(s,"until"),a.endTime=e,c=await this.swapV1PrivateGetTwapHistoryOrders(this.extend(a,s))}else c="inverse"===n?await this.cswapV1PrivateGetTradeOrderHistory(this.extend(a,s)):await this.swapV2PrivateGetTradeAllOrders(this.extend(a,s))}const h=this.safeDict(c,"data",{}),l=this.safeList2(h,"orders","list",[]);return this.parseOrders(l,r,t,i)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeDict(this.options,"accountsByType",{});let n;[n,r]=this.handleSubTypeAndParams("transfer",void 0,r);let d=this.safeString(o,i,i),c=this.safeString(o,s,s);"swap"===d&&(d="inverse"===n?"coinMPerp":"USDTMPerp"),"swap"===c&&(c="inverse"===n?"coinMPerp":"USDTMPerp");const h={fromAccount:d,toAccount:c,asset:a.id,amount:this.currencyToPrecision(e,t)},l=await this.apiAssetV1PrivatePostTransfer(this.extend(h,r));return{info:l,id:this.safeString(l,"transferId"),timestamp:void 0,datetime:void 0,currency:e,amount:t,fromAccount:i,toAccount:s,status:void 0}}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let a,o={};void 0!==e&&(a=this.currency(e));const n=this.safeDict(this.options,"accountsByType",{}),d=this.safeString(s,"fromAccount"),c=this.safeString(s,"toAccount"),h=this.safeString(n,d,d),l=this.safeString(n,c,c);if(void 0===h||void 0===l)throw new r.ExchangeError(this.id+" fromAccount & toAccount parameters are required");void 0!==d&&(o.fromAccount=h),void 0!==c&&(o.toAccount=l),s=this.omit(s,["fromAccount","toAccount"]);let u=!1;if([u,s]=this.handleOptionAndParams(s,"fetchTransfers","paginate",!1),u)return await this.fetchPaginatedCallDynamic("fetchTransfers",void 0,t,i,s,100);void 0!==t&&(o.startTime=t),void 0!==i&&(o.pageSize=i),[o,s]=this.handleUntilOption("endTime",o,s);const p=await this.apiV3PrivateGetAssetTransferRecord(this.extend(o,s)),f=this.safeList(p,"rows",[]);return this.parseTransfers(f,a,t,i)}parseTransfer(e,t=void 0){const i=this.safeString(e,"transferId"),s=this.safeInteger(e,"timestamp"),r=this.safeString(e,"asset"),a=this.safeCurrencyCode(r,t),o=this.safeString(e,"status"),n=this.safeDict(this.options,"accountsById",{}),d=this.safeString(e,"fromAccount"),c=this.safeString(e,"toAccount"),h=this.safeString(n,d,d),l=this.safeString(n,c,c);return{info:e,id:i,timestamp:s,datetime:this.iso8601(s),currency:a,amount:this.safeNumber(e,"amount"),fromAccount:h,toAccount:l,status:this.parseTransferStatus(o)}}parseTransferStatus(e){return this.safeString({CONFIRMED:"ok"},e,e)}async fetchDepositAddressesByNetwork(e,t={}){await this.loadMarkets();const i=this.currency(e),s=this.safeInteger(this.options,"recvWindow"),r=this.safeInteger(this.parseParams,"recvWindow",s),a={coin:i.id,offset:0,limit:1e3,recvWindow:r},o=await this.walletsV1PrivateGetCapitalDepositAddress(this.extend(a,t)),n=this.safeList(this.safeDict(o,"data"),"data"),d=this.parseDepositAddresses(n,[i.code],!1);return this.indexBy(d,"network")}async fetchDepositAddress(e,t={}){const i=this.safeString(t,"network");t=this.omit(t,["network"]);const s=await this.fetchDepositAddressesByNetwork(e,t);if(void 0!==i)return this.safeDict(s,i);{const t=this.safeDict(this.options,"defaultNetworks"),i=this.safeString(t,e);if(void 0!==i)return this.safeDict(s,i);{const e=Object.keys(s),t=this.safeString(e,0);return this.safeDict(s,t)}}}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"tag"),s=this.safeString(e,"coin"),r=(t=this.safeCurrency(s,t)).code,a=this.safeString(e,"addressWithPrefix"),o=this.safeString(e,"network"),n=this.networkIdToCode(o,r);return this.checkAddress(a),{info:e,currency:r,network:n,address:a,tag:i}}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.coin=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i);const o=await this.spotV3PrivateGetCapitalDepositHisrec(this.extend(r,s));return this.parseTransactions(o,a,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.coin=a.id),void 0!==t&&(r.startTime=t),void 0!==i&&(r.limit=i);const o=await this.spotV3PrivateGetCapitalWithdrawHistory(this.extend(r,s));return this.parseTransactions(o,a,t,i)}parseTransaction(e,t=void 0){const i=this.safeValue(e,"data"),s=void 0===i?void 0:this.safeString(i,"id"),r=this.safeString(e,"id",s),a=this.safeString(e,"address"),o=this.safeString(e,"addressTag");let n=this.safeInteger2(e,"insertTime","timestamp"),d=this.iso8601(n);void 0===n&&(d=this.safeString(e,"applyTime"),n=this.parse8601(d));const c=this.safeString(e,"network"),h=this.safeString(e,"coin");let l=this.safeCurrencyCode(h,t);void 0!==l&&l!==c&&l.indexOf(c)>=0&&void 0!==c&&(l=l.replace(c,""));const u="0"===this.safeString(e,"transferType")?"deposit":"withdrawal";return{info:e,id:r,txid:this.safeString(e,"txId"),type:u,currency:l,network:this.networkIdToCode(c),amount:this.safeNumber(e,"amount"),status:this.parseTransactionStatus(this.safeString(e,"status")),timestamp:n,datetime:d,address:a,addressFrom:void 0,addressTo:a,tag:o,tagFrom:o,tagTo:void 0,updated:void 0,comment:this.safeString(e,"info"),fee:{currency:l,cost:this.safeNumber(e,"transactionFee"),rate:void 0},internal:void 0}}parseTransactionStatus(e){return this.safeString({0:"pending",1:"ok",10:"pending",20:"rejected",30:"ok",40:"rejected",50:"ok",60:"pending",70:"rejected",2:"pending",3:"rejected",4:"pending",5:"rejected",6:"ok"},e,e)}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");await this.loadMarkets();const s=this.market(t);if("swap"!==s.type)throw new r.BadSymbol(this.id+" setMarginMode() supports swap contracts only");if("CROSS"===(e=e.toUpperCase())&&(e="CROSSED"),"ISOLATED"!==e&&"CROSSED"!==e)throw new r.BadRequest(this.id+" setMarginMode() marginMode argument should be isolated or cross");const a={symbol:s.id,marginType:e};let o;return[o,i]=this.handleSubTypeAndParams("setMarginMode",s,i),"inverse"===o?await this.cswapV1PrivatePostTradeMarginType(this.extend(a,i)):await this.swapV2PrivatePostTradeMarginType(this.extend(a,i))}async addMargin(e,t,i={}){return await this.setMargin(e,t,this.extend({type:1},i))}async reduceMargin(e,t,i={}){return await this.setMargin(e,t,this.extend({type:2},i))}async setMargin(e,t,i={}){const s=this.safeInteger(i,"type");if(void 0===s)throw new r.ArgumentsRequired(this.id+" setMargin() requires a type parameter either 1 (increase margin) or 2 (decrease margin)");if(!this.inArray(s,[1,2]))throw new r.ArgumentsRequired(this.id+" setMargin() requires a type parameter either 1 (increase margin) or 2 (decrease margin)");await this.loadMarkets();const a=this.market(e),o={symbol:a.id,amount:this.amountToPrecision(a.symbol,t),type:s},n=await this.swapV2PrivatePostTradePositionMargin(this.extend(o,i));return this.parseMarginModification(n,a)}parseMarginModification(e,t=void 0){const i=this.safeString(e,"type");return{info:e,symbol:this.safeString(t,"symbol"),type:"1"===i?"add":"reduce",marginMode:"isolated",amount:this.safeNumber(e,"amount"),total:this.safeNumber(e,"margin"),code:this.safeString(t,"settle"),status:void 0,timestamp:void 0,datetime:void 0}}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r;r=i.inverse?await this.cswapV1PrivateGetTradeLeverage(this.extend(s,t)):await this.swapV2PrivateGetTradeLeverage(this.extend(s,t));const a=this.safeDict(r,"data",{});return this.parseLeverage(a,i)}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),marginMode:void 0,longLeverage:this.safeInteger(e,"longLeverage"),shortLeverage:this.safeInteger(e,"shortLeverage")}}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");const s=this.safeStringUpper(i,"side");this.checkRequiredArgument("setLeverage",s,"side",["LONG","SHORT","BOTH"]),await this.loadMarkets();const a=this.market(t),o={symbol:a.id,side:s,leverage:e};return a.inverse?await this.cswapV1PrivatePostTradeLeverage(this.extend(o,i)):await this.swapV2PrivatePostTradeLeverage(this.extend(o,i))}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={};let n,d,c;if([c,s]=this.handleSubTypeAndParams("fetchMyTrades",a,s),"inverse"===c){if(void 0===this.safeString(s,"orderId"))throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires an orderId argument for inverse swap trades");d=await this.cswapV1PrivateGetTradeAllFillOrders(this.extend(o,s)),n=this.safeList(d,"data",[])}else{o.symbol=a.id;const e=this.milliseconds();if(void 0!==t){o[a.spot?"startTime":"startTs"]=t}else a.swap&&(o.startTs=e-2592e6);const r=this.safeInteger(s,"until");if(s=this.omit(s,"until"),void 0!==r){o[a.spot?"endTime":"endTs"]=r}else a.swap&&(o.endTs=e);if(a.spot){void 0!==i&&(o.limit=i),d=await this.spotV1PrivateGetTradeMyTrades(this.extend(o,s));const e=this.safeDict(d,"data",{});n=this.safeList(e,"fills",[])}else{const e=this.safeStringUpper(s,"tradingUnit","CONT");s=this.omit(s,"tradingUnit"),o.tradingUnit=e,d=await this.swapV2PrivateGetTradeAllFillOrders(this.extend(o,s));const t=this.safeDict(d,"data",{});n=this.safeList(t,"fill_orders",[])}}return this.parseTrades(n,a,t,i,s)}parseDepositWithdrawFee(e,t=void 0){const i=this.safeDict(e,"networks",{}),s=Object.keys(i),r=s.length,a={info:i,withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}};if(0!==r)for(let e=0;e0&&(t+=","),t+=r[e].toString()}t+="]",e[s]=t}}return e}async fetchMyLiquidations(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a,o,n,d={autoCloseType:"LIQUIDATION"};if([d,s]=this.handleUntilOption("endTime",d,s),void 0!==e&&(r=this.market(e),d.symbol=r.id),void 0!==t&&(d.startTime=t),void 0!==i&&(d.limit=i),[a,s]=this.handleSubTypeAndParams("fetchMyLiquidations",r,s),"inverse"===a)o=await this.cswapV1PrivateGetTradeForceOrders(this.extend(d,s)),n=this.safeList(o,"data",[]);else{o=await this.swapV2PrivateGetTradeForceOrders(this.extend(d,s));const e=this.safeDict(o,"data",{});n=this.safeList(e,"orders",[])}return this.parseLiquidations(n,r,t,i)}parseLiquidation(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeInteger(e,"time"),r=this.safeString(e,"executedQty"),o=this.safeString(t,"contractSize"),n=this.safeString(e,"avgPrice"),d=a.Y.stringMul(r,o),c=a.Y.stringMul(d,n);return this.safeLiquidation({info:e,symbol:this.safeSymbol(i,t),contracts:this.parseNumber(r),contractSize:this.parseNumber(o),price:this.parseNumber(n),baseValue:this.parseNumber(d),quoteValue:this.parseNumber(c),timestamp:s,datetime:this.iso8601(s)})}async closePosition(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={};let a;void 0!==this.safeString(i,"positionId")?a=await this.swapV1PrivatePostTradeClosePosition(this.extend(r,i)):(r.symbol=s.id,a=s.inverse?await this.cswapV1PrivatePostTradeCloseAllPositions(this.extend(r,i)):await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(r,i)));const o=this.safeDict(a,"data");return this.parseOrder(o,s)}async closeAllPositions(e={}){await this.loadMarkets();const t=this.safeInteger(this.options,"recvWindow"),i=this.safeInteger(this.parseParams,"recvWindow",t);let s,a;if([s,e]=this.handleMarketTypeAndParams("closeAllPositions",void 0,e),[a,e]=this.handleSubTypeAndParams("closeAllPositions",void 0,e),"margin"===s)throw new r.BadRequest(this.id+" closePositions () cannot be used for "+s+" markets");const o={recvWindow:i};let n;n="inverse"===a?await this.cswapV1PrivatePostTradeCloseAllPositions(this.extend(o,e)):await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(o,e));const d=this.safeDict(n,"data",{}),c=this.safeList(d,"success",[]),h=[];for(let e=0;e0?e+=',"'+i.toString()+'"':e='"'+i.toString()+'"':t>0?e+=","+i.toString():e=i.toString()}s="["+e+"]",o=s}0===t?r=a+"="+o:r+="&"+a+"="+o}return r}async fetchMarketLeverageTiers(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.swap)throw new r.BadRequest(this.id+" fetchMarketLeverageTiers() supports swap markets only");const s={symbol:i.id},a=await this.swapV1PrivateGetMaintMarginRatio(this.extend(s,t)),o=this.safeList(a,"data",[]);return this.parseMarketLeverageTiers(o,i)}parseMarketLeverageTiers(e,t=void 0){const i=[];for(let s=0;s{"use strict";i.d(t,{A:()=>d});var s=i(3885),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bit2c",name:"Bit2C",countries:["IL"],rateLimit:3e3,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,ws:!1},urls:{logo:"https://github.com/user-attachments/assets/db0bce50-6842-4c09-a1d5-0c87d22118aa",api:{rest:"https://bit2c.co.il"},www:"https://www.bit2c.co.il",referral:"https://bit2c.co.il/Aff/63bfed10-e359-420c-ab5a-ad368dab0baf",doc:["https://www.bit2c.co.il/home/api","https://github.com/OferE/bit2c"]},api:{public:{get:["Exchanges/{pair}/Ticker","Exchanges/{pair}/orderbook","Exchanges/{pair}/trades","Exchanges/{pair}/lasttrades"]},private:{post:["Merchant/CreateCheckout","Funds/AddCoinFundsRequest","Order/AddFund","Order/AddOrder","Order/GetById","Order/AddOrderMarketPriceBuy","Order/AddOrderMarketPriceSell","Order/CancelOrder","Order/AddCoinFundsRequest","Order/AddStopOrder","Payment/GetMyId","Payment/Send","Payment/Pay"],get:["Account/Balance","Account/Balance/v2","Order/MyOrders","Order/GetById","Order/AccountHistory","Order/OrderHistory"]}},markets:{"BTC/NIS":this.safeMarketStructure({id:"BtcNis",symbol:"BTC/NIS",base:"BTC",quote:"NIS",baseId:"Btc",quoteId:"Nis",type:"spot",spot:!0}),"ETH/NIS":this.safeMarketStructure({id:"EthNis",symbol:"ETH/NIS",base:"ETH",quote:"NIS",baseId:"Eth",quoteId:"Nis",type:"spot",spot:!0}),"LTC/NIS":this.safeMarketStructure({id:"LtcNis",symbol:"LTC/NIS",base:"LTC",quote:"NIS",baseId:"Ltc",quoteId:"Nis",type:"spot",spot:!0}),"USDC/NIS":this.safeMarketStructure({id:"UsdcNis",symbol:"USDC/NIS",base:"USDC",quote:"NIS",baseId:"Usdc",quoteId:"Nis",type:"spot",spot:!0})},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.025"),taker:this.parseNumber("0.03"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.03")],[this.parseNumber("20000"),this.parseNumber("0.0275")],[this.parseNumber("50000"),this.parseNumber("0.025")],[this.parseNumber("75000"),this.parseNumber("0.0225")],[this.parseNumber("100000"),this.parseNumber("0.02")],[this.parseNumber("250000"),this.parseNumber("0.015")],[this.parseNumber("500000"),this.parseNumber("0.0125")],[this.parseNumber("750000"),this.parseNumber("0.01")],[this.parseNumber("1000000"),this.parseNumber("0.008")],[this.parseNumber("2000000"),this.parseNumber("0.006")],[this.parseNumber("3000000"),this.parseNumber("0.004")],[this.parseNumber("4000000"),this.parseNumber("0.002")]],maker:[[this.parseNumber("0"),this.parseNumber("0.025")],[this.parseNumber("20000"),this.parseNumber("0.0225")],[this.parseNumber("50000"),this.parseNumber("0.02")],[this.parseNumber("75000"),this.parseNumber("0.0175")],[this.parseNumber("100000"),this.parseNumber("0.015")],[this.parseNumber("250000"),this.parseNumber("0.01")],[this.parseNumber("500000"),this.parseNumber("0.0075")],[this.parseNumber("750000"),this.parseNumber("0.005")],[this.parseNumber("1000000"),this.parseNumber("0.004")],[this.parseNumber("2000000"),this.parseNumber("0.003")],[this.parseNumber("3000000"),this.parseNumber("0.002")],[this.parseNumber("4000000"),this.parseNumber("0.001")]]}}},options:{fetchTradesMethod:"public_get_exchanges_pair_trades"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:30,untilDays:30,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"Please provide valid APIkey":r.AuthenticationError,"No order found.":r.OrderNotFound},broad:{"Please provide valid nonce":r.InvalidNonce,"please approve new terms of use on site":r.PermissionDenied}}})}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0},i=Object.keys(this.currencies);for(let s=0;s{"use strict";i.d(t,{A:()=>n});var s=i(2308),r=i(2079),a=i(1579),o=i(4852);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitbank",name:"bitbank",countries:["JP"],version:"v1",rateLimit:100,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1min","5m":"5min","15m":"15min","30m":"30min","1h":"1hour","4h":"4hour","8h":"8hour","12h":"12hour","1d":"1day","1w":"1week"},hostname:"bitbank.cc",urls:{logo:"https://github.com/user-attachments/assets/9d616de0-8a88-4468-8e38-d269acab0348",api:{public:"https://public.{hostname}",private:"https://api.{hostname}",markets:"https://api.{hostname}"},www:"https://bitbank.cc/",doc:"https://docs.bitbank.cc/",fees:"https://bitbank.cc/docs/fees/"},api:{public:{get:{"{pair}/ticker":1,tickers:1,tickers_jpy:1,"{pair}/depth":1,"{pair}/transactions":1,"{pair}/transactions/{yyyymmdd}":1,"{pair}/candlestick/{candletype}/{yyyymmdd}":1,"{pair}/circuit_break_info":1}},private:{get:{"user/assets":1,"user/spot/order":1,"user/spot/active_orders":1,"user/margin/positions":1,"user/spot/trade_history":1,"user/deposit_history":1,"user/unconfirmed_deposits":1,"user/deposit_originators":1,"user/withdrawal_account":1,"user/withdrawal_history":1,"spot/status":1,"spot/pairs":1},post:{"user/spot/order":1.66,"user/spot/cancel_order":1.66,"user/spot/cancel_orders":1.66,"user/spot/orders_info":1.66,"user/confirm_deposits":1.66,"user/confirm_deposits_all":1.66,"user/request_withdrawal":1.66}},markets:{get:{"spot/pairs":1}}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:a.kb,exceptions:{exact:{20001:r.AuthenticationError,20002:r.AuthenticationError,20003:r.AuthenticationError,20005:r.AuthenticationError,20004:r.InvalidNonce,40020:r.InvalidOrder,40021:r.InvalidOrder,40025:r.ExchangeError,40013:r.OrderNotFound,40014:r.OrderNotFound,50008:r.PermissionDenied,50009:r.OrderNotFound,50010:r.OrderNotFound,60001:r.InsufficientFunds,60005:r.InvalidOrder}}})}async fetchMarkets(e={}){const t=await this.marketsGetSpotPairs(e),i=this.safeValue(t,"data"),s=this.safeValue(i,"pairs",[]);return this.parseMarkets(s)}parseMarket(e){const t=this.safeString(e,"name"),i=this.safeString(e,"base_asset"),s=this.safeString(e,"quote_asset"),r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s);return{id:t,symbol:r+"/"+a,base:r,quote:a,settle:void 0,baseId:i,quoteId:s,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:this.safeValue(e,"is_enabled"),contract:!1,linear:void 0,inverse:void 0,taker:this.safeNumber(e,"taker_fee_rate_quote"),maker:this.safeNumber(e,"maker_fee_rate_quote"),contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(e,"amount_digits"))),price:this.parseNumber(this.parsePrecision(this.safeString(e,"price_digits")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"unit_amount"),max:this.safeNumber(e,"limit_max_amount")},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}parseTicker(e,t=void 0){const i=this.safeSymbol(void 0,t),s=this.safeInteger(e,"timestamp"),r=this.safeString(e,"last");return this.safeTicker({symbol:i,timestamp:s,datetime:this.iso8601(s),high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"vol"),quoteVolume:void 0,info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={pair:i.id},r=await this.publicGetPairTicker(this.extend(s,t)),a=this.safeDict(r,"data",{});return this.parseTicker(a,i)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={pair:s.id},a=await this.publicGetPairDepth(this.extend(r,i)),o=this.safeValue(a,"data",{}),n=this.safeInteger(o,"timestamp");return this.parseOrderBook(o,s.symbol,n)}parseTrade(e,t=void 0){const i=this.safeInteger(e,"executed_at");t=this.safeMarket(void 0,t);const s=this.safeString(e,"price"),r=this.safeString(e,"amount"),a=this.safeString2(e,"transaction_id","trade_id"),o=this.safeString(e,"maker_taker");let n;const d=this.safeString(e,"fee_amount_quote");void 0!==d&&(n={currency:t.quote,cost:d});const c=this.safeString(e,"order_id"),h=this.safeString(e,"type"),l=this.safeString(e,"side");return this.safeTrade({timestamp:i,datetime:this.iso8601(i),symbol:t.symbol,id:a,order:c,type:h,side:l,takerOrMaker:o,price:s,amount:r,cost:void 0,fee:n,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id},o=await this.publicGetPairTransactions(this.extend(a,s)),n=this.safeValue(o,"data",{}),d=this.safeList(n,"transactions",[]);return this.parseTrades(d,r,t,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.marketsGetSpotPairs(e),i=this.safeValue(t,"data",{}),s=this.safeValue(i,"pairs",[]),r={};for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(5625),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitbns",name:"Bitbns",countries:["IN"],rateLimit:1e3,certified:!1,version:"v2",has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:void 0,cancelAllOrders:!1,cancelOrder:!0,createOrder:!0,createStopOrder:!0,createTriggerOrder:!0,fechCurrencies:!1,fetchBalance:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:"emulated",fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,transfer:!1,withdraw:!1},hostname:"bitbns.com",urls:{logo:"https://github.com/user-attachments/assets/a5b9a562-cdd8-4bea-9fa7-fd24c1dad3d9",api:{www:"https://{hostname}",v1:"https://api.{hostname}/api/trade/v1",v2:"https://api.{hostname}/api/trade/v2"},www:"https://bitbns.com",referral:"https://ref.bitbns.com/1090961",doc:["https://bitbns.com/trade/#/api-trading/"],fees:"https://bitbns.com/fees"},api:{www:{get:["order/fetchMarkets","order/fetchTickers","order/fetchOrderbook","order/getTickerWithVolume","exchangeData/ohlc","exchangeData/orderBook","exchangeData/tradedetails"]},v1:{get:["platform/status","tickers","orderbook/sell/{symbol}","orderbook/buy/{symbol}"],post:["currentCoinBalance/EVERYTHING","getApiUsageStatus/USAGE","getOrderSocketToken/USAGE","currentCoinBalance/{symbol}","orderStatus/{symbol}","depositHistory/{symbol}","withdrawHistory/{symbol}","withdrawHistoryAll/{symbol}","depositHistoryAll/{symbol}","listOpenOrders/{symbol}","listOpenStopOrders/{symbol}","getCoinAddress/{symbol}","placeSellOrder/{symbol}","placeBuyOrder/{symbol}","buyStopLoss/{symbol}","sellStopLoss/{symbol}","cancelOrder/{symbol}","cancelStopLossOrder/{symbol}","listExecutedOrders/{symbol}","placeMarketOrder/{symbol}","placeMarketOrderQnty/{symbol}"]},v2:{post:["orders","cancel","getordersnew","marginOrders"]}},fees:{trading:{feeSide:"quote",tierBased:!1,percentage:!0,taker:this.parseNumber("0.0025"),maker:this.parseNumber("0.0025")}},precisionMode:o.kb,features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!0,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:100}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{400:r.BadRequest,409:r.BadSymbol,416:r.InsufficientFunds,417:r.OrderNotFound},broad:{}}})}async fetchStatus(e={}){const t=await this.v1GetPlatformStatus(e),i=this.safeString(t,"status");return{status:this.safeString({1:"ok"},i,i),updated:void 0,eta:void 0,url:void 0,info:t}}async fetchMarkets(e={}){const t=await this.wwwGetOrderFetchMarkets(e),i=[];for(let e=0;e1){let e=this.safeString(a,1);const r=this.account();r.free=this.safeString(s,t),r.used=this.safeString(s,"inorder"+e),"Money"===e&&(e="INR");i[this.safeCurrencyCode(e)]=r}}return this.safeBalance(i)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v1PostCurrentCoinBalanceEVERYTHING(e);return this.parseBalance(t)}parseStatus(e){return this.safeString({"-1":"cancelled",0:"open",1:"open",2:"done"},e,e)}parseOrder(e,t=void 0){const i=this.safeString2(e,"id","entry_id"),s=this.safeString(e,"time"),r=this.safeString(e,"t_rate");let a=this.safeString(e,"type");"0"===a?a="buy":"1"===a&&(a="sell");const o=this.safeString(e,"data");let n=this.safeString(e,"status");return n="Successfully cancelled the order"===o?"cancelled":this.parseStatus(n),this.safeOrder({info:e,id:i,clientOrderId:void 0,timestamp:this.parse8601(s),datetime:s,lastTradeTimestamp:void 0,symbol:this.safeString(t,"symbol"),timeInForce:void 0,postOnly:void 0,side:a,price:this.safeString(e,"rate"),triggerPrice:r,amount:this.safeString(e,"btc"),cost:void 0,average:void 0,filled:void 0,remaining:void 0,status:n,fee:{cost:void 0,currency:void 0,rate:void 0},trades:void 0},t)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.safeStringN(a,["triggerPrice","stopPrice","t_rate"]),d=this.safeString(a,"target_rate"),c=this.safeString(a,"trail_rate");a=this.omit(a,["triggerPrice","stopPrice","trail_rate","target_rate","t_rate"]);const h={side:i.toUpperCase(),symbol:o.uppercaseId,quantity:this.amountToPrecision(e,s)};let l="v2PostOrders";"limit"===t?h.rate=this.priceToPrecision(e,r):(l="v1PostPlaceMarketOrderQntySymbol",h.market=o.quoteId),void 0!==n&&(h.t_rate=this.priceToPrecision(e,n)),void 0!==d&&(h.target_rate=this.priceToPrecision(e,d)),void 0!==c&&(h.trail_rate=this.priceToPrecision(e,c));const u=await this[l](this.extend(h,a));return this.parseOrder(u,o)}async cancelOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const s=this.market(t),a=this.safeBool2(i,"trigger","stop");i=this.omit(i,["trigger","stop"]);const o={entry_id:e,symbol:s.uppercaseId};let n;const d=a?"StopLossOrder":"Order";let c="USDT"===s.quoteId?"usdtcancel":"cancel";return c+=d,o.side=c,n=await this.v2PostCancel(this.extend(o,i)),this.parseOrder(n,s)}async fetchOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" fetchOrder() requires a symbol argument");await this.loadMarkets();const s=this.market(t),a={symbol:s.id,entry_id:e};if(this.safeBool2(i,"trigger","stop"))throw new r.BadRequest(this.id+" fetchOrder cannot fetch stop orders");const o=await this.v1PostOrderStatusSymbol(this.extend(a,i)),n=this.safeList(o,"data",[]),d=this.safeDict(n,0);return this.parseOrder(d,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o=this.safeBool2(s,"trigger","stop");s=this.omit(s,["trigger","stop"]);const n="USDT"===a.quoteId?"usdtListOpen":"listOpen",d={symbol:a.uppercaseId,page:0,side:o?n+"StopOrders":n+"Orders"},c=await this.v2PostGetordersnew(this.extend(d,s)),h=this.safeList(c,"data",[]);return this.parseOrders(h,a,t,i)}parseTrade(e,t=void 0){t=this.safeMarket(void 0,t);const i=this.safeString2(e,"id","tradeId");let s=this.parse8601(this.safeString(e,"date"));s=this.safeInteger(e,"timestamp",s);const r=this.safeString2(e,"rate","price");let o=this.safeString(e,"amount"),n=this.safeStringLower(e,"type");void 0!==n&&(n.indexOf("buy")>=0?n="buy":n.indexOf("sell")>=0&&(n="sell"));const d=this.safeString(e,"factor");let c;void 0!==d?o=a.Y.stringDiv(o,d):(o=this.safeString(e,"base_volume"),c=this.safeString(e,"quote_volume"));const h=t.symbol;let l;const u=this.safeString(e,"fee");if(void 0!==u){l={cost:u,currency:t.quote}}return this.safeTrade({info:e,timestamp:s,datetime:this.iso8601(s),symbol:h,id:i,order:i,type:void 0,side:n,takerOrMaker:void 0,price:r,amount:o,cost:c,fee:l},t)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={symbol:a.id,page:0};void 0!==t&&(o.since=this.iso8601(t));const n=await this.v1PostListExecutedOrdersSymbol(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseTrades(d,a,t,i)}async fetchTrades(e,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={coin:a.baseId,market:a.quoteId},n=await this.wwwGetExchangeDataTradedetails(this.extend(o,s));return this.parseTrades(n,a,t,i)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires a currency code argument");await this.loadMarkets();const a=this.currency(e),o={symbol:a.id,page:0},n=await this.v1PostDepositHistorySymbol(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseTransactions(d,a,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchWithdrawals() requires a currency code argument");await this.loadMarkets();const a=this.currency(e),o={symbol:a.id,page:0},n=await this.v1PostWithdrawHistorySymbol(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseTransactions(d,a,t,i)}parseTransactionStatusByType(e,t=void 0){const i=this.safeDict({deposit:{0:"pending",1:"ok"},withdrawal:{0:"pending",1:"canceled",2:"pending",3:"failed",4:"pending",5:"failed",6:"ok"}},t,{});return this.safeString(i,e,e)}parseTransaction(e,t=void 0){const i=this.safeString(e,"unit"),s=this.safeCurrencyCode(i,t),r=this.parse8601(this.safeString2(e,"date","timestamp"));let a=this.safeString(e,"type");const o=this.safeString(e,"expTime","");let n;void 0!==a&&(a.indexOf("deposit")>=0?(a="deposit",n="ok"):(a.indexOf("withdraw")>=0||o.indexOf("withdraw")>=0)&&(a="withdrawal"));const d=this.safeNumber(e,"amount"),c=this.safeNumber(e,"fee");let h;return void 0!==c&&(h={currency:s,cost:c}),{info:e,id:void 0,txid:void 0,timestamp:r,datetime:this.iso8601(r),network:void 0,address:void 0,addressTo:void 0,addressFrom:void 0,tag:void 0,tagTo:void 0,tagFrom:void 0,type:a,amount:d,currency:s,status:n,updated:void 0,comment:void 0,internal:void 0,fee:h}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i={symbol:this.currency(e).id},s=await this.v1PostGetCoinAddressSymbol(this.extend(i,t)),r=this.safeDict(s,"data",{}),a=this.safeString(r,"token"),o=this.safeString(r,"tag");return this.checkAddress(a),{info:s,currency:e,network:void 0,address:a,tag:o}}nonce(){return this.milliseconds()}sign(e,t="www",i="GET",s={},a=void 0,o=void 0){if(!(t in this.urls.api))throw new r.ExchangeError(this.id+" does not have a testnet/sandbox URL for "+t+" endpoints");"www"!==t&&(this.checkRequiredCredentials(),a={"X-BITBNS-APIKEY":this.apiKey});let d=this.implodeHostname(this.urls.api[t])+"/"+this.implodeParams(e,s);const c=this.omit(s,this.extractParams(e)),h=this.nonce().toString();if("GET"===i)Object.keys(c).length&&(d+="?"+this.urlencode(c));else if("POST"===i){const e={timeStamp_nonce:h,body:o=Object.keys(c).length?this.json(c):"{}"},t=this.stringToBase64(this.json(e)),i=this.hmac(this.encode(t),this.encode(this.secret),n.Zf);a["X-BITBNS-PAYLOAD"]=t,a["X-BITBNS-SIGNATURE"]=i,a["Content-Type"]="application/x-www-form-urlencoded"}return{url:d,method:i,body:o,headers:a}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.safeString(n,"code"),l=this.safeString(n,"msg");if(void 0!==h&&"200"!==h&&"204"!==h||void 0!==l){const e=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,h,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwBroadlyMatchedException(this.exceptions.broad,l,e),new r.ExchangeError(e)}}}},8657:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(2079),r=i(5147),a=i(9332),o=i(1579),n=i(7481);class d extends a.A{describe(){return this.deepExtend(super.describe(),{id:"bitfinex",name:"Bitfinex",countries:["VG"],version:"v2",certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,createDepositAddress:!0,createLimitOrder:!0,createMarketOrder:!0,createOrder:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTrailingAmountOrder:!0,createTrailingPercentOrder:!1,createTriggerOrder:!0,editOrder:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrder:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingRate:"emulated",fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!0,fetchMarginMode:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!0,fetchOpenInterests:!0,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTickers:!0,fetchTime:!1,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:void 0,fetchTransactions:"emulated",fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!0,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","3h":"3h","4h":"4h","6h":"6h","12h":"12h","1d":"1D","1w":"7D","2w":"14D","1M":"1M"},rateLimit:250,urls:{logo:"https://github.com/user-attachments/assets/4a8e947f-ab46-481a-a8ae-8b20e9b03178",api:{v1:"https://api.bitfinex.com",public:"https://api-pub.bitfinex.com",private:"https://api.bitfinex.com"},www:"https://www.bitfinex.com",doc:["https://docs.bitfinex.com/v2/docs/","https://github.com/bitfinexcom/bitfinex-api-node"],fees:"https://www.bitfinex.com/fees"},api:{public:{get:{"conf/{config}":2.7,"conf/pub:{action}:{object}":2.7,"conf/pub:{action}:{object}:{detail}":2.7,"conf/pub:map:{object}":2.7,"conf/pub:map:{object}:{detail}":2.7,"conf/pub:map:currency:{detail}":2.7,"conf/pub:map:currency:sym":2.7,"conf/pub:map:currency:label":2.7,"conf/pub:map:currency:unit":2.7,"conf/pub:map:currency:undl":2.7,"conf/pub:map:currency:pool":2.7,"conf/pub:map:currency:explorer":2.7,"conf/pub:map:currency:tx:fee":2.7,"conf/pub:map:tx:method":2.7,"conf/pub:list:{object}":2.7,"conf/pub:list:{object}:{detail}":2.7,"conf/pub:list:currency":2.7,"conf/pub:list:pair:exchange":2.7,"conf/pub:list:pair:margin":2.7,"conf/pub:list:pair:futures":2.7,"conf/pub:list:competitions":2.7,"conf/pub:info:{object}":2.7,"conf/pub:info:{object}:{detail}":2.7,"conf/pub:info:pair":2.7,"conf/pub:info:pair:futures":2.7,"conf/pub:info:tx:status":2.7,"conf/pub:fees":2.7,"platform/status":8,tickers:2.7,"ticker/{symbol}":2.7,"tickers/hist":2.7,"trades/{symbol}/hist":2.7,"book/{symbol}/{precision}":1,"book/{symbol}/P0":1,"book/{symbol}/P1":1,"book/{symbol}/P2":1,"book/{symbol}/P3":1,"book/{symbol}/R0":1,"stats1/{key}:{size}:{symbol}:{side}/{section}":2.7,"stats1/{key}:{size}:{symbol}:{side}/last":2.7,"stats1/{key}:{size}:{symbol}:{side}/hist":2.7,"stats1/{key}:{size}:{symbol}/{section}":2.7,"stats1/{key}:{size}:{symbol}/last":2.7,"stats1/{key}:{size}:{symbol}/hist":2.7,"stats1/{key}:{size}:{symbol}:long/last":2.7,"stats1/{key}:{size}:{symbol}:long/hist":2.7,"stats1/{key}:{size}:{symbol}:short/last":2.7,"stats1/{key}:{size}:{symbol}:short/hist":2.7,"candles/trade:{timeframe}:{symbol}:{period}/{section}":2.7,"candles/trade:{timeframe}:{symbol}/{section}":2.7,"candles/trade:{timeframe}:{symbol}/last":2.7,"candles/trade:{timeframe}:{symbol}/hist":2.7,"status/{type}":2.7,"status/deriv":2.7,"status/deriv/{symbol}/hist":2.7,"liquidations/hist":80,"rankings/{key}:{timeframe}:{symbol}/{section}":2.7,"rankings/{key}:{timeframe}:{symbol}/hist":2.7,"pulse/hist":2.7,"pulse/profile/{nickname}":2.7,"funding/stats/{symbol}/hist":10,"ext/vasps":1},post:{"calc/trade/avg":2.7,"calc/fx":2.7}},private:{post:{"auth/r/wallets":2.7,"auth/r/wallets/hist":2.7,"auth/r/orders":2.7,"auth/r/orders/{symbol}":2.7,"auth/w/order/submit":2.7,"auth/w/order/update":2.7,"auth/w/order/cancel":2.7,"auth/w/order/multi":2.7,"auth/w/order/cancel/multi":2.7,"auth/r/orders/{symbol}/hist":2.7,"auth/r/orders/hist":2.7,"auth/r/order/{symbol}:{id}/trades":2.7,"auth/r/trades/{symbol}/hist":2.7,"auth/r/trades/hist":2.7,"auth/r/ledgers/{currency}/hist":2.7,"auth/r/ledgers/hist":2.7,"auth/r/info/margin/{key}":2.7,"auth/r/info/margin/base":2.7,"auth/r/info/margin/sym_all":2.7,"auth/r/positions":2.7,"auth/w/position/claim":2.7,"auth/w/position/increase:":2.7,"auth/r/position/increase/info":2.7,"auth/r/positions/hist":2.7,"auth/r/positions/audit":2.7,"auth/r/positions/snap":2.7,"auth/w/deriv/collateral/set":2.7,"auth/w/deriv/collateral/limits":2.7,"auth/r/funding/offers":2.7,"auth/r/funding/offers/{symbol}":2.7,"auth/w/funding/offer/submit":2.7,"auth/w/funding/offer/cancel":2.7,"auth/w/funding/offer/cancel/all":2.7,"auth/w/funding/close":2.7,"auth/w/funding/auto":2.7,"auth/w/funding/keep":2.7,"auth/r/funding/offers/{symbol}/hist":2.7,"auth/r/funding/offers/hist":2.7,"auth/r/funding/loans":2.7,"auth/r/funding/loans/hist":2.7,"auth/r/funding/loans/{symbol}":2.7,"auth/r/funding/loans/{symbol}/hist":2.7,"auth/r/funding/credits":2.7,"auth/r/funding/credits/hist":2.7,"auth/r/funding/credits/{symbol}":2.7,"auth/r/funding/credits/{symbol}/hist":2.7,"auth/r/funding/trades/{symbol}/hist":2.7,"auth/r/funding/trades/hist":2.7,"auth/r/info/funding/{key}":2.7,"auth/r/info/user":2.7,"auth/r/summary":2.7,"auth/r/logins/hist":2.7,"auth/r/permissions":2.7,"auth/w/token":2.7,"auth/r/audit/hist":2.7,"auth/w/transfer":2.7,"auth/w/deposit/address":24,"auth/w/deposit/invoice":24,"auth/w/withdraw":24,"auth/r/movements/{currency}/hist":2.7,"auth/r/movements/hist":2.7,"auth/r/alerts":5.34,"auth/w/alert/set":2.7,"auth/w/alert/price:{symbol}:{price}/del":2.7,"auth/w/alert/{type}:{symbol}:{price}/del":2.7,"auth/calc/order/avail":2.7,"auth/w/settings/set":2.7,"auth/r/settings":2.7,"auth/w/settings/del":2.7,"auth/r/pulse/hist":2.7,"auth/w/pulse/add":16,"auth/w/pulse/del":2.7}}},fees:{trading:{feeSide:"get",percentage:!0,tierBased:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.002"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("500000"),this.parseNumber("0.002")],[this.parseNumber("1000000"),this.parseNumber("0.002")],[this.parseNumber("2500000"),this.parseNumber("0.002")],[this.parseNumber("5000000"),this.parseNumber("0.002")],[this.parseNumber("7500000"),this.parseNumber("0.002")],[this.parseNumber("10000000"),this.parseNumber("0.0018")],[this.parseNumber("15000000"),this.parseNumber("0.0016")],[this.parseNumber("20000000"),this.parseNumber("0.0014")],[this.parseNumber("25000000"),this.parseNumber("0.0012")],[this.parseNumber("30000000"),this.parseNumber("0.001")]],maker:[[this.parseNumber("0"),this.parseNumber("0.001")],[this.parseNumber("500000"),this.parseNumber("0.0008")],[this.parseNumber("1000000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0004")],[this.parseNumber("5000000"),this.parseNumber("0.0002")],[this.parseNumber("7500000"),this.parseNumber("0")],[this.parseNumber("10000000"),this.parseNumber("0")],[this.parseNumber("15000000"),this.parseNumber("0")],[this.parseNumber("20000000"),this.parseNumber("0")],[this.parseNumber("25000000"),this.parseNumber("0")],[this.parseNumber("30000000"),this.parseNumber("0")]]}},funding:{withdraw:{}}},precisionMode:o.v,options:{precision:"R0",exchangeTypes:{MARKET:"market","EXCHANGE MARKET":"market",LIMIT:"limit","EXCHANGE LIMIT":"limit","EXCHANGE STOP":"market","EXCHANGE FOK":"limit","EXCHANGE STOP LIMIT":"limit","EXCHANGE IOC":"limit"},orderTypes:{market:"EXCHANGE MARKET",limit:"EXCHANGE LIMIT"},fiat:{USD:"USD",EUR:"EUR",JPY:"JPY",GBP:"GBP",CHN:"CHN"},v2AccountsByType:{spot:"exchange",exchange:"exchange",funding:"funding",margin:"margin",derivatives:"margin",future:"margin",swap:"margin"},withdraw:{includeFee:!1},networks:{BTC:"BITCOIN",LTC:"LITECOIN",ERC20:"ETHEREUM",OMNI:"TETHERUSO",LIQUID:"TETHERUSL",TRC20:"TETHERUSX",EOS:"TETHERUSS",AVAX:"TETHERUSDTAVAX",SOL:"TETHERUSDTSOL",ALGO:"TETHERUSDTALG",BCH:"TETHERUSDTBCH",KSM:"TETHERUSDTKSM",DVF:"TETHERUSDTDVF",OMG:"TETHERUSDTOMG"},networksById:{TETHERUSE:"ERC20"}},features:{default:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!0,marketBuyRequiresPrice:!1,marketBuyByCost:!0,selfTradePrevention:!1,iceberg:!1},createOrders:{max:75},fetchMyTrades:{marginMode:!1,limit:2500,daysBack:void 0,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:void 0,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e4}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{11010:s.RateLimitExceeded,10001:s.PermissionDenied,10020:s.BadRequest,10100:s.AuthenticationError,10114:s.InvalidNonce,20060:s.OnMaintenance,temporarily_unavailable:s.ExchangeNotAvailable},broad:{"available balance is only":s.InsufficientFunds,"not enough exchange balance":s.InsufficientFunds,"Order not found":s.OrderNotFound,"symbol: invalid":s.BadSymbol}},commonCurrencies:{UST:"USDT",EUTF0:"EURT",USTF0:"USDT",ALG:"ALGO",AMP:"AMPL",ATO:"ATOM",BCHABC:"XEC",BCHN:"BCH",DAT:"DATA",DOG:"MDOGE",DSH:"DASH",EDO:"PNT",EUS:"EURS",EUT:"EURT",HTX:"HT",IDX:"ID",IOT:"IOTA",IQX:"IQ",LUNA:"LUNC",LUNA2:"LUNA",MNA:"MANA",ORS:"ORS Group",PAS:"PASS",QSH:"QASH",QTM:"QTUM",RBT:"RBTC",SNG:"SNGLS",STJ:"STORJ",TERRAUST:"USTC",TSD:"TUSD",YGG:"YEED",YYW:"YOYOW",UDC:"USDC",VSY:"VSYS",WAX:"WAXP",XCH:"XCHF",ZBT:"ZB"}})}isFiat(e){return e in this.options.fiat}getCurrencyName(e){if(e in this.options.currencyNames)return this.options.currencyNames[e];throw new s.NotSupported(this.id+" "+e+" not supported for withdrawal")}amountToPrecision(e,t){return e=this.safeSymbol(e),this.decimalToPrecision(t,o.R3,this.markets[e].precision.amount,o.fv)}priceToPrecision(e,t){return e=this.safeSymbol(e),t=this.decimalToPrecision(t,o.D_,this.markets[e].precision.price,this.precisionMode),this.decimalToPrecision(t,o.R3,8,o.fv)}async fetchStatus(e={}){const t=await this.publicGetPlatformStatus(e),i=this.safeString(t,0);return{status:this.safeString({0:"maintenance",1:"ok"},i,i),updated:void 0,eta:void 0,url:void 0,info:t}}async fetchMarkets(e={}){const t=this.publicGetConfPubInfoPair(e),i=this.publicGetConfPubInfoPairFutures(e),s=this.publicGetConfPubListPairMargin(e);let[r,a,o]=await Promise.all([t,i,s]);r=this.safeList(r,0,[]),a=this.safeList(a,0,[]);const n=this.arrayConcat(r,a);o=this.safeValue(o,0,[]);const d=[];for(let e=0;e=0&&(r=!1);const a=!r;let c,h;if(i.indexOf(":")>=0){const e=i.split(":");c=e[0],h=e[1]}else c=i.slice(0,3),h=i.slice(3,6);let l=this.safeCurrencyCode(c),u=this.safeCurrencyCode(h);const p=l.split("F0"),f=u.split("F0");l=this.safeString(p,0),u=this.safeString(f,0);let m,g,v=l+"/"+u;a&&(m=u,g=u,v=v+":"+m);const y=this.safeString(s,3),b=this.safeString(s,4);let w=!1;r&&this.inArray(i,o)&&(w=!0),d.push({id:"t"+i,symbol:v,base:l,quote:u,settle:m,baseId:c,quoteId:h,settleId:g,type:r?"spot":"swap",spot:r,margin:w,swap:a,future:!1,option:!1,active:!0,contract:a,linear:!!a||void 0,inverse:!a&&void 0,contractSize:a?this.parseNumber("1"):void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:parseInt("8"),price:parseInt("5")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.parseNumber(y),max:this.parseNumber(b)},price:{min:this.parseNumber("1e-8"),max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:s})}return d}async fetchCurrencies(e={}){const t={config:["pub:list:currency","pub:map:currency:sym","pub:map:currency:label","pub:map:currency:unit","pub:map:currency:undl","pub:map:currency:pool","pub:map:currency:explorer","pub:map:currency:tx:fee","pub:map:tx:method","pub:info:tx:status"].join(",")},i=await this.publicGetConfConfig(this.extend(t,e)),s={sym:this.indexBy(this.safeList(i,1,[]),0),label:this.indexBy(this.safeList(i,2,[]),0),unit:this.indexBy(this.safeList(i,3,[]),0),undl:this.indexBy(this.safeList(i,4,[]),0),pool:this.indexBy(this.safeList(i,5,[]),0),explorer:this.indexBy(this.safeList(i,6,[]),0),fees:this.indexBy(this.safeList(i,7,[]),0),networks:this.safeList(i,8,[]),statuses:this.indexBy(this.safeList(i,9,[]),0)},r={};for(let e=0;e5,a=this.safeString(i,0),o=s?4:2;let n,d=this.safeString(i,o);const c=s?5:3,h=this.safeString(i,c);let l,u,p,f;"-"===d[0]?(n="sell",d=r.Y.stringAbs(d)):n="buy";let m=this.safeSymbol(void 0,t);const g=s?2:1,v=this.safeInteger(i,g);if(s){const e=i[1];m=this.safeSymbol(e),l=this.safeString(i,3);u=1===this.safeInteger(i,8)?"maker":"taker";let t=this.safeString(i,9);t=r.Y.stringNeg(t);const s=this.safeString(i,10);f={cost:t,currency:this.safeCurrencyCode(s)};const a=i[6];p=this.safeString(this.options.exchangeTypes,a)}return this.safeTrade({id:a,timestamp:v,datetime:this.iso8601(v),symbol:m,order:l,side:n,type:p,takerOrMaker:u,price:h,amount:d,cost:void 0,fee:f,info:i},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchTrades","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchTrades",e,t,i,s,1e4);const a=this.market(e);let o="-1",n={symbol:a.id};void 0!==t&&(n.start=t,o="1"),void 0!==i&&(n.limit=Math.min(i,1e4)),n.sort=o,[n,s]=this.handleUntilOption("end",n,s);const d=await this.publicGetTradesSymbolHist(this.extend(n,s)),c=this.sortBy(d,1),h=[];for(let e=0;e=0||e.indexOf("charged")>=0?"fee":e.indexOf("rebate")>=0?"rebate":e.indexOf("deposit")>=0||e.indexOf("withdrawal")>=0?"transaction":e.indexOf("transfer")>=0?"transfer":e.indexOf("payment")>=0?"payout":e.indexOf("exchange")>=0||e.indexOf("position")>=0?"trade":e}parseLedgerEntry(e,t=void 0){const i=this.safeList(e,"result",[]);let s;const r=this.safeString(i,0),a=this.safeString(i,1),o=this.safeCurrencyCode(a,t);t=this.safeCurrency(a,t);const n=this.safeInteger(i,3),d=this.safeNumber(i,5),c=this.safeNumber(i,6),h=this.safeString(i,8);if(void 0!==h){const e=h.split(" @ "),t=this.safeStringLower(e,0);s=this.parseLedgerEntryType(t)}return this.safeLedgerEntry({info:e,id:r,direction:void 0,account:void 0,referenceId:r,referenceAccount:void 0,type:s,currency:o,amount:d,timestamp:n,datetime:this.iso8601(n),before:void 0,after:c,status:void 0,fee:void 0},t)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchLedger","paginate"),a)return await this.fetchPaginatedCallDynamic("fetchLedger",e,t,i,s,2500);let o,n={};void 0!==t&&(n.start=t),void 0!==i&&(n.limit=i),[n,s]=this.handleUntilOption("end",n,s),void 0!==e?(r=this.currency(e),n.currency=r.id,o=await this.privatePostAuthRLedgersCurrencyHist(this.extend(n,s))):o=await this.privatePostAuthRLedgersHist(this.extend(n,s));const d=[];for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(1578),r=i(2079),a=i(1579),o=i(4852),n=i(5147);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitflyer",name:"bitFlyer",countries:["JP"],version:"v1",rateLimit:1e3,hostname:"bitflyer.com",has:{CORS:void 0,spot:!0,margin:!1,swap:void 0,future:void 0,option:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:void 0,cancelOrder:!0,createOrder:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:"emulated",fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposits:!0,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMyTrades:!0,fetchOpenOrders:"emulated",fetchOption:!1,fetchOptionChain:!1,fetchOrder:"emulated",fetchOrderBook:!0,fetchOrders:!0,fetchPositionMode:!1,fetchPositions:!0,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,transfer:!1,withdraw:!0},urls:{logo:"https://github.com/user-attachments/assets/d0217747-e54d-4533-8416-0d553dca74bb",api:{rest:"https://api.{hostname}"},www:"https://bitflyer.com",doc:"https://lightning.bitflyer.com/docs?lang=en"},api:{public:{get:["getmarkets/usa","getmarkets/eu","getmarkets","getboard","getticker","getexecutions","gethealth","getboardstate","getchats","getfundingrate"]},private:{get:["getpermissions","getbalance","getbalancehistory","getcollateral","getcollateralhistory","getcollateralaccounts","getaddresses","getcoinins","getcoinouts","getbankaccounts","getdeposits","getwithdrawals","getchildorders","getparentorders","getparentorder","getexecutions","getpositions","gettradingcommission"],post:["sendcoin","withdraw","sendchildorder","cancelchildorder","sendparentorder","cancelparentorder","cancelallchildorders"]}},fees:{trading:{maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")}},precisionMode:a.kb,features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"-2":r.OnMaintenance}}})}parseExpiryDate(e){const t=e.slice(0,2),i=e.slice(2,5),s=e.slice(5,9),r=this.safeString({JAN:"01",FEB:"02",MAR:"03",APR:"04",MAY:"05",JUN:"06",JUL:"07",AUG:"08",SEP:"09",OCT:"10",NOV:"11",DEC:"12"},i);return this.parse8601(s+"-"+r+"-"+t+"T00:00:00Z")}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return super.safeMarket(e,t,i,"spot")}async fetchMarkets(e={}){const t=await this.publicGetGetmarkets(e),i=await this.publicGetGetmarketsUsa(e),s=await this.publicGetGetmarketsEu(e);let r=this.arrayConcat(t,i);r=this.arrayConcat(r,s);const a=[];for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(9152),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitget",name:"Bitget",countries:["SG"],version:"v2",rateLimit:50,certified:!0,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!0,option:!1,addMargin:!0,borrowCrossMargin:!0,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!0,closePosition:!0,createConvertTrade:!0,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTrailingAmountOrder:!1,createTrailingPercentOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchConvertCurrencies:!0,fetchConvertQuote:!0,fetchConvertTrade:!1,fetchConvertTradeHistory:!0,fetchCrossBorrowRate:!0,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!0,fetchIsolatedBorrowRate:!0,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!0,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMarkPrice:!0,fetchMyLiquidations:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!0,fetchPositionHistory:"emulated",fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!0,fetchWithdrawAddresses:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!0,repayCrossMargin:!0,repayIsolatedMargin:!0,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!0,signIn:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1m"},hostname:"bitget.com",urls:{logo:"https://github.com/user-attachments/assets/fbaa10cc-a277-441d-a5b7-997dd9a87658",api:{spot:"https://api.{hostname}",mix:"https://api.{hostname}",user:"https://api.{hostname}",p2p:"https://api.{hostname}",broker:"https://api.{hostname}",margin:"https://api.{hostname}",common:"https://api.{hostname}",tax:"https://api.{hostname}",convert:"https://api.{hostname}",copy:"https://api.{hostname}",earn:"https://api.{hostname}",uta:"https://api.{hostname}"},www:"https://www.bitget.com",doc:["https://www.bitget.com/api-doc/common/intro","https://www.bitget.com/api-doc/spot/intro","https://www.bitget.com/api-doc/contract/intro","https://www.bitget.com/api-doc/broker/intro","https://www.bitget.com/api-doc/margin/intro","https://www.bitget.com/api-doc/copytrading/intro","https://www.bitget.com/api-doc/earn/intro","https://bitgetlimited.github.io/apidoc/en/mix","https://bitgetlimited.github.io/apidoc/en/spot","https://bitgetlimited.github.io/apidoc/en/broker","https://bitgetlimited.github.io/apidoc/en/margin"],fees:"https://www.bitget.cc/zh-CN/rate?tab=1",referral:"https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j"},api:{public:{common:{get:{"v2/public/annoucements":1,"v2/public/time":1}},spot:{get:{"spot/v1/notice/queryAllNotices":1,"spot/v1/public/time":1,"spot/v1/public/currencies":6.6667,"spot/v1/public/products":1,"spot/v1/public/product":1,"spot/v1/market/ticker":1,"spot/v1/market/tickers":1,"spot/v1/market/fills":2,"spot/v1/market/fills-history":2,"spot/v1/market/candles":1,"spot/v1/market/depth":1,"spot/v1/market/spot-vip-level":2,"spot/v1/market/merge-depth":1,"spot/v1/market/history-candles":1,"spot/v1/public/loan/coinInfos":2,"spot/v1/public/loan/hour-interest":2,"v2/spot/public/coins":6.6667,"v2/spot/public/symbols":1,"v2/spot/market/vip-fee-rate":2,"v2/spot/market/tickers":1,"v2/spot/market/merge-depth":1,"v2/spot/market/orderbook":1,"v2/spot/market/candles":1,"v2/spot/market/history-candles":1,"v2/spot/market/fills":2,"v2/spot/market/fills-history":2}},mix:{get:{"mix/v1/market/contracts":1,"mix/v1/market/depth":1,"mix/v1/market/ticker":1,"mix/v1/market/tickers":1,"mix/v1/market/contract-vip-level":2,"mix/v1/market/fills":1,"mix/v1/market/fills-history":2,"mix/v1/market/candles":1,"mix/v1/market/index":1,"mix/v1/market/funding-time":1,"mix/v1/market/history-fundRate":1,"mix/v1/market/current-fundRate":1,"mix/v1/market/open-interest":1,"mix/v1/market/mark-price":1,"mix/v1/market/symbol-leverage":1,"mix/v1/market/queryPositionLever":1,"mix/v1/market/open-limit":1,"mix/v1/market/history-candles":1,"mix/v1/market/history-index-candles":1,"mix/v1/market/history-mark-candles":1,"mix/v1/market/merge-depth":1,"v2/mix/market/vip-fee-rate":2,"v2/mix/market/union-interest-rate-history":4,"v2/mix/market/exchange-rate":4,"v2/mix/market/discount-rate":4,"v2/mix/market/merge-depth":1,"v2/mix/market/ticker":1,"v2/mix/market/tickers":1,"v2/mix/market/fills":1,"v2/mix/market/fills-history":2,"v2/mix/market/candles":1,"v2/mix/market/history-candles":1,"v2/mix/market/history-index-candles":1,"v2/mix/market/history-mark-candles":1,"v2/mix/market/open-interest":1,"v2/mix/market/funding-time":1,"v2/mix/market/symbol-price":1,"v2/mix/market/history-fund-rate":1,"v2/mix/market/current-fund-rate":1,"v2/mix/market/oi-limit":2,"v2/mix/market/contracts":1,"v2/mix/market/query-position-lever":2,"v2/mix/market/account-long-short":20}},margin:{get:{"margin/v1/cross/public/interestRateAndLimit":2,"margin/v1/isolated/public/interestRateAndLimit":2,"margin/v1/cross/public/tierData":2,"margin/v1/isolated/public/tierData":2,"margin/v1/public/currencies":1,"v2/margin/currencies":2,"v2/margin/market/long-short-ratio":20}},earn:{get:{"v2/earn/loan/public/coinInfos":2,"v2/earn/loan/public/hour-interest":2}},uta:{get:{"v3/market/instruments":1,"v3/market/tickers":1,"v3/market/orderbook":1,"v3/market/fills":1,"v3/market/open-interest":1,"v3/market/candles":1,"v3/market/history-candles":1,"v3/market/current-fund-rate":1,"v3/market/history-fund-rate":1,"v3/market/risk-reserve":1,"v3/market/discount-rate":1,"v3/market/margin-loans":1,"v3/market/position-tier":1,"v3/market/oi-limit":2}}},private:{spot:{get:{"spot/v1/wallet/deposit-address":4,"spot/v1/wallet/withdrawal-list":1,"spot/v1/wallet/deposit-list":1,"spot/v1/account/getInfo":20,"spot/v1/account/assets":2,"spot/v1/account/assets-lite":2,"spot/v1/account/transferRecords":1,"spot/v1/convert/currencies":2,"spot/v1/convert/convert-record":2,"spot/v1/loan/ongoing-orders":2,"spot/v1/loan/repay-history":2,"spot/v1/loan/revise-history":2,"spot/v1/loan/borrow-history":2,"spot/v1/loan/debts":2,"v2/spot/trade/orderInfo":1,"v2/spot/trade/unfilled-orders":1,"v2/spot/trade/history-orders":1,"v2/spot/trade/fills":2,"v2/spot/trade/current-plan-order":1,"v2/spot/trade/history-plan-order":1,"v2/spot/account/info":20,"v2/spot/account/assets":2,"v2/spot/account/subaccount-assets":2,"v2/spot/account/bills":2,"v2/spot/account/transferRecords":1,"v2/account/funding-assets":2,"v2/account/bot-assets":2,"v2/account/all-account-balance":20,"v2/spot/wallet/deposit-address":2,"v2/spot/wallet/deposit-records":2,"v2/spot/wallet/withdrawal-records":2},post:{"spot/v1/wallet/transfer":4,"spot/v1/wallet/transfer-v2":4,"spot/v1/wallet/subTransfer":10,"spot/v1/wallet/withdrawal":4,"spot/v1/wallet/withdrawal-v2":4,"spot/v1/wallet/withdrawal-inner":4,"spot/v1/wallet/withdrawal-inner-v2":4,"spot/v1/account/sub-account-spot-assets":200,"spot/v1/account/bills":2,"spot/v1/trade/orders":2,"spot/v1/trade/batch-orders":4,"spot/v1/trade/cancel-order":2,"spot/v1/trade/cancel-order-v2":2,"spot/v1/trade/cancel-symbol-order":2,"spot/v1/trade/cancel-batch-orders":4,"spot/v1/trade/cancel-batch-orders-v2":4,"spot/v1/trade/orderInfo":1,"spot/v1/trade/open-orders":1,"spot/v1/trade/history":1,"spot/v1/trade/fills":1,"spot/v1/plan/placePlan":1,"spot/v1/plan/modifyPlan":1,"spot/v1/plan/cancelPlan":1,"spot/v1/plan/currentPlan":1,"spot/v1/plan/historyPlan":1,"spot/v1/plan/batchCancelPlan":2,"spot/v1/convert/quoted-price":4,"spot/v1/convert/trade":4,"spot/v1/loan/borrow":2,"spot/v1/loan/repay":2,"spot/v1/loan/revise-pledge":2,"spot/v1/trace/order/orderCurrentList":2,"spot/v1/trace/order/orderHistoryList":2,"spot/v1/trace/order/closeTrackingOrder":2,"spot/v1/trace/order/updateTpsl":2,"spot/v1/trace/order/followerEndOrder":2,"spot/v1/trace/order/spotInfoList":2,"spot/v1/trace/config/getTraderSettings":2,"spot/v1/trace/config/getFollowerSettings":2,"spot/v1/trace/user/myTraders":2,"spot/v1/trace/config/setFollowerConfig":2,"spot/v1/trace/user/myFollowers":2,"spot/v1/trace/config/setProductCode":2,"spot/v1/trace/user/removeTrader":2,"spot/v1/trace/getRemovableFollower":2,"spot/v1/trace/user/removeFollower":2,"spot/v1/trace/profit/totalProfitInfo":2,"spot/v1/trace/profit/totalProfitList":2,"spot/v1/trace/profit/profitHisList":2,"spot/v1/trace/profit/profitHisDetailList":2,"spot/v1/trace/profit/waitProfitDetailList":2,"spot/v1/trace/user/getTraderInfo":2,"v2/spot/trade/place-order":2,"v2/spot/trade/cancel-order":2,"v2/spot/trade/batch-orders":20,"v2/spot/trade/batch-cancel-order":2,"v2/spot/trade/cancel-symbol-order":4,"v2/spot/trade/place-plan-order":1,"v2/spot/trade/modify-plan-order":1,"v2/spot/trade/cancel-plan-order":1,"v2/spot/trade/cancel-replace-order":2,"v2/spot/trade/batch-cancel-plan-order":2,"v2/spot/wallet/transfer":2,"v2/spot/wallet/subaccount-transfer":2,"v2/spot/wallet/withdrawal":2,"v2/spot/wallet/cancel-withdrawal":2,"v2/spot/wallet/modify-deposit-account":2}},mix:{get:{"mix/v1/account/account":2,"mix/v1/account/accounts":2,"mix/v1/position/singlePosition":2,"mix/v1/position/singlePosition-v2":2,"mix/v1/position/allPosition":4,"mix/v1/position/allPosition-v2":4,"mix/v1/position/history-position":1,"mix/v1/account/accountBill":2,"mix/v1/account/accountBusinessBill":4,"mix/v1/order/current":1,"mix/v1/order/marginCoinCurrent":1,"mix/v1/order/history":2,"mix/v1/order/historyProductType":4,"mix/v1/order/detail":2,"mix/v1/order/fills":2,"mix/v1/order/allFills":2,"mix/v1/plan/currentPlan":1,"mix/v1/plan/historyPlan":2,"mix/v1/trace/currentTrack":2,"mix/v1/trace/followerOrder":2,"mix/v1/trace/followerHistoryOrders":2,"mix/v1/trace/historyTrack":2,"mix/v1/trace/summary":1,"mix/v1/trace/profitSettleTokenIdGroup":1,"mix/v1/trace/profitDateGroupList":1,"mix/v1/trade/profitDateList":2,"mix/v1/trace/waitProfitDateList":1,"mix/v1/trace/traderSymbols":1,"mix/v1/trace/traderList":2,"mix/v1/trace/traderDetail":2,"mix/v1/trace/queryTraceConfig":2,"v2/mix/account/account":2,"v2/mix/account/accounts":2,"v2/mix/account/sub-account-assets":200,"v2/mix/account/interest-history":4,"v2/mix/account/max-open":1,"v2/mix/account/liq-price":1,"v2/mix/account/open-count":2,"v2/mix/account/bill":2,"v2/mix/account/transfer-limits":20,"v2/mix/account/union-config":20,"v2/mix/account/switch-union-usdt":20,"v2/mix/account/isolated-symbols":2,"v2/mix/market/query-position-lever":2,"v2/mix/position/single-position":2,"v2/mix/position/all-position":4,"v2/mix/position/adlRank":4,"v2/mix/position/history-position":1,"v2/mix/order/detail":2,"v2/mix/order/fills":2,"v2/mix/order/fill-history":2,"v2/mix/order/orders-pending":2,"v2/mix/order/orders-history":2,"v2/mix/order/plan-sub-order":2,"v2/mix/order/orders-plan-pending":2,"v2/mix/order/orders-plan-history":2,"v2/mix/market/position-long-short":20},post:{"mix/v1/account/sub-account-contract-assets":200,"mix/v1/account/open-count":1,"mix/v1/account/setLeverage":4,"mix/v1/account/setMargin":4,"mix/v1/account/setMarginMode":4,"mix/v1/account/setPositionMode":4,"mix/v1/order/placeOrder":2,"mix/v1/order/batch-orders":2,"mix/v1/order/cancel-order":2,"mix/v1/order/cancel-batch-orders":2,"mix/v1/order/modifyOrder":2,"mix/v1/order/cancel-symbol-orders":2,"mix/v1/order/cancel-all-orders":2,"mix/v1/order/close-all-positions":20,"mix/v1/plan/placePlan":2,"mix/v1/plan/modifyPlan":2,"mix/v1/plan/modifyPlanPreset":2,"mix/v1/plan/placeTPSL":2,"mix/v1/plan/placeTrailStop":2,"mix/v1/plan/placePositionsTPSL":2,"mix/v1/plan/modifyTPSLPlan":2,"mix/v1/plan/cancelPlan":2,"mix/v1/plan/cancelSymbolPlan":2,"mix/v1/plan/cancelAllPlan":2,"mix/v1/trace/closeTrackOrder":2,"mix/v1/trace/modifyTPSL":2,"mix/v1/trace/closeTrackOrderBySymbol":2,"mix/v1/trace/setUpCopySymbols":2,"mix/v1/trace/followerSetBatchTraceConfig":2,"mix/v1/trace/followerCloseByTrackingNo":2,"mix/v1/trace/followerCloseByAll":2,"mix/v1/trace/followerSetTpsl":2,"mix/v1/trace/cancelCopyTrader":4,"mix/v1/trace/traderUpdateConfig":2,"mix/v1/trace/myTraderList":2,"mix/v1/trace/myFollowerList":2,"mix/v1/trace/removeFollower":2,"mix/v1/trace/public/getFollowerConfig":2,"mix/v1/trace/report/order/historyList":2,"mix/v1/trace/report/order/currentList":2,"mix/v1/trace/queryTraderTpslRatioConfig":2,"mix/v1/trace/traderUpdateTpslRatioConfig":2,"v2/mix/account/set-auto-margin":4,"v2/mix/account/set-leverage":4,"v2/mix/account/set-all-leverage":4,"v2/mix/account/set-margin":4,"v2/mix/account/set-asset-mode":10,"v2/mix/account/set-margin-mode":4,"v2/mix/account/union-convert":20,"v2/mix/account/set-position-mode":4,"v2/mix/order/place-order":2,"v2/mix/order/click-backhand":20,"v2/mix/order/batch-place-order":20,"v2/mix/order/modify-order":2,"v2/mix/order/cancel-order":2,"v2/mix/order/batch-cancel-orders":2,"v2/mix/order/close-positions":20,"v2/mix/order/cancel-all-orders":20,"v2/mix/order/place-tpsl-order":2,"v2/mix/order/place-pos-tpsl":2,"v2/mix/order/place-plan-order":2,"v2/mix/order/modify-tpsl-order":2,"v2/mix/order/modify-plan-order":2,"v2/mix/order/cancel-plan-order":2}},user:{get:{"user/v1/fee/query":2,"user/v1/sub/virtual-list":2,"user/v1/sub/virtual-api-list":2,"user/v1/tax/spot-record":1,"user/v1/tax/future-record":1,"user/v1/tax/margin-record":1,"user/v1/tax/p2p-record":1,"v2/user/virtual-subaccount-list":2,"v2/user/virtual-subaccount-apikey-list":2},post:{"user/v1/sub/virtual-create":4,"user/v1/sub/virtual-modify":4,"user/v1/sub/virtual-api-batch-create":20,"user/v1/sub/virtual-api-create":4,"user/v1/sub/virtual-api-modify":4,"v2/user/create-virtual-subaccount":4,"v2/user/modify-virtual-subaccount":4,"v2/user/batch-create-subaccount-and-apikey":20,"v2/user/create-virtual-subaccount-apikey":4,"v2/user/modify-virtual-subaccount-apikey":4}},p2p:{get:{"p2p/v1/merchant/merchantList":2,"p2p/v1/merchant/merchantInfo":2,"p2p/v1/merchant/advList":2,"p2p/v1/merchant/orderList":2,"v2/p2p/merchantList":2,"v2/p2p/merchantInfo":2,"v2/p2p/orderList":2,"v2/p2p/advList":2}},broker:{get:{"broker/v1/account/info":2,"broker/v1/account/sub-list":20,"broker/v1/account/sub-email":20,"broker/v1/account/sub-spot-assets":2,"broker/v1/account/sub-future-assets":2,"broker/v1/account/subaccount-transfer":1,"broker/v1/account/subaccount-deposit":1,"broker/v1/account/subaccount-withdrawal":1,"broker/v1/account/sub-api-list":2,"v2/broker/account/info":2,"v2/broker/account/subaccount-list":20,"v2/broker/account/subaccount-email":2,"v2/broker/account/subaccount-spot-assets":2,"v2/broker/account/subaccount-future-assets":2,"v2/broker/manage/subaccount-apikey-list":2},post:{"broker/v1/account/sub-create":20,"broker/v1/account/sub-modify":20,"broker/v1/account/sub-modify-email":20,"broker/v1/account/sub-address":2,"broker/v1/account/sub-withdrawal":2,"broker/v1/account/sub-auto-transfer":4,"broker/v1/account/sub-api-create":2,"broker/v1/account/sub-api-modify":2,"v2/broker/account/modify-subaccount-email":2,"v2/broker/account/create-subaccount":20,"v2/broker/account/modify-subaccount":20,"v2/broker/account/subaccount-address":2,"v2/broker/account/subaccount-withdrawal":2,"v2/broker/account/set-subaccount-autotransfer":2,"v2/broker/manage/create-subaccount-apikey":2,"v2/broker/manage/modify-subaccount-apikey":2}},margin:{get:{"margin/v1/cross/account/riskRate":2,"margin/v1/cross/account/maxTransferOutAmount":2,"margin/v1/isolated/account/maxTransferOutAmount":2,"margin/v1/isolated/order/openOrders":2,"margin/v1/isolated/order/history":2,"margin/v1/isolated/order/fills":2,"margin/v1/isolated/loan/list":2,"margin/v1/isolated/repay/list":2,"margin/v1/isolated/interest/list":2,"margin/v1/isolated/liquidation/list":2,"margin/v1/isolated/fin/list":2,"margin/v1/cross/order/openOrders":2,"margin/v1/cross/order/history":2,"margin/v1/cross/order/fills":2,"margin/v1/cross/loan/list":2,"margin/v1/cross/repay/list":2,"margin/v1/cross/interest/list":2,"margin/v1/cross/liquidation/list":2,"margin/v1/cross/fin/list":2,"margin/v1/cross/account/assets":2,"margin/v1/isolated/account/assets":2,"v2/margin/crossed/borrow-history":2,"v2/margin/crossed/repay-history":2,"v2/margin/crossed/interest-history":2,"v2/margin/crossed/liquidation-history":2,"v2/margin/crossed/financial-records":2,"v2/margin/crossed/account/assets":2,"v2/margin/crossed/account/risk-rate":2,"v2/margin/crossed/account/max-borrowable-amount":2,"v2/margin/crossed/account/max-transfer-out-amount":2,"v2/margin/crossed/interest-rate-and-limit":2,"v2/margin/crossed/tier-data":2,"v2/margin/crossed/open-orders":2,"v2/margin/crossed/history-orders":2,"v2/margin/crossed/fills":2,"v2/margin/isolated/borrow-history":2,"v2/margin/isolated/repay-history":2,"v2/margin/isolated/interest-history":2,"v2/margin/isolated/liquidation-history":2,"v2/margin/isolated/financial-records":2,"v2/margin/isolated/account/assets":2,"v2/margin/isolated/account/risk-rate":2,"v2/margin/isolated/account/max-borrowable-amount":2,"v2/margin/isolated/account/max-transfer-out-amount":2,"v2/margin/isolated/interest-rate-and-limit":2,"v2/margin/isolated/tier-data":2,"v2/margin/isolated/open-orders":2,"v2/margin/isolated/history-orders":2,"v2/margin/isolated/fills":2},post:{"margin/v1/cross/account/borrow":2,"margin/v1/isolated/account/borrow":2,"margin/v1/cross/account/repay":2,"margin/v1/isolated/account/repay":2,"margin/v1/isolated/account/riskRate":2,"margin/v1/cross/account/maxBorrowableAmount":2,"margin/v1/isolated/account/maxBorrowableAmount":2,"margin/v1/isolated/account/flashRepay":2,"margin/v1/isolated/account/queryFlashRepayStatus":2,"margin/v1/cross/account/flashRepay":2,"margin/v1/cross/account/queryFlashRepayStatus":2,"margin/v1/isolated/order/placeOrder":4,"margin/v1/isolated/order/batchPlaceOrder":4,"margin/v1/isolated/order/cancelOrder":2,"margin/v1/isolated/order/batchCancelOrder":2,"margin/v1/cross/order/placeOrder":2,"margin/v1/cross/order/batchPlaceOrder":2,"margin/v1/cross/order/cancelOrder":2,"margin/v1/cross/order/batchCancelOrder":2,"v2/margin/crossed/account/borrow":2,"v2/margin/crossed/account/repay":2,"v2/margin/crossed/account/flash-repay":2,"v2/margin/crossed/account/query-flash-repay-status":2,"v2/margin/crossed/place-order":2,"v2/margin/crossed/batch-place-order":2,"v2/margin/crossed/cancel-order":2,"v2/margin/crossed/batch-cancel-order":2,"v2/margin/isolated/account/borrow":2,"v2/margin/isolated/account/repay":2,"v2/margin/isolated/account/flash-repay":2,"v2/margin/isolated/account/query-flash-repay-status":2,"v2/margin/isolated/place-order":2,"v2/margin/isolated/batch-place-order":2,"v2/margin/isolated/cancel-order":2,"v2/margin/isolated/batch-cancel-order":2}},copy:{get:{"v2/copy/mix-trader/order-current-track":2,"v2/copy/mix-trader/order-history-track":2,"v2/copy/mix-trader/order-total-detail":2,"v2/copy/mix-trader/profit-history-summarys":1,"v2/copy/mix-trader/profit-history-details":1,"v2/copy/mix-trader/profit-details":1,"v2/copy/mix-trader/profits-group-coin-date":1,"v2/copy/mix-trader/config-query-symbols":1,"v2/copy/mix-trader/config-query-followers":2,"v2/copy/mix-follower/query-current-orders":2,"v2/copy/mix-follower/query-history-orders":1,"v2/copy/mix-follower/query-settings":2,"v2/copy/mix-follower/query-traders":2,"v2/copy/mix-follower/query-quantity-limit":2,"v2/copy/mix-broker/query-traders":2,"v2/copy/mix-broker/query-history-traces":2,"v2/copy/mix-broker/query-current-traces":2,"v2/copy/spot-trader/profit-summarys":2,"v2/copy/spot-trader/profit-history-details":2,"v2/copy/spot-trader/profit-details":2,"v2/copy/spot-trader/order-total-detail":2,"v2/copy/spot-trader/order-history-track":2,"v2/copy/spot-trader/order-current-track":2,"v2/copy/spot-trader/config-query-settings":2,"v2/copy/spot-trader/config-query-followers":2,"v2/copy/spot-follower/query-traders":2,"v2/copy/spot-follower/query-trader-symbols":2,"v2/copy/spot-follower/query-settings":2,"v2/copy/spot-follower/query-history-orders":2,"v2/copy/spot-follower/query-current-orders":2},post:{"v2/copy/mix-trader/order-modify-tpsl":2,"v2/copy/mix-trader/order-close-positions":2,"v2/copy/mix-trader/config-setting-symbols":2,"v2/copy/mix-trader/config-setting-base":2,"v2/copy/mix-trader/config-remove-follower":2,"v2/copy/mix-follower/setting-tpsl":1,"v2/copy/mix-follower/settings":2,"v2/copy/mix-follower/close-positions":2,"v2/copy/mix-follower/cancel-trader":4,"v2/copy/spot-trader/order-modify-tpsl":2,"v2/copy/spot-trader/order-close-tracking":2,"v2/copy/spot-trader/config-setting-symbols":2,"v2/copy/spot-trader/config-remove-follower":2,"v2/copy/spot-follower/stop-order":2,"v2/copy/spot-follower/settings":2,"v2/copy/spot-follower/setting-tpsl":2,"v2/copy/spot-follower/order-close-tracking":2,"v2/copy/spot-follower/cancel-trader":2}},tax:{get:{"v2/tax/spot-record":20,"v2/tax/future-record":20,"v2/tax/margin-record":20,"v2/tax/p2p-record":20}},convert:{get:{"v2/convert/currencies":2,"v2/convert/quoted-price":2,"v2/convert/convert-record":2,"v2/convert/bgb-convert-coin-list":2,"v2/convert/bgb-convert-records":2},post:{"v2/convert/trade":2,"v2/convert/bgb-convert":2}},earn:{get:{"v2/earn/savings/product":2,"v2/earn/savings/account":2,"v2/earn/savings/assets":2,"v2/earn/savings/records":2,"v2/earn/savings/subscribe-info":2,"v2/earn/savings/subscribe-result":2,"v2/earn/savings/redeem-result":2,"v2/earn/sharkfin/product":2,"v2/earn/sharkfin/account":2,"v2/earn/sharkfin/assets":2,"v2/earn/sharkfin/records":2,"v2/earn/sharkfin/subscribe-info":2,"v2/earn/sharkfin/subscribe-result":4,"v2/earn/loan/ongoing-orders":2,"v2/earn/loan/repay-history":2,"v2/earn/loan/revise-history":2,"v2/earn/loan/borrow-history":2,"v2/earn/loan/debts":2,"v2/earn/loan/reduces":2,"v2/earn/account/assets":2},post:{"v2/earn/savings/subscribe":2,"v2/earn/savings/redeem":2,"v2/earn/sharkfin/subscribe":2,"v2/earn/loan/borrow":2,"v2/earn/loan/repay":2,"v2/earn/loan/revise-pledge":2}},common:{get:{"v2/common/trade-rate":2}},uta:{get:{"v3/account/assets":1,"v3/account/settings":1,"v3/account/deposit-records":2,"v3/account/financial-records":1,"v3/account/repayable-coins":2,"v3/account/payment-coins":2,"v3/account/convert-records":1,"v3/account/transferable-coins":2,"v3/account/sub-transfer-record":4,"v3/ins-loan/transfered":6.6667,"v3/ins-loan/symbols":6.6667,"v3/ins-loan/risk-unit":6.6667,"v3/ins-loan/repaid-history":6.6667,"v3/ins-loan/product-infos":6.6667,"v3/ins-loan/loan-order":6.6667,"v3/ins-loan/ltv-convert":6.6667,"v3/ins-loan/ensure-coins-convert":6.6667,"v3/position/current-position":1,"v3/position/history-position":1,"v3/trade/order-info":1,"v3/trade/unfilled-orders":1,"v3/trade/unfilled-strategy-orders":1,"v3/trade/history-orders":1,"v3/trade/history-strategy-orders":1,"v3/trade/fills":1,"v3/user/sub-list":2,"v3/user/sub-api-list":2},post:{"v3/account/set-leverage":2,"v3/account/set-hold-mode":2,"v3/account/repay":4,"v3/account/transfer":4,"v3/account/sub-transfer":4,"v3/account/max-open-available":4,"v3/ins-loan/bind-uid":6.6667,"v3/trade/place-order":2,"v3/trade/place-strategy-order":2,"v3/trade/modify-order":2,"v3/trade/modify-strategy-order":2,"v3/trade/cancel-order":2,"v3/trade/cancel-strategy-order":2,"v3/trade/place-batch":4,"v3/trade/batch-modify-order":2,"v3/trade/cancel-batch":4,"v3/trade/cancel-symbol-order":4,"v3/trade/close-positions":4,"v3/user/create-sub":2,"v3/user/freeze-sub":2,"v3/user/create-sub-api":2,"v3/user/update-sub-api":2,"v3/user/delete-sub-api":2}}}},fees:{spot:{taker:this.parseNumber("0.002"),maker:this.parseNumber("0.002")},swap:{taker:this.parseNumber("0.0006"),maker:this.parseNumber("0.0004")}},requiredCredentials:{apiKey:!0,secret:!0,password:!0},exceptions:{exact:{1:r.ExchangeError,"failure to get a peer from the ring-balancer":r.ExchangeNotAvailable,4010:r.PermissionDenied,4001:r.ExchangeError,4002:r.ExchangeError,40020:r.BadRequest,30001:r.AuthenticationError,30002:r.AuthenticationError,30003:r.AuthenticationError,30004:r.AuthenticationError,30005:r.InvalidNonce,30006:r.AuthenticationError,30007:r.BadRequest,30008:r.RequestTimeout,30009:r.ExchangeError,30010:r.AuthenticationError,30011:r.PermissionDenied,30012:r.AuthenticationError,30013:r.AuthenticationError,30014:r.DDoSProtection,30015:r.AuthenticationError,30016:r.ExchangeError,30017:r.ExchangeError,30018:r.ExchangeError,30019:r.ExchangeNotAvailable,30020:r.BadRequest,30021:r.BadRequest,30022:r.PermissionDenied,30023:r.BadRequest,30024:r.BadSymbol,30025:r.BadRequest,30026:r.DDoSProtection,30027:r.AuthenticationError,30028:r.PermissionDenied,30029:r.AccountSuspended,30030:r.ExchangeError,30031:r.BadRequest,30032:r.BadSymbol,30033:r.BadRequest,30034:r.ExchangeError,30035:r.ExchangeError,30036:r.ExchangeError,30037:r.ExchangeNotAvailable,30038:r.OnMaintenance,32001:r.AccountSuspended,32002:r.PermissionDenied,32003:r.CancelPending,32004:r.ExchangeError,32005:r.InvalidOrder,32006:r.InvalidOrder,32007:r.InvalidOrder,32008:r.InvalidOrder,32009:r.InvalidOrder,32010:r.ExchangeError,32011:r.ExchangeError,32012:r.ExchangeError,32013:r.ExchangeError,32014:r.ExchangeError,32015:r.ExchangeError,32016:r.ExchangeError,32017:r.ExchangeError,32018:r.ExchangeError,32019:r.ExchangeError,32020:r.ExchangeError,32021:r.ExchangeError,32022:r.ExchangeError,32023:r.ExchangeError,32024:r.ExchangeError,32025:r.ExchangeError,32026:r.ExchangeError,32027:r.ExchangeError,32028:r.AccountSuspended,32029:r.ExchangeError,32030:r.InvalidOrder,32031:r.ArgumentsRequired,32038:r.AuthenticationError,32040:r.ExchangeError,32044:r.ExchangeError,32045:r.ExchangeError,32046:r.ExchangeError,32047:r.ExchangeError,32048:r.InvalidOrder,32049:r.ExchangeError,32050:r.InvalidOrder,32051:r.InvalidOrder,32052:r.ExchangeError,32053:r.ExchangeError,32057:r.ExchangeError,32054:r.ExchangeError,32055:r.InvalidOrder,32056:r.ExchangeError,32058:r.ExchangeError,32059:r.InvalidOrder,32060:r.InvalidOrder,32061:r.InvalidOrder,32062:r.InvalidOrder,32063:r.InvalidOrder,32064:r.ExchangeError,32065:r.ExchangeError,32066:r.ExchangeError,32067:r.ExchangeError,32068:r.ExchangeError,32069:r.ExchangeError,32070:r.ExchangeError,32071:r.ExchangeError,32072:r.ExchangeError,32073:r.ExchangeError,32074:r.ExchangeError,32075:r.ExchangeError,32076:r.ExchangeError,32077:r.ExchangeError,32078:r.ExchangeError,32079:r.ExchangeError,32080:r.ExchangeError,32083:r.ExchangeError,33001:r.PermissionDenied,33002:r.AccountSuspended,33003:r.InsufficientFunds,33004:r.ExchangeError,33005:r.ExchangeError,33006:r.ExchangeError,33007:r.ExchangeError,33008:r.InsufficientFunds,33009:r.ExchangeError,33010:r.ExchangeError,33011:r.ExchangeError,33012:r.ExchangeError,33013:r.InvalidOrder,33014:r.OrderNotFound,33015:r.InvalidOrder,33016:r.ExchangeError,33017:r.InsufficientFunds,33018:r.ExchangeError,33020:r.ExchangeError,33021:r.BadRequest,33022:r.InvalidOrder,33023:r.ExchangeError,33024:r.InvalidOrder,33025:r.InvalidOrder,33026:r.ExchangeError,33027:r.InvalidOrder,33028:r.InvalidOrder,33029:r.InvalidOrder,33034:r.ExchangeError,33035:r.ExchangeError,33036:r.ExchangeError,33037:r.ExchangeError,33038:r.ExchangeError,33039:r.ExchangeError,33040:r.ExchangeError,33041:r.ExchangeError,33042:r.ExchangeError,33043:r.ExchangeError,33044:r.ExchangeError,33045:r.ExchangeError,33046:r.ExchangeError,33047:r.ExchangeError,33048:r.ExchangeError,33049:r.ExchangeError,33050:r.ExchangeError,33051:r.ExchangeError,33059:r.BadRequest,33060:r.BadRequest,33061:r.ExchangeError,33062:r.ExchangeError,33063:r.ExchangeError,33064:r.ExchangeError,33065:r.ExchangeError,21009:r.ExchangeError,34001:r.PermissionDenied,34002:r.InvalidAddress,34003:r.ExchangeError,34004:r.ExchangeError,34005:r.ExchangeError,34006:r.ExchangeError,34007:r.ExchangeError,34008:r.InsufficientFunds,34009:r.ExchangeError,34010:r.ExchangeError,34011:r.ExchangeError,34012:r.ExchangeError,34013:r.ExchangeError,34014:r.ExchangeError,34015:r.ExchangeError,34016:r.PermissionDenied,34017:r.AccountSuspended,34018:r.AuthenticationError,34019:r.PermissionDenied,34020:r.PermissionDenied,34021:r.InvalidAddress,34022:r.ExchangeError,34023:r.PermissionDenied,34026:r.ExchangeError,34036:r.ExchangeError,34037:r.ExchangeError,34038:r.ExchangeError,34039:r.ExchangeError,35001:r.ExchangeError,35002:r.ExchangeError,35003:r.ExchangeError,35004:r.ExchangeError,35005:r.AuthenticationError,35008:r.InvalidOrder,35010:r.InvalidOrder,35012:r.InvalidOrder,35014:r.InvalidOrder,35015:r.InvalidOrder,35017:r.ExchangeError,35019:r.InvalidOrder,35020:r.InvalidOrder,35021:r.InvalidOrder,35022:r.ExchangeError,35024:r.ExchangeError,35025:r.InsufficientFunds,35026:r.ExchangeError,35029:r.OrderNotFound,35030:r.InvalidOrder,35031:r.InvalidOrder,35032:r.ExchangeError,35037:r.ExchangeError,35039:r.ExchangeError,35040:r.InvalidOrder,35044:r.ExchangeError,35046:r.InsufficientFunds,35047:r.InsufficientFunds,35048:r.ExchangeError,35049:r.InvalidOrder,35050:r.InvalidOrder,35052:r.InsufficientFunds,35053:r.ExchangeError,35055:r.InsufficientFunds,35057:r.ExchangeError,35058:r.ExchangeError,35059:r.BadRequest,35060:r.BadRequest,35061:r.BadRequest,35062:r.InvalidOrder,35063:r.InvalidOrder,35064:r.InvalidOrder,35066:r.InvalidOrder,35067:r.InvalidOrder,35068:r.InvalidOrder,35069:r.InvalidOrder,35070:r.InvalidOrder,35071:r.InvalidOrder,35072:r.InvalidOrder,35073:r.InvalidOrder,35074:r.InvalidOrder,35075:r.InvalidOrder,35076:r.InvalidOrder,35077:r.InvalidOrder,35078:r.InvalidOrder,35079:r.InvalidOrder,35080:r.InvalidOrder,35081:r.InvalidOrder,35082:r.InvalidOrder,35083:r.InvalidOrder,35084:r.InvalidOrder,35085:r.InvalidOrder,35086:r.InvalidOrder,35087:r.InvalidOrder,35088:r.InvalidOrder,35089:r.InvalidOrder,35090:r.ExchangeError,35091:r.ExchangeError,35092:r.ExchangeError,35093:r.ExchangeError,35094:r.ExchangeError,35095:r.BadRequest,35096:r.ExchangeError,35097:r.ExchangeError,35098:r.ExchangeError,35099:r.ExchangeError,36001:r.BadRequest,36002:r.BadRequest,36005:r.ExchangeError,36101:r.AuthenticationError,36102:r.PermissionDenied,36103:r.AccountSuspended,36104:r.PermissionDenied,36105:r.PermissionDenied,36106:r.AccountSuspended,36107:r.PermissionDenied,36108:r.InsufficientFunds,36109:r.PermissionDenied,36201:r.PermissionDenied,36202:r.PermissionDenied,36203:r.InvalidOrder,36204:r.ExchangeError,36205:r.BadRequest,36206:r.BadRequest,36207:r.InvalidOrder,36208:r.InvalidOrder,36209:r.InvalidOrder,36210:r.InvalidOrder,36211:r.InvalidOrder,36212:r.InvalidOrder,36213:r.InvalidOrder,36214:r.ExchangeError,36216:r.OrderNotFound,36217:r.InvalidOrder,36218:r.InvalidOrder,36219:r.InvalidOrder,36220:r.InvalidOrder,36221:r.InvalidOrder,36222:r.InvalidOrder,36223:r.InvalidOrder,36224:r.InvalidOrder,36225:r.InvalidOrder,36226:r.InvalidOrder,36227:r.InvalidOrder,36228:r.InvalidOrder,36229:r.InvalidOrder,36230:r.InvalidOrder,400:r.BadRequest,401:r.AuthenticationError,403:r.PermissionDenied,404:r.BadRequest,405:r.BadRequest,415:r.BadRequest,429:r.DDoSProtection,500:r.ExchangeNotAvailable,1001:r.RateLimitExceeded,1002:r.ExchangeError,1003:r.ExchangeError,40001:r.AuthenticationError,40002:r.AuthenticationError,40003:r.AuthenticationError,40004:r.InvalidNonce,40005:r.InvalidNonce,40006:r.AuthenticationError,40007:r.BadRequest,40008:r.InvalidNonce,40009:r.AuthenticationError,40010:r.AuthenticationError,40011:r.AuthenticationError,40012:r.AuthenticationError,40013:r.ExchangeError,40014:r.PermissionDenied,40015:r.ExchangeError,40016:r.PermissionDenied,40017:r.ExchangeError,40018:r.PermissionDenied,40019:r.BadRequest,40031:r.AccountSuspended,40037:r.AuthenticationError,40102:r.BadRequest,40103:r.BadRequest,40104:r.ExchangeError,40105:r.ExchangeError,40106:r.ExchangeError,40107:r.ExchangeError,40108:r.InvalidOrder,40109:r.OrderNotFound,40200:r.OnMaintenance,40201:r.InvalidOrder,40202:r.ExchangeError,40203:r.BadRequest,40204:r.BadRequest,40205:r.BadRequest,40206:r.BadRequest,40207:r.BadRequest,40208:r.BadRequest,40209:r.BadRequest,40300:r.ExchangeError,40301:r.PermissionDenied,40302:r.BadRequest,40303:r.BadRequest,40304:r.BadRequest,40305:r.BadRequest,40306:r.ExchangeError,40308:r.OnMaintenance,40309:r.BadSymbol,40400:r.ExchangeError,40401:r.ExchangeError,40402:r.BadRequest,40403:r.BadRequest,40404:r.BadRequest,40405:r.BadRequest,40406:r.BadRequest,40407:r.ExchangeError,40408:r.ExchangeError,40409:r.ExchangeError,40500:r.InvalidOrder,40501:r.ExchangeError,40502:r.ExchangeError,40503:r.ExchangeError,40504:r.ExchangeError,40505:r.ExchangeError,40506:r.AuthenticationError,40507:r.AuthenticationError,40508:r.ExchangeError,40509:r.ExchangeError,40600:r.ExchangeError,40601:r.ExchangeError,40602:r.ExchangeError,40603:r.ExchangeError,40604:r.ExchangeNotAvailable,40605:r.ExchangeError,40606:r.ExchangeError,40607:r.ExchangeError,40608:r.ExchangeError,40609:r.ExchangeError,40700:r.BadRequest,40701:r.ExchangeError,40702:r.ExchangeError,40703:r.ExchangeError,40704:r.ExchangeError,40705:r.BadRequest,40706:r.InvalidOrder,40707:r.BadRequest,40708:r.BadRequest,40709:r.ExchangeError,40710:r.ExchangeError,40711:r.InsufficientFunds,40712:r.InsufficientFunds,40713:r.ExchangeError,40714:r.ExchangeError,40762:r.InsufficientFunds,40768:r.OrderNotFound,40808:r.InvalidOrder,41103:r.InvalidOrder,41114:r.OnMaintenance,43011:r.InvalidOrder,43001:r.OrderNotFound,43012:r.InsufficientFunds,43025:r.InvalidOrder,43115:r.OnMaintenance,45110:r.InvalidOrder,40774:r.InvalidOrder,45122:r.InvalidOrder,"invalid sign":r.AuthenticationError,"invalid currency":r.BadSymbol,"invalid symbol":r.BadSymbol,"invalid period":r.BadRequest,"invalid user":r.ExchangeError,"invalid amount":r.InvalidOrder,"invalid type":r.InvalidOrder,"invalid orderId":r.InvalidOrder,"invalid record":r.ExchangeError,"invalid accountId":r.BadRequest,"invalid address":r.BadRequest,"accesskey not null":r.AuthenticationError,"illegal accesskey":r.AuthenticationError,"sign not null":r.AuthenticationError,"req_time is too much difference from server time":r.InvalidNonce,"permissions not right":r.PermissionDenied,"illegal sign invalid":r.AuthenticationError,"user locked":r.AccountSuspended,"Request Frequency Is Too High":r.RateLimitExceeded,"more than a daily rate of cash":r.BadRequest,"more than the maximum daily withdrawal amount":r.BadRequest,"need to bind email or mobile":r.ExchangeError,"user forbid":r.PermissionDenied,"User Prohibited Cash Withdrawal":r.PermissionDenied,"Cash Withdrawal Is Less Than The Minimum Value":r.BadRequest,"Cash Withdrawal Is More Than The Maximum Value":r.BadRequest,"the account with in 24 hours ban coin":r.PermissionDenied,"order cancel fail":r.BadRequest,"base symbol error":r.BadSymbol,"base date error":r.ExchangeError,"api signature not valid":r.AuthenticationError,"gateway internal error":r.ExchangeError,"audit failed":r.ExchangeError,"order queryorder invalid":r.BadRequest,"market no need price":r.InvalidOrder,"limit need price":r.InvalidOrder,"userid not equal to account_id":r.ExchangeError,"your balance is low":r.InsufficientFunds,"address invalid cointype":r.ExchangeError,"system exception":r.ExchangeError,50003:r.ExchangeError,50004:r.BadSymbol,50006:r.PermissionDenied,50007:r.PermissionDenied,50008:r.RequestTimeout,50009:r.RateLimitExceeded,50010:r.ExchangeError,50014:r.InvalidOrder,50015:r.InvalidOrder,50016:r.InvalidOrder,50017:r.InvalidOrder,50018:r.InvalidOrder,50019:r.InvalidOrder,50020:r.InsufficientFunds,50021:r.InvalidOrder,50026:r.InvalidOrder,"invalid order query time":r.ExchangeError,"invalid start time":r.BadRequest,"invalid end time":r.BadRequest,20003:r.ExchangeError,"01001":r.ExchangeError,40024:r.RestrictedLocation,43111:r.PermissionDenied},broad:{"invalid size, valid range":r.ExchangeError}},precisionMode:o.kb,commonCurrencies:{APX:"AstroPepeX",DEGEN:"DegenReborn",EVA:"Evadore",JADE:"Jade Protocol",OMNI:"omni",TONCOIN:"TON"},options:{uta:!1,timeDifference:0,adjustForTimeDifference:!1,timeframes:{spot:{"1m":"1min","5m":"5min","3m":"3min","15m":"15min","30m":"30min","1h":"1h","4h":"4h","6h":"6Hutc","12h":"12Hutc","1d":"1Dutc","3d":"3Dutc","1w":"1Wutc","1M":"1Mutc"},swap:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1H","2h":"2H","4h":"4H","6h":"6Hutc","12h":"12Hutc","1d":"1Dutc","3d":"3Dutc","1w":"1Wutc","1M":"1Mutc"},uta:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1H","2h":"2H","4h":"4H","6h":"6H","12h":"12H","1d":"1D"}},fetchMarkets:{types:["spot","swap"]},defaultType:"spot",defaultSubType:"linear",createMarketBuyOrderRequiresPrice:!0,broker:"p4sve",withdraw:{fillResponseFromRequest:!0},fetchOHLCV:{maxRecentDaysPerTimeframe:{"1m":30,"3m":30,"5m":30,"15m":30,"30m":30,"1h":60,"2h":120,"4h":240,"6h":360,"12h":720,"1d":1440,"3d":4320,"1w":10080,"1M":43200},spot:{maxLimitPerTimeframe:{"1d":300,"3d":100,"1w":100,"1M":100},method:"publicSpotGetV2SpotMarketCandles"},swap:{maxLimitPerTimeframe:{"4h":540,"6h":360,"12h":180,"1d":90,"3d":30,"1w":13,"1M":4},method:"publicMixGetV2MixMarketCandles"}},fetchTrades:{spot:{method:"publicSpotGetV2SpotMarketFillsHistory"},swap:{method:"publicMixGetV2MixMarketFillsHistory"}},fetchFundingRate:{method:"publicMixGetV2MixMarketCurrentFundRate"},accountsByType:{spot:"spot",cross:"crossed_margin",isolated:"isolated_margin",swap:"usdt_futures",usdc_swap:"usdc_futures",future:"coin_futures",p2p:"p2p"},accountsById:{spot:"spot",crossed_margin:"cross",isolated_margin:"isolated",usdt_futures:"swap",usdc_futures:"usdc_swap",coin_futures:"future",p2p:"p2p"},sandboxMode:!1,networks:{TRC20:"TRC20",ERC20:"ERC20",BEP20:"BSC",ATOM:"ATOM",ACA:"AcalaToken",APT:"Aptos",ARBONE:"ArbitrumOne",ARBNOVA:"ArbitrumNova",AVAXC:"C-Chain",AVAXX:"X-Chain",AR:"Arweave",BCH:"BCH",BCHA:"BCHA",BITCI:"BITCI",BTC:"BTC",CELO:"CELO",CSPR:"CSPR",ADA:"Cardano",CHZ:"ChilizChain",CRC20:"CronosChain",DOGE:"DOGE",DOT:"DOT",EOS:"EOS",ETHF:"ETHFAIR",ETHW:"ETHW",ETC:"ETC",EGLD:"Elrond",FIL:"FIL",FIO:"FIO",FTM:"Fantom",HRC20:"HECO",ONE:"Harmony",HNT:"Helium",ICP:"ICP",IOTX:"IoTeX",KARDIA:"KAI",KAVA:"KAVA",KDA:"KDA",KLAY:"Klaytn",KSM:"Kusama",LAT:"LAT",LTC:"LTC",MINA:"MINA",MOVR:"MOVR",METIS:"MetisToken",GLMR:"Moonbeam",NEAR:"NEARProtocol",NULS:"NULS",OASYS:"OASYS",OASIS:"ROSE",OMNI:"OMNI",ONT:"Ontology",OPTIMISM:"Optimism",OSMO:"Osmosis",POKT:"PocketNetwork",MATIC:"Polygon",QTUM:"QTUM",REEF:"REEF",SOL:"SOL",SYS:"SYS",SXP:"Solar",XYM:"Symbol",TON:"TON",TT:"TT",TLOS:"Telos",THETA:"ThetaToken",VITE:"VITE",WAVES:"WAVES",WAX:"WAXP",WEMIX:"WEMIXMainnet",XDC:"XDCNetworkXDC",XRP:"XRP",FET:"FETCH",NEM:"NEM",REI:"REINetwork",ZIL:"ZIL",ABBC:"ABBCCoin",RSK:"RSK",AZERO:"AZERO",TRC10:"TRC10",JUNO:"JUNO",ZKSYNC:"zkSyncEra",STARKNET:"Starknet",VIC:"VICTION"},networksById:{},fetchPositions:{method:"privateMixGetV2MixPositionAllPosition"},defaultTimeInForce:"GTC",fiatCurrencies:["EUR","VND","PLN","CZK","HUF","DKK","AUD","CAD","NOK","SEK","CHF","MXN","COP","ARS","GBP","BRL","UAH","ZAR"]},rollingWindowSize:1e3,features:{spot:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:{last:!1,mark:!1,index:!1},price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,marketBuyRequiresPrice:!0,marketBuyByCost:!0},createOrders:{max:50},fetchMyTrades:{marginMode:!0,limit:100,daysBack:void 0,untilDays:90,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:90,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:200}},forPerps:{extends:"spot",createOrder:{triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!0,index:!0},price:!1},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!0,trailing:!0,marketBuyRequiresPrice:!1,marketBuyByCost:!1},fetchMyTrades:{untilDays:7},fetchClosedOrders:{trailing:!0}},swap:{linear:{extends:"forPerps"},inverse:{extends:"forPerps"}},future:{linear:{extends:"forPerps"},inverse:{extends:"forPerps"}}}})}setSandboxMode(e){this.options.sandboxMode=e}enableDemoTrading(e){this.setSandboxMode(e)}handleProductTypeAndParams(e=void 0,t={}){let i,s;[i,t]=this.handleSubTypeAndParams("handleProductTypeAndParams",void 0,t),void 0!==i&&void 0===e&&(s="linear"===i?"USDT-FUTURES":"COIN-FUTURES");let a=this.safeString2(t,"productType","category",s);if(void 0===a&&void 0!==e){const i=e.settle;if(e.spot){let e;[e,t]=this.handleMarginModeAndParams("handleProductTypeAndParams",t),a=void 0!==e?"MARGIN":"SPOT"}else a="USDT"===i?"USDT-FUTURES":"USDC"===i?"USDC-FUTURES":"SUSDT"===i?"SUSDT-FUTURES":"SUSDC"===i?"SUSDC-FUTURES":"SBTC"===i||"SETH"===i||"SEOS"===i?"SCOIN-FUTURES":"COIN-FUTURES"}if(void 0===a)throw new r.ArgumentsRequired(this.id+' requires a productType param, one of "USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES", "SUSDT-FUTURES", "SUSDC-FUTURES", "SCOIN-FUTURES" or for uta only "SPOT"');return[a,t=this.omit(t,["productType","category"])]}async fetchTime(e={}){const t=await this.publicCommonGetV2PublicTime(e),i=this.safeValue(t,"data",{});return this.safeInteger(i,"serverTime")}async fetchMarkets(e={}){let t;return this.options.adjustForTimeDifference&&await this.loadTimeDifference(),[t,e]=this.handleOptionAndParams(e,"fetchMarkets","uta",!1),t?await this.fetchUtaMarkets(e):await this.fetchDefaultMarkets(e)}async fetchDefaultMarkets(e){let t;const i=this.safeDict(this.options,"fetchMarkets"),s=["spot","swap"];t=void 0!==i?this.safeList(i,"types",s):this.safeList(this.options,"fetchMarkets",s);const o=[];let n=!1;for(let i=0;if&&(M=f),c.endTime=M)),b&&(M=g,M>f&&(M=f),c.endTime=M,y||(I=M-A));let x,_,C,B=!1;if((void 0!==I&&I<=P||a)&&(B=!0,A=(s=Math.min(s,200))*m,I=M-A,c.startTime=I,!d.spot)){const e=90;M-I>e*p&&(M=this.sum(I,e*p),c.endTime=M)}if(c.limit=s,[C,r]=this.handleParamString(r,"price"),[_,r]=this.handleProductTypeAndParams(d,r),u)void 0!==C&&("mark"===C?c.type="MARK":"index"===C&&(c.type="INDEX")),c.category=_,x=await this.publicUtaGetV3MarketCandles(this.extend(c,r));else if(d.spot)B?x=await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(c,r)):(v||(c.limit=1e3,s=1e3),x=await this.publicSpotGetV2SpotMarketCandles(this.extend(c,r)));else{c.productType=_;const e=this.extend(c,r);B||"mark"!==C&&"index"!==C?"mark"===C?x=await this.publicMixGetV2MixMarketHistoryMarkCandles(e):"index"===C?x=await this.publicMixGetV2MixMarketHistoryIndexCandles(e):B?x=await this.publicMixGetV2MixMarketHistoryCandles(e):(v||(e.limit=1e3,s=1e3),x=await this.publicMixGetV2MixMarketCandles(e)):(v||(e.limit=1e3,s=1e3),x=await this.publicMixGetV2MixMarketCandles(this.extend({kLineType:C},e)))}if(""===x)return[];const E=this.safeList(x,"data",x);return this.parseOHLCVs(E,d,t,i,s)}async fetchBalance(e={}){await this.loadMarkets();const t={};let i,s,a,o;if([o,e]=this.handleOptionAndParams(e,"fetchBalance","uta",!1),[i,e]=this.handleMarketTypeAndParams("fetchBalance",void 0,e),[s,e]=this.handleMarginModeAndParams("fetchBalance",e),o){a=await this.privateUtaGetV3AccountAssets(this.extend(t,e));const i=this.safeDict(a,"data",{}),s=this.safeList(i,"assets",[]);return this.parseUtaBalance(s)}if("swap"===i||"future"===i){let i;[i,e]=this.handleProductTypeAndParams(void 0,e),t.productType=i,a=await this.privateMixGetV2MixAccountAccounts(this.extend(t,e))}else if("isolated"===s)a=await this.privateMarginGetV2MarginIsolatedAccountAssets(this.extend(t,e));else if("cross"===s)a=await this.privateMarginGetV2MarginCrossedAccountAssets(this.extend(t,e));else{if("spot"!==i)throw new r.NotSupported(this.id+" fetchBalance() does not support "+i+" accounts");a=await this.privateSpotGetV2SpotAccountAssets(this.extend(t,e))}const n=this.safeValue(a,"data",[]);return this.parseBalance(n)}parseUtaBalance(e){const t={info:e};for(let i=0;i1)throw new r.ExchangeError(this.id+" createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent");"limit"===t&&(l.price=this.priceToPrecision(e,o));const _=this.safeString2(n,"triggerPriceType","triggerType","mark_price"),C=this.safeBool(n,"reduceOnly",!1),B=this.safeString2(n,"clientOid","clientOrderId"),E=this.safeString2(n,"force","timeInForce");let R;[R,n]=this.handlePostOnly(f,"post_only"===E,n);const L=this.safeStringUpper(this.options,"defaultTimeInForce"),N=this.safeStringUpper(n,"timeInForce",L);if(R?l.force="post_only":"GTC"===N?l.force="GTC":"FOK"===N?l.force="FOK":"IOC"===N&&(l.force="IOC"),n=this.omit(n,["stopPrice","triggerType","stopLossPrice","takeProfitPrice","stopLoss","takeProfit","postOnly","reduceOnly","clientOrderId","trailingPercent","trailingTriggerPrice"]),"swap"===c||"future"===c){let t;if(l.marginCoin=d.settleId,l.size=this.amountToPrecision(e,s),[t,n]=this.handleProductTypeAndParams(d,n),l.productType=t,void 0!==B&&(l.clientOid=B),(w||P||x)&&(l.triggerType=_),x){if(!f)throw new r.BadRequest(this.id+" createOrder() bitget trailing orders must be market orders");if(void 0===M)throw new r.ArgumentsRequired(this.id+" createOrder() bitget trailing orders must have a trailingTriggerPrice param");l.planType="track_plan",l.triggerPrice=this.priceToPrecision(e,M),l.callbackRatio=A}else if(w){if(l.planType="normal_plan",l.triggerPrice=this.priceToPrecision(e,m),void 0!==o&&(l.executePrice=this.priceToPrecision(e,o)),O){const t=this.safeString2(y,"triggerPrice","stopPrice");l.stopLossTriggerPrice=this.priceToPrecision(e,t);const i=this.safeString(y,"price");l.stopLossExecutePrice=this.priceToPrecision(e,i);const s=this.safeString(y,"type","mark_price");l.stopLossTriggerType=s}if(T){const t=this.safeString2(b,"triggerPrice","stopPrice");l.stopSurplusTriggerPrice=this.priceToPrecision(e,t);const i=this.safeString(b,"price");l.stopSurplusExecutePrice=this.priceToPrecision(e,i);const s=this.safeString(b,"type","mark_price");l.stopSurplusTriggerType=s}}else if(P){if(!f)throw new r.ExchangeError(this.id+" createOrder() bitget stopLoss or takeProfit orders must be market orders");l.holdSide=u?"sell"===i?"long":"short":"sell"===i?"buy":"sell",k?(l.triggerPrice=this.priceToPrecision(e,g),l.planType="pos_loss"):S&&(l.triggerPrice=this.priceToPrecision(e,v),l.planType="pos_profit")}else{if(O){const t=this.safeValue2(y,"triggerPrice","stopPrice");l.presetStopLossPrice=this.priceToPrecision(e,t)}if(T){const t=this.safeValue2(b,"triggerPrice","stopPrice");l.presetStopSurplusPrice=this.priceToPrecision(e,t)}}if(!P){void 0===h&&(h="cross");const e="cross"===h?"crossed":"isolated";l.marginMode=e;let t=i;C?u?(t="buy"===i?"sell":"buy",l.tradeSide="Close"):l.reduceOnly="YES":u&&(l.tradeSide="Open"),l.side=t}}else{if("spot"!==c)throw new r.NotSupported(this.id+" createOrder() does not support "+c+" orders");{if(P||I)throw new r.InvalidOrder(this.id+" createOrder() does not support stop loss/take profit orders on spot markets, only swap markets");let t,d;l.side=i;let c=!0;if([c,n]=this.handleOptionAndParams(n,"createOrder","createMarketBuyOrderRequiresPrice",!0),f&&"buy"===i){d="total";const i=this.safeNumber(n,"cost");if(n=this.omit(n,"cost"),void 0!==i)t=this.costToPrecision(e,i);else if(c){if(void 0===o)throw new r.InvalidOrder(this.id+" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument");{const i=this.numberToString(s),r=this.numberToString(o),n=a.Y.stringMul(i,r);t=this.costToPrecision(e,n)}}else t=this.costToPrecision(e,s)}else d="amount",t=this.amountToPrecision(e,s);void 0!==B&&(l.clientOid=B),void 0!==h?(l.loanType="normal",f&&"buy"===i?l.quoteSize=t:l.baseSize=t):(void 0!==t&&(l.size=t),void 0!==m&&(l.planType=d,l.triggerType=_,l.triggerPrice=this.priceToPrecision(e,m),void 0!==o&&(l.executePrice=this.priceToPrecision(e,o))))}}return this.extend(l,n)}async createUtaOrders(e,t={}){await this.loadMarkets();const i=[];let s,a;for(let t=0;t1)throw new r.ExchangeError(this.id+" editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent");let I,M,A;if(d=this.omit(d,["stopPrice","triggerType","stopLossPrice","takeProfitPrice","stopLoss","takeProfit","clientOrderId","trailingTriggerPrice","trailingPercent"]),[M,d]=this.handleProductTypeAndParams(c,d),[A,d]=this.handleOptionAndParams(d,"editOrder","uta",!1),A)if(void 0!==o&&(h.qty=this.amountToPrecision(t,o)),g||y){if(g){const e=this.safeString(d,"slTriggerBy","mark");h.slTriggerBy=e,h.stopLoss=this.priceToPrecision(t,m),void 0!==n?(h.slLimitPrice=this.priceToPrecision(t,n),h.slOrderType=this.safeString(d,"slOrderType","limit")):h.slOrderType=this.safeString(d,"slOrderType","market")}else if(y){const e=this.safeString(d,"tpTriggerBy","mark");h.tpTriggerBy=e,h.takeProfit=this.priceToPrecision(t,v),void 0!==n?(h.tpLimitPrice=this.priceToPrecision(t,n),h.tpOrderType=this.safeString(d,"tpOrderType","limit")):h.tpOrderType=this.safeString(d,"tpOrderType","market")}d=this.omit(d,["stopLossPrice","takeProfitPrice"]),I=await this.privateUtaPostV3TradeModifyStrategyOrder(this.extend(h,d))}else void 0!==n&&(h.price=this.priceToPrecision(t,n)),I=await this.privateUtaPostV3TradeModifyOrder(this.extend(h,d));else if(c.spot){const e=this.safeString(d,"cost");d=this.omit(d,"cost");if((this.safeBool(this.options,"editMarketBuyOrderRequiresPrice",!0)||void 0!==e)&&u&&"buy"===s){if(void 0===n&&void 0===e)throw new r.InvalidOrder(this.id+" editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively provide `cost` in the params");{const i=this.numberToString(o),s=this.numberToString(n),r=void 0===e?a.Y.stringMul(i,s):e;h.size=this.priceToPrecision(t,r)}}else h.size=this.amountToPrecision(t,o);h.orderType=i,void 0!==p?(h.triggerPrice=this.priceToPrecision(t,p),h.executePrice=this.priceToPrecision(t,n)):h.price=this.priceToPrecision(t,n),void 0!==p?I=await this.privateSpotPostV2SpotTradeModifyPlanOrder(this.extend(h,d)):(h.symbol=c.id,I=await this.privateSpotPostV2SpotTradeCancelReplaceOrder(this.extend(h,d)))}else{if(!c.swap&&!c.future)throw new r.NotSupported(this.id+" editOrder() does not support "+c.type+" orders");if(h.symbol=c.id,h.productType=M,y||g||(void 0!==o&&(h.newSize=this.amountToPrecision(t,o)),void 0===n||P||(h.newPrice=this.priceToPrecision(t,n))),P){if(!u)throw new r.BadRequest(this.id+" editOrder() bitget trailing orders must be market orders");void 0!==O&&(h.newTriggerPrice=this.priceToPrecision(t,O)),h.newCallbackRatio=T,I=await this.privateMixPostV2MixOrderModifyPlanOrder(this.extend(h,d))}else if(y||g)h.marginCoin=c.settleId,h.size=this.amountToPrecision(t,o),void 0!==n&&(h.executePrice=this.priceToPrecision(t,n)),g?h.triggerPrice=this.priceToPrecision(t,m):y&&(h.triggerPrice=this.priceToPrecision(t,v)),I=await this.privateMixPostV2MixOrderModifyTpslOrder(this.extend(h,d));else if(f){if(h.newTriggerPrice=this.priceToPrecision(t,p),k){const e=this.safeNumber2(b,"triggerPrice","stopPrice");h.newStopLossTriggerPrice=this.priceToPrecision(t,e);const i=this.safeNumber(b,"price");h.newStopLossExecutePrice=this.priceToPrecision(t,i);const s=this.safeString(b,"type","mark_price");h.newStopLossTriggerType=s}if(S){const e=this.safeNumber2(w,"triggerPrice","stopPrice");h.newSurplusTriggerPrice=this.priceToPrecision(t,e);const i=this.safeNumber(w,"price");h.newStopSurplusExecutePrice=this.priceToPrecision(t,i);const s=this.safeString(w,"type","mark_price");h.newStopSurplusTriggerType=s}I=await this.privateMixPostV2MixOrderModifyPlanOrder(this.extend(h,d))}else{const e=this.uuid(),i=this.safeString2(d,"newClientOid","newClientOrderId",e);if(d=this.omit(d,"newClientOrderId"),h.newClientOid=i,k){const e=this.safeValue2(b,"triggerPrice","stopPrice");h.newPresetStopLossPrice=this.priceToPrecision(t,e)}if(S){const e=this.safeValue2(w,"triggerPrice","stopPrice");h.newPresetStopSurplusPrice=this.priceToPrecision(t,e)}I=await this.privateMixPostV2MixOrderModifyOrder(this.extend(h,d))}}const x=this.safeDict(I,"data",{});return this.parseOrder(x,c)}async cancelOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const s=this.market(t);let a,o;[a,i]=this.handleMarginModeAndParams("cancelOrder",i);const n={},d=this.safeValue(i,"trailing"),c=this.safeValue2(i,"stop","trigger");let h;i=this.omit(i,["stop","trigger","trailing"]),s.spot&&c||(n.symbol=s.id),[h,i]=this.handleOptionAndParams(i,"cancelOrder","uta",!1);const l=c||d,u=(s.swap||s.future)&&l&&!h,p=this.safeString2(i,"clientOrderId","clientOid");if(u){const t=[],s={};void 0!==p?(i=this.omit(i,"clientOrderId"),s.clientOid=p):s.orderId=e,t.push(s),n.orderIdList=t}else void 0!==p?(i=this.omit(i,"clientOrderId"),n.clientOid=p):n.orderId=e;if(h)o=c?await this.privateUtaPostV3TradeCancelStrategyOrder(this.extend(n,i)):await this.privateUtaPostV3TradeCancelOrder(this.extend(n,i));else if(s.swap||s.future){let e;if([e,i]=this.handleProductTypeAndParams(s,i),n.productType=e,d){const e=this.safeString(i,"planType","track_plan");n.planType=e,o=await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(n,i))}else o=c?await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(n,i)):await this.privateMixPostV2MixOrderCancelOrder(this.extend(n,i))}else{if(!s.spot)throw new r.NotSupported(this.id+" cancelOrder() does not support "+s.type+" orders");void 0!==a?"isolated"===a?o=await this.privateMarginPostV2MarginIsolatedCancelOrder(this.extend(n,i)):"cross"===a&&(o=await this.privateMarginPostV2MarginCrossedCancelOrder(this.extend(n,i))):o=c?await this.privateSpotPostV2SpotTradeCancelPlanOrder(this.extend(n,i)):await this.privateSpotPostV2SpotTradeCancelOrder(this.extend(n,i))}const f=this.safeValue(o,"data",{});let m;if(u){m=this.safeValue(f,"successList",[])[0]}else m=h&&c?o:f;return this.parseOrder(m,s)}async cancelUtaOrders(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrders() requires a symbol argument");await this.loadMarkets();const s=this.market(t);let a;[a,i]=this.handleProductTypeAndParams(s,i);const o=[];for(let t=0;t=0&&(h="out"),this.safeLedgerEntry({info:e,id:this.safeString(e,"billId"),timestamp:r,datetime:this.iso8601(r),direction:h,account:void 0,referenceId:void 0,referenceAccount:void 0,type:this.parseLedgerType(this.safeString(e,"businessType")),currency:s,amount:c,before:void 0,after:o,status:void 0,fee:{currency:s,cost:n}},t)}parseLedgerType(e){return this.safeString({trans_to_cross:"transfer",trans_from_cross:"transfer",trans_to_exchange:"transfer",trans_from_exchange:"transfer",trans_to_isolated:"transfer",trans_from_isolated:"transfer",trans_to_contract:"transfer",trans_from_contract:"transfer",trans_to_otc:"transfer",trans_from_otc:"transfer",open_long:"trade",close_long:"trade",open_short:"trade",close_short:"trade",force_close_long:"trade",force_close_short:"trade",burst_long_loss_query:"trade",burst_short_loss_query:"trade",force_buy:"trade",force_sell:"trade",burst_buy:"trade",burst_sell:"trade",delivery_long:"settlement",delivery_short:"settlement",contract_settle_fee:"fee",append_margin:"transaction",adjust_down_lever_append_margin:"transaction",reduce_margin:"transaction",auto_append_margin:"transaction",cash_gift_issue:"cashback",cash_gift_recycle:"cashback",bonus_issue:"rebate",bonus_recycle:"rebate",bonus_expired:"rebate",transfer_in:"transfer",transfer_out:"transfer",deposit:"deposit",withdraw:"withdrawal",buy:"trade",sell:"trade"},e,e)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let a;if([a,s]=this.handleOptionAndParams(s,"fetchMyTrades","uta",!1),!a&&void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const o=this.market(e);let n={};[n,s]=this.handleUntilOption("endTime",n,s),void 0!==t&&(n.startTime=t),void 0!==i&&(n.limit=i);let d,c,h=!1;if([h,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),[d,s]=this.handleMarginModeAndParams("fetchMyTrades",s),h){let r,n;return a?(r="cursor",n="cursor"):o.spot?void 0!==d&&(r="minId",n="idLessThan"):(r="endId",n="idLessThan"),await this.fetchPaginatedCallCursor("fetchMyTrades",e,t,i,s,r,n)}if(a)c=await this.privateUtaGetV3TradeFills(this.extend(n,s));else if(n.symbol=o.id,o.spot)void 0!==d?(void 0===t&&(n.startTime=this.milliseconds()-7776e6),"isolated"===d?c=await this.privateMarginGetV2MarginIsolatedFills(this.extend(n,s)):"cross"===d&&(c=await this.privateMarginGetV2MarginCrossedFills(this.extend(n,s)))):c=await this.privateSpotGetV2SpotTradeFills(this.extend(n,s));else{let e;[e,s]=this.handleProductTypeAndParams(o,s),n.productType=e,c=await this.privateMixGetV2MixOrderFills(this.extend(n,s))}const l=this.safeValue(c,"data");if(a){const e=this.safeList(l,"list",[]);return this.parseTrades(e,o,t,i)}if(o.swap||o.future){const e=this.safeList(l,"fillList",[]);return this.parseTrades(e,o,t,i)}if(void 0!==d){const e=this.safeList(l,"fills",[]);return this.parseTrades(e,o,t,i)}return this.parseTrades(l,o,t,i)}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e);let s;[s,t]=this.handleProductTypeAndParams(i,t);const r={symbol:i.id};let a,o,n;if([o,t]=this.handleOptionAndParams(t,"fetchPosition","uta",!1),o){r.category=s,a=await this.privateUtaGetV3PositionCurrentPosition(this.extend(r,t));const e=this.safeDict(a,"data",{});n=this.safeList(e,"list",[])}else r.marginCoin=i.settleId,r.productType=s,a=await this.privateMixGetV2MixPositionSinglePosition(this.extend(r,t)),n=this.safeList(a,"data",[]);const d=this.safeDict(n,0,{});return this.parsePosition(d,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets();let i,s=!1;if([s,t]=this.handleOptionAndParams(t,"fetchPositions","paginate"),s)return await this.fetchPaginatedCallCursor("fetchPositions",void 0,void 0,void 0,t,"endId","idLessThan");let a,o;if(this.safeBool(t,"useHistoryEndpoint",!1)?i="privateMixGetV2MixPositionHistoryPosition":[i,t]=this.handleOptionAndParams(t,"fetchPositions","method","privateMixGetV2MixPositionAllPosition"),void 0!==e){const t=this.safeString(e,0);void 0!==t&&(a=this.market(t))}[o,t]=this.handleProductTypeAndParams(a,t);const n={};let d,c,h=!1;if([c,t]=this.handleOptionAndParams(t,"fetchPositions","uta",!1),c)n.category=o,d=await this.privateUtaGetV3PositionCurrentPosition(this.extend(n,t));else if("privateMixGetV2MixPositionAllPosition"===i){let e=this.safeString(t,"marginCoin","USDT");if(void 0!==a)e=a.settleId;else if("USDT-FUTURES"===o)e="USDT";else if("USDC-FUTURES"===o)e="USDC";else if("SUSDT-FUTURES"===o)e="SUSDT";else if("SUSDC-FUTURES"===o)e="SUSDC";else if(("SCOIN-FUTURES"===o||"COIN-FUTURES"===o)&&void 0===e)throw new r.ArgumentsRequired(this.id+" fetchPositions() requires a marginCoin parameter that matches the productType");n.marginCoin=e,n.productType=o,d=await this.privateMixGetV2MixPositionAllPosition(this.extend(n,t))}else h=!0,void 0!==a&&(n.symbol=a.id),n.productType=o,d=await this.privateMixGetV2MixPositionHistoryPosition(this.extend(n,t));let l=[];if(c||h){const e=this.safeDict(d,"data",{});l=this.safeList(e,"list",[])}else l=this.safeList(d,"data",[]);const u=[];for(let e=0;e0)throw new r.BadRequest(this.id+" reduceMargin() amount parameter must be a negative value");if(void 0===this.safeString(i,"holdSide"))throw new r.ArgumentsRequired(this.id+" reduceMargin() requires a holdSide parameter, either long or short");return await this.modifyMarginHelper(e,t,"reduce",i)}async addMargin(e,t,i={}){if(void 0===this.safeString(i,"holdSide"))throw new r.ArgumentsRequired(this.id+" addMargin() requires a holdSide parameter, either long or short");return await this.modifyMarginHelper(e,t,"add",i)}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e);let s;[s,t]=this.handleProductTypeAndParams(i,t);const r={symbol:i.id,marginCoin:i.settleId,productType:s},a=await this.privateMixGetV2MixAccountAccount(this.extend(r,t)),o=this.safeDict(a,"data",{});return this.parseLeverage(o,i)}parseLeverage(e,t=void 0){const i="crossed"===this.safeString(e,"marginMode"),s=i?"crossedMarginLeverage":"isolatedLongLever",r=i?"crossedMarginLeverage":"isolatedShortLever";return{info:e,symbol:t.symbol,marginMode:i?"cross":"isolated",longLeverage:this.safeInteger(e,s),shortLeverage:this.safeInteger(e,r)}}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");await this.loadMarkets();const s=this.market(t);let a;[a,i]=this.handleProductTypeAndParams(s,i);const o={symbol:s.id,leverage:this.numberToString(e)};let n,d;if([n,i]=this.handleOptionAndParams(i,"setLeverage","uta",!1),n){if("SPOT"===a){let e;[e,i]=this.handleMarginModeAndParams("fetchTrades",i),void 0!==e&&(a="MARGIN")}o.coin=s.settleId,o.category=a,d=await this.privateUtaPostV3AccountSetLeverage(this.extend(o,i))}else o.marginCoin=s.settleId,o.productType=a,d=await this.privateMixPostV2MixAccountSetLeverage(this.extend(o,i));return d}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");if("cross"===(e=e.toLowerCase())&&(e="crossed"),"isolated"!==e&&"crossed"!==e)throw new r.ArgumentsRequired(this.id+" setMarginMode() marginMode must be either isolated or crossed (cross)");await this.loadMarkets();const s=this.market(t);let a;[a,i]=this.handleProductTypeAndParams(s,i);const o={symbol:s.id,marginCoin:s.settleId,marginMode:e,productType:a};return await this.privateMixPostV2MixAccountSetMarginMode(this.extend(o,i))}async setPositionMode(e,t=void 0,i={}){await this.loadMarkets();const s=e?"hedge_mode":"one_way_mode",r={};let a,o,n,d;return void 0!==t&&(a=this.market(t)),[o,i]=this.handleProductTypeAndParams(a,i),[n,i]=this.handleOptionAndParams(i,"setPositionMode","uta",!1),n?(r.holdMode=s,d=await this.privateUtaPostV3AccountSetHoldMode(this.extend(r,i))):(r.posMode=s,r.productType=o,d=await this.privateMixPostV2MixAccountSetPositionMode(this.extend(r,i))),d}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new r.BadRequest(this.id+" fetchOpenInterest() supports contract markets only");let s;[s,t]=this.handleProductTypeAndParams(i,t);const a={symbol:i.id};let o,n;[o,t]=this.handleOptionAndParams(t,"fetchOpenInterest","uta",!1),o?(a.category=s,n=await this.publicUtaGetV3MarketOpenInterest(this.extend(a,t))):(a.productType=s,n=await this.publicMixGetV2MixMarketOpenInterest(this.extend(a,t)));const d=this.safeDict(n,"data",{});return this.parseOpenInterest(d,i)}parseOpenInterest(e,t=void 0){const i=this.safeList2(e,"openInterestList","list",[]),s=this.safeInteger(e,"ts"),r=this.safeString(i[0],"symbol");return this.safeOpenInterest({symbol:this.safeSymbol(r,t,void 0,"contract"),openInterestAmount:this.safeNumber2(i[0],"size","openInterest"),openInterestValue:void 0,timestamp:s,datetime:this.iso8601(s),info:e},t)}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchTransfers() requires a code argument");let a;await this.loadMarkets(),[a,s]=this.handleMarketTypeAndParams("fetchTransfers",void 0,s);const o=this.safeString(s,"fromAccount",a);s=this.omit(s,"fromAccount");const n=this.safeValue(this.options,"accountsByType",{});a=this.safeString(n,o);const d=this.currency(e);let c={coin:d.id,fromType:a};void 0!==t&&(c.startTime=t),void 0!==i&&(c.limit=i),[c,s]=this.handleUntilOption("endTime",c,s);const h=await this.privateSpotGetV2SpotAccountTransferRecords(this.extend(c,s)),l=this.safeList(h,"data",[]);return this.parseTransfers(l,d,t,i)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeValue(this.options,"accountsByType",{}),n={fromType:this.safeString(o,i),toType:this.safeString(o,s),amount:t,coin:a.id},d=this.safeString(r,"symbol");let c;r=this.omit(r,"symbol"),void 0!==d&&(c=this.market(d),n.symbol=c.id);const h=await this.privateSpotPostV2SpotWalletTransfer(this.extend(n,r)),l=this.safeValue(h,"data",{});return l.ts=this.safeInteger(h,"requestTime"),this.parseTransfer(l,a)}parseTransfer(e,t=void 0){const i=this.safeInteger(e,"ts"),s=this.safeStringLower(e,"status"),r=this.safeString(e,"coin"),a=this.safeString(e,"fromType"),o=this.safeValue(this.options,"accountsById",{}),n=this.safeString(o,a,a),d=this.safeString(e,"toType"),c=this.safeString(o,d,d);return{info:e,id:this.safeString(e,"transferId"),timestamp:i,datetime:this.iso8601(i),currency:this.safeCurrencyCode(r,t),amount:this.safeNumber(e,"size"),fromAccount:n,toAccount:c,status:this.parseTransferStatus(s)}}parseTransferStatus(e){return this.safeString({successful:"ok"},e,e)}parseDepositWithdrawFee(e,t=void 0){const i=this.safeValue(e,"chains",[]),s=i.length,r={info:e,withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}};for(let e=0;e0&&(r=this.market(e[0]),d.symbol=r.id)}void 0!==t&&(d.startTime=t),void 0!==i&&(d.limit=i),[d,s]=this.handleUntilOption("endTime",d,s),[a,s]=this.handleProductTypeAndParams(r,s),[o,s]=this.handleOptionAndParams(s,"fetchPositionsHistory","uta",!1),o?(d.category=a,n=await this.privateUtaGetV3PositionHistoryPosition(this.extend(d,s))):n=await this.privateMixGetV2MixPositionHistoryPosition(this.extend(d,s));const c=this.safeDict(n,"data",{}),h=this.safeList(c,"list",[]),l=this.parsePositions(h,e,s);return this.filterBySinceLimit(l,t,i)}async fetchConvertQuote(e,t,i=void 0,s={}){await this.loadMarkets();const r={fromCoin:e,toCoin:t,fromCoinSize:this.numberToString(i)},a=await this.privateConvertGetV2ConvertQuotedPrice(this.extend(r,s)),o=this.safeDict(a,"data",{}),n=this.safeString(o,"fromCoin",e),d=this.currency(n),c=this.safeString(o,"toCoin",t),h=this.currency(c);return this.parseConversion(o,d,h)}async createConvertTrade(e,t,i,s=void 0,a={}){await this.loadMarkets();const o=this.safeString2(a,"price","cnvtPrice");if(void 0===o)throw new r.ArgumentsRequired(this.id+" createConvertTrade() requires a price parameter");const n=this.safeString2(a,"toAmount","toCoinSize");if(void 0===n)throw new r.ArgumentsRequired(this.id+" createConvertTrade() requires a toAmount parameter");a=this.omit(a,["price","toAmount"]);const d={traceId:e,fromCoin:t,toCoin:i,fromCoinSize:this.numberToString(s),toCoinSize:n,cnvtPrice:o},c=await this.privateConvertPostV2ConvertTrade(this.extend(d,a)),h=this.safeDict(c,"data",{}),l=this.safeString(h,"toCoin",i),u=this.currency(l);return this.parseConversion(h,void 0,u)}async fetchConvertTradeHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={},a=this.milliseconds();r.startTime=void 0!==t?t:a-864e5;const o=this.safeString2(s,"endTime","until");r.endTime=void 0!==o?o:a,void 0!==i&&(r.limit=i),s=this.omit(s,"until");const n=await this.privateConvertGetV2ConvertConvertRecord(this.extend(r,s)),d=this.safeDict(n,"data",{}),c=this.safeList(d,"dataList",[]);return this.parseConversions(c,e,"fromCoin","toCoin",t,i)}parseConversion(e,t=void 0,i=void 0){const s=this.safeInteger(e,"ts"),r=this.safeString(e,"fromCoin"),a=this.safeCurrencyCode(r,t),o=this.safeString(e,"toCoin"),n=this.safeCurrencyCode(o,i);return{info:e,timestamp:s,datetime:this.iso8601(s),id:this.safeString2(e,"id","traceId"),fromCurrency:a,fromAmount:this.safeNumber(e,"fromCoinSize"),toCurrency:n,toAmount:this.safeNumber(e,"toCoinSize"),price:this.safeNumber(e,"cnvtPrice"),fee:this.safeNumber(e,"fee")}}async fetchConvertCurrencies(e={}){await this.loadMarkets();const t=await this.privateConvertGetV2ConvertCurrencies(e),i={},s=this.safeList(t,"data",[]);for(let e=0;e0&&(h=h+"?"+this.urlencode(l))}if(o){this.checkRequiredCredentials();const e=this.nonce().toString();let t=e+i+c;if("POST"===i)t+=a=this.json(s);else if(Object.keys(s).length){let e="?"+this.urlencode(this.keysort(s));e.indexOf("%24")>-1&&(e=e.replace("%24","$")),h+=e,t+=e}const o=this.hmac(this.encode(t),this.encode(this.secret),n.s,"base64"),d=this.safeString(this.options,"broker");r={"ACCESS-KEY":this.apiKey,"ACCESS-SIGN":o,"ACCESS-TIMESTAMP":e,"ACCESS-PASSPHRASE":this.password,"X-CHANNEL-API-CODE":d},"POST"===i&&(r["Content-Type"]="application/json")}if(this.safeBool2(this.options,"sandboxMode","sandbox",!1)&&"v2/public/time"!==e&&"v3/market/current-fund-rate"!==e){void 0===r&&(r={});const e=this.safeString(s,"productType");"SCOIN-FUTURES"!==e&&"SUSDT-FUTURES"!==e&&"SUSDC-FUTURES"!==e&&(r.PAPTRADING="1")}return{url:h,method:i,body:a,headers:r}}}},357:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(3974),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bithumb",name:"Bithumb",countries:["KR"],rateLimit:500,pro:!0,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!0,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},hostname:"bithumb.com",urls:{logo:"https://github.com/user-attachments/assets/c9e0eefb-4777-46b9-8f09-9d7f7c4af82d",api:{public:"https://api.{hostname}/public",private:"https://api.{hostname}"},www:"https://www.bithumb.com",doc:"https://apidocs.bithumb.com",fees:"https://en.bithumb.com/customer_support/info_fee"},api:{public:{get:["ticker/ALL_{quoteId}","ticker/{baseId}_{quoteId}","orderbook/ALL_{quoteId}","orderbook/{baseId}_{quoteId}","transaction_history/{baseId}_{quoteId}","network-info","assetsstatus/multichain/ALL","assetsstatus/multichain/{currency}","withdraw/minimum/ALL","withdraw/minimum/{currency}","assetsstatus/ALL","assetsstatus/{baseId}","candlestick/{baseId}_{quoteId}/{interval}"]},private:{post:["info/account","info/balance","info/wallet_address","info/ticker","info/orders","info/user_transactions","info/order_detail","trade/place","trade/cancel","trade/btc_withdrawal","trade/krw_deposit","trade/krw_withdrawal","trade/market_buy","trade/market_sell","trade/stop_limit"]}},fees:{trading:{maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0025")}},precisionMode:o.v,features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{"Bad Request(SSL)":r.BadRequest,"Bad Request(Bad Method)":r.BadRequest,"Bad Request.(Auth Data)":r.AuthenticationError,"Not Member":r.AuthenticationError,"Invalid Apikey":r.AuthenticationError,"Method Not Allowed.(Access IP)":r.PermissionDenied,"Method Not Allowed.(BTC Adress)":r.InvalidAddress,"Method Not Allowed.(Access)":r.PermissionDenied,"Database Fail":r.ExchangeNotAvailable,"Invalid Parameter":r.BadRequest,5600:r.ExchangeError,"Unknown Error":r.ExchangeError,"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions":r.ExchangeError},timeframes:{"1m":"1m","3m":"3m","5m":"5m","10m":"10m","30m":"30m","1h":"1h","6h":"6h","12h":"12h","1d":"24h"},options:{quoteCurrencies:{BTC:{limits:{cost:{min:2e-4,max:100}}},KRW:{limits:{cost:{min:500,max:5e9}}},USDT:{limits:{cost:{min:void 0,max:void 0}}}}},commonCurrencies:{ALT:"ArchLoot",FTC:"FTC2",SOC:"Soda Coin"}})}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return super.safeMarket(e,t,i,"spot")}amountToPrecision(e,t){return this.decimalToPrecision(t,o.R3,this.markets[e].precision.amount,o.fv)}async fetchMarkets(e={}){const t=[],i=this.safeDict(this.options,"quoteCurrencies",{}),s=Object.keys(i),r=[];for(let t=0;t1){const e=t[0];let s=t[1];s.length<8&&(s="0"+s),i=this.parse8601(e+" "+s)}else i=this.safeIntegerProduct(e,"transaction_date",.001)}void 0!==i&&(i-=324e5);let r=this.safeString(e,"type");r="ask"===r?"sell":"buy";const a=this.safeString(e,"cont_no");t=this.safeMarket(void 0,t);const o=this.safeString(e,"price"),n=this.fixCommaNumber(this.safeString2(e,"units_traded","units")),d=this.safeString(e,"total");let c;const h=this.safeString(e,"fee");if(void 0!==h){const t=this.safeString(e,"fee_currency");c={cost:h,currency:this.commonCurrencyCode(t)}}return this.safeTrade({id:a,info:e,timestamp:i,datetime:this.iso8601(i),symbol:t.symbol,order:void 0,type:undefined,side:r,takerOrMaker:void 0,price:o,amount:n,cost:d,fee:c},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={baseId:r.baseId,quoteId:r.quoteId};void 0!==i&&(a.count=i);const o=await this.publicGetTransactionHistoryBaseIdQuoteId(this.extend(a,s)),n=this.safeList(o,"data",[]);return this.parseTrades(n,r,t,i)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d={order_currency:n.id,payment_currency:n.quote,units:s};let c="privatePostTradePlace";"limit"===t?(d.price=a,d.type="buy"===i?"bid":"ask"):c="privatePostTradeMarket"+this.capitalize(i);const h=await this[c](this.extend(d,o)),l=this.safeString(h,"order_id");if(void 0===l)throw new r.InvalidOrder(this.id+" createOrder() did not return an order id");return this.safeOrder({info:h,symbol:e,type:t,side:i,id:l},n)}async fetchOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" fetchOrder() requires a symbol argument");await this.loadMarkets();const s=this.market(t),a={order_id:e,count:1,order_currency:s.base,payment_currency:s.quote},o=await this.privatePostInfoOrderDetail(this.extend(a,i)),n=this.safeDict(o,"data");return this.parseOrder(this.extend(n,{order_id:e}),s)}parseOrderStatus(e){return this.safeString({Pending:"open",Completed:"closed",Cancel:"canceled"},e,e)}parseOrder(e,t=void 0){const i=this.safeIntegerProduct(e,"order_date",.001),s="bid"===this.safeString2(e,"type","side")?"buy":"sell",r=this.parseOrderStatus(this.safeString(e,"order_status")),o=this.safeString2(e,"order_price","price");let n="limit";a.Y.stringEquals(o,"0")&&(n="market");const d=this.fixCommaNumber(this.safeString2(e,"order_qty","units"));let c,h=this.fixCommaNumber(this.safeString(e,"units_remaining"));void 0===h&&("closed"===r?h="0":"canceled"!==r&&(h=d));const l=this.safeString(e,"order_currency"),u=this.safeString(e,"payment_currency"),p=this.safeCurrencyCode(l),f=this.safeCurrencyCode(u);void 0!==p&&void 0!==f&&(c=p+"/"+f),void 0===c&&(c=(t=this.safeMarket(void 0,t)).symbol);const m=this.safeString(e,"order_id"),g=this.safeList(e,"contract",[]);return this.safeOrder({info:e,id:m,clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:void 0,symbol:c,type:n,timeInForce:void 0,postOnly:void 0,side:s,price:o,triggerPrice:void 0,amount:d,cost:void 0,average:void 0,filled:void 0,remaining:h,status:r,fee:void 0,trades:g},t)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchOpenOrders() requires a symbol argument");await this.loadMarkets();const a=this.market(e);void 0===i&&(i=100);const o={count:i,order_currency:a.base,payment_currency:a.quote};void 0!==t&&(o.after=t);const n=await this.privatePostInfoOrders(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseOrders(d,a,t,i)}async cancelOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");if(!("side"in i))throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a `side` parameter (sell or buy)");const s=this.market(t),a="buy"===i.side?"bid":"ask";i=this.omit(i,["side","currency"]);const o={order_id:e,type:a,order_currency:s.base,payment_currency:s.quote},n=await this.privatePostTradeCancel(this.extend(o,i));return this.safeOrder({info:n})}async cancelUnifiedOrder(e,t={}){const i={side:e.side};return await this.cancelOrder(e.id,e.symbol,this.extend(i,t))}async withdraw(e,t,i,s=void 0,a={}){[s,a]=this.handleWithdrawTagAndParams(s,a),this.checkAddress(i),await this.loadMarkets();const o=this.currency(e),n={units:t,address:i,currency:o.id};if("XRP"===e||"XMR"===e||"EOS"===e||"STEEM"===e||"TON"===e){const t=this.safeString(a,"destination");if(void 0===s&&void 0===t)throw new r.ArgumentsRequired(this.id+" "+e+" withdraw() requires a tag argument or an extra destination param");void 0!==s&&(n.destination=s)}const d=await this.privatePostTradeBtcWithdrawal(this.extend(n,a));return this.parseTransaction(d,o)}parseTransaction(e,t=void 0){return{id:void 0,txid:void 0,timestamp:void 0,datetime:void 0,network:void 0,addressFrom:void 0,address:void 0,addressTo:void 0,amount:void 0,type:void 0,currency:(t=this.safeCurrency(void 0,t)).code,status:void 0,updated:void 0,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:void 0,info:e}}fixCommaNumber(e){if(void 0===e)return;let t=e;for(;t.indexOf(",")>-1;)t=t.replace(",","");return t}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o="/"+this.implodeParams(e,s);let d=this.implodeHostname(this.urls.api[t])+o;const c=this.omit(s,this.extractParams(e));if("public"===t)Object.keys(c).length&&(d+="?"+this.urlencode(c));else{this.checkRequiredCredentials(),a=this.urlencode(this.extend({endpoint:o},c));const e=this.nonce().toString(),t=o+"\0"+a+"\0"+e,i=this.hmac(this.encode(t),this.encode(this.secret),n.Zf),s=this.stringToBase64(i);r={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","Api-Key":this.apiKey,"Api-Sign":s,"Api-Nonce":e}}return{url:d,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0!==n&&"status"in n){const e=this.safeString(n,"status"),t=this.safeString(n,"message");if(void 0!==e){if("0000"===e)return;if("거래 진행중인 내역이 존재하지 않습니다."===t)return;const i=this.id+" "+t;throw this.throwExactlyMatchedException(this.exceptions,e,i),this.throwExactlyMatchedException(this.exceptions,t,i),new r.ExchangeError(i)}}}}},1837:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(1466),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitmart",name:"BitMart",countries:["US","CN","HK","KR"],rateLimit:33.34,version:"v2",certified:!0,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,createTrailingPercentOrder:!0,fetchBalance:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFee:!0,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIsolatedBorrowRate:!0,fetchIsolatedBorrowRates:!0,fetchLedger:!0,fetchLiquidations:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyLiquidations:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!0,fetchPositions:!0,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactionFee:!0,fetchTransactionFees:!1,fetchTransfer:!1,fetchTransfers:!0,fetchWithdrawAddresses:!0,fetchWithdrawAddressesByNetwork:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!0,setLeverage:!0,setMarginMode:!1,setPositionMode:!0,transfer:!0,withdraw:!0},hostname:"bitmart.com",urls:{logo:"https://github.com/user-attachments/assets/0623e9c4-f50e-48c9-82bd-65c3908c3a14",api:{spot:"https://api-cloud.{hostname}",swap:"https://api-cloud-v2.{hostname}"},www:"https://www.bitmart.com/",doc:"https://developer-pro.bitmart.com/",referral:{url:"http://www.bitmart.com/?r=rQCFLh",discount:.3},fees:"https://www.bitmart.com/fee/en"},requiredCredentials:{apiKey:!0,secret:!0,uid:!0},api:{public:{get:{"system/time":3,"system/service":3,"spot/v1/currencies":7.5,"spot/v1/symbols":7.5,"spot/v1/symbols/details":5,"spot/quotation/v3/tickers":6,"spot/quotation/v3/ticker":4,"spot/quotation/v3/lite-klines":5,"spot/quotation/v3/klines":7,"spot/quotation/v3/books":4,"spot/quotation/v3/trades":4,"spot/v1/ticker":5,"spot/v2/ticker":30,"spot/v1/ticker_detail":5,"spot/v1/steps":30,"spot/v1/symbols/kline":6,"spot/v1/symbols/book":5,"spot/v1/symbols/trades":5,"contract/v1/tickers":15,"contract/public/details":5,"contract/public/depth":5,"contract/public/open-interest":30,"contract/public/funding-rate":30,"contract/public/funding-rate-history":30,"contract/public/kline":6,"account/v1/currencies":30,"contract/public/markprice-kline":5}},private:{get:{"account/sub-account/v1/transfer-list":7.5,"account/sub-account/v1/transfer-history":7.5,"account/sub-account/main/v1/wallet":5,"account/sub-account/main/v1/subaccount-list":7.5,"account/contract/sub-account/main/v1/wallet":5,"account/contract/sub-account/main/v1/transfer-list":7.5,"account/contract/sub-account/v1/transfer-history":7.5,"account/v1/wallet":5,"account/v1/currencies":30,"spot/v1/wallet":5,"account/v1/deposit/address":30,"account/v1/withdraw/charge":32,"account/v2/deposit-withdraw/history":7.5,"account/v1/deposit-withdraw/detail":7.5,"account/v1/withdraw/address/list":30,"spot/v1/order_detail":1,"spot/v2/orders":5,"spot/v1/trades":5,"spot/v2/trades":4,"spot/v3/orders":5,"spot/v2/order_detail":1,"spot/v1/margin/isolated/borrow_record":1,"spot/v1/margin/isolated/repay_record":1,"spot/v1/margin/isolated/pairs":30,"spot/v1/margin/isolated/account":5,"spot/v1/trade_fee":30,"spot/v1/user_fee":30,"spot/v1/broker/rebate":1,"contract/private/assets-detail":5,"contract/private/order":1.2,"contract/private/order-history":10,"contract/private/position":10,"contract/private/position-v2":10,"contract/private/get-open-orders":1.2,"contract/private/current-plan-order":1.2,"contract/private/trades":10,"contract/private/position-risk":10,"contract/private/affilate/rebate-list":10,"contract/private/affilate/trade-list":10,"contract/private/transaction-history":10,"contract/private/get-position-mode":1},post:{"account/sub-account/main/v1/sub-to-main":30,"account/sub-account/sub/v1/sub-to-main":30,"account/sub-account/main/v1/main-to-sub":30,"account/sub-account/sub/v1/sub-to-sub":30,"account/sub-account/main/v1/sub-to-sub":30,"account/contract/sub-account/main/v1/sub-to-main":7.5,"account/contract/sub-account/main/v1/main-to-sub":7.5,"account/contract/sub-account/sub/v1/sub-to-main":7.5,"account/v1/withdraw/apply":7.5,"spot/v1/submit_order":1,"spot/v1/batch_orders":1,"spot/v2/cancel_order":1,"spot/v1/cancel_orders":15,"spot/v4/query/order":1,"spot/v4/query/client-order":1,"spot/v4/query/open-orders":5,"spot/v4/query/history-orders":5,"spot/v4/query/trades":5,"spot/v4/query/order-trades":5,"spot/v4/cancel_orders":3,"spot/v4/cancel_all":90,"spot/v4/batch_orders":3,"spot/v3/cancel_order":1,"spot/v2/batch_orders":1,"spot/v2/submit_order":1,"spot/v1/margin/submit_order":1.5,"spot/v1/margin/isolated/borrow":30,"spot/v1/margin/isolated/repay":30,"spot/v1/margin/isolated/transfer":30,"account/v1/transfer-contract-list":60,"account/v1/transfer-contract":60,"contract/private/submit-order":2.5,"contract/private/cancel-order":1.5,"contract/private/cancel-orders":30,"contract/private/submit-plan-order":2.5,"contract/private/cancel-plan-order":1.5,"contract/private/submit-leverage":2.5,"contract/private/submit-tp-sl-order":2.5,"contract/private/modify-plan-order":2.5,"contract/private/modify-preset-plan-order":2.5,"contract/private/modify-limit-order":2.5,"contract/private/modify-tp-sl-order":2.5,"contract/private/submit-trail-order":2.5,"contract/private/cancel-trail-order":1.5,"contract/private/set-position-mode":1}}},timeframes:{"1m":1,"3m":3,"5m":5,"15m":15,"30m":30,"45m":45,"1h":60,"2h":120,"3h":180,"4h":240,"1d":1440,"1w":10080,"1M":43200},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0040"),maker:this.parseNumber("0.0035"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0020")],[this.parseNumber("10"),this.parseNumber("0.18")],[this.parseNumber("50"),this.parseNumber("0.0016")],[this.parseNumber("250"),this.parseNumber("0.0014")],[this.parseNumber("1000"),this.parseNumber("0.0012")],[this.parseNumber("5000"),this.parseNumber("0.0010")],[this.parseNumber("25000"),this.parseNumber("0.0008")],[this.parseNumber("50000"),this.parseNumber("0.0006")]],maker:[[this.parseNumber("0"),this.parseNumber("0.001")],[this.parseNumber("10"),this.parseNumber("0.0009")],[this.parseNumber("50"),this.parseNumber("0.0008")],[this.parseNumber("250"),this.parseNumber("0.0007")],[this.parseNumber("1000"),this.parseNumber("0.0006")],[this.parseNumber("5000"),this.parseNumber("0.0005")],[this.parseNumber("25000"),this.parseNumber("0.0004")],[this.parseNumber("50000"),this.parseNumber("0.0003")]]}}},precisionMode:o.kb,exceptions:{exact:{3e4:r.ExchangeError,30001:r.AuthenticationError,30002:r.AuthenticationError,30003:r.AccountSuspended,30004:r.AuthenticationError,30005:r.AuthenticationError,30006:r.AuthenticationError,30007:r.AuthenticationError,30008:r.AuthenticationError,30010:r.PermissionDenied,30011:r.AuthenticationError,30012:r.AuthenticationError,30013:r.RateLimitExceeded,30014:r.ExchangeNotAvailable,30016:r.OnMaintenance,30017:r.RateLimitExceeded,30018:r.BadRequest,30019:r.PermissionDenied,6e4:r.BadRequest,60001:r.BadRequest,60002:r.BadRequest,60003:r.ExchangeError,60004:r.ExchangeError,60005:r.ExchangeError,60006:r.ExchangeError,60007:r.InvalidAddress,60008:r.InsufficientFunds,60009:r.ExchangeError,60010:r.ExchangeError,60011:r.InvalidAddress,60012:r.ExchangeError,60020:r.PermissionDenied,60021:r.PermissionDenied,60022:r.PermissionDenied,60026:r.PermissionDenied,60027:r.PermissionDenied,60028:r.AccountSuspended,60029:r.AccountSuspended,60030:r.BadRequest,60031:r.BadRequest,60050:r.ExchangeError,60051:r.ExchangeError,61001:r.InsufficientFunds,61003:r.BadRequest,61004:r.BadRequest,61005:r.BadRequest,61006:r.NotSupported,61007:r.ExchangeError,61008:r.ExchangeError,7e4:r.ExchangeError,70001:r.BadRequest,70002:r.BadSymbol,70003:r.NetworkError,71001:r.BadRequest,71002:r.BadRequest,71003:r.BadRequest,71004:r.BadRequest,71005:r.BadRequest,5e4:r.BadRequest,50001:r.BadSymbol,50002:r.BadRequest,50003:r.BadRequest,50004:r.BadRequest,50005:r.OrderNotFound,50006:r.InvalidOrder,50007:r.InvalidOrder,50008:r.InvalidOrder,50009:r.InvalidOrder,50010:r.InvalidOrder,50011:r.InvalidOrder,50012:r.InvalidOrder,50013:r.InvalidOrder,50014:r.BadRequest,50015:r.BadRequest,50016:r.BadRequest,50017:r.BadRequest,50018:r.BadRequest,50019:r.ExchangeError,50020:r.InsufficientFunds,50021:r.BadRequest,50022:r.ExchangeNotAvailable,50023:r.BadSymbol,50024:r.BadRequest,50025:r.BadRequest,50026:r.BadRequest,50027:r.BadRequest,50028:r.BadRequest,50029:r.InvalidOrder,50030:r.OrderNotFound,50031:r.OrderNotFound,50032:r.OrderNotFound,50033:r.InvalidOrder,50034:r.InvalidOrder,50035:r.InvalidOrder,50036:r.ExchangeError,50037:r.BadRequest,50038:r.BadRequest,50039:r.BadRequest,50040:r.BadSymbol,50041:r.ExchangeError,50042:r.BadRequest,51e3:r.BadSymbol,51001:r.ExchangeError,51002:r.ExchangeError,51003:r.ExchangeError,51004:r.InsufficientFunds,51005:r.InvalidOrder,51006:r.InvalidOrder,51007:r.BadRequest,51008:r.ExchangeError,51009:r.InvalidOrder,51010:r.InvalidOrder,51011:r.InvalidOrder,51012:r.InvalidOrder,51013:r.InvalidOrder,51014:r.InvalidOrder,51015:r.InvalidOrder,52e3:r.BadRequest,52001:r.BadRequest,52002:r.BadRequest,52003:r.BadRequest,52004:r.BadRequest,53e3:r.AccountSuspended,53001:r.AccountSuspended,53002:r.PermissionDenied,53003:r.PermissionDenied,53005:r.PermissionDenied,53006:r.PermissionDenied,53007:r.PermissionDenied,53008:r.PermissionDenied,53009:r.PermissionDenied,53010:r.PermissionDenied,57001:r.BadRequest,58001:r.BadRequest,59001:r.ExchangeError,59002:r.ExchangeError,59003:r.ExchangeError,59004:r.ExchangeError,59005:r.PermissionDenied,59006:r.ExchangeError,59007:r.ExchangeError,59008:r.ExchangeError,59009:r.ExchangeError,59010:r.InsufficientFunds,59011:r.ExchangeError,40001:r.ExchangeError,40002:r.ExchangeError,40003:r.ExchangeError,40004:r.ExchangeError,40005:r.ExchangeError,40006:r.PermissionDenied,40007:r.BadRequest,40008:r.InvalidNonce,40009:r.BadRequest,40010:r.BadRequest,40011:r.BadRequest,40012:r.ExchangeError,40013:r.ExchangeError,40014:r.BadSymbol,40015:r.BadSymbol,40016:r.InvalidOrder,40017:r.InvalidOrder,40018:r.InvalidOrder,40019:r.ExchangeError,40020:r.InvalidOrder,40021:r.ExchangeError,40022:r.ExchangeError,40023:r.ExchangeError,40024:r.ExchangeError,40025:r.ExchangeError,40026:r.ExchangeError,40027:r.InsufficientFunds,40028:r.PermissionDenied,40029:r.InvalidOrder,40030:r.InvalidOrder,40031:r.InvalidOrder,40032:r.InvalidOrder,40033:r.InvalidOrder,40034:r.BadSymbol,40035:r.OrderNotFound,40036:r.InvalidOrder,40037:r.OrderNotFound,40038:r.BadRequest,40039:r.BadRequest,40040:r.InvalidOrder,40041:r.InvalidOrder,40042:r.InvalidOrder,40043:r.InvalidOrder,40044:r.InvalidOrder,40045:r.InvalidOrder,40046:r.PermissionDenied,40047:r.PermissionDenied,40048:r.InvalidOrder,40049:r.InvalidOrder,40050:r.InvalidOrder},broad:{"You contract account available balance not enough":r.InsufficientFunds,"This trading pair does not support API trading":r.BadSymbol}},commonCurrencies:{$GM:"GOLDMINER",$HERO:"Step Hero",$PAC:"PAC",BP:"BEYOND",GDT:"Gorilla Diamond",GLD:"Goldario",MVP:"MVP Coin",TRU:"Truebit"},options:{defaultNetworks:{USDT:"TRC20",BTC:"BTC",ETH:"ERC20"},timeDifference:0,adjustForTimeDifference:!1,networks:{ERC20:"ERC20",SOL:"SOL",BTC:"BTC",TRC20:"TRC20",OMNI:"OMNI",XLM:"XLM",EOS:"EOS",NEO:"NEO",BTM:"BTM",BCH:"BCH",LTC:"LTC",BSV:"BSV",XRP:"XRP",PLEX:"PLEX",XCH:"XCH",NEAR:"NEAR",FIO:"FIO",SCRT:"SCRT",IOTX:"IOTX",ALGO:"ALGO",ATOM:"ATOM",DOT:"DOT",ADA:"ADA",DOGE:"DOGE",XYM:"XYM",GLMR:"GLMR",MOVR:"MOVR",ZIL:"ZIL",INJ:"INJ",KSM:"KSM",ZEC:"ZEC",NAS:"NAS",POLYGON:"MATIC",HRC20:"HECO",XDC:"XDC",ONE:"ONE",LAT:"LAT",CSPR:"Casper",ICP:"Computer",XTZ:"XTZ",MINA:"MINA",BEP20:"BSC_BNB",THETA:"THETA",AKT:"AKT",AR:"AR",CELO:"CELO",FIL:"FIL",NULS:"NULS",ETC:"ETC",DASH:"DASH",DGB:"DGB",BEP2:"BEP2",GRIN:"GRIN",WAVES:"WAVES",ABBC:"ABBC",ACA:"ACA",QTUM:"QTUM",PAC:"PAC",TLOS:"TLOS",KARDIA:"KardiaChain",FUSE:"FUSE",TRC10:"TRC10",FIRO:"FIRO",FTM:"Fantom",EVER:"EVER",KAVA:"KAVA",HYDRA:"HYDRA",PLCU:"PLCU",BRISE:"BRISE",OPTIMISM:"OPTIMISM",REEF:"REEF",SYS:"SYS",VITE:"VITE",STX:"STX",SXP:"SXP",BITCI:"BITCI",XRD:"XRD",ASTR:"ASTAR",ZEN:"HORIZEN",LTO:"LTO",ETHW:"ETHW",ETHF:"ETHF",IOST:"IOST",APT:"APT",ONT:"ONT",EVMOS:"EVMOS",XMR:"XMR",OASYS:"OAS",OSMO:"OSMO",OMAX:"OMAX Chain",DESO:"DESO",BFIC:"BFIC",OHO:"OHO",CS:"CS",CHEQ:"CHEQ",NODL:"NODL",NEM:"XEM",FRA:"FRA",ERGO:"ERG"},networksById:{ETH:"ERC20",Ethereum:"ERC20",USDT:"OMNI",Bitcoin:"BTC"},defaultType:"spot",fetchBalance:{type:"spot"},accountsByType:{spot:"spot",swap:"swap"},createMarketBuyOrderRequiresPrice:!0,brokerId:"CCXTxBitmart000"},features:{default:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!0,leverage:!0,selfTradePrevention:!1,iceberg:!1},createOrders:{max:10},fetchMyTrades:{marginMode:!0,limit:200,daysBack:void 0,untilDays:99999,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:200,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:200,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},forDerivatives:{extends:"default",createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!0,index:!1},price:!1},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,marketBuyRequiresPrice:!0,marketBuyByCost:!0},fetchMyTrades:{marginMode:!0,limit:void 0,daysBack:void 0,untilDays:99999},fetchOrder:{marginMode:!1,trigger:!1,trailing:!0},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!0,trailing:!1},fetchClosedOrders:{marginMode:!0,limit:200,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1},fetchOHLCV:{limit:500}},spot:{extends:"default"},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:void 0,inverse:void 0}}})}async fetchTime(e={}){const t=await this.publicGetSystemTime(e),i=this.safeDict(t,"data",{});return this.safeInteger(i,"server_time")}async fetchStatus(e={}){const t=this.safeDict(this.options,"fetchStatus",{}),i=this.safeString(this.options,"defaultType");let s=this.safeString(t,"type",i);s=this.safeString(e,"type",s),e=this.omit(e,"type");const r=await this.publicGetSystemService(e),a=this.safeDict(r,"data",{}),o=this.safeList(a,"service",[]),n=this.indexBy(o,"service_type");"swap"===s&&(s="contract");const d=this.safeString(n,s);let c,h;if(void 0!==d){2===this.safeInteger(d,"status")?c="ok":(c="maintenance",h=this.safeInteger(d,"end_time"))}return{status:c,updated:void 0,eta:h,url:void 0,info:r}}async fetchSpotMarkets(e={}){const t=await this.publicGetSpotV1SymbolsDetails(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"symbols",[]),r=[],o=this.fees.trading;for(let e=0;e=0;if(!n){const e=i.split("-");a=this.safeString(e,0);const t=this.safeString(e,1);void 0!==t&&(o=t.toUpperCase())}const d=this.safeCurrencyCode(a);let c=this.safeDict(r,d);void 0===c&&(c={info:t,id:a,code:d,precision:void 0,name:this.safeString(t,"name"),deposit:void 0,withdraw:void 0,active:void 0,networks:{},type:n?"other":"crypto"});const h=this.networkIdToCode(o),l=this.safeBool(t,"withdraw_enabled"),u=this.safeBool(t,"deposit_enabled");c.networks[h]={info:t,id:o,code:h,withdraw:l,deposit:u,active:l&&u,fee:this.safeNumber(t,"withdraw_fee"),limits:{withdraw:{min:this.safeNumber(t,"withdraw_minsize"),max:void 0},deposit:{min:void 0,max:void 0}}},r[d]=c}const a=Object.keys(r);for(let e=0;e0&&(t=this.safeValue(a,e[0]))}o=this.safeDict(t,"info",{}),s=this.safeString(o,"currency")}else{const i=this.safeDict(a,t);void 0!==i?(o=this.safeDict(i,"info",{}),s=this.safeString(o,"currency")):r+="-"+this.networkCodeToId(t,e)}return void 0!==s?s:r}async fetchTransactionFee(e,t={}){await this.loadMarkets();const i=this.currency(e);let s;[s,t]=this.handleNetworkCodeAndParams(t);const r={currency:this.getCurrencyIdFromCodeAndNetwork(i.code,s)},a=await this.privateGetAccountV1WithdrawCharge(this.extend(r,t)),o=a.data,n={};return n[e]=this.safeNumber(o,"withdraw_fee"),{info:a,withdraw:n,deposit:{}}}parseDepositWithdrawFee(e,t=void 0){return{info:e,withdraw:{fee:this.safeNumber(e,"withdraw_fee"),percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}}}async fetchDepositWithdrawFee(e,t={}){let i;await this.loadMarkets(),[i,t]=this.handleNetworkCodeAndParams(t);const s={currency:this.getCurrencyIdFromCodeAndNetwork(e,i)},r=(await this.privateGetAccountV1WithdrawCharge(this.extend(s,t))).data;return this.parseDepositWithdrawFee(r)}parseTicker(e,t=void 0){const i=this.safeList(e,"result",[]),s=this.safeString2(e,"avg_price","index_price");let r=this.safeString2(e,"symbol","contract_symbol"),o=this.safeInteger2(e,"timestamp","ts"),n=this.safeString2(e,"last_price","last"),d=this.safeString2(e,"price_change_percent_24h","change_24h"),c=this.safeString(e,"fluctuation"),h=this.safeString2(e,"high_24h","high_price"),l=this.safeString2(e,"low_24h","low_price"),u=this.safeString2(e,"best_bid","bid_px"),p=this.safeString2(e,"best_bid_size","bid_sz"),f=this.safeString2(e,"best_ask","ask_px"),m=this.safeString2(e,"best_ask_size","ask_sz"),g=this.safeString(e,"open_24h"),v=this.safeStringN(e,["base_volume_24h","v_24h","volume_24h"]),y=this.safeStringLowerN(e,["quote_volume_24h","qv_24h","turnover_24h"]);const b=this.safeString(i,0);void 0!==b&&(r=b,o=this.safeInteger(i,12),h=this.safeString(i,5),l=this.safeString(i,6),u=this.safeString(i,8),p=this.safeString(i,9),f=this.safeString(i,10),m=this.safeString(i,11),g=this.safeString(i,4),n=this.safeString(i,1),c=this.safeString(i,7),v=this.safeString(i,2),y=this.safeStringLower(i,3));const w=(t=this.safeMarket(r,t)).symbol;return void 0===o&&(o=this.safeIntegerProduct(e,"s_t",1e3)),void 0===d&&(d=a.Y.stringMul(c,"100")),void 0===y&&(void 0===v?y=this.safeString(e,"volume_24h",y):(y=v,v=void 0)),this.safeTicker({symbol:w,timestamp:o,datetime:this.iso8601(o),high:h,low:l,bid:u,bidVolume:p,ask:f,askVolume:m,vwap:void 0,open:g,close:n,last:n,previousClose:void 0,change:void 0,percentage:d,average:s,baseVolume:v,quoteVolume:y,indexPrice:this.safeString(e,"index_price"),info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={};let a;if(i.swap)s.symbol=i.id,a=await this.publicGetContractPublicDetails(this.extend(s,t));else{if(!i.spot)throw new r.NotSupported(this.id+" fetchTicker() does not support "+i.type+" markets, only spot and swap markets are accepted");s.symbol=i.id,a=await this.publicGetSpotQuotationV3Ticker(this.extend(s,t))}let o=[],n={};if(i.spot)n=this.safeDict(a,"data",{});else{const e=this.safeDict(a,"data",{});o=this.safeList(e,"symbols",[]),n=this.safeDict(o,0,{})}return this.parseTicker(n,i)}async fetchTickers(e=void 0,t={}){let i,s,a;if(await this.loadMarkets(),void 0!==(e=this.marketSymbols(e))){const t=this.safeString(e,0);s=this.market(t)}if([i,t]=this.handleMarketTypeAndParams("fetchTickers",s,t),"spot"===i)a=await this.publicGetSpotQuotationV3Tickers(t);else{if("swap"!==i)throw new r.NotSupported(this.id+" fetchTickers() does not support "+i+" markets, only spot and swap markets are accepted");a=await this.publicGetContractPublicDetails(t)}let o=[];if("spot"===i)o=this.safeList(a,"data",[]);else{const e=this.safeDict(a,"data",{});o=this.safeList(e,"symbols",[])}const n={};for(let e=0;e{"use strict";i.d(t,{A:()=>c});var s=i(8186),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(8995);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitmex",name:"BitMEX",countries:["SC"],version:"v1",userAgent:void 0,rateLimit:100,certified:!0,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!0,option:!1,addMargin:void 0,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!0,createOrder:!0,createReduceOnlyOrder:!0,createStopOrder:!0,createTrailingAmountOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDepositsWithdrawals:"emulated",fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:"emulated",fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:"emulated",fetchLeverages:!0,fetchLeverageTiers:!1,fetchLiquidations:!0,fetchMarginAdjustmentHistory:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransactions:"emulated",fetchTransfer:!1,fetchTransfers:!1,index:!0,reduceMargin:void 0,sandbox:!0,setLeverage:!0,setMargin:void 0,setMarginMode:!0,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","1h":"1h","1d":"1d"},urls:{test:{public:"https://testnet.bitmex.com",private:"https://testnet.bitmex.com"},logo:"https://github.com/user-attachments/assets/c78425ab-78d5-49d6-bd14-db7734798f04",api:{public:"https://www.bitmex.com",private:"https://www.bitmex.com"},www:"https://www.bitmex.com",doc:["https://www.bitmex.com/app/apiOverview","https://github.com/BitMEX/api-connectors/tree/master/official-http"],fees:"https://www.bitmex.com/app/fees",referral:{url:"https://www.bitmex.com/app/register/NZTR1q",discount:.1}},api:{public:{get:{announcement:5,"announcement/urgent":5,chat:5,"chat/channels":5,"chat/connected":5,"chat/pinned":5,funding:5,guild:5,instrument:5,"instrument/active":5,"instrument/activeAndIndices":5,"instrument/activeIntervals":5,"instrument/compositeIndex":5,"instrument/indices":5,"instrument/usdVolume":5,insurance:5,leaderboard:5,liquidation:5,"orderBook/L2":5,"porl/nonce":5,quote:5,"quote/bucketed":5,schema:5,"schema/websocketHelp":5,settlement:5,stats:5,"stats/history":5,"stats/historyUSD":5,trade:5,"trade/bucketed":5,"wallet/assets":5,"wallet/networks":5}},private:{get:{address:5,apiKey:5,execution:5,"execution/tradeHistory":5,globalNotification:5,"leaderboard/name":5,order:5,"porl/snapshots":5,position:5,user:5,"user/affiliateStatus":5,"user/checkReferralCode":5,"user/commission":5,"user/csa":5,"user/depositAddress":5,"user/executionHistory":5,"user/getWalletTransferAccounts":5,"user/margin":5,"user/quoteFillRatio":5,"user/quoteValueRatio":5,"user/staking":5,"user/staking/instruments":5,"user/staking/tiers":5,"user/tradingVolume":5,"user/unstakingRequests":5,"user/wallet":5,"user/walletHistory":5,"user/walletSummary":5,userAffiliates:5,userEvent:5},post:{address:5,chat:5,guild:5,"guild/archive":5,"guild/join":5,"guild/kick":5,"guild/leave":5,"guild/sharesTrades":5,order:1,"order/cancelAllAfter":5,"order/closePosition":5,"position/isolate":1,"position/leverage":1,"position/riskLimit":5,"position/transferMargin":1,"user/addSubaccount":5,"user/cancelWithdrawal":5,"user/communicationToken":5,"user/confirmEmail":5,"user/confirmWithdrawal":5,"user/logout":5,"user/preferences":5,"user/requestWithdrawal":5,"user/unstakingRequests":5,"user/updateSubaccount":5,"user/walletTransfer":5},put:{guild:5,order:1},delete:{order:1,"order/all":1,"user/unstakingRequests":5}}},exceptions:{exact:{"Invalid API Key.":a.AuthenticationError,"This key is disabled.":a.PermissionDenied,"Access Denied":a.PermissionDenied,"Duplicate clOrdID":a.InvalidOrder,"orderQty is invalid":a.InvalidOrder,"Invalid price":a.InvalidOrder,"Invalid stopPx for ordType":a.InvalidOrder,"Account is restricted":a.PermissionDenied},broad:{"Signature not valid":a.AuthenticationError,overloaded:a.ExchangeNotAvailable,"Account has insufficient Available Balance":a.InsufficientFunds,"Service unavailable":a.ExchangeNotAvailable,"Server Error":a.ExchangeError,"Unable to cancel order due to existing state":a.InvalidOrder,"We require all new traders to verify":a.PermissionDenied}},precisionMode:r.kb,options:{"api-expires":5,fetchOHLCVOpenTimestamp:!0,oldPrecision:!1,networks:{BTC:"btc",ERC20:"eth",BEP20:"bsc",TRC20:"tron",AVAXC:"avax",NEAR:"near",XTZ:"xtz",DOT:"dot",SOL:"sol",ADA:"ada"}},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0},triggerDirection:!0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,marketBuyRequiresPrice:!1,marketBuyByCost:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e6,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e6,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e6,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e4}},spot:{extends:"default",createOrder:{triggerPriceType:{index:!1}}},derivatives:{extends:"default",createOrder:{triggerPriceType:{index:!0}}},swap:{linear:{extends:"derivatives"},inverse:{extends:"derivatives"}},future:{linear:{extends:"derivatives"},inverse:{extends:"derivatives"}}},commonCurrencies:{USDt:"USDT",XBt:"BTC",XBT:"BTC",Gwei:"ETH",GWEI:"ETH",LAMP:"SOL",LAMp:"SOL"}})}async fetchCurrencies(e={}){const t=await this.publicGetWalletAssets(e),i={};for(let e=0;e=0)throw new a.OrderNotFound(this.id+" cancelOrder() failed: "+d);return this.parseOrder(n)}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeValue2(i,"clOrdID","clientOrderId"),r={};void 0===s?r.orderID=e:(r.clOrdID=s,i=this.omit(i,["clOrdID","clientOrderId"]));const a=await this.privateDeleteOrder(this.extend(r,i));return this.parseOrders(a)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i={};let s;void 0!==e&&(s=this.market(e),i.symbol=s.id);const r=await this.privateDeleteOrderAll(this.extend(i,t));return this.parseOrders(r,s)}async cancelAllOrdersAfter(e,t={}){await this.loadMarkets();const i={timeout:e>0?this.parseToInt(e/1e3):0};return await this.privatePostOrderCancelAllAfter(this.extend(i,t))}async fetchLeverages(e=void 0,t={}){await this.loadMarkets();const i=await this.fetchPositions(e,t);return this.parseLeverages(i,e,"symbol")}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),marginMode:this.safeStringLower(e,"marginMode"),longLeverage:this.safeInteger(e,"leverage"),shortLeverage:this.safeInteger(e,"leverage")}}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.privateGetPosition(t),s=this.parsePositions(i,e);return this.filterByArrayPositions(s,"symbol",e,!1)}parsePosition(e,t=void 0){const i=(t=this.safeMarket(this.safeString(e,"symbol"),t)).symbol,s=this.safeString(e,"timestamp"),r=!0===this.safeValue(e,"crossMargin")?"cross":"isolated",a=o.Y.stringAbs(this.safeString2(e,"foreignNotional","homeNotional")),n=this.safeString(t,"settle"),d=this.convertToRealAmount(n,this.safeString(e,"maintMargin")),c=this.convertToRealAmount(n,this.safeString(e,"unrealisedPnl")),h=this.parseNumber(o.Y.stringAbs(this.safeString(e,"currentQty"))),l=this.safeNumber(t,"contractSize");let u;const p=this.safeString(e,"homeNotional");return void 0!==p&&(u="-"===p[0]?"short":"long"),this.safePosition({info:e,id:this.safeString(e,"account"),symbol:i,timestamp:this.parse8601(s),datetime:s,lastUpdateTimestamp:void 0,hedged:void 0,side:u,contracts:h,contractSize:l,entryPrice:this.safeNumber(e,"avgEntryPrice"),markPrice:this.safeNumber(e,"markPrice"),lastPrice:void 0,notional:this.parseNumber(a),leverage:this.safeNumber(e,"leverage"),collateral:void 0,initialMargin:this.safeNumber(e,"initMargin"),initialMarginPercentage:this.safeNumber(e,"initMarginReq"),maintenanceMargin:d,maintenanceMarginPercentage:this.safeNumber(e,"maintMarginReq"),unrealizedPnl:c,liquidationPrice:this.safeNumber(e,"liquidationPrice"),marginMode:r,marginRatio:void 0,percentage:this.safeNumber(e,"unrealisedPnlPcnt"),stopLossPrice:void 0,takeProfitPrice:void 0})}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const a=this.currency(e),o=this.convertFromRealAmount(e,t);let n;[n,r]=this.handleNetworkCodeAndParams(r);const c={currency:a.id,amount:o,address:i,network:this.networkCodeToId(n,a.code)};void 0!==this.twofa&&(c.otpToken=(0,d.O)(this.twofa));const h=await this.privatePostUserRequestWithdrawal(this.extend(c,r));return this.parseTransaction(h,a)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets();const i=await this.publicGetInstrumentActiveAndIndices(t),s=[];for(let e=0;e1&&this.inArray(t[1],i)){e=this.currency(t[0]).id+":"+t[1],r.symbol=e}else a=this.market(e),r.symbol=a.id}void 0!==t&&(r.startTime=this.iso8601(t)),void 0!==i&&(r.count=i);const o=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==o&&(r.endTime=this.iso8601(o)),void 0===t&&void 0===o&&(r.reverse=!0);const n=await this.publicGetFunding(this.extend(r,s));return this.parseFundingRateHistories(n,a,t,i)}parseFundingRateHistory(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeString(e,"timestamp");return{info:e,symbol:this.safeSymbol(i,t),fundingRate:this.safeNumber(e,"fundingRate"),timestamp:this.parse8601(s),datetime:s}}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new a.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");if(e<.01||e>100)throw new a.BadRequest(this.id+" leverage should be between 0.01 and 100");await this.loadMarkets();const s=this.market(t);if("swap"!==s.type&&"future"!==s.type)throw new a.BadSymbol(this.id+" setLeverage() supports future and swap contracts only");const r={symbol:s.id,leverage:e};return await this.privatePostPositionLeverage(this.extend(r,i))}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new a.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");if("isolated"!==(e=e.toLowerCase())&&"cross"!==e)throw new a.BadRequest(this.id+" setMarginMode() marginMode argument should be isolated or cross");await this.loadMarkets();const s=this.market(t);if("swap"!==s.type&&"future"!==s.type)throw new a.BadSymbol(this.id+" setMarginMode() supports swap and future contracts only");const r="cross"!==e,o={symbol:s.id,enabled:r};return await this.privatePostPositionIsolate(this.extend(o,i))}async fetchDepositAddress(e,t={}){let i;if(await this.loadMarkets(),[i,t]=this.handleNetworkCodeAndParams(t),void 0===i)throw new a.ArgumentsRequired(this.id+' fetchDepositAddress requires params["network"]');const s=this.currency(e);t=this.omit(t,"network");const r={currency:s.id,network:this.networkCodeToId(i,s.code)},o=await this.privateGetUserDepositAddress(this.extend(r,t));return{info:o,currency:e,network:i,address:o.replace('"',"").replace('"',""),tag:void 0}}parseDepositWithdrawFee(e,t=void 0){const i=this.safeValue(e,"networks",[]),s=i.length,r={info:e,withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}};if(0!==s){const a=this.safeString(e,"scale"),n=this.parsePrecision(a);for(let e=0;e=400){const t=this.safeValue(n,"error",{}),i=this.safeString(t,"message"),s=this.id+" "+o;if(this.throwExactlyMatchedException(this.exceptions.exact,i,s),this.throwBroadlyMatchedException(this.exceptions.broad,i,s),400===e)throw new a.BadRequest(s);throw new a.ExchangeError(s)}}}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o="/api/"+this.version+"/"+e;if("GET"===i)Object.keys(s).length&&(o+="?"+this.urlencode(s));else{const e=this.safeString(s,"_format");void 0!==e&&(o+="?"+this.urlencode({_format:e}),s=this.omit(s,"_format"))}const d=this.urls.api[t]+o,c=this.checkRequiredCredentials(!1);if("private"===t||"public"===t&&c){this.checkRequiredCredentials();let e=i+o,t=this.safeInteger(this.options,"api-expires");r={"Content-Type":"application/json","api-key":this.apiKey},t=this.sum(this.seconds(),t);const d=t.toString();e+=d,r["api-expires"]=d,"POST"!==i&&"PUT"!==i&&"DELETE"!==i||Object.keys(s).length&&(e+=a=this.json(s)),r["api-signature"]=this.hmac(this.encode(e),this.encode(this.secret),n.s)}return{url:d,method:i,body:a,headers:r}}}},2753:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(7202),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitopro",name:"BitoPro",countries:["TW"],version:"v3",rateLimit:100,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,createStopOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","3h":"3h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://github.com/user-attachments/assets/affc6337-b95a-44bf-aacd-04f9722364f6",api:{rest:"https://api.bitopro.com/v3"},www:"https://www.bitopro.com",doc:["https://github.com/bitoex/bitopro-offical-api-docs/blob/master/v3-1/rest-1/rest.md"],fees:"https://www.bitopro.com/fees"},requiredCredentials:{apiKey:!0,secret:!0},api:{public:{get:{"order-book/{pair}":1,tickers:1,"tickers/{pair}":1,"trades/{pair}":1,"provisioning/currencies":1,"provisioning/trading-pairs":1,"provisioning/limitations-and-fees":1,"trading-history/{pair}":1,"price/otc/{currency}":1}},private:{get:{"accounts/balance":1,"orders/history":1,"orders/all/{pair}":1,"orders/trades/{pair}":1,"orders/{pair}/{orderId}":1,"wallet/withdraw/{currency}/{serial}":1,"wallet/withdraw/{currency}/id/{id}":1,"wallet/depositHistory/{currency}":1,"wallet/withdrawHistory/{currency}":1,"orders/open":1},post:{"orders/{pair}":.5,"orders/batch":20/3,"wallet/withdraw/{currency}":10},put:{orders:5},delete:{"orders/{pair}/{id}":2/3,"orders/all":5,"orders/{pair}":5}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.001"),taker:this.parseNumber("0.002"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("3000000"),this.parseNumber("0.00194")],[this.parseNumber("5000000"),this.parseNumber("0.0015")],[this.parseNumber("30000000"),this.parseNumber("0.0014")],[this.parseNumber("300000000"),this.parseNumber("0.0013")],[this.parseNumber("550000000"),this.parseNumber("0.0012")],[this.parseNumber("1300000000"),this.parseNumber("0.0011")]],maker:[[this.parseNumber("0"),this.parseNumber("0.001")],[this.parseNumber("3000000"),this.parseNumber("0.00097")],[this.parseNumber("5000000"),this.parseNumber("0.0007")],[this.parseNumber("30000000"),this.parseNumber("0.0006")],[this.parseNumber("300000000"),this.parseNumber("0.0005")],[this.parseNumber("550000000"),this.parseNumber("0.0004")],[this.parseNumber("1300000000"),this.parseNumber("0.0003")]]}}},options:{networks:{ERC20:"ERC20",ETH:"ERC20",TRX:"TRX",TRC20:"TRX",BEP20:"BSC",BSC:"BSC"},fiatCurrencies:["TWD"]},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"Unsupported currency.":r.BadRequest,"Unsupported order type":r.BadRequest,"Invalid body":r.BadRequest,"Invalid Signature":r.AuthenticationError,"Address not in whitelist.":r.BadRequest},broad:{"Invalid amount":r.InvalidOrder,"Balance for ":r.InsufficientFunds,"Invalid ":r.BadRequest,"Wrong parameter":r.BadRequest}},commonCurrencies:{}})}async fetchCurrencies(e={}){const t=await this.publicGetProvisioningCurrencies(e),i=this.safeList(t,"data",[]),s={},r=this.safeList(this.options,"fiatCurrencies",[]);for(let e=0;e=200&&e<300)return;const h=this.id+" "+o,l=this.safeString(n,"error");throw this.throwExactlyMatchedException(this.exceptions.exact,l,h),this.throwBroadlyMatchedException(this.exceptions.broad,l,h),new r.ExchangeError(h)}}},9061:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(8800),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitrue",name:"Bitrue",countries:["SG"],rateLimit:10,certified:!1,version:"v1",pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!0,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!0,setMargin:!0,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1H","2h":"2H","4h":"4H","1d":"1D","1w":"1W"},urls:{logo:"https://github.com/user-attachments/assets/67abe346-1273-461a-bd7c-42fa32907c8e",api:{spot:"https://www.bitrue.com/api",fapi:"https://fapi.bitrue.com/fapi",dapi:"https://fapi.bitrue.com/dapi",kline:"https://www.bitrue.com/kline-api"},www:"https://www.bitrue.com",referral:"https://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQE",doc:["https://github.com/Bitrue-exchange/bitrue-official-api-docs","https://www.bitrue.com/api-docs"],fees:"https://bitrue.zendesk.com/hc/en-001/articles/4405479952537"},api:{spot:{kline:{public:{get:{"public.json":.24,"public{currency}.json":.24}}},v1:{public:{get:{ping:.24,time:.24,exchangeInfo:.24,depth:{cost:1,byLimit:[[100,.24],[500,1.2],[1e3,2.4]]},trades:.24,historicalTrades:1.2,aggTrades:.24,"ticker/24hr":{cost:.24,noSymbol:9.6},"ticker/price":.24,"ticker/bookTicker":.24,"market/kline":.24}},private:{get:{order:5,openOrders:5,allOrders:25,account:25,myTrades:25,"etf/net-value/{symbol}":.24,"withdraw/history":120,"deposit/history":120},post:{order:5,"withdraw/commit":120},delete:{order:5}}},v2:{private:{get:{myTrades:1.2}}}},fapi:{v1:{public:{get:{ping:.24,time:.24,contracts:.24,depth:.24,ticker:.24,klines:.24}}},v2:{private:{get:{myTrades:5,openOrders:5,order:5,account:5,leverageBracket:5,commissionRate:5,futures_transfer_history:5,forceOrdersHistory:5},post:{positionMargin:5,level_edit:5,cancel:5,order:25,allOpenOrders:5,futures_transfer:5}}}},dapi:{v1:{public:{get:{ping:.24,time:.24,contracts:.24,depth:.24,ticker:.24,klines:.24}}},v2:{private:{get:{myTrades:5,openOrders:5,order:5,account:5,leverageBracket:5,commissionRate:5,futures_transfer_history:5,forceOrdersHistory:5},post:{positionMargin:5,level_edit:5,cancel:5,order:5,allOpenOrders:5,futures_transfer:5}}}}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.00098"),maker:this.parseNumber("0.00098")},future:{trading:{feeSide:"quote",tierBased:!0,percentage:!0,taker:this.parseNumber("0.000400"),maker:this.parseNumber("0.000200"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.000400")],[this.parseNumber("250"),this.parseNumber("0.000400")],[this.parseNumber("2500"),this.parseNumber("0.000350")],[this.parseNumber("7500"),this.parseNumber("0.000320")],[this.parseNumber("22500"),this.parseNumber("0.000300")],[this.parseNumber("50000"),this.parseNumber("0.000270")],[this.parseNumber("100000"),this.parseNumber("0.000250")],[this.parseNumber("200000"),this.parseNumber("0.000220")],[this.parseNumber("400000"),this.parseNumber("0.000200")],[this.parseNumber("750000"),this.parseNumber("0.000170")]],maker:[[this.parseNumber("0"),this.parseNumber("0.000200")],[this.parseNumber("250"),this.parseNumber("0.000160")],[this.parseNumber("2500"),this.parseNumber("0.000140")],[this.parseNumber("7500"),this.parseNumber("0.000120")],[this.parseNumber("22500"),this.parseNumber("0.000100")],[this.parseNumber("50000"),this.parseNumber("0.000080")],[this.parseNumber("100000"),this.parseNumber("0.000060")],[this.parseNumber("200000"),this.parseNumber("0.000040")],[this.parseNumber("400000"),this.parseNumber("0.000020")],[this.parseNumber("750000"),this.parseNumber("0")]]}}},delivery:{trading:{feeSide:"base",tierBased:!0,percentage:!0,taker:this.parseNumber("0.000500"),maker:this.parseNumber("0.000100"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.000500")],[this.parseNumber("250"),this.parseNumber("0.000450")],[this.parseNumber("2500"),this.parseNumber("0.000400")],[this.parseNumber("7500"),this.parseNumber("0.000300")],[this.parseNumber("22500"),this.parseNumber("0.000250")],[this.parseNumber("50000"),this.parseNumber("0.000240")],[this.parseNumber("100000"),this.parseNumber("0.000240")],[this.parseNumber("200000"),this.parseNumber("0.000240")],[this.parseNumber("400000"),this.parseNumber("0.000240")],[this.parseNumber("750000"),this.parseNumber("0.000240")]],maker:[[this.parseNumber("0"),this.parseNumber("0.000100")],[this.parseNumber("250"),this.parseNumber("0.000080")],[this.parseNumber("2500"),this.parseNumber("0.000050")],[this.parseNumber("7500"),this.parseNumber("0.0000030")],[this.parseNumber("22500"),this.parseNumber("0")],[this.parseNumber("50000"),this.parseNumber("-0.000050")],[this.parseNumber("100000"),this.parseNumber("-0.000060")],[this.parseNumber("200000"),this.parseNumber("-0.000070")],[this.parseNumber("400000"),this.parseNumber("-0.000080")],[this.parseNumber("750000"),this.parseNumber("-0.000090")]]}}}},options:{createMarketBuyOrderRequiresPrice:!0,fetchMarkets:{types:["spot","linear","inverse"]},fetchMyTradesMethod:"v2PrivateGetMyTrades",hasAlreadyAuthenticatedSuccessfully:!1,currencyToPrecisionRoundingMode:o.R3,recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,parseOrderToPrecision:!1,newOrderRespType:{market:"FULL",limit:"FULL"},networks:{ERC20:"ETH",TRC20:"TRX",AETERNITY:"Aeternity",AION:"AION",ALGO:"Algorand",ASK:"ASK",ATOM:"ATOM",AVAXC:"AVAX C-Chain",BCH:"BCH",BEP2:"BEP2",BEP20:"BEP20",Bitcoin:"Bitcoin",BRP20:"BRP20",ADA:"Cardano",CASINOCOIN:"CasinoCoin","CASINOCOIN-XRPL":"CasinoCoin XRPL",CONTENTOS:"Contentos",DASH:"Dash",DECOIN:"Decoin",DFI:"DeFiChain",DGB:"DGB",DIVI:"Divi",DOGE:"dogecoin",EOS:"EOS",ETC:"ETC",FILECOIN:"Filecoin",FREETON:"FREETON",HBAR:"HBAR",HEDERA:"Hedera Hashgraph",HRC20:"HRC20",ICON:"ICON",ICP:"ICP",IGNIS:"Ignis",INTERNETCOMPUTER:"Internet Computer",IOTA:"IOTA",KAVA:"KAVA",KSM:"KSM",LTC:"LiteCoin",LUNA:"Luna",MATIC:"MATIC",MOBILECOIN:"Mobile Coin",MONACOIN:"MonaCoin",XMR:"Monero",NEM:"NEM",NEP5:"NEP5",OMNI:"OMNI",PAC:"PAC",DOT:"Polkadot",RAVEN:"Ravencoin",SAFEX:"Safex",SOL:"SOLANA",SGB:"Songbird",XML:"Stellar Lumens",XYM:"Symbol",XTZ:"Tezos",theta:"theta",THETA:"THETA",VECHAIN:"VeChain",WANCHAIN:"Wanchain",XINFIN:"XinFin Network",XRP:"XRP",XRPL:"XRPL",ZIL:"ZIL"},defaultType:"spot",timeframes:{spot:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1H","2h":"2H","4h":"4H","12h":"12H","1d":"1D","1w":"1W"},future:{"1m":"1min","5m":"5min","15m":"15min","30m":"30min","1h":"1h","1d":"1day","1w":"1week","1M":"1month"}},accountsByType:{spot:"wallet",future:"contract",swap:"contract",funding:"wallet",fund:"wallet",contract:"contract"}},commonCurrencies:{MIM:"MIM Swarm"},precisionMode:o.kb,features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!0,marketBuyByCost:!0,selfTradePrevention:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:90,daysBackCanceled:1,untilDays:90,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1440}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{marginMode:!0,leverage:!0,marketBuyRequiresPrice:!1,marketBuyByCost:!1},fetchOHLCV:{limit:300},fetchClosedOrders:void 0},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"System is under maintenance.":r.OnMaintenance,"System abnormality":r.ExchangeError,"You are not authorized to execute this request.":r.PermissionDenied,"API key does not exist":r.AuthenticationError,"Order would trigger immediately.":r.OrderImmediatelyFillable,"Stop price would trigger immediately.":r.OrderImmediatelyFillable,"Order would immediately match and take.":r.OrderImmediatelyFillable,"Account has insufficient balance for requested action.":r.InsufficientFunds,"Rest API trading is not enabled.":r.ExchangeNotAvailable,"You don't have permission.":r.PermissionDenied,"Market is closed.":r.ExchangeNotAvailable,"Too many requests. Please try again later.":r.DDoSProtection,"-1000":r.ExchangeNotAvailable,"-1001":r.ExchangeNotAvailable,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1013":r.InvalidOrder,"-1015":r.RateLimitExceeded,"-1016":r.ExchangeNotAvailable,"-1020":r.BadRequest,"-1021":r.InvalidNonce,"-1022":r.AuthenticationError,"-1100":r.BadRequest,"-1101":r.BadRequest,"-1102":r.BadRequest,"-1103":r.BadRequest,"-1104":r.BadRequest,"-1105":r.BadRequest,"-1106":r.BadRequest,"-1111":r.BadRequest,"-1112":r.InvalidOrder,"-1114":r.BadRequest,"-1115":r.BadRequest,"-1116":r.BadRequest,"-1117":r.BadRequest,"-1166":r.InvalidOrder,"-1118":r.BadRequest,"-1119":r.BadRequest,"-1120":r.BadRequest,"-1121":r.BadSymbol,"-1125":r.AuthenticationError,"-1127":r.BadRequest,"-1128":r.BadRequest,"-1130":r.BadRequest,"-1131":r.BadRequest,"-1160":r.InvalidOrder,"-1156":r.InvalidOrder,"-2008":r.AuthenticationError,"-2010":r.ExchangeError,"-2011":r.OrderNotFound,"-2013":r.OrderNotFound,"-2014":r.AuthenticationError,"-2015":r.AuthenticationError,"-2017":r.InsufficientFunds,"-2019":r.InsufficientFunds,"-3005":r.InsufficientFunds,"-3006":r.InsufficientFunds,"-3008":r.InsufficientFunds,"-3010":r.ExchangeError,"-3015":r.ExchangeError,"-3022":r.AccountSuspended,"-4028":r.BadRequest,"-3020":r.InsufficientFunds,"-3041":r.InsufficientFunds,"-5013":r.InsufficientFunds,"-11008":r.InsufficientFunds,"-4051":r.InsufficientFunds},broad:{"Insufficient account balance":r.InsufficientFunds,"has no operation privilege":r.PermissionDenied,MAX_POSITION:r.InvalidOrder}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchStatus(e={}){const t=await this.spotV1PublicGetPing(e);return{status:Object.keys(t).length?"maintenance":"ok",updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.spotV1PublicGetTime(e);return this.safeInteger(t,"serverTime")}async fetchCurrencies(e={}){const t=await this.spotV1PublicGetExchangeInfo(e),i={},s=this.safeList(t,"coins",[]);for(let e=0;e100&&(t=100),e.limit=t),s.linear?a=await this.fapiV1PublicGetDepth(this.extend(e,i)):s.inverse&&(a=await this.dapiV1PublicGetDepth(this.extend(e,i)))}else{if(!s.spot)throw new r.NotSupported(this.id+" fetchOrderBook only support spot & swap markets");{const e={symbol:s.id};void 0!==t&&(t>1e3&&(t=1e3),e.limit=t),a=await this.spotV1PublicGetDepth(this.extend(e,i))}}const o=this.safeInteger2(a,"time","lastUpdateId"),n=this.parseOrderBook(a,e,o);return n.nonce=this.safeInteger(a,"lastUpdateId"),n}parseTicker(e,t=void 0){const i=this.safeSymbol(void 0,t),s=this.safeString2(e,"lastPrice","last"),r=this.safeInteger(e,"time");let o;return o=t.swap?a.Y.stringMul(this.safeString(e,"rose"),"100"):this.safeString(e,"priceChangePercent"),this.safeTicker({symbol:i,timestamp:r,datetime:this.iso8601(r),high:this.safeString2(e,"highPrice","high"),low:this.safeString2(e,"lowPrice","low"),bid:this.safeString2(e,"bidPrice","buy"),bidVolume:this.safeString(e,"bidQty"),ask:this.safeString2(e,"askPrice","sell"),askVolume:this.safeString(e,"askQty"),vwap:this.safeString(e,"weightedAvgPrice"),open:this.safeString(e,"openPrice"),close:s,last:s,previousClose:void 0,change:this.safeString(e,"priceChange"),percentage:o,average:void 0,baseVolume:this.safeString2(e,"volume","vol"),quoteVolume:this.safeString(e,"quoteVolume"),info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e);let s,a;if(i.swap){const e={contractName:i.id};i.linear?s=await this.fapiV1PublicGetTicker(this.extend(e,t)):i.inverse&&(s=await this.dapiV1PublicGetTicker(this.extend(e,t))),a=s}else{if(!i.spot)throw new r.NotSupported(this.id+" fetchTicker only support spot & swap markets");{const e={symbol:i.id};s=await this.spotV1PublicGetTicker24hr(this.extend(e,t)),a=this.safeDict(s,0,{})}}return this.parseTicker(a,i)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.safeDict(this.options,"timeframes",{});let d,c;if(o.swap){const e=this.safeDict(n,"future",{}),i={contractName:o.id,interval:this.safeString(e,t,"1min")};void 0!==s&&(i.limit=s),o.linear?d=await this.fapiV1PublicGetKlines(this.extend(i,a)):o.inverse&&(d=await this.dapiV1PublicGetKlines(this.extend(i,a))),c=d}else{if(!o.spot)throw new r.NotSupported(this.id+" fetchOHLCV only support spot & swap markets");{const e=this.safeDict(n,"spot",{}),i={symbol:o.id,scale:this.safeString(e,t,"1m")};void 0!==s&&(i.limit=s);const r=this.safeInteger(a,"until");void 0!==r&&(a=this.omit(a,"until"),i.fromIdx=r),d=await this.spotV1PublicGetMarketKline(this.extend(i,a)),c=this.safeList(d,"data",[])}}return this.parseOHLCVs(c,o,t,i,s)}parseOHLCV(e,t=void 0){let i=this.safeTimestamp(e,"i");return void 0===i&&(i=this.safeInteger(e,"idx")),[i,this.safeNumber2(e,"o","open"),this.safeNumber2(e,"h","high"),this.safeNumber2(e,"l","low"),this.safeNumber2(e,"c","close"),this.safeNumber2(e,"v","vol")]}async fetchBidsAsks(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e,void 0,!1);const i=this.safeString(e,0),s=this.market(i);let a;if(s.swap){const e={contractName:s.id};s.linear?a=await this.fapiV1PublicGetTicker(this.extend(e,t)):s.inverse&&(a=await this.dapiV1PublicGetTicker(this.extend(e,t)))}else{if(!s.spot)throw new r.NotSupported(this.id+" fetchBidsAsks only support spot & swap markets");{const e={symbol:s.id};a=await this.spotV1PublicGetTickerBookTicker(this.extend(e,t))}}const o={};return o[s.id]=a,this.parseTickers(o,e)}async fetchTickers(e=void 0,t={}){let i,s;await this.loadMarkets();const a={};let o;if(void 0!==(e=this.marketSymbols(e))){const o=this.safeString(e,0),n=this.market(o);if(n.swap)throw new r.NotSupported(this.id+" fetchTickers does not support swap markets, please use fetchTicker instead");if(!n.spot)throw new r.NotSupported(this.id+" fetchTickers only support spot & swap markets");i=await this.spotV1PublicGetTicker24hr(this.extend(a,t)),s=i}else{if([o,t]=this.handleMarketTypeAndParams("fetchTickers",void 0,t),"spot"!==o)throw new r.NotSupported(this.id+" fetchTickers only support spot when symbols are not proved");i=await this.spotV1PublicGetTicker24hr(this.extend(a,t)),s=i}const n={};for(let e=0;e1e3&&(i=1e3),d.limit=i),a.swap)d.contractName=a.id,a.linear?o=await this.fapiV2PrivateGetMyTrades(this.extend(d,s)):a.inverse&&(o=await this.dapiV2PrivateGetMyTrades(this.extend(d,s))),n=this.safeList(o,"data",[]);else{if(!a.spot)throw new r.NotSupported(this.id+" fetchMyTrades only support spot & swap markets");d.symbol=a.id,o=await this.spotV2PrivateGetMyTrades(this.extend(d,s)),n=o}return this.parseTrades(n,a,t,i)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchDeposits() requires a code argument");await this.loadMarkets();const a=this.currency(e),o={coin:a.id,status:1};void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i);const n=await this.spotV1PrivateGetDepositHistory(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseTransactions(d,a,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchWithdrawals() requires a code argument");await this.loadMarkets();const a=this.currency(e),o={coin:a.id,status:5};void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i);const n=await this.spotV1PrivateGetWithdrawHistory(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseTransactions(d,a)}parseTransactionStatusByType(e,t=void 0){const i=this.safeDict({deposit:{0:"pending",1:"ok"},withdrawal:{0:"pending",5:"ok",6:"canceled"}},t,{});return this.safeString(i,e,e)}parseTransaction(e,t=void 0){const i=this.safeString2(e,"id","withdrawId"),s=this.safeString(e,"tagType");let r,a,o=this.safeString(e,"addressTo"),n=this.safeString(e,"addressFrom");if(void 0!==s){if(void 0!==o){const e=o.split("_");o=this.safeString(e,0),r=this.safeString(e,1)}if(void 0!==n){const e=n.split("_");n=this.safeString(e,0),a=this.safeString(e,1)}}const d=this.safeString(e,"txid"),c=this.safeInteger(e,"createdAt"),h=this.safeInteger(e,"updatedAt"),l="payAmount"in e||"ctime"in e?"withdrawal":"deposit",u=this.parseTransactionStatusByType(this.safeString(e,"status"),l),p=this.safeNumber(e,"amount");let f,m=this.safeString2(e,"symbol","coin");if(void 0!==m){const e=m.split("_");m=this.safeString(e,0);const t=this.safeString(e,1);void 0!==t&&(f=t.toUpperCase())}const g=this.safeCurrencyCode(m,t),v=this.safeNumber(e,"fee");let y;return void 0!==v&&(y={currency:g,cost:v}),{info:e,id:i,txid:d,timestamp:c,datetime:this.iso8601(c),network:f,address:o,addressTo:o,addressFrom:n,tag:r,tagTo:r,tagFrom:a,type:l,amount:p,currency:g,status:u,updated:h,internal:!1,comment:void 0,fee:y}}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const a=this.currency(e),o={coin:a.id,amount:t,addressTo:i};let n;[n,r]=this.handleNetworkCodeAndParams(r),void 0!==n&&(o.chainName=this.networkCodeToId(n)),void 0!==s&&(o.tag=s);const d=await this.spotV1PrivatePostWithdrawCommit(this.extend(o,r)),c=this.safeDict(d,"data",{});return this.parseTransaction(c,a)}parseDepositWithdrawFee(e,t=void 0){const i=this.safeList(e,"chainDetail",[]),s=i.length,r={info:e,withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0},networks:{}};if(0!==s)for(let e=0;e200&&(i=200),r.limit=i);const o=this.safeInteger(s,"until");void 0!==o&&(s=this.omit(s,"until"),r.endTime=o);const n=await this.fapiV2PrivateGetFuturesTransferHistory(this.extend(r,s)),d=this.safeList(n,"data",[]);return this.parseTransfers(d,a,t,i)}async transfer(e,t,i,s,r={}){await this.loadMarkets();const a=this.currency(e),o=this.safeDict(this.options,"accountsByType",{}),n=this.safeString(o,i,i),d=this.safeString(o,s,s),c={coinSymbol:a.id,amount:this.currencyToPrecision(e,t),transferType:n+"_to_"+d},h=await this.fapiV2PrivatePostFuturesTransfer(this.extend(c,r)),l=this.safeDict(h,"data",{});return this.parseTransfer(l,a)}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");if(e<1||e>125)throw new r.BadRequest(this.id+" leverage should be between 1 and 125");await this.loadMarkets();const s=this.market(t);let a;const o={contractName:s.id,leverage:e};if(!s.swap)throw new r.NotSupported(this.id+" setLeverage only support swap markets");return s.linear?a=await this.fapiV2PrivatePostLevelEdit(this.extend(o,i)):s.inverse&&(a=await this.dapiV2PrivatePostLevelEdit(this.extend(o,i))),a}parseMarginModification(e,t=void 0){return{info:e,symbol:t.symbol,type:void 0,marginMode:"isolated",amount:void 0,total:void 0,code:void 0,status:void 0,timestamp:void 0,datetime:void 0}}async setMargin(e,t,i={}){await this.loadMarkets();const s=this.market(e);if(!s.swap)throw new r.NotSupported(this.id+" setMargin only support swap markets");let a;const o={contractName:s.id,amount:this.parseToNumeric(t)};return s.linear?a=await this.fapiV2PrivatePostPositionMargin(this.extend(o,i)):s.inverse&&(a=await this.dapiV2PrivatePostPositionMargin(this.extend(o,i))),this.parseMarginModification(a,s)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.safeString(t,0),d=this.safeString(t,1),c=this.safeString(t,2);let h;if(h="api"===o&&"kline"===d||"open"===o&&e.indexOf("listenKey")>=0?this.urls.api[o]:this.urls.api[o]+"/"+d,h=h+"/"+this.implodeParams(e,s),s=this.omit(s,this.extractParams(e)),"private"===c){this.checkRequiredCredentials();const t=this.safeInteger(this.options,"recvWindow",5e3);if("spot"===o||"open"===o){let e=this.urlencode(this.extend({timestamp:this.nonce(),recvWindow:t},s));e+="&signature="+this.hmac(this.encode(e),this.encode(this.secret),n.s),r={"X-MBX-APIKEY":this.apiKey},"GET"===i||"DELETE"===i?h+="?"+e:(a=e,r["Content-Type"]="application/x-www-form-urlencoded")}else{const c=this.nonce().toString();let l;"fapi"===o?l="/fapi":"dapi"===o&&(l="/dapi"),l=l+"/"+d+"/"+e;let u=c+i+l;if("GET"===i){Object.keys(s).length>0&&(u+="?"+this.urlencode(s));const e=this.hmac(this.encode(u),this.encode(this.secret),n.s);r={"X-CH-APIKEY":this.apiKey,"X-CH-SIGN":e,"X-CH-TS":c},h+="?"+this.urlencode(s)}else{const e=this.extend({recvWindow:t},s);u+=a=this.json(e);const i=this.hmac(this.encode(u),this.encode(this.secret),n.s);r={"Content-Type":"application/json","X-CH-APIKEY":this.apiKey,"X-CH-SIGN":i,"X-CH-TS":c}}}}else Object.keys(s).length&&(h+="?"+this.urlencode(s));return{url:h,method:i,body:a,headers:r}}handleErrors(e,t,i,s,o,n,d,c,h){if(418===e||429===e)throw new r.DDoSProtection(this.id+" "+e.toString()+" "+t+" "+n);if(e>=400){if(n.indexOf("Price * QTY is zero or less")>=0)throw new r.InvalidOrder(this.id+" order cost = amount * price is zero or less "+n);if(n.indexOf("LOT_SIZE")>=0)throw new r.InvalidOrder(this.id+" order amount should be evenly divisible by lot size "+n);if(n.indexOf("PRICE_FILTER")>=0)throw new r.InvalidOrder(this.id+" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid float value in general, use this.priceToPrecision (symbol, amount) "+n)}if(void 0===d)return;const l=this.safeBool(d,"success",!0);if(!l){const e=this.safeString(d,"msg");let t;if(void 0!==e){try{t=JSON.parse(e)}catch(e){t=void 0}void 0!==t&&(d=t)}}const u=this.safeString(d,"msg");void 0!==u&&(this.throwExactlyMatchedException(this.exceptions.exact,u,this.id+" "+u),this.throwBroadlyMatchedException(this.exceptions.broad,u,this.id+" "+u));const p=this.safeString(d,"code");if(void 0!==p){if("200"===p||a.Y.stringEquals(p,"0"))return;if("-2015"===p&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new r.DDoSProtection(this.id+" temporary banned: "+n);const e=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,p,e),new r.ExchangeError(e)}if(!l)throw new r.ExchangeError(this.id+" "+n)}calculateRateLimiterCost(e,t,i,s,r={}){if("noSymbol"in r&&!("symbol"in s))return r.noSymbol;if("byLimit"in r&&"limit"in s){const e=s.limit,t=r.byLimit;for(let i=0;i{"use strict";i.d(t,{A:()=>d});var s=i(9656),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitso",name:"Bitso",countries:["MX"],rateLimit:2e3,version:"v3",has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!1,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFee:!1,fetchTransactionFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},urls:{logo:"https://github.com/user-attachments/assets/178c8e56-9054-4107-b192-5e5053d4f975",api:{rest:"https://bitso.com/api"},test:{rest:"https://stage.bitso.com/api"},www:"https://bitso.com",doc:"https://bitso.com/api_info",fees:"https://bitso.com/fees",referral:"https://bitso.com/?ref=itej"},precisionMode:o.kb,options:{precision:{XRP:1e-6,MXN:.01,TUSD:.01},defaultPrecision:1e-8,networks:{TRC20:"trx",ERC20:"erc20",BEP20:"bsc",BEP2:"bep2"}},timeframes:{"1m":"60","5m":"300","15m":"900","30m":"1800","1h":"3600","4h":"14400","12h":"43200","1d":"86400","1w":"604800"},api:{public:{get:["available_books","ticker","order_book","trades","ohlc"]},private:{get:["account_status","balance","fees","fundings","fundings/{fid}","funding_destination","kyc_documents","ledger","ledger/trades","ledger/fees","ledger/fundings","ledger/withdrawals","mx_bank_codes","open_orders","order_trades/{oid}","orders/{oid}","user_trades","user_trades/{tid}","withdrawals/","withdrawals/{wid}"],post:["bitcoin_withdrawal","debit_card_withdrawal","ether_withdrawal","orders","phone_number","phone_verification","phone_withdrawal","spei_withdrawal","ripple_withdrawal","bcash_withdrawal","litecoin_withdrawal"],delete:["orders","orders/{oid}","orders/all"]}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:300}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{"0201":r.AuthenticationError,104:r.InvalidNonce,"0304":r.BadRequest}})}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){const r={};void 0!==i&&(r.limit=i);const a=await this.privateGetLedger(this.extend(r,s)),o=this.safeValue(a,"payload",[]),n=this.safeCurrency(e);return this.parseLedger(o,n,t,i)}parseLedgerEntryType(e){return this.safeString({funding:"transaction",withdrawal:"transaction",trade:"trade",fee:"fee"},e,e)}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"operation"),s=this.parseLedgerEntryType(i),r=this.safeValue(e,"balance_updates",[]),o=this.safeValue(r,0,{});let n,d;const c=this.safeString(o,"amount"),h=this.safeString(o,"currency"),l=this.safeCurrencyCode(h,t);t=this.safeCurrency(h,t);const u=this.safeValue(e,"details",{});let p=this.safeString2(u,"fid","wid");if(void 0===p&&(p=this.safeString(u,"tid")),"funding"===i)n="in";else if("withdrawal"===i)n="out";else if("trade"===i)n=void 0;else if("fee"===i){n="out";d={cost:a.Y.stringAbs(c),currency:t}}const f=this.parse8601(this.safeString(e,"created_at"));return this.safeLedgerEntry({info:e,id:this.safeString(e,"eid"),direction:n,account:void 0,referenceId:p,referenceAccount:void 0,type:s,currency:l,amount:c,timestamp:f,datetime:this.iso8601(f),before:void 0,after:void 0,status:"ok",fee:d},t)}async fetchMarkets(e={}){const t=await this.publicGetAvailableBooks(e),i=this.safeValue(t,"payload",[]),s=[];for(let e=0;e=0){const e=a.split("?dt=");a=this.safeString(e,0),r=this.safeString(e,1)}return this.checkAddress(a),{info:s,currency:e,network:void 0,address:a,tag:r}}async fetchTransactionFees(e=void 0,t={}){await this.loadMarkets();const i=await this.privateGetFees(t),s={},r=this.safeValue(i,"payload",{}),a=this.safeValue(r,"deposit_fees",[]);for(let t=0;t{"use strict";i.d(t,{A:()=>d});var s=i(5223),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitstamp",name:"Bitstamp",countries:["GB"],rateLimit:75,version:"v2",userAgent:this.userAgents.chrome,pro:!0,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactionFees:!0,fetchTransactions:"emulated",fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},urls:{logo:"https://github.com/user-attachments/assets/d5480572-1fee-43cb-b900-d38c522d0024",api:{public:"https://www.bitstamp.net/api",private:"https://www.bitstamp.net/api"},www:"https://www.bitstamp.net",doc:"https://www.bitstamp.net/api"},timeframes:{"1m":"60","3m":"180","5m":"300","15m":"900","30m":"1800","1h":"3600","2h":"7200","4h":"14400","6h":"21600","12h":"43200","1d":"86400","1w":"259200"},requiredCredentials:{apiKey:!0,secret:!0},api:{public:{get:{"ohlc/{pair}/":1,"order_book/{pair}/":1,"ticker/":1,"ticker_hour/{pair}/":1,"ticker/{pair}/":1,"transactions/{pair}/":1,"trading-pairs-info/":1,"currencies/":1,"eur_usd/":1,"travel_rule/vasps/":1}},private:{get:{"travel_rule/contacts/":1,"contacts/{contact_uuid}/":1,"earn/subscriptions/":1,"earn/transactions/":1},post:{"account_balances/":1,"account_balances/{currency}/":1,"balance/":1,"balance/{pair}/":1,"bch_withdrawal/":1,"bch_address/":1,"user_transactions/":1,"user_transactions/{pair}/":1,"crypto-transactions/":1,open_order:1,"open_orders/all/":1,"open_orders/{pair}/":1,"order_status/":1,"cancel_order/":1,"cancel_all_orders/":1,"cancel_all_orders/{pair}/":1,"buy/{pair}/":1,"buy/market/{pair}/":1,"buy/instant/{pair}/":1,"sell/{pair}/":1,"sell/market/{pair}/":1,"sell/instant/{pair}/":1,"transfer-to-main/":1,"transfer-from-main/":1,"my_trading_pairs/":1,"fees/trading/":1,"fees/trading/{market_symbol}":1,"fees/withdrawal/":1,"fees/withdrawal/{currency}/":1,"withdrawal-requests/":1,"withdrawal/open/":1,"withdrawal/status/":1,"withdrawal/cancel/":1,"liquidation_address/new/":1,"liquidation_address/info/":1,"btc_unconfirmed/":1,"websockets_token/":1,"btc_withdrawal/":1,"btc_address/":1,"ripple_withdrawal/":1,"ripple_address/":1,"ltc_withdrawal/":1,"ltc_address/":1,"eth_withdrawal/":1,"eth_address/":1,"xrp_withdrawal/":1,"xrp_address/":1,"xlm_withdrawal/":1,"xlm_address/":1,"pax_withdrawal/":1,"pax_address/":1,"link_withdrawal/":1,"link_address/":1,"usdc_withdrawal/":1,"usdc_address/":1,"omg_withdrawal/":1,"omg_address/":1,"dai_withdrawal/":1,"dai_address/":1,"knc_withdrawal/":1,"knc_address/":1,"mkr_withdrawal/":1,"mkr_address/":1,"zrx_withdrawal/":1,"zrx_address/":1,"gusd_withdrawal/":1,"gusd_address/":1,"aave_withdrawal/":1,"aave_address/":1,"bat_withdrawal/":1,"bat_address/":1,"uma_withdrawal/":1,"uma_address/":1,"snx_withdrawal/":1,"snx_address/":1,"uni_withdrawal/":1,"uni_address/":1,"yfi_withdrawal/":1,"yfi_address/":1,"audio_withdrawal/":1,"audio_address/":1,"crv_withdrawal/":1,"crv_address/":1,"algo_withdrawal/":1,"algo_address/":1,"comp_withdrawal/":1,"comp_address/":1,"grt_withdrawal/":1,"grt_address/":1,"usdt_withdrawal/":1,"usdt_address/":1,"eurt_withdrawal/":1,"eurt_address/":1,"matic_withdrawal/":1,"matic_address/":1,"sushi_withdrawal/":1,"sushi_address/":1,"chz_withdrawal/":1,"chz_address/":1,"enj_withdrawal/":1,"enj_address/":1,"alpha_withdrawal/":1,"alpha_address/":1,"ftt_withdrawal/":1,"ftt_address/":1,"storj_withdrawal/":1,"storj_address/":1,"axs_withdrawal/":1,"axs_address/":1,"sand_withdrawal/":1,"sand_address/":1,"hbar_withdrawal/":1,"hbar_address/":1,"rgt_withdrawal/":1,"rgt_address/":1,"fet_withdrawal/":1,"fet_address/":1,"skl_withdrawal/":1,"skl_address/":1,"cel_withdrawal/":1,"cel_address/":1,"sxp_withdrawal/":1,"sxp_address/":1,"ada_withdrawal/":1,"ada_address/":1,"slp_withdrawal/":1,"slp_address/":1,"ftm_withdrawal/":1,"ftm_address/":1,"perp_withdrawal/":1,"perp_address/":1,"dydx_withdrawal/":1,"dydx_address/":1,"gala_withdrawal/":1,"gala_address/":1,"shib_withdrawal/":1,"shib_address/":1,"amp_withdrawal/":1,"amp_address/":1,"sgb_withdrawal/":1,"sgb_address/":1,"avax_withdrawal/":1,"avax_address/":1,"wbtc_withdrawal/":1,"wbtc_address/":1,"ctsi_withdrawal/":1,"ctsi_address/":1,"cvx_withdrawal/":1,"cvx_address/":1,"imx_withdrawal/":1,"imx_address/":1,"nexo_withdrawal/":1,"nexo_address/":1,"ust_withdrawal/":1,"ust_address/":1,"ant_withdrawal/":1,"ant_address/":1,"gods_withdrawal/":1,"gods_address/":1,"rad_withdrawal/":1,"rad_address/":1,"band_withdrawal/":1,"band_address/":1,"inj_withdrawal/":1,"inj_address/":1,"rly_withdrawal/":1,"rly_address/":1,"rndr_withdrawal/":1,"rndr_address/":1,"vega_withdrawal/":1,"vega_address/":1,"1inch_withdrawal/":1,"1inch_address/":1,"ens_withdrawal/":1,"ens_address/":1,"mana_withdrawal/":1,"mana_address/":1,"lrc_withdrawal/":1,"lrc_address/":1,"ape_withdrawal/":1,"ape_address/":1,"mpl_withdrawal/":1,"mpl_address/":1,"euroc_withdrawal/":1,"euroc_address/":1,"sol_withdrawal/":1,"sol_address/":1,"dot_withdrawal/":1,"dot_address/":1,"near_withdrawal/":1,"near_address/":1,"doge_withdrawal/":1,"doge_address/":1,"flr_withdrawal/":1,"flr_address/":1,"dgld_withdrawal/":1,"dgld_address/":1,"ldo_withdrawal/":1,"ldo_address/":1,"travel_rule/contacts/":1,"earn/subscribe/":1,"earn/subscriptions/setting/":1,"earn/unsubscribe":1,"wecan_withdrawal/":1,"wecan_address/":1,"trac_withdrawal/":1,"trac_address/":1,"eurcv_withdrawal/":1,"eurcv_address/":1,"pyusd_withdrawal/":1,"pyusd_address/":1,"lmwr_withdrawal/":1,"lmwr_address/":1,"pepe_withdrawal/":1,"pepe_address/":1,"blur_withdrawal/":1,"blur_address/":1,"vext_withdrawal/":1,"vext_address/":1,"cspr_withdrawal/":1,"cspr_address/":1,"vchf_withdrawal/":1,"vchf_address/":1,"veur_withdrawal/":1,"veur_address/":1,"truf_withdrawal/":1,"truf_address/":1,"wif_withdrawal/":1,"wif_address/":1,"smt_withdrawal/":1,"smt_address/":1,"sui_withdrawal/":1,"sui_address/":1,"jup_withdrawal/":1,"jup_address/":1,"ondo_withdrawal/":1,"ondo_address/":1,"boba_withdrawal/":1,"boba_address/":1,"pyth_withdrawal/":1,"pyth_address/":1}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.004"),maker:this.parseNumber("0.004"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("10000"),this.parseNumber("0.003")],[this.parseNumber("100000"),this.parseNumber("0.002")],[this.parseNumber("500000"),this.parseNumber("0.0018")],[this.parseNumber("1500000"),this.parseNumber("0.0016")],[this.parseNumber("5000000"),this.parseNumber("0.0012")],[this.parseNumber("20000000"),this.parseNumber("0.001")],[this.parseNumber("50000000"),this.parseNumber("0.0008")],[this.parseNumber("100000000"),this.parseNumber("0.0006")],[this.parseNumber("250000000"),this.parseNumber("0.0005")],[this.parseNumber("1000000000"),this.parseNumber("0.0003")]],maker:[[this.parseNumber("0"),this.parseNumber("0.003")],[this.parseNumber("10000"),this.parseNumber("0.002")],[this.parseNumber("100000"),this.parseNumber("0.001")],[this.parseNumber("500000"),this.parseNumber("0.0008")],[this.parseNumber("1500000"),this.parseNumber("0.0006")],[this.parseNumber("5000000"),this.parseNumber("0.0003")],[this.parseNumber("20000000"),this.parseNumber("0.002")],[this.parseNumber("50000000"),this.parseNumber("0.0001")],[this.parseNumber("100000000"),this.parseNumber("0")],[this.parseNumber("250000000"),this.parseNumber("0")],[this.parseNumber("1000000000"),this.parseNumber("0")]]}},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{BTC:0,BCH:0,LTC:0,ETH:0,XRP:0,XLM:0,PAX:0,USD:7.5,EUR:0}}},precisionMode:o.kb,commonCurrencies:{UST:"USTC"},options:{networksById:{"bitcoin-cash":"BCH",bitcoin:"BTC",ethereum:"ERC20",litecoin:"LTC",stellar:"XLM",xrpl:"XRP",tron:"TRC20",algorand:"ALGO",flare:"FLR",hedera:"HBAR",cardana:"ADA",songbird:"FLR","avalanche-c-chain":"AVAX",solana:"SOL",polkadot:"DOT",near:"NEAR",doge:"DOGE",sui:"SUI",casper:"CSRP"}},exceptions:{exact:{"No permission found":r.PermissionDenied,"API key not found":r.AuthenticationError,"IP address not allowed":r.PermissionDenied,"Invalid nonce":r.InvalidNonce,"Invalid signature":r.AuthenticationError,"Authentication failed":r.AuthenticationError,"Missing key, signature and nonce parameters":r.AuthenticationError,"Wrong API key format":r.AuthenticationError,"Your account is frozen":r.PermissionDenied,"Please update your profile with your FATCA information, before using API.":r.PermissionDenied,"Order not found.":r.OrderNotFound,"Price is more than 20% below market price.":r.InvalidOrder,"Bitstamp.net is under scheduled maintenance. We'll be back soon.":r.OnMaintenance,"Order could not be placed.":r.ExchangeNotAvailable,"Invalid offset.":r.BadRequest,"Trading is currently unavailable for your account.":r.AccountSuspended},broad:{"Minimum order size is":r.InvalidOrder,"Check your account balance for details.":r.InsufficientFunds,"Ensure this value has at least":r.InvalidAddress,"Ensure that there are no more than":r.InvalidOrder}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:void 0,untilDays:30,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}async fetchMarkets(e={}){const t=await this.fetchMarketsFromCache(e),i=[];for(let e=0;es){const i=await this.publicGetTradingPairsInfo(e);this.options.fetchMarkets=this.extend(t,{response:i,timestamp:r})}return this.safeValue(this.options.fetchMarkets,"response")}async fetchCurrencies(e={}){const t=await this.fetchMarketsFromCache(e),i={};for(let e=0;e2)throw new r.ExchangeError(this.id+" getMarketFromTrade() too many keys: "+this.json(t)+" in the trade: "+this.json(e));if(2===i){let e=t[0]+t[1];if(e in this.markets_by_id)return this.safeMarket(e);if(e=t[1]+t[0],e in this.markets_by_id)return this.safeMarket(e)}}parseTrade(e,t=void 0){const i=this.safeString2(e,"id","tid");let s,r,o=this.safeString(e,"price"),n=this.safeString(e,"amount");const d=this.safeString(e,"order_id");let c,h=this.safeString(e,"cost");if(void 0===t){const i=Object.keys(e);for(let e=0;e=0&&(c=s,t=this.safeMarket(c,t,"_"))}}void 0===t&&(t=this.getMarketFromTrade(e));const l=this.safeString(e,"fee"),u=t.quote,p=void 0!==c?c:t.marketId;o=this.safeString(e,p,o),n=this.safeString(e,t.baseId,n),h=this.safeString(e,t.quoteId,h),s=t.symbol;const f=this.safeString2(e,"date","datetime");let m,g;if(void 0!==f&&(f.indexOf(" ")>=0?m=this.parse8601(f):(m=parseInt(f),m*=1e3)),"id"in e){if(void 0!==n){a.Y.stringLt(n,"0")?(r="sell",n=a.Y.stringNeg(n)):r="buy"}}else r=this.safeString(e,"type"),r="1"===r?"sell":"0"===r?"buy":void 0;return void 0!==h&&(h=a.Y.stringAbs(h)),void 0!==l&&(g={cost:l,currency:u}),this.safeTrade({id:i,info:e,timestamp:m,datetime:this.iso8601(m),symbol:s,order:d,type:undefined,side:r,takerOrMaker:void 0,price:o,amount:n,cost:h,fee:g},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={pair:r.id,time:"hour"},o=await this.publicGetTransactionsPair(this.extend(a,s));return this.parseTrades(o,r,t,i)}parseOHLCV(e,t=void 0){return[this.safeTimestamp(e,"timestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={pair:a.id,step:this.safeString(this.timeframes,t,t)},n=this.parseTimeframe(t);if(void 0===s)if(void 0===i)o.limit=1e3;else{s=1e3;const e=this.parseToInt(i/1e3);o.start=e,o.end=this.sum(e,n*(s-1)),o.limit=s}else{if(void 0!==i){const e=this.parseToInt(i/1e3);o.start=e,o.end=this.sum(e,n*(s-1))}o.limit=Math.min(s,1e3)}const d=await this.publicGetOhlcPair(this.extend(o,r)),c=this.safeValue(d,"data",{}),h=this.safeList(c,"ohlc",[]);return this.parseOHLCVs(h,a,t,i,s)}parseBalance(e){const t={info:e,timestamp:void 0,datetime:void 0};void 0===e&&(e=[]);for(let i=0;i1&&(u=e[0],h=e[1])}let p={currency:void 0,cost:void 0,rate:void 0};return void 0!==o&&(p={currency:n,cost:o,rate:void 0}),{info:e,id:this.safeString(e,"id"),txid:this.safeString(e,"transaction_id"),type:c,currency:r,network:void 0,amount:this.parseNumber(d),status:l,timestamp:i,datetime:this.iso8601(i),address:u,addressFrom:void 0,addressTo:u,tag:h,tagFrom:void 0,tagTo:h,updated:void 0,comment:void 0,internal:void 0,fee:p}}parseTransactionStatus(e){return this.safeString({0:"pending",1:"pending",2:"ok",3:"canceled",4:"failed"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeString(e,"client_order_id");let r=this.safeString(e,"type");void 0!==r&&(r="1"===r?"sell":"buy");const a=this.parse8601(this.safeString(e,"datetime")),o=this.safeStringLower(e,"currency_pair"),n=this.safeSymbol(o,t,"/"),d=this.parseOrderStatus(this.safeString(e,"status")),c=this.safeString(e,"amount"),h=this.safeValue(e,"transactions",[]),l=this.safeString(e,"price");return this.safeOrder({id:i,clientOrderId:s,datetime:this.iso8601(a),timestamp:a,lastTradeTimestamp:void 0,status:d,symbol:n,type:void 0,timeInForce:void 0,postOnly:void 0,side:r,price:l,triggerPrice:void 0,cost:void 0,amount:c,filled:void 0,remaining:void 0,trades:h,fee:void 0,info:e,average:void 0},t)}parseLedgerEntryType(e){return this.safeString({0:"transaction",1:"transaction",2:"trade",14:"transfer"},e,e)}parseLedgerEntry(e,t=void 0){const i=this.parseLedgerEntryType(this.safeString(e,"type"));if("trade"===i){const s=this.parseTrade(e);let r;const a=Object.keys(e);for(let e=0;e=0){const t=a[e].replace("_","");r=this.safeMarket(t,r)}void 0===r&&(r=this.getMarketFromTrade(e));const o="buy"===s.side?"in":"out";return this.safeLedgerEntry({info:e,id:s.id,timestamp:s.timestamp,datetime:s.datetime,direction:o,account:void 0,referenceId:s.order,referenceAccount:void 0,type:i,currency:r.base,amount:s.amount,before:void 0,after:void 0,status:"ok",fee:s.fee},t)}{const s=this.parseTransaction(e,t);let r;if("amount"in e){const t=this.safeString(e,"amount");r=a.Y.stringGt(t,"0")?"in":"out"}else if("currency"in s&&void 0!==s.currency){const i=this.safeString(s,"currency");t=this.currency(i);const o=this.safeString(e,t.id);r=a.Y.stringGt(o,"0")?"in":"out"}return this.safeLedgerEntry({info:e,id:s.id,timestamp:s.timestamp,datetime:s.datetime,direction:r,account:void 0,referenceId:s.txid,referenceAccount:void 0,type:i,currency:s.currency,amount:s.amount,before:void 0,after:void 0,status:s.status,fee:s.fee},t)}}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};void 0!==i&&(r.limit=i);const a=await this.privatePostUserTransactions(this.extend(r,s));let o;return void 0!==e&&(o=this.currency(e)),this.parseLedger(a,o,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a=await this.privatePostOpenOrdersAll(s);return this.parseOrders(a,r,t,i,{status:"open",type:"limit"})}getCurrencyName(e){return e.toLowerCase()}isFiat(e){return"USD"===e||"EUR"===e||"GBP"===e}async fetchDepositAddress(e,t={}){if(this.isFiat(e))throw new r.NotSupported(this.id+" fiat fetchDepositAddress() for "+e+" is not supported!");const i=this.getCurrencyName(e),s="privatePost"+this.capitalize(i)+"Address",a=await this[s](t),o=this.safeString(a,"address"),n=this.safeString2(a,"memo_id","destination_tag");return this.checkAddress(o),{info:a,currency:e,network:void 0,address:o,tag:n}}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets(),this.checkAddress(i);const a={amount:t};let o,n;if(this.isFiat(e))n="privatePostWithdrawalOpen",o=this.currency(e),a.iban=i,a.account_currency=o.id;else{const t=this.getCurrencyName(e);n="privatePost"+this.capitalize(t)+"Withdrawal","XRP"===e?void 0!==s&&(a.destination_tag=s):"XLM"!==e&&"HBAR"!==e||void 0!==s&&(a.memo_id=s),a.address=i}const d=await this[n](this.extend(a,r));return this.parseTransaction(d,o)}async transfer(e,t,i,s,a={}){await this.loadMarkets();const o=this.currency(e),n={amount:this.parseToNumeric(this.currencyToPrecision(e,t)),currency:o.id.toUpperCase()};let d;if("main"===i)n.subAccount=s,d=await this.privatePostTransferFromMain(this.extend(n,a));else{if("main"!==s)throw new r.BadRequest(this.id+" transfer() only supports from or to main");n.subAccount=i,d=await this.privatePostTransferToMain(this.extend(n,a))}const c=this.parseTransfer(d,o);return c.amount=t,c.fromAccount=i,c.toAccount=s,c}parseTransfer(e,t=void 0){const i=this.safeString(e,"status");return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:t.code,amount:void 0,fromAccount:void 0,toAccount:void 0,status:this.parseTransferStatus(i)}}parseTransferStatus(e){return this.safeString({ok:"ok",error:"failed"},e,e)}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/";o+=this.version+"/",o+=this.implodeParams(e,s);const d=this.omit(s,this.extractParams(e));if("public"===t)Object.keys(d).length&&(o+="?"+this.urlencode(d));else{this.checkRequiredCredentials();const e="BITSTAMP "+this.apiKey,t=this.uuid(),s=this.milliseconds().toString(),c="v2";let h="";r={"X-Auth":e,"X-Auth-Nonce":t,"X-Auth-Timestamp":s,"X-Auth-Version":c},"POST"===i&&(Object.keys(d).length?(a=this.urlencode(d),h="application/x-www-form-urlencoded",r["Content-Type"]=h):(a=this.urlencode({foo:"bar"}),h="application/x-www-form-urlencoded",r["Content-Type"]=h));const l=a||"",u=e+i+o.replace("https://","")+h+t+s+c+l,p=this.hmac(this.encode(u),this.encode(this.secret),n.s);r["X-Auth-Signature"]=p}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.safeString(n,"status"),l=this.safeValue(n,"error");if("error"===h||void 0!==l){let e=[];if("string"==typeof l)e.push(l);else if(void 0!==l){const t=Object.keys(l);for(let i=0;i{"use strict";i.d(t,{A:()=>n});var s=i(8535),r=i(2079),a=i(1579),o=i(5147);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitteam",name:"BIT.TEAM",countries:["UK"],version:"v2.0.6",rateLimit:1,certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,deposit:!1,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledOrders:!0,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!0,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!1,ws:!1},timeframes:{"1m":"1","5m":"5","15m":"15","1h":"60","1d":"1D"},urls:{logo:"https://github.com/user-attachments/assets/b41b5e0d-98e5-4bd3-8a6e-aeb230a4a135",api:{history:"https://history.bit.team",public:"https://bit.team",private:"https://bit.team"},www:"https://bit.team/",referral:"https://bit.team/auth/sign-up?ref=bitboy2023",doc:["https://bit.team/trade/api/documentation"]},api:{history:{get:{"api/tw/history/{pairName}/{resolution}":1}},public:{get:{"trade/api/asset":1,"trade/api/currencies":1,"trade/api/orderbooks/{symbol}":1,"trade/api/orders":1,"trade/api/pair/{name}":1,"trade/api/pairs":1,"trade/api/pairs/precisions":1,"trade/api/rates":1,"trade/api/trade/{id}":1,"trade/api/trades":1,"trade/api/ccxt/pairs":1,"trade/api/cmc/assets":1,"trade/api/cmc/orderbook/{pair}":1,"trade/api/cmc/summary":1,"trade/api/cmc/ticker":1,"trade/api/cmc/trades/{pair}":1}},private:{get:{"trade/api/ccxt/balance":1,"trade/api/ccxt/order/{id}":1,"trade/api/ccxt/ordersOfUser":1,"trade/api/ccxt/tradesOfUser":1,"trade/api/transactionsOfUser":1},post:{"trade/api/ccxt/cancel-all-order":1,"trade/api/ccxt/cancelorder":1,"trade/api/ccxt/ordercreate":1}}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.002"),maker:this.parseNumber("0.002")}},precisionMode:a.kb,options:{networksById:{Ethereum:"ERC20",ethereum:"ERC20",Tron:"TRC20",tron:"TRC20",Binance:"BSC",binance:"BSC","Binance Smart Chain":"BSC",bscscan:"BSC",Bitcoin:"BTC",bitcoin:"BTC",Litecoin:"LTC",litecoin:"LTC",Polygon:"POLYGON",polygon:"POLYGON",PRIZM:"PRIZM",Decimal:"Decimal",ufobject:"ufobject",tonchain:"tonchain"},currenciesValuedInUsd:{USDT:!0,BUSD:!0}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:100,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{400002:r.BadSymbol,401e3:r.AuthenticationError,403002:r.BadRequest,404200:r.BadSymbol},broad:{"is not allowed":r.BadRequest,"Insufficient funds":r.InsufficientFunds,"Invalid request params input":r.BadRequest,"must be a number":r.BadRequest,"must be a string":r.BadRequest,"must be of type":r.BadRequest,"must be one of":r.BadRequest,"Order not found":r.OrderNotFound,"Pair with pair name":r.BadSymbol,pairName:r.BadSymbol,"Service Unavailable":r.ExchangeNotAvailable,"Symbol ":r.BadSymbol}}})}async fetchMarkets(e={}){const t=await this.publicGetTradeApiCcxtPairs(e),i=this.safeValue(t,"result",{}),s=this.safeValue(i,"pairs",[]);return this.parseMarkets(s)}parseMarket(e){const t=this.safeString(e,"name"),i=this.safeInteger(e,"id"),s=t.split("_"),r=this.safeString(s,0),a=this.safeString(s,1),o=this.safeCurrencyCode(r),n=this.safeCurrencyCode(a),d=this.safeValue(e,"active"),c=this.safeString(e,"timeStart"),h=this.parse8601(c);let l;const u=this.safeValue(this.options,"currenciesValuedInUsd",{});if(this.safeBool(u,n,!1)){const t=this.safeValue(e,"settings",{});l=this.safeNumber(t,"limit_usd")}return this.safeMarketStructure({id:t,numericId:i,symbol:o+"/"+n,base:o,quote:n,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:d,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(e,"baseStep"))),price:this.parseNumber(this.parsePrecision(this.safeString(e,"quoteStep")))},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:l,max:void 0}},created:h,info:e})}async fetchCurrencies(e={}){const t=await this.publicGetTradeApiCurrencies(e),i=this.safeValue(t,"result",{}),s=this.safeValue(i,"currencies",[]);let r=await this.publicGetTradeApiCmcAssets();r=this.indexBy(r,"unified_cryptoasset_id");const a={};for(let e=0;e=0&&"GET"===s){const e=i.split("/order/"),t=this.safeString(e,1);throw new r.OrderNotFound(this.id+" order "+t+" not found")}if(i.indexOf("/cmc/orderbook/")>=0){const e=i.split("/cmc/orderbook/"),t=this.safeString(e,1);throw new r.BadSymbol(this.id+" symbolId "+t+" not found")}}const t=this.id+" "+o,a=this.safeString(n,"message"),d=this.safeString(n,"code");throw this.throwBroadlyMatchedException(this.exceptions.broad,a,t),this.throwExactlyMatchedException(this.exceptions.exact,d,t),new r.ExchangeError(t)}}}},2263:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(7754),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bittrade",name:"BitTrade",countries:["JP"],rateLimit:100,userAgent:this.userAgents.chrome39,certified:!1,version:"v1",hostname:"api-cloud.bittrade.co.jp",pro:!0,has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAccounts:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingLimits:!0,fetchWithdrawals:!0,withdraw:!0},timeframes:{"1m":"1min","5m":"5min","15m":"15min","30m":"30min","1h":"60min","4h":"4hour","1d":"1day","1w":"1week","1M":"1mon","1y":"1year"},urls:{logo:"https://user-images.githubusercontent.com/1294454/85734211-85755480-b705-11ea-8b35-0b7f1db33a2f.jpg",api:{market:"https://{hostname}",public:"https://{hostname}",private:"https://{hostname}",v2Public:"https://{hostname}",v2Private:"https://{hostname}"},www:"https://www.bittrade.co.jp",referral:"https://www.bittrade.co.jp/register/?invite_code=znnq3",doc:"https://api-doc.bittrade.co.jp",fees:"https://www.bittrade.co.jp/ja-jp/support/fee"},api:{v2Public:{get:{"reference/currencies":1,"market-status":1}},v2Private:{get:{"account/ledger":1,"account/withdraw/quota":1,"account/withdraw/address":1,"account/deposit/address":1,"account/repayment":5,"reference/transact-fee-rate":1,"account/asset-valuation":.2,"point/account":5,"sub-user/user-list":1,"sub-user/user-state":1,"sub-user/account-list":1,"sub-user/deposit-address":1,"sub-user/query-deposit":1,"user/api-key":1,"user/uid":1,"algo-orders/opening":1,"algo-orders/history":1,"algo-orders/specific":1,"c2c/offers":1,"c2c/offer":1,"c2c/transactions":1,"c2c/repayment":1,"c2c/account":1,"etp/reference":1,"etp/transactions":5,"etp/transaction":5,"etp/rebalance":1,"etp/limit":1},post:{"account/transfer":1,"account/repayment":5,"point/transfer":5,"sub-user/management":1,"sub-user/creation":1,"sub-user/tradable-market":1,"sub-user/transferability":1,"sub-user/api-key-generation":1,"sub-user/api-key-modification":1,"sub-user/api-key-deletion":1,"sub-user/deduct-mode":1,"algo-orders":1,"algo-orders/cancel-all-after":1,"algo-orders/cancellation":1,"c2c/offer":1,"c2c/cancellation":1,"c2c/cancel-all":1,"c2c/repayment":1,"c2c/transfer":1,"etp/creation":5,"etp/redemption":5,"etp/{transactId}/cancel":10,"etp/batch-cancel":50}},market:{get:{"history/kline":1,"detail/merged":1,depth:1,trade:1,"history/trade":1,detail:1,tickers:1,etp:1}},public:{get:{"common/symbols":1,"common/currencys":1,"common/timestamp":1,"common/exchange":1,"settings/currencys":1}},private:{get:{"account/accounts":.2,"account/accounts/{id}/balance":.2,"account/accounts/{sub-uid}":1,"account/history":4,"cross-margin/loan-info":1,"margin/loan-info":1,"fee/fee-rate/get":1,"order/openOrders":.4,"order/orders":.4,"order/orders/{id}":.4,"order/orders/{id}/matchresults":.4,"order/orders/getClientOrder":.4,"order/history":1,"order/matchresults":1,"query/deposit-withdraw":1,"margin/loan-orders":.2,"margin/accounts/balance":.2,"cross-margin/loan-orders":1,"cross-margin/accounts/balance":1,"points/actions":1,"points/orders":1,"subuser/aggregate-balance":10,"stable-coin/exchange_rate":1,"stable-coin/quote":1},post:{"account/transfer":1,"futures/transfer":1,"order/batch-orders":.4,"order/orders/place":.2,"order/orders/submitCancelClientOrder":.2,"order/orders/batchCancelOpenOrders":.4,"order/orders/{id}/submitcancel":.2,"order/orders/batchcancel":.4,"dw/withdraw/api/create":1,"dw/withdraw-virtual/{id}/cancel":1,"dw/transfer-in/margin":10,"dw/transfer-out/margin":10,"margin/orders":10,"margin/orders/{id}/repay":10,"cross-margin/transfer-in":1,"cross-margin/transfer-out":1,"cross-margin/orders":1,"cross-margin/orders/{id}/repay":1,"stable-coin/exchange":1,"subuser/transfer":10}}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:120,untilDays:2,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:void 0,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:2e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{broad:{"contract is restricted of closing positions on API. Please contact customer service":r.OnMaintenance,maintain:r.OnMaintenance},exact:{"bad-request":r.BadRequest,"base-date-limit-error":r.BadRequest,"api-not-support-temp-addr":r.PermissionDenied,timeout:r.RequestTimeout,"gateway-internal-error":r.ExchangeNotAvailable,"account-frozen-balance-insufficient-error":r.InsufficientFunds,"invalid-amount":r.InvalidOrder,"order-limitorder-amount-min-error":r.InvalidOrder,"order-limitorder-amount-max-error":r.InvalidOrder,"order-marketorder-amount-min-error":r.InvalidOrder,"order-limitorder-price-min-error":r.InvalidOrder,"order-limitorder-price-max-error":r.InvalidOrder,"order-holding-limit-failed":r.InvalidOrder,"order-orderprice-precision-error":r.InvalidOrder,"order-etp-nav-price-max-error":r.InvalidOrder,"order-orderstate-error":r.OrderNotFound,"order-queryorder-invalid":r.OrderNotFound,"order-update-error":r.ExchangeNotAvailable,"api-signature-check-failed":r.AuthenticationError,"api-signature-not-valid":r.AuthenticationError,"base-record-invalid":r.OrderNotFound,"base-symbol-trade-disabled":r.BadSymbol,"base-symbol-error":r.BadSymbol,"system-maintenance":r.OnMaintenance,"invalid symbol":r.BadSymbol,"symbol trade not open now":r.BadSymbol,"invalid-address":r.BadRequest,"base-currency-chain-error":r.BadRequest,"dw-insufficient-balance":r.InsufficientFunds}},options:{defaultNetwork:"ERC20",networks:{ETH:"erc20",TRX:"trc20",HRC20:"hrc20",HECO:"hrc20",HT:"hrc20",ALGO:"algo",OMNI:""},fetchOrdersByStatesMethod:"private_get_order_orders",fetchOpenOrdersMethod:"fetch_open_orders_v1",createMarketBuyOrderRequiresPrice:!0,fetchMarketsMethod:"publicGetCommonSymbols",fetchBalanceMethod:"privateGetAccountAccountsIdBalance",createOrderMethod:"privatePostOrderOrdersPlace",currencyToPrecisionRoundingMode:o.R3,language:"en-US",broker:{id:"AA03022abc"}},commonCurrencies:{GET:"Themis",GTC:"Game.com",HIT:"HitChain",PNT:"Penta",SBTC:"Super Bitcoin",BIFI:"Bitcoin File"}})}async fetchTime(e={}){const t=await this.publicGetCommonTimestamp(e);return this.safeInteger(t,"data")}async fetchTradingLimits(e=void 0,t={}){await this.loadMarkets(),void 0===e&&(e=this.symbols);const i={};for(let s=0;s100)&&(i=100),await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a={type:"deposit",from:0};void 0!==r&&(a.currency=r.id),void 0!==i&&(a.size=i);const o=await this.privateGetQueryDepositWithdraw(this.extend(a,s));return this.parseTransactions(o.data,r,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){let r;(void 0===i||i>100)&&(i=100),await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a={type:"withdraw",from:0};void 0!==r&&(a.currency=r.id),void 0!==i&&(a.size=i);const o=await this.privateGetQueryDepositWithdraw(this.extend(a,s));return this.parseTransactions(o.data,r,t,i)}parseTransaction(e,t=void 0){const i=this.safeInteger(e,"created-at"),s=this.safeCurrencyCode(this.safeString(e,"currency"));let r=this.safeString(e,"type");"withdraw"===r&&(r="withdrawal");let o=this.safeString(e,"fee");return void 0!==o&&(o=a.Y.stringAbs(o)),{info:e,id:this.safeString2(e,"id","data"),txid:this.safeString(e,"tx-hash"),timestamp:i,datetime:this.iso8601(i),network:this.safeStringUpper(e,"chain"),address:this.safeString(e,"address"),addressTo:void 0,addressFrom:void 0,tag:this.safeString(e,"address-tag"),tagTo:void 0,tagFrom:void 0,type:r,amount:this.safeNumber(e,"amount"),currency:s,status:this.parseTransactionStatus(this.safeString(e,"state")),updated:this.safeInteger(e,"updated-at"),comment:void 0,internal:void 0,fee:{currency:s,cost:this.parseNumber(o),rate:void 0}}}parseTransactionStatus(e){return this.safeString({unknown:"failed",confirming:"pending",confirmed:"ok",safe:"ok",orphan:"failed",submitted:"pending",canceled:"canceled",reexamine:"pending",reject:"failed",pass:"pending","wallet-reject":"failed","confirm-error":"failed",repealed:"failed","wallet-transfer":"pending","pre-transfer":"pending"},e,e)}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets(),this.checkAddress(i);const a=this.currency(e),o={address:i,amount:t,currency:a.id.toLowerCase()};void 0!==s&&(o["addr-tag"]=s);const n=this.safeValue(this.options,"networks",{});let d=this.safeStringUpper(r,"network");d=this.safeStringLower(n,d,d),void 0!==d&&(o.chain="erc20"===d?a.id+d:d+a.id,r=this.omit(r,"network"));const c=await this.privatePostDwWithdrawApiCreate(this.extend(o,r));return this.parseTransaction(c,a)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o="/";"market"===t?o+=t:"public"===t||"private"===t?o+=this.version:"v2Public"!==t&&"v2Private"!==t||(o+="v2"),o+="/"+this.implodeParams(e,s);const d=this.omit(s,this.extractParams(e));if("private"===t||"v2Private"===t){this.checkRequiredCredentials();const e=this.ymdhms(this.milliseconds(),"T");let t={SignatureMethod:"HmacSHA256",SignatureVersion:"2",AccessKeyId:this.apiKey,Timestamp:e};"POST"!==i&&(t=this.extend(t,d));const s=this.keysort(t);let c=this.urlencode(s);const h=[i,this.hostname,o,c].join("\n"),l=this.hmac(this.encode(h),this.encode(this.secret),n.s,"base64");c+="&"+this.urlencode({Signature:l}),o+="?"+c,"POST"===i?(a=this.json(d),r={"Content-Type":"application/json"}):r={"Content-Type":"application/x-www-form-urlencoded"}}else Object.keys(s).length&&(o+="?"+this.urlencode(s));return o=this.implodeParams(this.urls.api[t],{hostname:this.hostname})+o,{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0!==n&&"status"in n){if("error"===this.safeString(n,"status")){const e=this.safeString(n,"err-code"),t=this.id+" "+o;this.throwBroadlyMatchedException(this.exceptions.broad,o,t),this.throwExactlyMatchedException(this.exceptions.exact,e,t);const i=this.safeString(n,"err-msg");throw this.throwExactlyMatchedException(this.exceptions.exact,i,t),new r.ExchangeError(t)}}}}},3727:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(8716),r=i(2079),a=i(1579),o=i(5147),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bitvavo",name:"Bitvavo",countries:["NL"],rateLimit:60,version:"v2",certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,editOrder:!0,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d"},urls:{logo:"https://github.com/user-attachments/assets/d213155c-8c71-4701-9bd5-45351febc2a8",api:{public:"https://api.bitvavo.com",private:"https://api.bitvavo.com"},www:"https://bitvavo.com/",doc:"https://docs.bitvavo.com/",fees:"https://bitvavo.com/en/fees",referral:"https://bitvavo.com/?a=24F34952F7"},api:{public:{get:{time:1,markets:1,assets:1,"{market}/book":1,"{market}/trades":5,"{market}/candles":1,"ticker/price":1,"ticker/book":1,"ticker/24h":{cost:1,noMarket:25}}},private:{get:{account:1,order:1,orders:5,ordersOpen:{cost:1,noMarket:25},trades:5,balance:5,deposit:1,depositHistory:5,withdrawalHistory:5},post:{order:1,withdrawal:1},put:{order:1},delete:{order:1,orders:1}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0025"),maker:this.parseNumber("0.002"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0025")],[this.parseNumber("100000"),this.parseNumber("0.0020")],[this.parseNumber("250000"),this.parseNumber("0.0016")],[this.parseNumber("500000"),this.parseNumber("0.0012")],[this.parseNumber("1000000"),this.parseNumber("0.0010")],[this.parseNumber("2500000"),this.parseNumber("0.0008")],[this.parseNumber("5000000"),this.parseNumber("0.0006")],[this.parseNumber("10000000"),this.parseNumber("0.0005")],[this.parseNumber("25000000"),this.parseNumber("0.0004")]],maker:[[this.parseNumber("0"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.0010")],[this.parseNumber("250000"),this.parseNumber("0.0008")],[this.parseNumber("500000"),this.parseNumber("0.0006")],[this.parseNumber("1000000"),this.parseNumber("0.0005")],[this.parseNumber("2500000"),this.parseNumber("0.0004")],[this.parseNumber("5000000"),this.parseNumber("0.0004")],[this.parseNumber("10000000"),this.parseNumber("0.0003")],[this.parseNumber("25000000"),this.parseNumber("0.0003")]]}}},requiredCredentials:{apiKey:!0,secret:!0},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:void 0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!0,selfTradePrevention:{EXPIRE_MAKER:!1,EXPIRE_TAKER:!1,EXPIRE_BOTH:!0,NONE:!1},iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!0,limit:1e3,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:void 0,fetchOHLCV:{limit:1440}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{101:r.ExchangeError,102:r.BadRequest,103:r.RateLimitExceeded,104:r.RateLimitExceeded,105:r.PermissionDenied,107:r.ExchangeNotAvailable,108:r.ExchangeNotAvailable,109:r.ExchangeNotAvailable,110:r.BadRequest,200:r.BadRequest,201:r.BadRequest,202:r.BadRequest,203:r.BadSymbol,204:r.BadRequest,205:r.BadRequest,206:r.BadRequest,210:r.InvalidOrder,211:r.InvalidOrder,212:r.InvalidOrder,213:r.InvalidOrder,214:r.InvalidOrder,215:r.InvalidOrder,216:r.InsufficientFunds,217:r.InvalidOrder,230:r.ExchangeError,231:r.ExchangeError,232:r.BadRequest,233:r.InvalidOrder,234:r.InvalidOrder,235:r.ExchangeError,236:r.BadRequest,240:r.OrderNotFound,300:r.AuthenticationError,301:r.AuthenticationError,302:r.AuthenticationError,303:r.AuthenticationError,304:r.AuthenticationError,305:r.AuthenticationError,306:r.AuthenticationError,307:r.PermissionDenied,308:r.AuthenticationError,309:r.AuthenticationError,310:r.PermissionDenied,311:r.PermissionDenied,312:r.PermissionDenied,315:r.BadRequest,317:r.AccountSuspended,400:r.ExchangeError,401:r.ExchangeError,402:r.PermissionDenied,403:r.PermissionDenied,404:r.OnMaintenance,405:r.ExchangeError,406:r.BadRequest,407:r.ExchangeError,408:r.InsufficientFunds,409:r.InvalidAddress,410:r.ExchangeError,411:r.BadRequest,412:r.InvalidAddress,413:r.InvalidAddress,414:r.ExchangeError},broad:{"start parameter is invalid":r.BadRequest,"symbol parameter is invalid":r.BadSymbol,"amount parameter is invalid":r.InvalidOrder,"orderId parameter is invalid":r.InvalidOrder}},options:{currencyToPrecisionRoundingMode:a.R3,"BITVAVO-ACCESS-WINDOW":1e4,networks:{ERC20:"ETH",TRC20:"TRX"},operatorId:void 0,fiatCurrencies:["EUR"]},precisionMode:a.kb,commonCurrencies:{MIOTA:"IOTA"}})}async fetchTime(e={}){const t=await this.publicGetTime(e);return this.safeInteger(t,"time")}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e);return this.parseMarkets(t)}parseMarkets(e){const t=[],i=this.fees;for(let s=0;s{"use strict";i.d(t,{A:()=>n});var s=i(5254),r=i(2079),a=i(5147),o=i(1579);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"blockchaincom",secret:void 0,name:"Blockchain.com",countries:["LX"],rateLimit:500,version:"v3",pro:!0,has:{CORS:!1,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,cancelAllOrders:!0,cancelOrder:!0,createOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCurrencies:!1,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchL2OrderBook:!0,fetchL3OrderBook:!0,fetchLedger:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPositionMode:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!0,transfer:!1,withdraw:!0},timeframes:void 0,urls:{logo:"https://github.com/user-attachments/assets/975e3054-3399-4363-bcee-ec3c6d63d4e8",test:{public:"https://testnet-api.delta.exchange",private:"https://testnet-api.delta.exchange"},api:{public:"https://api.blockchain.com/v3/exchange",private:"https://api.blockchain.com/v3/exchange"},www:"https://blockchain.com",doc:["https://api.blockchain.com/v3"],fees:"https://exchange.blockchain.com/fees"},api:{public:{get:{tickers:1,"tickers/{symbol}":1,symbols:1,"symbols/{symbol}":1,"l2/{symbol}":1,"l3/{symbol}":1}},private:{get:{fees:1,orders:1,"orders/{orderId}":1,trades:1,fills:1,deposits:1,"deposits/{depositId}":1,accounts:1,"accounts/{account}/{currency}":1,whitelist:1,"whitelist/{currency}":1,withdrawals:1,"withdrawals/{withdrawalId}":1},post:{orders:1,"deposits/{currency}":1,withdrawals:1},delete:{orders:1,"orders/{orderId}":1}}},fees:{trading:{feeSide:"get",tierBased:!0,percentage:!0,tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0045")],[this.parseNumber("10000"),this.parseNumber("0.0035")],[this.parseNumber("50000"),this.parseNumber("0.0018")],[this.parseNumber("100000"),this.parseNumber("0.0018")],[this.parseNumber("500000"),this.parseNumber("0.0018")],[this.parseNumber("1000000"),this.parseNumber("0.0018")],[this.parseNumber("2500000"),this.parseNumber("0.0018")],[this.parseNumber("5000000"),this.parseNumber("0.0016")],[this.parseNumber("25000000"),this.parseNumber("0.0014")],[this.parseNumber("100000000"),this.parseNumber("0.0011")],[this.parseNumber("500000000"),this.parseNumber("0.0008")],[this.parseNumber("1000000000"),this.parseNumber("0.0006")]],maker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("10000"),this.parseNumber("0.0017")],[this.parseNumber("50000"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.0008")],[this.parseNumber("500000"),this.parseNumber("0.0007")],[this.parseNumber("1000000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0005")],[this.parseNumber("5000000"),this.parseNumber("0.0004")],[this.parseNumber("25000000"),this.parseNumber("0.0003")],[this.parseNumber("100000000"),this.parseNumber("0.0002")],[this.parseNumber("500000000"),this.parseNumber("0.0001")],[this.parseNumber("1000000000"),this.parseNumber("0")]]}}},requiredCredentials:{apiKey:!1,secret:!0},options:{networks:{ERC20:"ETH",TRC20:"TRX",ALGO:"ALGO",ADA:"ADA",AR:"AR",ATOM:"ATOM",AVAXC:"AVAX",BCH:"BCH",BSV:"BSV",BTC:"BTC",DCR:"DCR",DESO:"DESO",DASH:"DASH",CELO:"CELO",CHZ:"CHZ",MATIC:"MATIC",SOL:"SOL",DOGE:"DOGE",DOT:"DOT",EOS:"EOS",ETC:"ETC",FIL:"FIL",KAVA:"KAVA",LTC:"LTC",IOTA:"MIOTA",NEAR:"NEAR",STX:"STX",XLM:"XLM",XMR:"XMR",XRP:"XRP",XTZ:"XTZ",ZEC:"ZEC",ZIL:"ZIL"}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!0},hedged:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,symbolRequired:!1,trailing:!1},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{401:r.AuthenticationError,404:r.OrderNotFound},broad:{}}})}async fetchMarkets(e={}){const t=await this.publicGetSymbols(e),i=Object.keys(t),s=[];for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(1769),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"blofin",name:"BloFin",countries:["US"],version:"v1",rateLimit:100,pro:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,borrowMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!0,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTriggerOrder:!0,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:void 0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!1,fetchLedger:!0,fetchLedgerEntry:void 0,fetchLeverage:!0,fetchLeverages:!0,fetchLeverageTiers:!1,fetchMarginMode:!0,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrder:void 0,fetchOpenOrders:!0,fetchOrder:void 0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!0,fetchPositions:!0,fetchPositionsForSymbol:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!0,signIn:!1,transfer:!0,withdraw:!1},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1H","2h":"2H","4h":"4H","6h":"6H","8h":"8H","12h":"12H","1d":"1D","3d":"3D","1w":"1W","1M":"1M"},hostname:"www.blofin.com",urls:{logo:"https://github.com/user-attachments/assets/518cdf80-f05d-4821-a3e3-d48ceb41d73b",api:{rest:"https://openapi.blofin.com"},test:{rest:"https://demo-trading-openapi.blofin.com"},referral:{url:"https://blofin.com/register?referral_code=f79EsS",discount:.05},www:"https://www.blofin.com",doc:"https://blofin.com/docs"},api:{public:{get:{"market/instruments":1,"market/tickers":1,"market/books":1,"market/trades":1,"market/candles":1,"market/mark-price":1,"market/funding-rate":1,"market/funding-rate-history":1}},private:{get:{"asset/balances":1,"trade/orders-pending":1,"trade/fills-history":1,"asset/deposit-history":1,"asset/withdrawal-history":1,"asset/bills":1,"account/balance":1,"account/positions":1,"account/leverage-info":1,"account/margin-mode":1,"account/position-mode":1,"account/batch-leverage-info":1,"trade/orders-tpsl-pending":1,"trade/orders-algo-pending":1,"trade/orders-history":1,"trade/orders-tpsl-history":1,"trade/orders-algo-history":1,"trade/order/price-range":1,"user/query-apikey":1,"affiliate/basic":1,"copytrading/instruments":1,"copytrading/account/balance":1,"copytrading/account/positions-by-order":1,"copytrading/account/positions-details-by-order":1,"copytrading/account/positions-by-contract":1,"copytrading/account/position-mode":1,"copytrading/account/leverage-info":1,"copytrading/trade/orders-pending":1,"copytrading/trade/pending-tpsl-by-contract":1,"copytrading/trade/position-history-by-order":1,"copytrading/trade/orders-history":1,"copytrading/trade/pending-tpsl-by-order":1},post:{"account/set-margin-mode":1,"account/set-position-mode":1,"trade/order":1,"trade/order-algo":1,"trade/cancel-order":1,"trade/cancel-algo":1,"account/set-leverage":1,"trade/batch-orders":1,"trade/order-tpsl":1,"trade/cancel-batch-orders":1,"trade/cancel-tpsl":1,"trade/close-position":1,"asset/transfer":1,"copytrading/account/set-position-mode":1,"copytrading/account/set-leverage":1,"copytrading/trade/place-order":1,"copytrading/trade/cancel-order":1,"copytrading/trade/place-tpsl-by-contract":1,"copytrading/trade/cancel-tpsl-by-contract":1,"copytrading/trade/place-tpsl-by-order":1,"copytrading/trade/cancel-tpsl-by-order":1,"copytrading/trade/close-position-by-order":1,"copytrading/trade/close-position-by-contract":1}}},fees:{swap:{taker:this.parseNumber("0.00060"),maker:this.parseNumber("0.00020")}},requiredCredentials:{apiKey:!0,secret:!0,password:!0},features:{default:{sandbox:!1,createOrder:{timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:{max:10},fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1440}},spot:{extends:"default",createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,hedged:!1}},forDerivatives:{extends:"default",createOrder:{marginMode:!0,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!0},hedged:!0}},swap:{linear:{extends:"forDerivatives"},inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{400:r.BadRequest,401:r.AuthenticationError,500:r.ExchangeError,404:r.BadRequest,405:r.BadRequest,406:r.BadRequest,429:r.RateLimitExceeded,152001:r.BadRequest,152002:r.BadRequest,152003:r.BadRequest,152004:r.BadRequest,152005:r.BadRequest,152006:r.InvalidOrder,152007:r.InvalidOrder,152008:r.InvalidOrder,152009:r.InvalidOrder,150003:r.InvalidOrder,150004:r.InvalidOrder,542:r.InvalidOrder,102002:r.InvalidOrder,102005:r.InvalidOrder,102014:r.InvalidOrder,102015:r.InvalidOrder,102022:r.InvalidOrder,102037:r.InvalidOrder,102038:r.InvalidOrder,102039:r.InvalidOrder,102040:r.InvalidOrder,102047:r.InvalidOrder,102048:r.InvalidOrder,102049:r.InvalidOrder,102050:r.InvalidOrder,102051:r.InvalidOrder,102052:r.InvalidOrder,102053:r.InvalidOrder,102054:r.InvalidOrder,102055:r.InvalidOrder,102064:r.BadRequest,102065:r.BadRequest,102068:r.BadRequest,103013:r.ExchangeError,"Order failed. Insufficient USDT margin in account":r.InsufficientFunds},broad:{"Internal Server Error":r.ExchangeNotAvailable,"server error":r.ExchangeNotAvailable}},httpExceptions:{429:r.ExchangeNotAvailable},precisionMode:o.kb,options:{brokerId:"ec6dd3a7dd982d0b",accountsByType:{swap:"futures",funding:"funding",future:"futures",copy_trading:"copy_trading",earn:"earn",spot:"spot"},accountsById:{funding:"funding",futures:"swap",copy_trading:"copy_trading",earn:"earn",spot:"spot"},defaultNetwork:"ERC20",defaultNetworks:{ETH:"ERC20",BTC:"BTC",USDT:"TRC20"},networks:{BTC:"Bitcoin",BEP20:"BSC",ERC20:"ERC20",TRC20:"TRC20"},fetchOpenInterestHistory:{timeframes:{"5m":"5m","1h":"1H","8h":"8H","1d":"1D","5M":"5m","1H":"1H","8H":"8H","1D":"1D"}},fetchOHLCV:{timezone:"UTC"},fetchPositions:{method:"privateGetAccountPositions"},createOrder:"privatePostTradeOrder",createMarketBuyOrderRequiresPrice:!1,fetchMarkets:["swap"],defaultType:"swap",fetchLedger:{method:"privateGetAssetBills"},fetchOpenOrders:{method:"privateGetTradeOrdersPending"},cancelOrders:{method:"privatePostTradeCancelBatchOrders"},fetchCanceledOrders:{method:"privateGetTradeOrdersHistory"},fetchClosedOrders:{method:"privateGetTradeOrdersHistory"},withdraw:{password:void 0,pwd:void 0},exchangeType:{spot:"SPOT",swap:"SWAP",SPOT:"SPOT",SWAP:"SWAP"}}})}async fetchMarkets(e={}){const t=await this.publicGetMarketInstruments(e),i=this.safeList(t,"data",[]);return this.parseMarkets(i)}parseMarket(e){const t=this.safeString(e,"instId"),i=this.safeStringLower(e,"instType"),s="spot"===i,r="future"===i,o="swap"===i,n="option"===i,d=o||r,c=this.safeString(e,"baseCurrency"),h=this.safeString(e,"quoteCurrency"),l=this.safeString(e,"quoteCurrency"),u=this.safeCurrencyCode(l),p=this.safeCurrencyCode(c),f=this.safeCurrencyCode(h);let m=p+"/"+f;o&&(m=m+":"+u);const g=void 0,v=this.safeString(e,"tickSize"),y=this.safeDict2(this.fees,i,"trading",{}),b=this.safeNumber(y,"taker"),w=this.safeNumber(y,"maker");let k=this.safeString(e,"maxLeverage","100");k=a.Y.stringMax(k,"1");const S="live"===this.safeString(e,"state");return this.safeMarketStructure({id:t,symbol:m,base:p,quote:f,baseId:c,quoteId:h,settle:u,settleId:l,type:i,spot:s,option:n,margin:s&&a.Y.stringGt(k,"1"),swap:o,future:r,active:S,taker:b,maker:w,contract:d,linear:d?h===l:void 0,inverse:d?c===l:void 0,contractSize:d?this.safeNumber(e,"contractValue"):void 0,expiry:g,expiryDatetime:g,strike:undefined,optionType:undefined,created:this.safeInteger(e,"listTime"),precision:{amount:this.safeNumber(e,"lotSize"),price:this.parseNumber(v)},limits:{leverage:{min:this.parseNumber("1"),max:this.parseNumber(k)},amount:{min:this.safeNumber(e,"minSize"),max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:e})}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={instId:this.market(e).id};void 0!==(t=void 0===t?50:t)&&(s.size=t);const r=await this.publicGetMarketBooks(this.extend(s,i)),a=this.safeList(r,"data",[]),o=this.safeDict(a,0,{}),n=this.safeInteger(o,"ts");return this.parseOrderBook(o,e,n)}parseTicker(e,t=void 0){const i=this.safeInteger(e,"ts"),s=this.safeString(e,"instId"),r=(t=this.safeMarket(s,t,"-")).symbol,a=this.safeString(e,"last"),o=this.safeString(e,"open24h"),n=this.safeBool(t,"spot",!1)?this.safeString(e,"volCurrency24h"):void 0,d=this.safeString(e,"vol24h"),c=this.safeString(e,"high24h"),h=this.safeString(e,"low24h");return this.safeTicker({symbol:r,timestamp:i,datetime:this.iso8601(i),high:c,low:h,bid:this.safeString(e,"bidPrice"),bidVolume:this.safeString(e,"bidSize"),ask:this.safeString(e,"askPrice"),askVolume:this.safeString(e,"askSize"),vwap:void 0,open:o,close:a,last:a,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:d,quoteVolume:n,indexPrice:this.safeString(e,"indexPrice"),markPrice:this.safeString(e,"markPrice"),info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={instId:i.id},r=await this.publicGetMarketTickers(this.extend(s,t)),a=this.safeList(r,"data",[]),o=this.safeDict(a,0,{});return this.parseTicker(o,i)}async fetchMarkPrice(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.publicGetMarketMarkPrice(this.extend(s,t)),a=this.safeList(r,"data",[]),o=this.safeDict(a,0,{});return this.parseTicker(o,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.publicGetMarketTickers(t),s=this.safeList(i,"data",[]);return this.parseTickers(s,e)}parseTrade(e,t=void 0){const i=this.safeString(e,"tradeId"),s=this.safeString(e,"instId"),r=(t=this.safeMarket(s,t,"-")).symbol,a=this.safeInteger(e,"ts"),o=this.safeString2(e,"price","fillPrice"),n=this.safeString2(e,"size","fillSize"),d=this.safeString(e,"side"),c=this.safeString(e,"orderId"),h=this.safeString(e,"fee");let l;return void 0!==h&&(l={cost:h,currency:t.settle}),this.safeTrade({info:e,timestamp:a,datetime:this.iso8601(a),symbol:r,id:i,order:c,type:void 0,takerOrMaker:void 0,side:d,price:o,amount:n,cost:void 0,fee:l},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchTrades","paginate"),r)return await this.fetchPaginatedCallCursor("fetchTrades",e,t,i,s,"tradeId","after",void 0,100);const a=this.market(e),o={instId:a.id};let n,d;void 0!==i&&(o.limit=i),[d,s]=this.handleOptionAndParams(s,"fetchTrades","method","publicGetMarketTrades"),"publicGetMarketTrades"===d&&(n=await this.publicGetMarketTrades(this.extend(o,s)));const c=this.safeList(n,"data",[]);return this.parseTrades(c,a,t,i)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,6)]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e);let o=!1;if([o,r]=this.handleOptionAndParams(r,"fetchOHLCV","paginate"),o)return await this.fetchPaginatedCallDeterministic("fetchOHLCV",e,i,s,t,r,100);void 0===s&&(s=100);const n={instId:a.id,bar:this.safeString(this.timeframes,t,t),limit:s},d=this.safeInteger(r,"until");let c;void 0!==d&&(n.after=d,r=this.omit(r,"until")),c=await this.publicGetMarketCandles(this.extend(n,r));const h=this.safeList(c,"data",[]);return this.parseOHLCVs(h,a,t,i,s)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();let a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),a)return await this.fetchPaginatedCallDeterministic("fetchFundingRateHistory",e,t,i,"8h",s,100);const o=this.market(e),n={instId:o.id};void 0!==t&&(n.before=Math.max(t-1,0)),void 0!==i&&(n.limit=i);const d=this.safeInteger(s,"until");void 0!==d&&(n.after=d,s=this.omit(s,"until"));const c=await this.publicGetMarketFundingRateHistory(this.extend(n,s)),h=[],l=this.safeList(c,"data",[]);for(let e=0;e0?s=s+","+r.id:s+=r.id}const a={instId:s,marginMode:i},o=await this.privateGetAccountBatchLeverageInfo(this.extend(a,t)),n=this.safeList(o,"data",[]);return this.parseLeverages(n,e,"instId")}async fetchLeverage(e,t={}){let i;if(await this.loadMarkets(),[i,t]=this.handleMarginModeAndParams("fetchLeverage",t),void 0===i&&(i=this.safeString(t,"marginMode","cross")),"cross"!==i&&"isolated"!==i)throw new r.BadRequest(this.id+" fetchLeverage() requires a marginMode parameter that must be either cross or isolated");const s=this.market(e),a={instId:s.id,marginMode:i},o=await this.privateGetAccountLeverageInfo(this.extend(a,t)),n=this.safeDict(o,"data",{});return this.parseLeverage(n,s)}parseLeverage(e,t=void 0){const i=this.safeString(e,"instId"),s=this.safeInteger(e,"leverage");return{info:e,symbol:this.safeSymbol(i,t),marginMode:this.safeStringLower(e,"marginMode"),longLeverage:s,shortLeverage:s}}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");if(e<1||e>125)throw new r.BadRequest(this.id+" setLeverage() leverage should be between 1 and 125");await this.loadMarkets();const s=this.market(t);let a;if([a,i]=this.handleMarginModeAndParams("setLeverage",i,"cross"),"cross"!==a&&"isolated"!==a)throw new r.BadRequest(this.id+" setLeverage() requires a marginMode parameter that must be either cross or isolated");const o={leverage:e,marginMode:a,instId:s.id};return await this.privatePostAccountSetLeverage(this.extend(o,i))}async closePosition(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r=this.safeString(i,"clientOrderId");let a;[a,i]=this.handleMarginModeAndParams("closePosition",i,"cross");const o={instId:s.id,marginMode:a};void 0!==r&&(o.clientOrderId=r);const n=await this.privatePostTradeClosePosition(this.extend(o,i));return this.safeDict(n,"data")}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchClosedOrders","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchClosedOrders",e,t,i,s);const a={};let o;void 0!==e&&(o=this.market(e),a.instId=o.id),void 0!==i&&(a.limit=i),void 0!==t&&(a.begin=t);const n=this.safeBoolN(s,["stop","trigger","tpsl","TPSL"],!1);let d;[d,s]=this.handleOptionAndParams(s,"fetchOpenOrders","method","privateGetTradeOrdersHistory");const c=this.omit(s,["method","stop","trigger","tpsl","TPSL"]);let h;h=n||"privateGetTradeOrdersTpslHistory"===d?await this.privateGetTradeOrdersTpslHistory(this.extend(a,c)):await this.privateGetTradeOrdersHistory(this.extend(a,c));const l=this.safeList(h,"data",[]);return this.parseOrders(l,o,t,i)}async fetchMarginMode(e,t={}){await this.loadMarkets();const i=this.market(e),s=await this.privateGetAccountMarginMode(t),r=this.safeDict(s,"data",{});return this.parseMarginMode(r,i)}parseMarginMode(e,t=void 0){return{info:e,symbol:this.safeString(t,"symbol"),marginMode:this.safeString(e,"marginMode")}}async setMarginMode(e,t=void 0,i={}){let s;this.checkRequiredArgument("setMarginMode",e,"marginMode",["cross","isolated"]),await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r={marginMode:e},a=await this.privatePostAccountSetMarginMode(this.extend(r,i)),o=this.safeDict(a,"data",{});return this.parseMarginMode(o,s)}async fetchPositionMode(e=void 0,t={}){const i=await this.privateGetAccountPositionMode(t),s=this.safeDict(i,"data",{});return{info:s,hedged:"long_short_mode"===this.safeString(s,"positionMode")}}async setPositionMode(e,t=void 0,i={}){const s={positionMode:e?"long_short_mode":"net_mode"};return await this.privatePostAccountSetPositionMode(this.extend(s,i))}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.safeString(n,"code"),l=this.safeString(n,"msg"),u=this.id+" "+o;if(void 0!==h&&"0"!==h)throw this.throwExactlyMatchedException(this.exceptions.exact,l,u),this.throwExactlyMatchedException(this.exceptions.exact,h,u),this.throwBroadlyMatchedException(this.exceptions.broad,l,u),new r.ExchangeError(u);const p=this.safeList(n,"data"),f=this.safeDict(p,0),m=this.safeString(f,"msg"),g=this.safeString(f,"code");void 0!==g&&"0"!==g&&(this.throwExactlyMatchedException(this.exceptions.exact,g,u),this.throwExactlyMatchedException(this.exceptions.exact,m,u),this.throwBroadlyMatchedException(this.exceptions.broad,m,u))}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o="/api/"+this.version+"/"+this.implodeParams(e,s);const d=this.omit(s,this.extractParams(e));let c=this.implodeHostname(this.urls.api.rest)+o;if("public"===t)this.isEmpty(d)||(c+="?"+this.urlencode(d));else if("private"===t){this.checkRequiredCredentials();const e=this.milliseconds().toString();r={"ACCESS-KEY":this.apiKey,"ACCESS-PASSPHRASE":this.password,"ACCESS-TIMESTAMP":e,"ACCESS-NONCE":e};let t="";if("GET"===i){if(!this.isEmpty(d)){const e="?"+this.urlencode(d);c+=e,o+=e}}else this.isEmpty(d)||(t=a=this.json(d)),r["Content-Type"]="application/json";const s=o+i+e+e+t,h=this.stringToBase64(this.hmac(this.encode(s),this.encode(this.secret),n.s));r["ACCESS-SIGN"]=h}return{url:c,method:i,body:a,headers:r}}}},5376:(e,t,i)=>{"use strict";i.d(t,{A:()=>c});var s=i(3829),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(4035);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"btcbox",name:"BtcBox",countries:["JP"],rateLimit:1e3,version:"v1",pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTransfer:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1,ws:!1},urls:{logo:"https://github.com/user-attachments/assets/1e2cb499-8d0f-4f8f-9464-3c015cfbc76b",api:{rest:"https://www.btcbox.co.jp/api"},www:"https://www.btcbox.co.jp/",doc:"https://blog.btcbox.jp/en/archives/8762",fees:"https://support.btcbox.co.jp/hc/en-us/articles/360001235694-Fees-introduction"},api:{public:{get:["depth","orders","ticker","tickers"]},private:{post:["balance","trade_add","trade_cancel","trade_list","trade_view","wallet"]},webApi:{get:["ajax/coin/coinInfo"]}},options:{fetchMarkets:{webApiEnable:!0,webApiRetries:3},amountPrecision:"0.0001"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{104:r.AuthenticationError,105:r.PermissionDenied,106:r.InvalidNonce,107:r.InvalidOrder,200:r.InsufficientFunds,201:r.InvalidOrder,202:r.InvalidOrder,203:r.OrderNotFound,401:r.OrderNotFound,402:r.DDoSProtection}})}async fetchMarkets(e={}){const t=this.publicGetTickers(),i=this.fetchWebEndpoint("fetchMarkets","webApiGetAjaxCoinCoinInfo",!0),[s,r]=await Promise.all([t,i]),a=this.safeDict(r,"data",{}),o=Object.keys(s),n=[];for(let e=0;e1&&(r.coin=s.baseId);const a=await this.publicGetDepth(this.extend(r,i));return this.parseOrderBook(a,s.symbol)}parseTicker(e,t=void 0){const i=this.safeSymbol(void 0,t),s=this.safeString(e,"last");return this.safeTicker({symbol:i,timestamp:void 0,datetime:void 0,high:this.safeString(e,"high"),low:this.safeString(e,"low"),bid:this.safeString(e,"buy"),bidVolume:void 0,ask:this.safeString(e,"sell"),askVolume:void 0,vwap:void 0,open:void 0,close:s,last:s,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString(e,"vol"),quoteVolume:this.safeString(e,"volume"),info:e},t)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={};this.symbols.length>1&&(s.coin=i.baseId);const r=await this.publicGetTicker(this.extend(s,t));return this.parseTicker(r,i)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.publicGetTickers(t);return this.parseTickers(i,e)}parseTrade(e,t=void 0){const i=this.safeTimestamp(e,"date");t=this.safeMarket(void 0,t);const s=this.safeString(e,"tid"),r=this.safeString(e,"price"),a=this.safeString(e,"amount"),o=this.safeString(e,"type");return this.safeTrade({info:e,id:s,order:void 0,timestamp:i,datetime:this.iso8601(i),symbol:t.symbol,type:undefined,side:o,takerOrMaker:void 0,price:r,amount:a,cost:void 0,fee:void 0},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={};this.symbols.length>1&&(a.coin=r.baseId);const o=await this.publicGetOrders(this.extend(a,s));return this.parseTrades(o,r,t,i)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n={amount:s,price:r,type:i,coin:o.baseId},d=await this.privatePostTradeAdd(this.extend(n,a));return this.parseOrder(d,o)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets(),void 0===t&&(t="BTC/JPY");const s=this.market(t),r={id:e,coin:s.baseId},a=await this.privatePostTradeCancel(this.extend(r,i));return this.parseOrder(a,s)}parseOrderStatus(e){return this.safeString({part:"open",all:"closed",cancelled:"canceled",closed:"closed",no:"closed"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"id");let s;void 0!==this.safeString(e,"datetime")&&(s=this.parse8601(e.datetime+"+09:00"));const r=this.safeString(e,"amount_original"),o=this.safeString(e,"amount_outstanding"),n=this.safeString(e,"price");let d=this.parseOrderStatus(this.safeString(e,"status"));void 0===d&&a.Y.stringEquals(o,"0")&&(d="closed");t=this.safeMarket(void 0,t);const c=this.safeString(e,"type");return this.safeOrder({id:i,clientOrderId:void 0,timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,amount:r,remaining:o,filled:void 0,side:c,type:void 0,timeInForce:void 0,postOnly:void 0,status:d,symbol:t.symbol,price:n,triggerPrice:void 0,cost:void 0,trades:undefined,fee:void 0,info:e,average:void 0},t)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets(),void 0===t&&(t="BTC/JPY");const s=this.market(t),r=this.extend({id:e,coin:s.baseId},i),a=await this.privatePostTradeView(this.extend(r,i));return this.parseOrder(a,s)}async fetchOrdersByType(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(t),o={type:e,coin:a.baseId},n=await this.privatePostTradeList(this.extend(o,r)),d=this.parseOrders(n,a,i,s);if("open"===e)for(let e=0;e=400)return;const h=this.safeValue(n,"result");if(void 0===h||!0===h)return;const l=this.safeValue(n,"code"),u=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions,l,u),new r.ExchangeError(u)}async request(e,t="public",i="GET",s={},a=void 0,o=void 0,n={}){let d=await this.fetch2(e,t,i,s,a,o,n);if("string"==typeof d){if(d=this.strip(d),!this.isJsonEncodedObject(d))throw new r.ExchangeError(this.id+" "+d);d=JSON.parse(d)}return d}}},4936:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(2317),r=i(2079),a=i(1579),o=i(5147),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"btcmarkets",name:"BTC Markets",countries:["AU"],rateLimit:1e3,version:"v3",has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createTriggerOrder:!0,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:"emulated",fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTime:!0,fetchTrades:!0,fetchTransactions:"emulated",fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://github.com/user-attachments/assets/8c8d6907-3873-4cc4-ad20-e22fba28247e",api:{public:"https://api.btcmarkets.net",private:"https://api.btcmarkets.net"},www:"https://btcmarkets.net",doc:["https://api.btcmarkets.net/doc/v3","https://github.com/BTCMarkets/API"]},api:{public:{get:["markets","markets/{marketId}/ticker","markets/{marketId}/trades","markets/{marketId}/orderbook","markets/{marketId}/candles","markets/tickers","markets/orderbooks","time"]},private:{get:["orders","orders/{id}","batchorders/{ids}","trades","trades/{id}","withdrawals","withdrawals/{id}","deposits","deposits/{id}","transfers","transfers/{id}","addresses","withdrawal-fees","assets","accounts/me/trading-fees","accounts/me/withdrawal-limits","accounts/me/balances","accounts/me/transactions","reports/{id}"],post:["orders","batchorders","withdrawals","reports"],delete:["orders","orders/{id}","batchorders/{ids}"],put:["orders/{id}"]}},timeframes:{"1m":"1m","1h":"1h","1d":"1d"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!0,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:a.kb,exceptions:{exact:{InsufficientFund:r.InsufficientFunds,InvalidPrice:r.InvalidOrder,InvalidAmount:r.InvalidOrder,MissingArgument:r.BadRequest,OrderAlreadyCancelled:r.InvalidOrder,OrderNotFound:r.OrderNotFound,OrderStatusIsFinal:r.InvalidOrder,InvalidPaginationParameter:r.BadRequest},broad:{}},fees:{percentage:!0,tierBased:!0,maker:this.parseNumber("-0.0005"),taker:this.parseNumber("0.0020")},options:{fees:{AUD:{maker:this.parseNumber("0.0085"),taker:this.parseNumber("0.0085")}}}})}async fetchTransactionsWithMethod(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={};let o;void 0!==s&&(a.limit=s),void 0!==i&&(a.after=i),void 0!==t&&(o=this.currency(t));const n=await this[e](this.extend(a,r));return this.parseTransactions(n,o,i,s)}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactionsWithMethod("privateGetTransfers",e,t,i,s)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactionsWithMethod("privateGetDeposits",e,t,i,s)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactionsWithMethod("privateGetWithdrawals",e,t,i,s)}parseTransactionStatus(e){return this.safeString({Accepted:"pending","Pending Authorization":"pending",Complete:"ok",Cancelled:"cancelled",Failed:"failed"},e,e)}parseTransactionType(e){return this.safeString({Withdraw:"withdrawal",Deposit:"deposit"},e,e)}parseTransaction(e,t=void 0){const i=this.parse8601(this.safeString(e,"creationTime")),s=this.parse8601(this.safeString(e,"lastUpdate"));let r=this.parseTransactionType(this.safeStringLower(e,"type"));"withdraw"===r&&(r="withdrawal");const a=this.safeDict(e,"paymentDetail",{}),n=this.safeString(a,"txId");let d,c=this.safeString(a,"address");if(void 0!==c){const e=c.split("?dt=");e.length>1&&(c=e[0],d=e[1])}const h=c,l=d,u=this.safeString(e,"fee"),p=this.parseTransactionStatus(this.safeString(e,"status")),f=this.safeString(e,"assetName"),m=this.safeCurrencyCode(f);let g=this.safeString(e,"amount");return u&&(g=o.Y.stringSub(g,u)),{id:this.safeString(e,"id"),txid:n,timestamp:i,datetime:this.iso8601(i),network:void 0,address:c,addressTo:h,addressFrom:undefined,tag:d,tagTo:l,tagFrom:undefined,type:r,amount:this.parseNumber(g),currency:m,status:p,updated:s,comment:this.safeString(e,"description"),internal:void 0,fee:{currency:m,cost:this.parseNumber(u),rate:void 0},info:e}}async fetchMarkets(e={}){const t=await this.publicGetMarkets(e);return this.parseMarkets(t)}parseMarket(e){const t=this.safeString(e,"baseAssetName"),i=this.safeString(e,"quoteAssetName"),s=this.safeString(e,"marketId"),r=this.safeCurrencyCode(t),a=this.safeCurrencyCode(i),o=r+"/"+a,n=this.safeValue(this.safeDict(this.options,"fees",{}),a,this.fees),d=this.parseNumber(this.parsePrecision(this.safeString(e,"priceDecimals"))),c=this.safeNumber(e,"minOrderAmount"),h=this.safeNumber(e,"maxOrderAmount");let l;return"AUD"===a&&(l=d),{id:s,symbol:o,base:r,quote:a,settle:void 0,baseId:t,quoteId:i,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:"Online"===this.safeString(e,"status"),contract:!1,linear:void 0,inverse:void 0,taker:n.taker,maker:n.maker,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(e,"amountDecimals"))),price:d},limits:{leverage:{min:void 0,max:void 0},amount:{min:c,max:h},price:{min:l,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e}}async fetchTime(e={}){const t=await this.publicGetTime(e);return this.parse8601(this.safeString(t,"timestamp"))}parseBalance(e){const t={info:e};for(let i=0;i{"use strict";i.d(t,{A:()=>d});var s=i(8430),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"btcturk",name:"BTCTurk",countries:["TR"],rateLimit:100,pro:!1,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,ws:!1},timeframes:{"1m":1,"15m":15,"30m":30,"1h":60,"4h":240,"1d":"1 d","1w":"1 w","1y":"1 y"},urls:{logo:"https://github.com/user-attachments/assets/10e0a238-9f60-4b06-9dda-edfc7602f1d6",api:{public:"https://api.btcturk.com/api/v2",private:"https://api.btcturk.com/api/v1",graph:"https://graph-api.btcturk.com/v1"},www:"https://www.btcturk.com",doc:"https://github.com/BTCTrader/broker-api-docs"},api:{public:{get:{orderbook:1,ticker:.1,trades:1,ohlc:1,"server/exchangeinfo":1}},private:{get:{"users/balances":1,openOrders:1,allOrders:1,"users/transactions/trade":1},post:{"users/transactions/crypto":1,"users/transactions/fiat":1,order:1,cancelOrder:1},delete:{order:1}},graph:{get:{ohlcs:1,"klines/history":1}}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:30,symbolRequired:!0},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:30,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:void 0,fetchOHLCV:{limit:void 0}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},fees:{trading:{maker:this.parseNumber("0.0005"),taker:this.parseNumber("0.0009")}},exceptions:{exact:{FAILED_ORDER_WITH_OPEN_ORDERS:r.InsufficientFunds,FAILED_LIMIT_ORDER:r.InvalidOrder,FAILED_MARKET_ORDER:r.InvalidOrder}},precisionMode:o.kb})}async fetchMarkets(e={}){const t=await this.publicGetServerExchangeinfo(e),i=this.safeDict(t,"data",{}),s=this.safeList(i,"symbols",[]);return this.parseMarkets(s)}parseMarket(e){const t=this.safeString(e,"name"),i=this.safeString(e,"numerator"),s=this.safeString(e,"denominator"),r=this.safeCurrencyCode(i),a=this.safeCurrencyCode(s),o=this.safeList(e,"filters",[]);let n,d,c,h,l;for(let e=0;e{"use strict";i.d(t,{A:()=>n});var s=i(7198),r=i(2079),a=i(1579),o=i(4852);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bullish",name:"Bullish",countries:["DE"],version:"v3",rateLimit:20,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,createDepositAddress:!1,createLimitBuyOrder:!0,createLimitOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketOrder:!0,createMarketSellOrder:!0,createOrder:!0,createPostOnlyOrder:!0,createTriggerOrder:!0,deposit:!1,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!0,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!0,fetchWithdrawal:!1,fetchWithdrawals:!1,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!0,transfer:!0,withdraw:!0,ws:!0},timeframes:{"1m":"1m","5m":"5m","30m":"30m","1h":"1h","6h":"6h","12h":"12h","1d":"1d"},urls:{logo:"https://github.com/user-attachments/assets/68f0686b-84f0-4da9-a751-f7089af3a9ed",api:{public:"https://api.exchange.bullish.com/trading-api",private:"https://api.exchange.bullish.com/trading-api"},test:{public:"https://api.simnext.bullish-test.com/trading-api",private:"https://api.simnext.bullish-test.com/trading-api"},www:"https://bullish.com/",referral:"",doc:["https://api.exchange.bullish.com/docs/api/rest/"]},api:{public:{get:{"v1/nonce":1,"v1/time":1,"v1/assets":1,"v1/assets/{symbol}":1,"v1/markets":1,"v1/markets/{symbol}":1,"v1/history/markets/{symbol}":1,"v1/markets/{symbol}/orderbook/hybrid":1,"v1/markets/{symbol}/trades":1,"v1/markets/{symbol}/tick":1,"v1/markets/{symbol}/candle":1,"v1/history/markets/{symbol}/trades":1,"v1/history/markets/{symbol}/funding-rate":1,"v1/index-prices":1,"v1/index-prices/{assetSymbol}":1,"v1/expiry-prices/{symbol}":1,"v1/option-ladder":1,"v1/option-ladder/{symbol}":1}},private:{get:{"v2/orders":1,"v2/history/orders":1,"v2/orders/{orderId}":1,"v2/amm-instructions":1,"v2/amm-instructions/{instructionId}":1,"v1/wallets/transactions":1,"v1/wallets/limits/{symbol}":1,"v1/wallets/deposit-instructions/crypto/{symbol}":1,"v1/wallets/withdrawal-instructions/crypto/{symbol}":1,"v1/wallets/deposit-instructions/fiat/{symbol}":1,"v1/wallets/withdrawal-instructions/fiat/{symbol}":1,"v1/wallets/self-hosted/verification-attempts":1,"v1/trades":5,"v1/history/trades":5,"v1/trades/{tradeId}":5,"v1/trades/client-order-id/{clientOrderId}":1,"v1/accounts/asset":1,"v1/accounts/asset/{symbol}":1,"v1/users/logout":1,"v1/users/hmac/login":1,"v1/accounts/trading-accounts":1,"v1/accounts/trading-accounts/{tradingAccountId}":1,"v1/derivatives-positions":1,"v1/history/derivatives-settlement":1,"v1/history/transfer":1,"v1/history/borrow-interest":1,"v2/mmp-configuration":1,"v2/otc-trades":1,"v2/otc-trades/{otcTradeId}":1,"v2/otc-trades/unconfirmed-trade":1},post:{"v2/orders":5,"v2/command":5,"v2/amm-instructions":1,"v1/wallets/withdrawal":1,"v2/users/login":1,"v1/simulate-portfolio-margin":1,"v1/wallets/self-hosted/initiate":1,"v2/mmp-configuration":1,"v2/otc-trades":1,"v2/otc-command":1}}},fees:{trading:{tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001")}},precisionMode:a.kb,options:{timeDifference:0,adjustForTimeDifference:!1,networks:{BTC:"BTC",EOS:"EOS",ERC20:"ETH"},defaultNetwork:"ERC20",defaultNetworks:{USDC:"ERC20"},tradingAccountId:void 0},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:90,symbolRequired:!1,untilDays:90},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:90,untilDays:90,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,daysBack:90,untilDays:90,trigger:!1,trailing:!1,symbolRequired:!1},fetchCanceledAndClosedOrders:{marginMode:!1,limit:100,daysBack:90,untilDays:90,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1,daysBackCanceled:1,untilDays:1,trigger:!1,trailing:!1,symbolRequired:!1},fetchCanceledOrders:{marginMode:!1,limit:100,daysBack:1,untilDays:1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:{extends:"default"},inverse:void 0}},exceptions:{exact:{1:r.BadRequest,5:r.InvalidOrder,6:r.DuplicateOrderId,13:r.BadRequest,15:r.BadRequest,18:r.BadRequest,1002:r.BadRequest,2001:r.BadRequest,2002:r.BadRequest,2003:r.BadRequest,2004:r.BadRequest,2005:r.ExchangeError,2006:r.BadRequest,2007:r.BadRequest,2008:r.BadRequest,2009:r.BadSymbol,2010:r.AuthenticationError,2011:r.AuthenticationError,2012:r.BadRequest,2013:r.InvalidOrder,2015:r.OperationRejected,2016:r.BadRequest,2017:r.BadRequest,2018:r.BadRequest,2020:r.PermissionDenied,2021:r.OperationRejected,2029:r.InvalidNonce,2035:r.InvalidNonce,3001:r.InsufficientFunds,3002:r.OrderNotFound,3003:r.PermissionDenied,3004:r.InsufficientFunds,3005:r.InsufficientFunds,3006:r.InsufficientFunds,3007:r.DuplicateOrderId,3031:r.BadRequest,3032:r.BadRequest,3033:r.PermissionDenied,3034:r.RateLimitExceeded,3035:r.RateLimitExceeded,3047:r.OperationRejected,3048:r.OperationRejected,3049:r.OperationRejected,3051:r.InsufficientFunds,3052:r.InsufficientFunds,3063:r.BadRequest,3064:r.OrderNotFillable,3065:r.MarketClosed,3066:r.ExchangeError,3067:r.MarketClosed,6007:r.InvalidOrder,6011:r.InvalidOrder,6012:r.InvalidOrder,6013:r.InvalidOrder,8301:r.ExchangeError,8305:r.ExchangeError,8306:r.ExchangeError,8307:r.ExchangeError,8310:r.InvalidAddress,8311:r.BadRequest,8313:r.BadRequest,8315:r.OperationRejected,8316:r.OperationRejected,8317:r.OperationRejected,8318:r.NotSupported,8319:r.NotSupported,8320:r.InvalidAddress,8322:r.BadRequest,8327:r.AuthenticationError,8329:r.ExchangeError,8331:r.InvalidAddress,8332:r.BadRequest,8333:r.BadRequest,8334:r.BadRequest,8335:r.InvalidAddress,8336:r.InvalidAddress,8399:r.ExchangeError},broad:{HttpInvalidParameterException:r.BadRequest,UNAUTHORIZED_COMMAND:r.AuthenticationError,QUERY_FILTER_ERROR:r.BadRequest,INVALID_SYMBOL:r.BadSymbol}}})}async fetchTime(e={}){const t=await this.publicGetV1Time(e);return this.safeInteger(t,"timestamp")}async fetchCurrencies(e={}){const t=await this.publicGetV1Assets(e),i={};for(let e=0;en)throw e}return[]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e);let o=!1;if([o,r]=this.handleOptionAndParams(r,"fetchOHLCV","paginate"),o)return await this.fetchPaginatedCallDeterministic("fetchOHLCV",e,i,s,t,r,100);let n={symbol:a.id,timeBucket:this.safeString(this.timeframes,t,t),_pageSize:100};[n,r]=this.handleUntilOption("createdAtDatetime[lte]",n,r);let d=this.safeInteger(n,"createdAtDatetime[lte]");const c=1e3*this.parseTimeframe(t)*100;let h=i;void 0===h&&void 0===d?(d=this.milliseconds(),h=d-c):void 0===h?h=d-c:void 0===d&&(d=this.sum(h,c)),n["createdAtDatetime[gte]"]=this.iso8601(h),n["createdAtDatetime[lte]"]=this.iso8601(d);const l=await this.publicGetV1MarketsSymbolCandle(this.extend(n,r));return this.parseOHLCVs(l,a,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,"createdAtTimestamp"),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"volume")]}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();let a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),a)return s=this.handlePaginationParams("fetchFundingRateHistory",t,s),await this.fetchPaginatedCallDynamic("fetchFundingRateHistory",e,t,i,s,100);const o=this.market(e);if(!o.swap)throw new r.BadRequest(this.id+" fetchFundingRateHistory() supports swap markets only");const n={symbol:o.id};void 0!==i&&(n._pageSize=this.getClosestLimit(i)),s=this.handleSinceAndUntil(t,s,"updatedAtDatetime[gte]","updatedAtDatetime[lte]");const d=await this.publicGetV1HistoryMarketsSymbolFundingRate(this.extend(n,s)),c=[],h=this.toArray(d);for(let t=0;tt&&(r=t)}const o=this.iso8601(e),n=this.iso8601(r);t[i]=o,t[s]=n}return t}getClosestLimit(e){let t=5;return e>5&&e<26?t=25:e>25&&e<51?t=50:e>50&&(t=100),t}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({status:"OPEN"},s))}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({status:"CANCELLED",method:"privateGetV2Orders"},s))}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({status:"CLOSED",method:"privateGetV2Orders"},s))}async fetchCanceledAndClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({status:"CLOSED",method:"privateGetV2HistoryOrders"},s))}async fetchOrder(e,t=void 0,i={}){await Promise.all([this.loadMarkets(),this.handleToken()]);const s=await this.loadAccount(i);let r;void 0!==t&&(r=this.market(t));const a={orderId:e,tradingAccountId:s},o=await this.privateGetV2OrdersOrderId(this.extend(a,i));return this.parseOrder(o,r)}async createOrder(e,t,i,s,a=void 0,o={}){await Promise.all([this.loadMarkets(),this.handleToken()]);const n=await this.loadAccount(o),d=this.market(e),c={commandType:"V3CreateOrder",symbol:d.id,side:i.toUpperCase(),quantity:this.amountToPrecision(e,s),tradingAccountId:n},h="market"===t||"MARKET"===t;let l=!1;[l,o]=this.handlePostOnly(h,"POST_ONLY"===t,o),l&&(t="POST_ONLY");let u="GTC";[u,o]=this.handleOptionAndParams(o,"createOrder","timeInForce",u),o.timeInForce=u.toUpperCase(),h||(c.price=this.priceToPrecision(e,a));const p=this.safeString(o,"triggerPrice");if(void 0!==p){if(h)throw new r.NotSupported(this.id+" createOrder() does not support market trigger orders");c.stopPrice=this.priceToPrecision(e,p),t="STOP_LIMIT",o=this.omit(o,"triggerPrice")}c.type=t.toUpperCase();const f=await this.privatePostV2Orders(this.extend(c,o));return this.parseOrder(f,d)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await Promise.all([this.loadMarkets(),this.handleToken()]);const n=await this.loadAccount(o),d=this.market(t),c={commandType:"V1AmendOrder",symbol:d.id,tradingAccountId:n};void 0===this.safeString(o,"clientOrderId")&&(c.orderId=e),void 0!==i&&(c.type=i.toUpperCase());this.safeBool(o,"postOnly",!1)&&(o=this.omit(o,"postOnly"),c.type="POST_ONLY"),void 0!==r&&(c.quantity=this.amountToPrecision(t,r)),void 0!==a&&(c.price=this.priceToPrecision(t,a));const h=await this.privatePostV2Command(this.extend(c,o));return this.parseOrder(h,d)}async cancelOrder(e,t=void 0,i={}){await Promise.all([this.loadMarkets(),this.handleToken()]);const s=await this.loadAccount(i);if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");const a=this.market(t),o={symbol:a.id,tradingAccountId:s,commandType:this.safeString(i,"commandType","V3CancelOrder"),orderId:e},n=await this.privatePostV2Command(this.extend(o,i));return this.parseOrder(n,a)}async cancelAllOrders(e=void 0,t={}){await Promise.all([this.loadMarkets(),this.handleToken()]);const i={tradingAccountId:await this.loadAccount(t)};let s;void 0!==e?(s=this.market(e),i.symbol=s.id,i.commandType="V1CancelAllOrdersByMarket"):i.commandType="V1CancelAllOrders";const r=[await this.privatePostV2Command(this.extend(i,t))];return this.parseOrders(r,s)}parseOrder(e,t=void 0){const i=this.safeString(e,"symbol");void 0===t&&(t=this.safeMarket(i));const s=this.safeSymbol(i,t),r=this.safeString(e,"orderId"),a=this.safeInteger(e,"createdAtTimestamp"),o=this.safeString(e,"type"),n=this.safeStringLower(e,"side"),d=this.safeString(e,"price"),c=this.safeString(e,"quantity"),h=this.safeString(e,"quantityFilled");let l=this.parseOrderStatus(this.safeString(e,"status"));if("closed"===l){"User cancelled"===this.safeString(e,"statusReason")&&(l="canceled")}const u=this.safeString(e,"timeInForce"),p=this.safeString(e,"stopPrice"),f=this.safeString(e,"quoteAmount"),m={},g=this.safeNumber(e,"quoteFee");void 0!==g&&(m.cost=g,m.currency=t.quote);const v=this.safeString(e,"averageFillPrice");return this.safeOrder({id:r,clientOrderId:this.safeString(e,"clientOrderId"),timestamp:a,datetime:this.iso8601(a),lastTradeTimestamp:void 0,status:l,symbol:s,type:this.parseOrderType(o),timeInForce:u,postOnly:"POST_ONLY"===o,side:n,price:d,triggerPrice:p,amount:c,filled:h,remaining:void 0,cost:f,trades:void 0,fee:m,info:e,average:v},t)}parseOrderStatus(e){return this.safeString({OPEN:"open",CLOSED:"closed",CANCELLED:"canceled",REJECTED:"rejected"},e,e)}parseOrderType(e){return this.safeString({LMT:"limit",MKT:"market",POST_ONLY:"limit",STOP_LIMIT:"limit"},e,e)}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await Promise.all([this.loadMarkets(),this.handleToken()]);let r={};[r,s]=this.handleUntilOption("createdAtDatetime[lte]",r,s);const a=this.safeInteger(r,"createdAtDatetime[lte]");void 0!==a&&(r["createdAtDatetime[lte]"]=this.iso8601(a)),void 0!==t&&(r["createdAtDatetime[gte]"]=this.iso8601(t));const o=await this.privateGetV1WalletsTransactions(this.extend(r,s)),n=this.safeList(o,"data",[]);let d;return void 0!==e&&(d=this.currency(e)),this.parseTransactions(n,d,t,i)}async withdraw(e,t,i,s=void 0,a={}){await Promise.all([this.loadMarkets(),this.handleToken()]);const o=this.currency(e),n={command:{commandType:"V1Withdraw",destinationId:i,symbol:o.id,quantity:this.currencyToPrecision(e,t)}};let d;if([d,a]=this.handleNetworkCodeAndParams(a),void 0===d)throw new r.ArgumentsRequired(this.id+" withdraw() requires a network parameter");n.network=this.networkCodeToId(d);const c=await this.privatePostV1WalletsWithdrawal(this.extend(n,a));return this.parseTransaction(c,o)}parseTransaction(e,t=void 0){const i=this.safeString(e,"custodyTransactionId"),s=this.safeString(e,"direction"),r=this.parse8601(this.safeString(e,"createdAtDateTime")),a=this.parse8601(this.safeString(e,"updatedAtDateTime")),o=this.safeString(e,"network"),n=this.safeDict(e,"transactionDetails"),d=this.safeString(n,"blockchainTxId"),c=this.safeString(n,"address"),h=this.safeNumber(e,"quantity"),l=this.safeString(e,"symbol"),u=this.safeCurrencyCode(l,t),p=this.safeString(e,"status"),f=this.safeList(n,"sources",[]),m=this.safeDict(f,0,{}),g=this.safeString(m,"address"),v={currency:void 0,cost:void 0,rate:void 0},y=this.safeNumber(e,"fee");return void 0!==y&&(v.cost=y,v.currency=u),{id:i,txid:d,timestamp:r,datetime:this.iso8601(r),network:this.networkIdToCode(o),addressFrom:g,address:c,addressTo:c,amount:h,type:this.parseTransactionType(s),currency:u,status:this.parseTransactionStatus(p),updated:a,tagFrom:void 0,tag:void 0,tagTo:void 0,comment:void 0,internal:void 0,fee:v,info:e}}parseTransactionType(e){return this.safeString({DEPOSIT:"deposit",WITHDRAW:"withdrawal"},e,e)}parseTransactionStatus(e){return this.safeString({COMPLETE:"ok",FAILED:"failed",PENDING:"pending",CANCELLED:"canceled"},e,e)}async loadAccount(e={}){let t;if([t,e]=this.handleOptionAndParams(e,"fetchMyTrades","tradingAccountId"),void 0===t){const i=await this.privateGetV1AccountsTradingAccounts(e);for(let e=0;e1||c)&&(void 0===n&&(n=this.defaultNetworkCode(e)),void 0!==n)){for(let e=0;es?await this.signIn():this.token}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.safeString(n,"errorCode"),l=this.safeString(n,"type");if(void 0!==h&&"0"!==h&&"1001"!==h||void 0!==l&&"HttpInvalidParameterException"===l){let e="";const t=this.safeString(n,"errorCodeName");e=void 0!==t?t:l;const i=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,e,i),this.throwBroadlyMatchedException(this.exceptions.broad,e,i),this.throwExactlyMatchedException(this.exceptions.exact,h,i),new r.ExchangeError(i)}}}},5462:(e,t,i)=>{"use strict";i.d(t,{A:()=>c});var s=i(1293),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(5354);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bybit",name:"Bybit",countries:["VG"],version:"v5",userAgent:void 0,rateLimit:20,hostname:"bybit.com",pro:!0,certified:!0,has:{CORS:!0,spot:!0,margin:!0,swap:!0,future:!0,option:!0,borrowCrossMargin:!0,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,cancelOrdersForSymbols:!0,closeAllPositions:!1,closePosition:!1,createConvertTrade:!0,createMarketBuyOrderWithCost:!0,createMarketSellOrderWithCost:!0,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTrailingAmountOrder:!0,createTriggerOrder:!0,editOrder:!0,editOrders:!0,fetchAllGreeks:!0,fetchBalance:!0,fetchBidsAsks:"emulated",fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrder:!0,fetchClosedOrders:!0,fetchConvertCurrencies:!0,fetchConvertQuote:!0,fetchConvertTrade:!0,fetchConvertTradeHistory:!0,fetchCrossBorrowRate:!0,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingRate:"emulated",fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!0,fetchIndexOHLCV:!0,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!0,fetchLeverageTiers:!0,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyLiquidations:!0,fetchMySettlementHistory:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!0,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!0,fetchOptionChain:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:"emulated",fetchPositions:!0,fetchPositionsHistory:!0,fetchPremiumIndexOHLCV:!0,fetchSettlementHistory:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfers:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!0,fetchWithdrawals:!0,repayCrossMargin:!0,sandbox:!0,setLeverage:!0,setMarginMode:!0,setPositionMode:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","1h":"60","2h":"120","4h":"240","6h":"360","12h":"720","1d":"D","1w":"W","1M":"M"},urls:{test:{spot:"https://api-testnet.{hostname}",futures:"https://api-testnet.{hostname}",v2:"https://api-testnet.{hostname}",public:"https://api-testnet.{hostname}",private:"https://api-testnet.{hostname}"},logo:"https://github.com/user-attachments/assets/97a5d0b3-de10-423d-90e1-6620960025ed",api:{spot:"https://api.{hostname}",futures:"https://api.{hostname}",v2:"https://api.{hostname}",public:"https://api.{hostname}",private:"https://api.{hostname}"},demotrading:{spot:"https://api-demo.{hostname}",futures:"https://api-demo.{hostname}",v2:"https://api-demo.{hostname}",public:"https://api-demo.{hostname}",private:"https://api-demo.{hostname}"},www:"https://www.bybit.com",doc:["https://bybit-exchange.github.io/docs/inverse/","https://bybit-exchange.github.io/docs/linear/","https://github.com/bybit-exchange"],fees:"https://help.bybit.com/hc/en-us/articles/360039261154",referral:"https://www.bybit.com/invite?ref=XDK12WP"},api:{public:{get:{"spot/v3/public/symbols":1,"spot/v3/public/quote/depth":1,"spot/v3/public/quote/depth/merged":1,"spot/v3/public/quote/trades":1,"spot/v3/public/quote/kline":1,"spot/v3/public/quote/ticker/24hr":1,"spot/v3/public/quote/ticker/price":1,"spot/v3/public/quote/ticker/bookTicker":1,"spot/v3/public/server-time":1,"spot/v3/public/infos":1,"spot/v3/public/margin-product-infos":1,"spot/v3/public/margin-ensure-tokens":1,"v3/public/time":1,"contract/v3/public/copytrading/symbol/list":1,"derivatives/v3/public/order-book/L2":1,"derivatives/v3/public/kline":1,"derivatives/v3/public/tickers":1,"derivatives/v3/public/instruments-info":1,"derivatives/v3/public/mark-price-kline":1,"derivatives/v3/public/index-price-kline":1,"derivatives/v3/public/funding/history-funding-rate":1,"derivatives/v3/public/risk-limit/list":1,"derivatives/v3/public/delivery-price":1,"derivatives/v3/public/recent-trade":1,"derivatives/v3/public/open-interest":1,"derivatives/v3/public/insurance":1,"v5/announcements/index":5,"v5/market/time":5,"v5/market/kline":5,"v5/market/mark-price-kline":5,"v5/market/index-price-kline":5,"v5/market/premium-index-price-kline":5,"v5/market/instruments-info":5,"v5/market/orderbook":5,"v5/market/tickers":5,"v5/market/funding/history":5,"v5/market/recent-trade":5,"v5/market/open-interest":5,"v5/market/historical-volatility":5,"v5/market/insurance":5,"v5/market/risk-limit":5,"v5/market/delivery-price":5,"v5/market/account-ratio":5,"v5/spot-lever-token/info":5,"v5/spot-lever-token/reference":5,"v5/spot-margin-trade/data":5,"v5/spot-margin-trade/collateral":5,"v5/spot-cross-margin-trade/data":5,"v5/spot-cross-margin-trade/pledge-token":5,"v5/spot-cross-margin-trade/borrow-token":5,"v5/crypto-loan/collateral-data":5,"v5/crypto-loan/loanable-data":5,"v5/crypto-loan-common/loanable-data":5,"v5/crypto-loan-common/collateral-data":5,"v5/crypto-loan-fixed/supply-order-quote":5,"v5/crypto-loan-fixed/borrow-order-quote":5,"v5/ins-loan/product-infos":5,"v5/ins-loan/ensure-tokens-convert":5,"v5/earn/product":5}},private:{get:{"v5/market/instruments-info":5,"v2/private/wallet/fund/records":25,"spot/v3/private/order":2.5,"spot/v3/private/open-orders":2.5,"spot/v3/private/history-orders":2.5,"spot/v3/private/my-trades":2.5,"spot/v3/private/account":2.5,"spot/v3/private/reference":2.5,"spot/v3/private/record":2.5,"spot/v3/private/cross-margin-orders":10,"spot/v3/private/cross-margin-account":10,"spot/v3/private/cross-margin-loan-info":10,"spot/v3/private/cross-margin-repay-history":10,"spot/v3/private/margin-loan-infos":10,"spot/v3/private/margin-repaid-infos":10,"spot/v3/private/margin-ltv":10,"asset/v3/private/transfer/inter-transfer/list/query":50,"asset/v3/private/transfer/sub-member/list/query":50,"asset/v3/private/transfer/sub-member-transfer/list/query":50,"asset/v3/private/transfer/universal-transfer/list/query":25,"asset/v3/private/coin-info/query":25,"asset/v3/private/deposit/address/query":10,"contract/v3/private/copytrading/order/list":30,"contract/v3/private/copytrading/position/list":40,"contract/v3/private/copytrading/wallet/balance":25,"contract/v3/private/position/limit-info":25,"contract/v3/private/order/unfilled-orders":1,"contract/v3/private/order/list":1,"contract/v3/private/position/list":1,"contract/v3/private/execution/list":1,"contract/v3/private/position/closed-pnl":1,"contract/v3/private/account/wallet/balance":1,"contract/v3/private/account/fee-rate":1,"contract/v3/private/account/wallet/fund-records":1,"unified/v3/private/order/unfilled-orders":1,"unified/v3/private/order/list":1,"unified/v3/private/position/list":1,"unified/v3/private/execution/list":1,"unified/v3/private/delivery-record":1,"unified/v3/private/settlement-record":1,"unified/v3/private/account/wallet/balance":1,"unified/v3/private/account/transaction-log":1,"unified/v3/private/account/borrow-history":1,"unified/v3/private/account/borrow-rate":1,"unified/v3/private/account/info":1,"user/v3/private/frozen-sub-member":10,"user/v3/private/query-sub-members":5,"user/v3/private/query-api":5,"user/v3/private/get-member-type":1,"asset/v3/private/transfer/transfer-coin/list/query":50,"asset/v3/private/transfer/account-coin/balance/query":50,"asset/v3/private/transfer/account-coins/balance/query":25,"asset/v3/private/transfer/asset-info/query":50,"asset/v3/public/deposit/allowed-deposit-list/query":.17,"asset/v3/private/deposit/record/query":10,"asset/v3/private/withdraw/record/query":10,"v5/order/realtime":5,"v5/order/history":5,"v5/order/spot-borrow-check":1,"v5/position/list":5,"v5/execution/list":5,"v5/position/closed-pnl":5,"v5/position/move-history":5,"v5/pre-upgrade/order/history":5,"v5/pre-upgrade/execution/list":5,"v5/pre-upgrade/position/closed-pnl":5,"v5/pre-upgrade/account/transaction-log":5,"v5/pre-upgrade/asset/delivery-record":5,"v5/pre-upgrade/asset/settlement-record":5,"v5/account/wallet-balance":1,"v5/account/borrow-history":1,"v5/account/instruments-info":1,"v5/account/collateral-info":1,"v5/asset/coin-greeks":1,"v5/account/fee-rate":10,"v5/account/info":5,"v5/account/transaction-log":1,"v5/account/contract-transaction-log":1,"v5/account/smp-group":1,"v5/account/mmp-state":5,"v5/account/withdrawal":5,"v5/asset/exchange/query-coin-list":.5,"v5/asset/exchange/convert-result-query":.5,"v5/asset/exchange/query-convert-history":.5,"v5/asset/exchange/order-record":5,"v5/asset/delivery-record":5,"v5/asset/settlement-record":5,"v5/asset/transfer/query-asset-info":50,"v5/asset/transfer/query-account-coins-balance":25,"v5/asset/transfer/query-account-coin-balance":50,"v5/asset/transfer/query-transfer-coin-list":50,"v5/asset/transfer/query-inter-transfer-list":50,"v5/asset/transfer/query-sub-member-list":50,"v5/asset/transfer/query-universal-transfer-list":25,"v5/asset/deposit/query-allowed-list":5,"v5/asset/deposit/query-record":10,"v5/asset/deposit/query-sub-member-record":10,"v5/asset/deposit/query-internal-record":5,"v5/asset/deposit/query-address":10,"v5/asset/deposit/query-sub-member-address":10,"v5/asset/coin/query-info":28,"v5/asset/withdraw/query-address":10,"v5/asset/withdraw/query-record":10,"v5/asset/withdraw/withdrawable-amount":5,"v5/asset/withdraw/vasp/list":5,"v5/asset/convert/small-balance-list":5,"v5/asset/convert/small-balance-history":5,"v5/fiat/query-coin-list":5,"v5/fiat/reference-price":5,"v5/fiat/trade-query":5,"v5/fiat/query-trade-history":5,"v5/fiat/balance-query":5,"v5/user/query-sub-members":5,"v5/user/query-api":5,"v5/user/sub-apikeys":5,"v5/user/get-member-type":5,"v5/user/aff-customer-info":5,"v5/user/del-submember":5,"v5/user/submembers":5,"v5/affiliate/aff-user-list":5,"v5/spot-lever-token/order-record":1,"v5/spot-margin-trade/interest-rate-history":5,"v5/spot-margin-trade/state":5,"v5/spot-margin-trade/max-borrowable":5,"v5/spot-margin-trade/position-tiers":5,"v5/spot-margin-trade/coinstate":5,"v5/spot-margin-trade/repayment-available-amount":5,"v5/spot-margin-trade/get-auto-repay-mode":5,"v5/spot-cross-margin-trade/loan-info":1,"v5/spot-cross-margin-trade/account":1,"v5/spot-cross-margin-trade/orders":1,"v5/spot-cross-margin-trade/repay-history":1,"v5/crypto-loan/borrowable-collateralisable-number":5,"v5/crypto-loan/ongoing-orders":5,"v5/crypto-loan/repayment-history":5,"v5/crypto-loan/borrow-history":5,"v5/crypto-loan/max-collateral-amount":5,"v5/crypto-loan/adjustment-history":5,"v5/crypto-loan-common/max-collateral-amount":10,"v5/crypto-loan-common/adjustment-history":10,"v5/crypto-loan-common/position":10,"v5/crypto-loan-flexible/ongoing-coin":10,"v5/crypto-loan-flexible/borrow-history":10,"v5/crypto-loan-flexible/repayment-history":10,"v5/crypto-loan-fixed/borrow-contract-info":10,"v5/crypto-loan-fixed/supply-contract-info":10,"v5/crypto-loan-fixed/borrow-order-info":10,"v5/crypto-loan-fixed/renew-info":10,"v5/crypto-loan-fixed/supply-order-info":10,"v5/crypto-loan-fixed/repayment-history":10,"v5/ins-loan/product-infos":5,"v5/ins-loan/ensure-tokens-convert":5,"v5/ins-loan/loan-order":5,"v5/ins-loan/repaid-history":5,"v5/ins-loan/ltv-convert":5,"v5/lending/info":5,"v5/lending/history-order":5,"v5/lending/account":5,"v5/broker/earning-record":5,"v5/broker/earnings-info":5,"v5/broker/account-info":5,"v5/broker/asset/query-sub-member-deposit-record":10,"v5/earn/product":5,"v5/earn/order":5,"v5/earn/position":5,"v5/earn/yield":5,"v5/earn/hourly-yield":5},post:{"spot/v3/private/order":2.5,"spot/v3/private/cancel-order":2.5,"spot/v3/private/cancel-orders":2.5,"spot/v3/private/cancel-orders-by-ids":2.5,"spot/v3/private/purchase":2.5,"spot/v3/private/redeem":2.5,"spot/v3/private/cross-margin-loan":10,"spot/v3/private/cross-margin-repay":10,"asset/v3/private/transfer/inter-transfer":150,"asset/v3/private/withdraw/create":300,"asset/v3/private/withdraw/cancel":50,"asset/v3/private/transfer/sub-member-transfer":150,"asset/v3/private/transfer/transfer-sub-member-save":150,"asset/v3/private/transfer/universal-transfer":10,"user/v3/private/create-sub-member":10,"user/v3/private/create-sub-api":10,"user/v3/private/update-api":10,"user/v3/private/delete-api":10,"user/v3/private/update-sub-api":10,"user/v3/private/delete-sub-api":10,"contract/v3/private/copytrading/order/create":30,"contract/v3/private/copytrading/order/cancel":30,"contract/v3/private/copytrading/order/close":30,"contract/v3/private/copytrading/position/close":40,"contract/v3/private/copytrading/position/set-leverage":40,"contract/v3/private/copytrading/wallet/transfer":25,"contract/v3/private/copytrading/order/trading-stop":2.5,"contract/v3/private/order/create":1,"contract/v3/private/order/cancel":1,"contract/v3/private/order/cancel-all":1,"contract/v3/private/order/replace":1,"contract/v3/private/position/set-auto-add-margin":1,"contract/v3/private/position/switch-isolated":1,"contract/v3/private/position/switch-mode":1,"contract/v3/private/position/switch-tpsl-mode":1,"contract/v3/private/position/set-leverage":1,"contract/v3/private/position/trading-stop":1,"contract/v3/private/position/set-risk-limit":1,"contract/v3/private/account/setMarginMode":1,"unified/v3/private/order/create":30,"unified/v3/private/order/replace":30,"unified/v3/private/order/cancel":30,"unified/v3/private/order/create-batch":30,"unified/v3/private/order/replace-batch":30,"unified/v3/private/order/cancel-batch":30,"unified/v3/private/order/cancel-all":30,"unified/v3/private/position/set-leverage":2.5,"unified/v3/private/position/tpsl/switch-mode":2.5,"unified/v3/private/position/set-risk-limit":2.5,"unified/v3/private/position/trading-stop":2.5,"unified/v3/private/account/upgrade-unified-account":2.5,"unified/v3/private/account/setMarginMode":2.5,"fht/compliance/tax/v3/private/registertime":50,"fht/compliance/tax/v3/private/create":50,"fht/compliance/tax/v3/private/status":50,"fht/compliance/tax/v3/private/url":50,"v5/order/create":2.5,"v5/order/amend":5,"v5/order/cancel":2.5,"v5/order/cancel-all":50,"v5/order/create-batch":5,"v5/order/amend-batch":5,"v5/order/cancel-batch":5,"v5/order/disconnected-cancel-all":5,"v5/position/set-leverage":5,"v5/position/switch-isolated":5,"v5/position/set-tpsl-mode":5,"v5/position/switch-mode":5,"v5/position/set-risk-limit":5,"v5/position/trading-stop":5,"v5/position/set-auto-add-margin":5,"v5/position/add-margin":5,"v5/position/move-positions":5,"v5/position/confirm-pending-mmr":5,"v5/account/upgrade-to-uta":5,"v5/account/quick-repayment":5,"v5/account/set-margin-mode":5,"v5/account/set-hedging-mode":5,"v5/account/mmp-modify":5,"v5/account/mmp-reset":5,"v5/account/borrow":5,"v5/account/repay":5,"v5/account/no-convert-repay":5,"v5/asset/exchange/quote-apply":1,"v5/asset/exchange/convert-execute":1,"v5/asset/transfer/inter-transfer":50,"v5/asset/transfer/save-transfer-sub-member":150,"v5/asset/transfer/universal-transfer":10,"v5/asset/deposit/deposit-to-account":5,"v5/asset/withdraw/create":50,"v5/asset/withdraw/cancel":50,"v5/asset/covert/get-quote":10,"v5/asset/covert/small-balance-execute":10,"v5/fiat/quote-apply":10,"v5/fiat/trade-execute":10,"v5/user/create-sub-member":10,"v5/user/create-sub-api":10,"v5/user/frozen-sub-member":10,"v5/user/update-api":10,"v5/user/update-sub-api":10,"v5/user/delete-api":10,"v5/user/delete-sub-api":10,"v5/spot-lever-token/purchase":2.5,"v5/spot-lever-token/redeem":2.5,"v5/spot-margin-trade/switch-mode":5,"v5/spot-margin-trade/set-leverage":5,"v5/spot-margin-trade/set-auto-repay-mode":5,"v5/spot-cross-margin-trade/loan":2.5,"v5/spot-cross-margin-trade/repay":2.5,"v5/spot-cross-margin-trade/switch":2.5,"v5/crypto-loan/borrow":5,"v5/crypto-loan/repay":5,"v5/crypto-loan/adjust-ltv":5,"v5/crypto-loan-common/adjust-ltv":50,"v5/crypto-loan-common/max-loan":10,"v5/crypto-loan-flexible/borrow":50,"v5/crypto-loan-flexible/repay":50,"v5/crypto-loan-flexible/repay-collateral":50,"v5/crypto-loan-fixed/borrow":50,"v5/crypto-loan-fixed/renew":50,"v5/crypto-loan-fixed/supply":50,"v5/crypto-loan-fixed/borrow-order-cancel":50,"v5/crypto-loan-fixed/supply-order-cancel":50,"v5/crypto-loan-fixed/fully-repay":50,"v5/crypto-loan-fixed/repay-collateral":50,"v5/ins-loan/association-uid":5,"v5/ins-loan/repay-loan":5,"v5/lending/purchase":5,"v5/lending/redeem":5,"v5/lending/redeem-cancel":5,"v5/account/set-collateral-switch":5,"v5/account/set-collateral-switch-batch":5,"v5/account/demo-apply-money":5,"v5/broker/award/info":5,"v5/broker/award/distribute-award":5,"v5/broker/award/distribution-record":5,"v5/earn/place-order":5}}},httpExceptions:{403:a.RateLimitExceeded},exceptions:{exact:{"-10009":a.BadRequest,"-1004":a.BadRequest,"-1021":a.BadRequest,"-1103":a.BadRequest,"-1140":a.InvalidOrder,"-1197":a.InvalidOrder,"-2013":a.InvalidOrder,"-2015":a.AuthenticationError,"-6017":a.BadRequest,"-6025":a.BadRequest,"-6029":a.BadRequest,5004:a.ExchangeError,7001:a.BadRequest,10001:a.BadRequest,10002:a.InvalidNonce,10003:a.AuthenticationError,10004:a.AuthenticationError,10005:a.PermissionDenied,10006:a.RateLimitExceeded,10007:a.AuthenticationError,10008:a.AccountSuspended,10009:a.AuthenticationError,10010:a.PermissionDenied,10014:a.BadRequest,10016:a.ExchangeError,10017:a.BadRequest,10018:a.RateLimitExceeded,10020:a.PermissionDenied,10024:a.PermissionDenied,10027:a.PermissionDenied,10028:a.PermissionDenied,10029:a.PermissionDenied,12137:a.InvalidOrder,12201:a.BadRequest,12141:a.BadRequest,100028:a.PermissionDenied,110001:a.OrderNotFound,110003:a.InvalidOrder,110004:a.InsufficientFunds,110005:a.InvalidOrder,110006:a.InsufficientFunds,110007:a.InsufficientFunds,110008:a.InvalidOrder,110009:a.InvalidOrder,110010:a.InvalidOrder,110011:a.InvalidOrder,110012:a.InsufficientFunds,110013:a.BadRequest,110014:a.InsufficientFunds,110015:a.BadRequest,110016:a.InvalidOrder,110017:a.InvalidOrder,110018:a.BadRequest,110019:a.InvalidOrder,110020:a.InvalidOrder,110021:a.InvalidOrder,110022:a.InvalidOrder,110023:a.InvalidOrder,110024:a.BadRequest,110025:a.NoChange,110026:a.MarginModeAlreadySet,110027:a.NoChange,110028:a.BadRequest,110029:a.BadRequest,110030:a.InvalidOrder,110031:a.InvalidOrder,110032:a.InvalidOrder,110033:a.InvalidOrder,110034:a.InvalidOrder,110035:a.InvalidOrder,110036:a.InvalidOrder,110037:a.InvalidOrder,110038:a.InvalidOrder,110039:a.InvalidOrder,110040:a.InvalidOrder,110041:a.InvalidOrder,110042:a.InvalidOrder,110043:a.BadRequest,110044:a.InsufficientFunds,110045:a.InsufficientFunds,110046:a.BadRequest,110047:a.BadRequest,110048:a.BadRequest,110049:a.BadRequest,110050:a.BadRequest,110051:a.InsufficientFunds,110052:a.InsufficientFunds,110053:a.InsufficientFunds,110054:a.InvalidOrder,110055:a.InvalidOrder,110056:a.InvalidOrder,110057:a.InvalidOrder,110058:a.InvalidOrder,110059:a.InvalidOrder,110060:a.BadRequest,110061:a.BadRequest,110062:a.BadRequest,110063:a.ExchangeError,110064:a.InvalidOrder,110065:a.PermissionDenied,110066:a.ExchangeError,110067:a.PermissionDenied,110068:a.PermissionDenied,110069:a.PermissionDenied,110070:a.InvalidOrder,110071:a.ExchangeError,110072:a.InvalidOrder,110073:a.ExchangeError,110092:a.InvalidOrder,110093:a.InvalidOrder,110094:a.InvalidOrder,130006:a.InvalidOrder,130021:a.InsufficientFunds,130074:a.InvalidOrder,131001:a.InsufficientFunds,131084:a.ExchangeError,131200:a.ExchangeError,131201:a.ExchangeError,131202:a.BadRequest,131203:a.BadRequest,131204:a.BadRequest,131205:a.BadRequest,131206:a.ExchangeError,131207:a.BadRequest,131208:a.ExchangeError,131209:a.BadRequest,131210:a.BadRequest,131211:a.BadRequest,131212:a.InsufficientFunds,131213:a.BadRequest,131214:a.BadRequest,131215:a.BadRequest,131216:a.ExchangeError,131217:a.ExchangeError,131231:a.NotSupported,131232:a.NotSupported,131002:a.BadRequest,131003:a.ExchangeError,131004:a.AuthenticationError,131085:a.InsufficientFunds,131086:a.BadRequest,131088:a.BadRequest,131089:a.BadRequest,131090:a.ExchangeError,131091:a.ExchangeError,131092:a.ExchangeError,131093:a.ExchangeError,131094:a.BadRequest,131095:a.BadRequest,131096:a.BadRequest,131097:a.ExchangeError,131098:a.ExchangeError,131099:a.ExchangeError,140001:a.OrderNotFound,140003:a.InvalidOrder,140004:a.InsufficientFunds,140005:a.InvalidOrder,140006:a.InsufficientFunds,140007:a.InsufficientFunds,140008:a.InvalidOrder,140009:a.InvalidOrder,140010:a.InvalidOrder,140011:a.InvalidOrder,140012:a.InsufficientFunds,140013:a.BadRequest,140014:a.InsufficientFunds,140015:a.InvalidOrder,140016:a.InvalidOrder,140017:a.InvalidOrder,140018:a.BadRequest,140019:a.InvalidOrder,140020:a.InvalidOrder,140021:a.InvalidOrder,140022:a.InvalidOrder,140023:a.InvalidOrder,140024:a.BadRequest,140025:a.BadRequest,140026:a.BadRequest,140027:a.BadRequest,140028:a.InvalidOrder,140029:a.BadRequest,140030:a.InvalidOrder,140031:a.BadRequest,140032:a.InvalidOrder,140033:a.InvalidOrder,140034:a.InvalidOrder,140035:a.InvalidOrder,140036:a.BadRequest,140037:a.InvalidOrder,140038:a.BadRequest,140039:a.BadRequest,140040:a.InvalidOrder,140041:a.InvalidOrder,140042:a.InvalidOrder,140043:a.BadRequest,140044:a.InsufficientFunds,140045:a.InsufficientFunds,140046:a.BadRequest,140047:a.BadRequest,140048:a.BadRequest,140049:a.BadRequest,140050:a.InvalidOrder,140051:a.InsufficientFunds,140052:a.InsufficientFunds,140053:a.InsufficientFunds,140054:a.InvalidOrder,140055:a.InvalidOrder,140056:a.InvalidOrder,140057:a.InvalidOrder,140058:a.InvalidOrder,140059:a.InvalidOrder,140060:a.BadRequest,140061:a.BadRequest,140062:a.BadRequest,140063:a.ExchangeError,140064:a.InvalidOrder,140065:a.PermissionDenied,140066:a.ExchangeError,140067:a.PermissionDenied,140068:a.PermissionDenied,140069:a.PermissionDenied,140070:a.InvalidOrder,170001:a.ExchangeError,170005:a.InvalidOrder,170007:a.RequestTimeout,170010:a.InvalidOrder,170011:a.InvalidOrder,170019:a.InvalidOrder,170031:a.ExchangeError,170032:a.ExchangeError,170033:a.InsufficientFunds,170034:a.InsufficientFunds,170035:a.BadRequest,170036:a.BadRequest,170037:a.BadRequest,170105:a.BadRequest,170115:a.InvalidOrder,170116:a.InvalidOrder,170117:a.InvalidOrder,170121:a.InvalidOrder,170124:a.InvalidOrder,170130:a.BadRequest,170131:a.InsufficientFunds,170132:a.InvalidOrder,170133:a.InvalidOrder,170134:a.InvalidOrder,170135:a.InvalidOrder,170136:a.InvalidOrder,170137:a.InvalidOrder,170139:a.InvalidOrder,170140:a.InvalidOrder,170141:a.InvalidOrder,170142:a.InvalidOrder,170143:a.InvalidOrder,170144:a.InvalidOrder,170145:a.InvalidOrder,170146:a.InvalidOrder,170147:a.InvalidOrder,170148:a.InvalidOrder,170149:a.ExchangeError,170150:a.ExchangeError,170151:a.InvalidOrder,170157:a.InvalidOrder,170159:a.InvalidOrder,170190:a.InvalidOrder,170191:a.InvalidOrder,170192:a.InvalidOrder,170193:a.InvalidOrder,170194:a.InvalidOrder,170195:a.InvalidOrder,170196:a.InvalidOrder,170197:a.InvalidOrder,170198:a.InvalidOrder,170199:a.InvalidOrder,170200:a.InvalidOrder,170201:a.PermissionDenied,170202:a.InvalidOrder,170203:a.InvalidOrder,170204:a.InvalidOrder,170206:a.InvalidOrder,170210:a.InvalidOrder,170213:a.OrderNotFound,170217:a.InvalidOrder,170218:a.InvalidOrder,170221:a.BadRequest,170222:a.RateLimitExceeded,170223:a.InsufficientFunds,170224:a.PermissionDenied,170226:a.InsufficientFunds,170227:a.ExchangeError,170228:a.InvalidOrder,170229:a.InvalidOrder,170234:a.ExchangeError,170241:a.ManualInteractionNeeded,170371:a.InvalidOrder,170372:a.InvalidOrder,175e3:a.InvalidOrder,175001:a.InvalidOrder,175002:a.InvalidOrder,175003:a.InsufficientFunds,175004:a.InvalidOrder,175005:a.InvalidOrder,175006:a.InsufficientFunds,175007:a.InvalidOrder,175008:a.InvalidOrder,175009:a.InvalidOrder,175010:a.PermissionDenied,175012:a.InvalidOrder,175013:a.InvalidOrder,175014:a.InvalidOrder,175015:a.InvalidOrder,175016:a.InvalidOrder,175017:a.InvalidOrder,175027:a.ExchangeError,176002:a.BadRequest,176004:a.BadRequest,176003:a.BadRequest,176006:a.BadRequest,176005:a.BadRequest,176008:a.BadRequest,176007:a.BadRequest,176010:a.BadRequest,176009:a.BadRequest,176012:a.BadRequest,176011:a.BadRequest,176014:a.BadRequest,176013:a.BadRequest,176015:a.InsufficientFunds,176016:a.BadRequest,176017:a.BadRequest,176018:a.BadRequest,176019:a.BadRequest,176020:a.BadRequest,176021:a.BadRequest,176022:a.BadRequest,176023:a.BadRequest,176024:a.BadRequest,176025:a.BadRequest,176026:a.BadRequest,176027:a.BadRequest,176028:a.BadRequest,176029:a.BadRequest,176030:a.BadRequest,176031:a.BadRequest,176034:a.BadRequest,176035:a.PermissionDenied,176036:a.PermissionDenied,176037:a.PermissionDenied,176038:a.BadRequest,176039:a.BadRequest,176040:a.BadRequest,181e3:a.BadRequest,181001:a.BadRequest,181002:a.InvalidOrder,181003:a.InvalidOrder,181004:a.InvalidOrder,182e3:a.InvalidOrder,181017:a.BadRequest,20001:a.OrderNotFound,20003:a.InvalidOrder,20004:a.InvalidOrder,20005:a.InvalidOrder,20006:a.InvalidOrder,20007:a.InvalidOrder,20008:a.InvalidOrder,20009:a.InvalidOrder,20010:a.InvalidOrder,20011:a.InvalidOrder,20012:a.InvalidOrder,20013:a.InvalidOrder,20014:a.InvalidOrder,20015:a.InvalidOrder,20016:a.InvalidOrder,20017:a.InvalidOrder,20018:a.InvalidOrder,20019:a.InvalidOrder,20020:a.InvalidOrder,20021:a.InvalidOrder,20022:a.BadRequest,20023:a.BadRequest,20031:a.BadRequest,20070:a.BadRequest,20071:a.BadRequest,20084:a.BadRequest,30001:a.BadRequest,30003:a.InvalidOrder,30004:a.InvalidOrder,30005:a.InvalidOrder,30007:a.InvalidOrder,30008:a.InvalidOrder,30009:a.ExchangeError,30010:a.InsufficientFunds,30011:a.PermissionDenied,30012:a.PermissionDenied,30013:a.PermissionDenied,30014:a.InvalidOrder,30015:a.InvalidOrder,30016:a.ExchangeError,30017:a.InvalidOrder,30018:a.InvalidOrder,30019:a.InvalidOrder,30020:a.InvalidOrder,30021:a.InvalidOrder,30022:a.InvalidOrder,30023:a.InvalidOrder,30024:a.InvalidOrder,30025:a.InvalidOrder,30026:a.InvalidOrder,30027:a.InvalidOrder,30028:a.InvalidOrder,30029:a.InvalidOrder,30030:a.InvalidOrder,30031:a.InsufficientFunds,30032:a.InvalidOrder,30033:a.RateLimitExceeded,30034:a.OrderNotFound,30035:a.RateLimitExceeded,30036:a.ExchangeError,30037:a.InvalidOrder,30041:a.ExchangeError,30042:a.InsufficientFunds,30043:a.InvalidOrder,30044:a.InvalidOrder,30045:a.InvalidOrder,30049:a.InsufficientFunds,30050:a.ExchangeError,30051:a.ExchangeError,30052:a.ExchangeError,30054:a.ExchangeError,30057:a.ExchangeError,30063:a.ExchangeError,30067:a.InsufficientFunds,30068:a.ExchangeError,30074:a.InvalidOrder,30075:a.InvalidOrder,30078:a.ExchangeError,33004:a.AuthenticationError,34026:a.ExchangeError,34036:a.BadRequest,35015:a.BadRequest,340099:a.ExchangeError,3400045:a.ExchangeError,3100116:a.BadRequest,3100198:a.BadRequest,3200300:a.InsufficientFunds},broad:{"Not supported symbols":a.BadSymbol,"Request timeout":a.RequestTimeout,"unknown orderInfo":a.OrderNotFound,"invalid api_key":a.AuthenticationError,oc_diff:a.InsufficientFunds,new_oc:a.InsufficientFunds,"openapi sign params error!":a.AuthenticationError}},precisionMode:r.kb,options:{usePrivateInstrumentsInfo:!1,enableDemoTrading:!1,fetchMarkets:{types:["spot","linear","inverse","option"],options:["BTC","ETH","SOL","XRP","MNT","DOGE"]},enableUnifiedMargin:void 0,enableUnifiedAccount:void 0,unifiedMarginStatus:void 0,createMarketBuyOrderRequiresPrice:!1,createUnifiedMarginAccount:!1,defaultType:"swap",defaultSubType:"linear",defaultSettle:"USDT",code:"BTC",recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,loadAllOptions:!1,loadExpiredOptions:!1,brokerId:"CCXT",accountsByType:{spot:"SPOT",margin:"SPOT",future:"CONTRACT",swap:"CONTRACT",option:"OPTION",investment:"INVESTMENT",unified:"UNIFIED",funding:"FUND",fund:"FUND",contract:"CONTRACT"},accountsById:{SPOT:"spot",MARGIN:"spot",CONTRACT:"contract",OPTION:"option",INVESTMENT:"investment",UNIFIED:"unified",FUND:"fund"},networks:{ERC20:"ETH",TRC20:"TRX",BEP20:"BSC",SOL:"SOL",ACA:"ACA",ADA:"ADA",ALGO:"ALGO",APT:"APTOS",AR:"AR",ARBONE:"ARBI",AVAXC:"CAVAX",AVAXX:"XAVAX",ATOM:"ATOM",BCH:"BCH",BEP2:"BNB",CHZ:"CHZ",DCR:"DCR",DGB:"DGB",DOGE:"DOGE",DOT:"DOT",EGLD:"EGLD",EOS:"EOS",ETC:"ETC",ETHF:"ETHF",ETHW:"ETHW",FIL:"FIL",STEP:"FITFI",FLOW:"FLOW",FTM:"FTM",GLMR:"GLMR",HBAR:"HBAR",HNT:"HNT",ICP:"ICP",ICX:"ICX",KDA:"KDA",KLAY:"KLAY",KMA:"KMA",KSM:"KSM",LTC:"LTC",MATIC:"MATIC",MINA:"MINA",MOVR:"MOVR",NEAR:"NEAR",NEM:"NEM",OASYS:"OAS",OASIS:"ROSE",OMNI:"OMNI",ONE:"ONE",OPTIMISM:"OP",POKT:"POKT",QTUM:"QTUM",RVN:"RVN",SC:"SC",SCRT:"SCRT",STX:"STX",THETA:"THETA",TON:"TON",WAVES:"WAVES",WAX:"WAXP",XDC:"XDC",XEC:"XEC",XLM:"XLM",XRP:"XRP",XTZ:"XTZ",XYM:"XYM",ZEN:"ZEN",ZIL:"ZIL",ZKSYNC:"ZKSYNC"},networksById:{ETH:"ERC20",TRX:"TRC20",BSC:"BEP20",OMNI:"OMNI",SPL:"SOL"},defaultNetwork:"ERC20",defaultNetworks:{USDT:"TRC20"},intervals:{"5m":"5min","15m":"15min","30m":"30min","1h":"1h","4h":"4h","1d":"1d"},useMarkPriceForPositionCollateral:!1},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:{last:!0,mark:!0,index:!0},price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!0,selfTradePrevention:!0,trailing:!0,iceberg:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!0},createOrders:{max:10},fetchMyTrades:{marginMode:!1,limit:100,daysBack:730,untilDays:7,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:50,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:50,daysBack:730,daysBackCanceled:1,untilDays:7,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3},editOrders:{max:10}},spot:{extends:"default",fetchCurrencies:{private:!0},createOrder:{triggerPriceType:void 0,triggerDirection:!1,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!0},marketBuyRequiresPrice:!0}},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:{extends:"default"},inverse:{extends:"default"}}},fees:{trading:{feeSide:"get",tierBased:!0,percentage:!0,taker:75e-5,maker:1e-4},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}}})}enableDemoTrading(e){if(this.isSandboxModeEnabled)throw new a.NotSupported(this.id+" demo trading does not support in sandbox environment");if(e)this.urls.apiBackupDemoTrading=this.urls.api,this.urls.api=this.urls.demotrading;else if("apiBackupDemoTrading"in this.urls){this.urls.api=this.urls.apiBackupDemoTrading;const e=this.omit(this.urls,"apiBackupDemoTrading");this.urls=e}this.options.enableDemoTrading=e}nonce(){return this.milliseconds()-this.options.timeDifference}addPaginationCursorToResult(e){const t=this.safeDict(e,"result",{}),i=this.safeListN(t,["list","rows","data","dataList"],[]),s=this.safeString2(t,"nextPageCursor","cursor"),r=i.length;if(void 0!==s&&r>0){const e=i[0];e.nextPageCursor=s,i[0]=e}return i}async isUnifiedEnabled(e={}){const t=this.safeBool(this.options,"enableUnifiedMargin"),i=this.safeBool(this.options,"enableUnifiedAccount");if(void 0===t||void 0===i){if(this.options.enableDemoTrading)return this.options.enableUnifiedMargin=!1,this.options.enableUnifiedAccount=!0,this.options.unifiedMarginStatus=6,[this.options.enableUnifiedMargin,this.options.enableUnifiedAccount];const t=[this.privateGetV5UserQueryApi(e),this.privateGetV5AccountInfo(e)],i=await Promise.all(t),s=i[0],r=i[1],a=this.safeDict(s,"result",{}),o=this.safeDict(r,"result",{});this.options.enableUnifiedMargin=1===this.safeInteger(a,"unified"),this.options.enableUnifiedAccount=1===this.safeInteger(a,"uta"),this.options.unifiedMarginStatus=this.safeInteger(o,"unifiedMarginStatus",6)}return[this.options.enableUnifiedMargin,this.options.enableUnifiedAccount]}async upgradeUnifiedTradeAccount(e={}){return await this.privatePostV5AccountUpgradeToUta(e)}createExpiredOptionMarket(e){let t,i;const s=e.split("-"),r=e.split("/");let a,o;if(e.indexOf("/")>-1){a=this.safeString(r,0),o=this.safeString(s,1);const e=this.safeString(r,1).split(":"),n=this.safeString(e,0);t=n,i=n}else a=this.safeString(s,0),o=this.convertMarketIdExpireDate(this.safeString(s,1)),e.endsWith("-USDT")?(t="USDT",i="USDT"):(t="USDC",i="USDC");const n=this.safeString(s,2),d=this.safeString(s,3),c=this.convertExpireDate(o),h=this.parse8601(c);let l,u;return"BTC"===a?(l=this.parseNumber("0.01"),u=this.parseNumber("5")):"ETH"===a?(l=this.parseNumber("0.1"),u=this.parseNumber("0.1")):"SOL"===a&&(l=this.parseNumber("1"),u=this.parseNumber("0.01")),{id:a+"-"+this.convertExpireDateToMarketIdDate(o)+"-"+n+"-"+d,symbol:a+"/"+t+":"+i+"-"+o+"-"+n+"-"+d,base:a,quote:t,settle:i,baseId:a,quoteId:t,settleId:i,active:!1,type:"option",linear:void 0,inverse:void 0,spot:!1,swap:!1,future:!1,option:!0,margin:!1,contract:!0,contractSize:this.parseNumber("1"),expiry:h,expiryDatetime:c,optionType:"C"===d?"call":"put",strike:this.parseNumber(n),precision:{amount:l,price:u},limits:{amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:void 0}}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return void 0!==e&&(e.indexOf("-C")>-1||e.indexOf("-P")>-1)&&!(e in this.markets_by_id)?this.createExpiredOptionMarket(e):super.safeMarket(e,t,i,s)}getBybitType(e,t,i={}){let s,r;return[s,i]=this.handleMarketTypeAndParams(e,t,i),[r,i]=this.handleSubTypeAndParams(e,t,i),"option"===s||"spot"===s?[s,i]:[r,i]}getAmount(e,t){const i=void 0===this.market(e).precision.amount,s=this.numberToString(t);return i||"0"===s?s:this.amountToPrecision(e,t)}getPrice(e,t){if(void 0===t)return t;return void 0===this.market(e).precision.price?t:this.priceToPrecision(e,t)}getCost(e,t){return void 0===this.market(e).precision.price?t:this.costToPrecision(e,t)}async fetchTime(e={}){const t=await this.publicGetV5MarketTime(e);return this.safeInteger(t,"time")}async fetchCurrencies(e={}){if(!this.checkRequiredCredentials(!1))return{};if(this.options.enableDemoTrading)return{};const t=await this.privateGetV5AssetCoinQueryInfo(e),i=this.safeDict(t,"result",{}),s=this.safeList(i,"rows",[]),r={};for(let e=0;e1)throw new a.InvalidOrder(this.id+" returned more than one order");return this.safeValue(r,0)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const[s,r]=await this.isUnifiedEnabled();if(!(s||r))return await this.fetchOrderClassic(e,t,i);let o=!1;if([o,i]=this.handleOptionAndParams(i,"fetchOrder","acknowledged"),!o)throw new a.ArgumentsRequired(this.id+' fetchOrder() can only access an order if it is in last 500 orders (of any status) for your account. Set params["acknowledged"] = true to hide this warning. Alternatively, we suggest to use fetchOpenOrder or fetchClosedOrder');const n=this.market(t);let d;[d,i]=this.getBybitType("fetchOrder",n,i);const c={symbol:n.id,orderId:e,category:d};let h;[h,i]=this.handleParamBool2(i,"trigger","stop",!1),h&&(c.orderFilter="StopOrder");const l=await this.privateGetV5OrderRealtime(this.extend(c,i)),u=this.safeDict(l,"result",{}),p=this.safeList(u,"list",[]);if(0===p.length){const t=h?"":' If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';throw new a.OrderNotFound("Order "+e.toString()+" was not found."+t)}const f=this.safeDict(p,0,{});return this.parseOrder(f,n)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){const r=await this.isUnifiedEnabled();if(this.safeBool(r,1))throw new a.NotSupported(this.id+" fetchOrders() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrders, fetchClosedOrders or fetchCanceledOrders");return await this.fetchOrdersClassic(e,t,i,s)}async fetchOrdersClassic(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchOrders","paginate"),r)return await this.fetchPaginatedCallCursor("fetchOrders",e,t,i,s,"nextPageCursor","cursor",void 0,50);const o={};let n,d;if(void 0!==e&&(n=this.market(e),o.symbol=n.id),[d,s]=this.getBybitType("fetchOrders",n,s),"spot"===d)throw new a.NotSupported(this.id+" fetchOrders() is not supported for spot markets");o.category=d;const c=this.safeBoolN(s,["trigger","stop"],!1);s=this.omit(s,["trigger","stop"]),c&&(o.orderFilter="StopOrder"),void 0!==i&&(o.limit=i),void 0!==t&&(o.startTime=t);const h=this.safeInteger(s,"until"),l=this.safeInteger(s,"endTime",h);s=this.omit(s,["endTime","until"]),void 0!==l&&(o.endTime=l);const u=await this.privateGetV5OrderHistory(this.extend(o,s)),p=this.addPaginationCursorToResult(u);return this.parseOrders(p,n,t,i)}async fetchClosedOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderId:e},r=await this.fetchClosedOrders(t,void 0,void 0,this.extend(s,i)),o=r.length;if(0===o){const t=this.safeBoolN(i,["trigger","stop"],!1)?"":' If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';throw new a.OrderNotFound("Order "+e.toString()+" was not found."+t)}if(o>1)throw new a.InvalidOrder(this.id+" returned more than one order");return this.safeValue(r,0)}async fetchOpenOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderId:e},r=await this.fetchOpenOrders(t,void 0,void 0,this.extend(s,i)),o=r.length;if(0===o){const t=this.safeBoolN(i,["trigger","stop"],!1)?"":' If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';throw new a.OrderNotFound("Order "+e.toString()+" was not found."+t)}if(o>1)throw new a.InvalidOrder(this.id+" returned more than one order");return this.safeValue(r,0)}async fetchCanceledAndClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchCanceledAndClosedOrders","paginate"),r)return await this.fetchPaginatedCallCursor("fetchCanceledAndClosedOrders",e,t,i,s,"nextPageCursor","cursor",void 0,50);const a={};let o,n;void 0!==e&&(o=this.market(e),a.symbol=o.id),[n,s]=this.getBybitType("fetchCanceledAndClosedOrders",o,s),a.category=n;const d=this.safeBoolN(s,["trigger","stop"],!1);s=this.omit(s,["trigger","stop"]),d&&(a.orderFilter="StopOrder"),void 0!==i&&(a.limit=i),void 0!==t&&(a.startTime=t);const c=this.safeInteger(s,"until"),h=this.safeInteger(s,"endTime",c);s=this.omit(s,["endTime","until"]),void 0!==h&&(a.endTime=h);const l=await this.privateGetV5OrderHistory(this.extend(a,s)),u=this.addPaginationCursorToResult(l);return this.parseOrders(u,o,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();return await this.fetchCanceledAndClosedOrders(e,t,i,this.extend({orderStatus:"Filled"},s))}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();return await this.fetchCanceledAndClosedOrders(e,t,i,this.extend({orderStatus:"Cancelled"},s))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchOpenOrders","paginate"),r)return await this.fetchPaginatedCallCursor("fetchOpenOrders",e,t,i,s,"nextPageCursor","cursor",void 0,50);const a={};let o,n;if(void 0!==e&&(o=this.market(e),a.symbol=o.id),[n,s]=this.getBybitType("fetchOpenOrders",o,s),"linear"===n||"inverse"===n){const t=this.safeString(s,"baseCoin");if(void 0===e&&void 0===t){const e=this.safeString(this.options,"defaultSettle","USDT"),t=this.safeString(s,"settleCoin",e);a.settleCoin=t}}a.category=n;const d=this.safeBool2(s,"stop","trigger",!1);s=this.omit(s,["stop","trigger"]),d&&(a.orderFilter="StopOrder"),void 0!==i&&(a.limit=i);const c=await this.privateGetV5OrderRealtime(this.extend(a,s)),h=this.addPaginationCursorToResult(c);return this.parseOrders(h,o,t,i)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){const a={},o=this.safeString2(r,"clientOrderId","orderLinkId");return void 0!==o?a.orderLinkId=o:a.orderId=e,r=this.omit(r,["clientOrderId","orderLinkId"]),await this.fetchMyTrades(t,i,s,this.extend(a,r))}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),r)return await this.fetchPaginatedCallCursor("fetchMyTrades",e,t,i,s,"nextPageCursor","cursor",void 0,100);let a,o,n={execType:"Trade"};void 0!==e&&(a=this.market(e),n.symbol=a.id),[o,s]=this.getBybitType("fetchMyTrades",a,s),n.category=o,void 0!==i&&(n.limit=i),void 0!==t&&(n.startTime=t),[n,s]=this.handleUntilOption("endTime",n,s);const d=await this.privateGetV5ExecutionList(this.extend(n,s)),c=this.addPaginationCursorToResult(d);return this.parseTrades(c,a,t,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"addressDeposit"),s=this.safeString(e,"tagDeposit"),r=this.safeString(t,"code");return this.checkAddress(i),{info:e,currency:r,network:this.networkIdToCode(this.safeString(e,"chain"),r),address:i,tag:s}}async fetchDepositAddressesByNetwork(e,t={}){await this.loadMarkets();let i=this.currency(e);const s={coin:i.id};let r;[r,t]=this.handleNetworkCodeAndParams(t),void 0!==r&&(s.chainType=this.networkCodeToId(r,e));const a=await this.privateGetV5AssetDepositQueryAddress(this.extend(s,t)),o=this.safeDict(a,"result",{}),n=this.safeList(o,"chains",[]),d=this.safeString(o,"coin");i=this.currency(d);const c=this.parseDepositAddresses(n,[i.code],!1,{currency:i.code});return this.indexBy(c,"network")}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),[s,r]=this.handleNetworkCodeAndParams(t),a=await this.fetchDepositAddressesByNetwork(e,r);return a[this.selectNetworkCodeFromUnifiedNetworks(i.code,s,a)]}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchDeposits","paginate"),r)return await this.fetchPaginatedCallCursor("fetchDeposits",e,t,i,s,"nextPageCursor","cursor",void 0,50);let a,o={};void 0!==e&&(a=this.currency(e),o.coin=a.id),void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i),[o,s]=this.handleUntilOption("endTime",o,s);const n=await this.privateGetV5AssetDepositQueryRecord(this.extend(o,s)),d=this.addPaginationCursorToResult(n);return this.parseTransactions(d,a,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchWithdrawals","paginate"),r)return await this.fetchPaginatedCallCursor("fetchWithdrawals",e,t,i,s,"nextPageCursor","cursor",void 0,50);let a,o={};void 0!==e&&(a=this.currency(e),o.coin=a.id),void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i),[o,s]=this.handleUntilOption("endTime",o,s);const n=await this.privateGetV5AssetWithdrawQueryRecord(this.extend(o,s)),d=this.addPaginationCursorToResult(n);return this.parseTransactions(d,a,t,i)}parseTransactionStatus(e){return this.safeString({0:"unknown",1:"pending",2:"processing",3:"ok",4:"fail",SecurityCheck:"pending",Pending:"pending",success:"ok",CancelByUser:"canceled",Reject:"rejected",Fail:"failed",BlockchainConfirmed:"ok"},e,e)}parseTransaction(e,t=void 0){const i=this.safeString(e,"coin"),s=this.safeCurrencyCode(i,t),r=this.safeInteger2(e,"createTime","successAt"),a=this.safeInteger(e,"updateTime"),o=this.parseTransactionStatus(this.safeString(e,"status")),n=this.safeNumber2(e,"depositFee","withdrawFee"),d="depositFee"in e?"deposit":"withdrawal";let c;void 0!==n&&(c={cost:n,currency:s});const h=this.safeString(e,"toAddress");return{info:e,id:this.safeString2(e,"id","withdrawId"),txid:this.safeString(e,"txID"),timestamp:r,datetime:this.iso8601(r),network:this.networkIdToCode(this.safeString(e,"chain")),address:void 0,addressTo:h,addressFrom:void 0,tag:this.safeString(e,"tag"),tagTo:void 0,tagFrom:void 0,type:d,amount:this.safeNumber(e,"amount"),currency:s,status:o,updated:a,fee:c,internal:void 0,comment:void 0}}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchLedger","paginate"),r)return await this.fetchPaginatedCallCursor("fetchLedger",e,t,i,s,"nextPageCursor","cursor",void 0,50);const a={},o=await this.isUnifiedEnabled();let n,d,c,h="coin";if(o[1]?(h="currency",void 0!==t&&(a.startTime=t)):void 0!==t&&(a.start_date=this.yyyymmdd(t)),void 0!==e&&(n=this.currency(e),a[h]=n.id),void 0!==i&&(a.limit=i),[d,s]=this.handleSubTypeAndParams("fetchLedger",void 0,s),o[1]){const e=this.safeInteger(this.options,"unifiedMarginStatus",5);c="inverse"===d&&e<5?await this.privateGetV5AccountContractTransactionLog(this.extend(a,s)):await this.privateGetV5AccountTransactionLog(this.extend(a,s))}else c=await this.privateGetV5AccountContractTransactionLog(this.extend(a,s));const l=this.addPaginationCursorToResult(c);return this.parseLedger(l,n,t,i)}parseLedgerEntry(e,t=void 0){const i=this.safeString2(e,"coin","currency"),s=this.safeCurrencyCode(i,t);t=this.safeCurrency(i,t);const r=this.safeString2(e,"amount","change"),a=this.safeString2(e,"wallet_balance","cashBalance"),n=o.Y.stringLt(r,"0")?"out":"in";let d,c,h;if(void 0!==a&&void 0!==r){const e="out"===n?r:o.Y.stringNeg(r);d=this.parseToNumeric(o.Y.stringAdd(a,e)),c=this.parseToNumeric(a),h=this.parseToNumeric(o.Y.stringAbs(r))}let l=this.parse8601(this.safeString(e,"exec_time"));return void 0===l&&(l=this.safeInteger(e,"transactionTime")),this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),direction:n,account:this.safeString(e,"wallet_id"),referenceId:this.safeString(e,"tx_id"),referenceAccount:void 0,type:this.parseLedgerEntryType(this.safeString(e,"type")),currency:s,amount:h,timestamp:l,datetime:this.iso8601(l),before:d,after:c,status:"ok",fee:{currency:s,cost:this.safeNumber(e,"fee")}},t)}parseLedgerEntryType(e){return this.safeString({Deposit:"transaction",Withdraw:"transaction",RealisedPNL:"trade",Commission:"fee",Refund:"cashback",Prize:"prize",ExchangeOrderWithdraw:"transaction",ExchangeOrderDeposit:"transaction",TRANSFER_IN:"transaction",TRANSFER_OUT:"transaction",TRADE:"trade",SETTLEMENT:"trade",DELIVERY:"trade",LIQUIDATION:"trade",BONUS:"Prize",FEE_REFUND:"cashback",INTEREST:"transaction",CURRENCY_BUY:"trade",CURRENCY_SELL:"trade"},e,e)}async withdraw(e,t,i,s=void 0,r={}){let a;[s,r]=this.handleWithdrawTagAndParams(s,r);const o=(await this.isUnifiedEnabled())[1];[a,r]=this.handleOptionAndParams(r,"withdraw","accountType"),void 0===a&&(a=o?"UTA":"SPOT"),await this.loadMarkets(),this.checkAddress(i);const n=this.currency(e),d={coin:n.id,amount:this.numberToString(t),address:i,timestamp:this.milliseconds(),accountType:a};void 0!==s&&(d.tag=s);const[c,h]=this.handleNetworkCodeAndParams(r),l=this.networkCodeToId(c);void 0!==l&&(d.chain=l.toUpperCase());const u=await this.privatePostV5AssetWithdrawCreate(this.extend(d,h)),p=this.safeDict(u,"result",{});return this.parseTransaction(p,n)}async fetchPosition(e,t={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchPosition() requires a symbol argument");await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let r,o;[o,t]=this.getBybitType("fetchPosition",i,t),s.category=o,r=await this.privateGetV5PositionList(this.extend(s,t));const n=this.safeDict(r,"result",{}),d=this.safeList2(n,"list","dataList",[]),c=this.safeInteger(r,"time"),h=this.safeDict(d,0,{}),l=this.parsePosition(h,i);return l.timestamp=c,l.datetime=this.iso8601(c),l}async fetchPositions(e=void 0,t={}){await this.loadMarkets();let i,s=!1;if([s,t]=this.handleOptionAndParams(t,"fetchPositions","paginate"),s)return await this.fetchPaginatedCallCursor("fetchPositions",e,void 0,void 0,t,"nextPageCursor","cursor",void 0,200);if(void 0!==e&&Array.isArray(e)){const t=e.length;if(t>1)throw new a.ArgumentsRequired(this.id+" fetchPositions() does not accept an array with more than one symbol");1===t&&(i=e[0]),e=this.marketSymbols(e)}else void 0!==e&&(i=e,e=[this.symbol(i)]);const r={};let o,n;if(void 0!==i&&(o=this.market(i),i=o.symbol,r.symbol=o.id),[n,t]=this.getBybitType("fetchPositions",o,t),"linear"===n||"inverse"===n){const e=this.safeString(t,"baseCoin");if("linear"===n){if(void 0===i&&void 0===e){const e=this.safeString(this.options,"defaultSettle","USDT"),i=this.safeString(t,"settleCoin",e);r.settleCoin=i}}else void 0===i&&void 0===e&&(r.category="inverse")}void 0===this.safeInteger(t,"limit")&&(r.limit=200),t=this.omit(t,["type"]),r.category=n;const d=await this.privateGetV5PositionList(this.extend(r,t)),c=this.addPaginationCursorToResult(d),h=[];for(let e=0;e0&&(r=this.market(e[0])));const n=this.safeInteger(s,"until");[a,s]=this.handleSubTypeAndParams("fetchPositionsHistory",r,s,"linear"),s=this.omit(s,"until");const d={category:a};void 0!==e&&1===o&&(d.symbol=r.id),void 0!==t&&(d.startTime=t),void 0!==i&&(d.limit=i),void 0!==n&&(d.endTime=n);const c=await this.privateGetV5PositionClosedPnl(this.extend(d,s)),h=this.safeDict(c,"result"),l=this.safeList(h,"list"),u=this.parsePositions(l,e,s);return this.filterBySinceLimit(u,t,i)}async fetchConvertCurrencies(e={}){let t;await this.loadMarkets();const[i,s]=await this.isUnifiedEnabled(),r=i||s?"eb_convert_uta":"eb_convert_spot";[t,e]=this.handleOptionAndParams(e,"fetchConvertCurrencies","accountType",r);const a={accountType:t},o=await this.privateGetV5AssetExchangeQueryCoinList(this.extend(a,e)),n={},d=this.safeDict(o,"result",{}),c=this.safeList(d,"coins",[]);for(let e=0;e=0,t=o.indexOf("unified/v3")>=0,c=o.indexOf("contract/v3")>=0,h=o.indexOf("v5")>=0,l=this.nonce().toString();if(e){a=Object.keys(s).length?this.json(s):"{}";const e=l+this.apiKey+a,t=this.hmac(this.encode(e),this.encode(this.secret),n.s,"hex");r={"Content-Type":"application/json","X-BAPI-API-KEY":this.apiKey,"X-BAPI-TIMESTAMP":l,"X-BAPI-SIGN":t}}else if(t||c||h){r={"Content-Type":"application/json","X-BAPI-API-KEY":this.apiKey,"X-BAPI-TIMESTAMP":l,"X-BAPI-RECV-WINDOW":this.options.recvWindow.toString()},(t||c)&&(r["X-BAPI-SIGN-TYPE"]="2");const e=this.extend({},s),h=this.rawencode(e),u=l.toString()+this.apiKey+this.options.recvWindow.toString();let p,f;"POST"===i?p=u+(a=this.json(e)):(p=u+h,o+="?"+h),f=this.secret.indexOf("PRIVATE KEY")>-1?(0,d.n)(p,this.secret,n.s):this.hmac(this.encode(p),this.encode(this.secret),n.s),r["X-BAPI-SIGN"]=f}else{const e=this.extend(s,{api_key:this.apiKey,recv_window:this.options.recvWindow,timestamp:l}),t=this.keysort(e),c=this.rawencode(t,!0);let h;if(h=this.secret.indexOf("PRIVATE KEY")>-1?(0,d.n)(c,this.secret,n.s):this.hmac(this.encode(c),this.encode(this.secret),n.s),"POST"===i){const t=o.indexOf("spot")>=0,i=this.extend(e,{sign:h});t?(a=this.urlencode(i),r={"Content-Type":"application/x-www-form-urlencoded"}):(a=this.json(i),r={"Content-Type":"application/json"})}else o+="?"+this.rawencode(t,!0),o+="&sign="+h}}if("POST"===i){const e=this.safeString(this.options,"brokerId");void 0!==e&&(r.Referer=e)}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,o,n,d,c){if(!n)return;const h=this.safeString2(n,"ret_code","retCode");if("0"!==h){if("30084"===h)return;let e;throw e="10005"===h&&i.indexOf("order")<0?this.id+' private api uses /user/v3/private/query-api to check if you have a unified account. The API key of user id must own one of permissions: "Account Transfer", "Subaccount Transfer", "Withdrawal" '+o:this.id+" "+o,o.indexOf("Withdraw address chain or destination tag are not equal")>-1&&(e+="; You might also need to ensure the address is whitelisted"),this.throwBroadlyMatchedException(this.exceptions.broad,o,e),this.throwExactlyMatchedException(this.exceptions.exact,h,e),new a.ExchangeError(e)}}}},5e3:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(5439),r=i(2079),a=i(5147),o=i(4852),n=i(1579);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"bydfi",name:"BYDFi",countries:["SG"],rateLimit:50,version:"v1",certified:!1,pro:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!1,cancelOrders:!1,cancelOrdersWithClientOrderId:!1,cancelOrderWithClientOrderId:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createLimitBuyOrder:!1,createLimitOrder:!0,createLimitSellOrder:!1,createMarketBuyOrder:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!0,createMarketOrderWithCost:!1,createMarketSellOrder:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!1,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTrailingAmountOrder:!1,createTrailingPercentOrder:!0,createTriggerOrder:!1,deposit:!1,editOrder:!0,editOrders:!0,editOrderWithClientOrderId:!0,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL2OrderBook:!0,fetchL3OrderBook:!1,fetchLastPrices:!1,fetchLedger:!1,fetchLedgerEntry:!1,fetchLeverage:!0,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrdersByStatus:!1,fetchOrderTrades:!1,fetchOrderWithClientOrderId:!1,fetchPosition:!1,fetchPositionHistory:!0,fetchPositionMode:!0,fetchPositions:!0,fetchPositionsForSymbol:!0,fetchPositionsHistory:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawAddresses:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!0,signIn:!1,transfer:!0,watchMyLiquidationsForSymbols:!1,withdraw:!1,ws:!0},urls:{logo:"https://github.com/user-attachments/assets/bfffb73d-29bd-465d-b75b-98e210491769",api:{public:"https://api.bydfi.com/api",private:"https://api.bydfi.com/api"},www:"https://bydfi.com/",doc:"https://developers.bydfi.com/en/",referral:"https://partner.bydfi.com/j/DilWutCI"},fees:{},api:{public:{get:{"v1/public/api_limits":1,"v1/swap/market/exchange_info":1,"v1/swap/market/depth":1,"v1/swap/market/trades":1,"v1/swap/market/klines":1,"v1/swap/market/ticker/24hr":1,"v1/swap/market/ticker/price":1,"v1/swap/market/mark_price":1,"v1/swap/market/funding_rate":1,"v1/swap/market/funding_rate_history":1,"v1/swap/market/risk_limit":1}},private:{get:{"v1/account/assets":1,"v1/account/transfer_records":1,"v1/spot/deposit_records":1,"v1/spot/withdraw_records":1,"v1/swap/trade/open_order":1,"v1/swap/trade/plan_order":1,"v1/swap/trade/leverage":1,"v1/swap/trade/history_order":1,"v1/swap/trade/history_trade":1,"v1/swap/trade/position_history":1,"v1/swap/trade/positions":1,"v1/swap/account/balance":1,"v1/swap/user_data/assets_margin":1,"v1/swap/user_data/position_side/dual":1,"v1/agent/teams":1,"v1/agent/agent_links":1,"v1/agent/regular_overview":1,"v1/agent/agent_sub_overview":1,"v1/agent/partener_user_deposit":1,"v1/agent/partener_users_data":1,"v1/agent/affiliate_uids":1,"v1/agent/affiliate_commission":1,"v1/agent/internal_withdrawal_status":1},post:{"v1/account/transfer":1,"v1/swap/trade/place_order":1,"v1/swap/trade/batch_place_order":1,"v1/swap/trade/edit_order":1,"v1/swap/trade/batch_edit_order":1,"v1/swap/trade/cancel_all_order":1,"v1/swap/trade/leverage":1,"v1/swap/trade/batch_leverage_margin":1,"v1/swap/user_data/margin_type":1,"v1/swap/user_data/position_side/dual":1,"v1/agent/internal_withdrawal":1}}},features:{spot:void 0,swap:{linear:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:{mark:!0,last:!0,index:!1},stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!0,selfTradePrevention:!1,trailing:!0,iceberg:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!1},createOrders:{max:5},fetchMyTrades:{marginMode:!1,daysBack:182,limit:500,untilDays:7,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchCanceledAndClosedOrders:{marginMode:!1,limit:500,daysBack:182,untilDays:7,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:void 0,fetchOHLCV:{limit:500}},inverse:void 0},future:{linear:void 0,inverse:void 0}},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d"},precisionMode:n.kb,exceptions:{exact:{101001:r.AuthenticationError,101103:r.AuthenticationError,102001:r.BadRequest,102002:r.PermissionDenied,401:r.AuthenticationError,500:r.ExchangeError,501:r.ExchangeError,506:r.ExchangeError,510:r.RateLimitExceeded,511:r.AuthenticationError,513:r.BadRequest,514:r.BadRequest,600:r.BadRequest,"Position does not exist":r.BadRequest,"Requires transaction permissions":r.PermissionDenied,"Service error":r.ExchangeError,"transfer failed":r.InsufficientFunds},broad:{"is missing":r.ArgumentsRequired}},commonCurrencies:{},options:{networks:{ERC20:"ETH"},timeInForce:{GTC:"GTC",FOK:"FOK",IOC:"IOC",PO:"POST_ONLY"},accountsByType:{spot:"SPOT",swap:"SWAP",funding:"FUND"},accountsById:{SPOT:"spot",SWAP:"swap",FUND:"funding"}}})}async fetchMarkets(e={}){const t=await this.publicGetV1SwapMarketExchangeInfo(e),i=this.safeList(t,"data",[]);return this.parseMarkets(i)}parseMarket(e){const t=this.safeString(e,"symbol"),i=this.safeString(e,"baseAsset"),s=this.safeString(e,"quoteAsset"),r=this.safeString(e,"marginAsset"),o=this.safeCurrencyCode(i),n=this.safeCurrencyCode(s),d=this.safeCurrencyCode(r),c=o+"/"+n+":"+d,h=this.safeBool(e,"reverse"),l=this.safeString(e,"limitMaxQty"),u=this.safeString(e,"marketMaxQty"),p=a.Y.stringMax(l,u),f=this.safeString(e,"marketMinQty"),m=this.safeString(e,"limitMinQty"),g=a.Y.stringMin(f,m),v=this.safeString(e,"contractFactor"),y=this.parsePrecision(this.safeString(e,"priceOrderPrecision")),b=this.parsePrecision(this.safeString(e,"volumePrecision")),w=a.Y.stringDiv(b,v),k=this.parsePrecision(this.safeString(e,"basePrecision")),S=this.safeNumber(e,"feeRateTaker"),O=this.safeNumber(e,"feeRateMaker"),T=this.safeNumber(e,"maxLeverageLevel"),P=this.safeString(e,"status");return this.safeMarketStructure({id:t,symbol:c,base:o,quote:n,settle:d,baseId:i,quoteId:s,settleId:r,type:"swap",spot:!1,margin:void 0,swap:!0,future:!1,option:!1,active:"NORMAL"===P,contract:!0,linear:!h,inverse:h,taker:S,maker:O,contractSize:this.parseNumber(v),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(w),price:this.parseNumber(y),base:this.parseNumber(k)},limits:{leverage:{min:void 0,max:T},amount:{min:this.parseNumber(g),max:this.parseNumber(p)},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:this.parse8601(this.safeString(e,"createdAt")),info:e})}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={symbol:s.id};void 0!==t&&(r.limit=this.getClosestLimit(t));const a=await this.publicGetV1SwapMarketDepth(this.extend(r,i)),o=this.safeDict(a,"data",{}),n=this.milliseconds(),d=this.parseOrderBook(o,s.symbol,n,"bids","asks","price","amount");return d.nonce=this.safeInteger(o,"lastUpdateId"),d}getClosestLimit(e){const t=[5,10,20,50,100,500,1e3];let i=1e3;for(let s=0;su&&(l=u)):void 0===c&&(c=l-p),d.startTime=c,d.endTime=l,void 0!==s&&(d.limit=s);const f=await this.publicGetV1SwapMarketKlines(this.extend(d,r)),m=this.safeList(f,"data",[]);return this.parseOHLCVs(m,o,t,i,s)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,"t"),this.safeNumber(e,"o"),this.safeNumber(e,"h"),this.safeNumber(e,"l"),this.safeNumber(e,"c"),this.safeNumber(e,"v")]}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i=await this.publicGetV1SwapMarketTicker24hr(t),s=this.safeList(i,"data",[]);return this.parseTickers(s,e)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.publicGetV1SwapMarketTicker24hr(this.extend(s,t)),a=this.safeList(r,"data",[]),o=this.safeDict(a,0,{});return this.parseTicker(o,i)}parseTicker(e,t=void 0){const i=this.safeString2(e,"symbol","s");t=this.safeMarket(i,t);const s=this.safeInteger2(e,"time","E"),r=this.safeString2(e,"last","c");return this.safeTicker({symbol:this.safeSymbol(i,t),timestamp:s,datetime:this.iso8601(s),high:this.safeString2(e,"high","h"),low:this.safeString2(e,"low","l"),bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:void 0,open:this.safeString2(e,"open","o"),close:r,last:r,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:this.safeString2(e,"vol","v"),quoteVolume:void 0,markPrice:void 0,indexPrice:void 0,info:e},t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.publicGetV1SwapMarketFundingRate(this.extend(s,t)),a=this.safeDict(r,"data");return this.parseFundingRate(a,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t),r=this.safeInteger(e,"time"),a=this.safeInteger(e,"nextFundingTime");return{info:e,symbol:s,markPrice:void 0,indexPrice:void 0,interestRate:void 0,estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.safeNumber(e,"lastFundingRate"),fundingTimestamp:void 0,fundingDatetime:void 0,nextFundingRate:void 0,nextFundingTimestamp:a,nextFundingDatetime:this.iso8601(a),previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:void 0}}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={symbol:a.id};let n;void 0!==t&&(o.startTime=t),void 0!==i&&(o.limit=i),[n,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","until"),void 0!==n&&(o.endTime=n);const d=await this.publicGetV1SwapMarketFundingRateHistory(this.extend(o,s)),c=this.safeList(d,"data",[]);return this.parseFundingRateHistories(c,a,t,i)}parseFundingRateHistory(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeInteger(e,"fundingTime");return{info:e,symbol:this.safeSymbol(i,t),fundingRate:this.safeNumber(e,"fundingRate"),timestamp:s,datetime:this.iso8601(s)}}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e);let n=this.createOrderRequest(e,t,i,s,r,a),d="W001";[d,a]=this.handleOptionAndParams(a,"createOrder","wallet",d),n=this.extend(n,{wallet:d});const c=await this.privatePostV1SwapTradePlaceOrder(n),h=this.safeDict(c,"data",{});return this.parseOrder(h,o)}createOrderRequest(e,t,i,s,a=void 0,o={}){const n={symbol:this.market(e).id,side:i.toUpperCase()},d=this.safeString(o,"stopLossPrice"),c=void 0!==d,h=this.safeString(o,"takeProfitPrice"),l=void 0!==h,u=this.safeString(o,"trailingPercent"),p=void 0!==u;let f;if(c||l)f=c?d:h,o=this.omit(o,["stopLossPrice","takeProfitPrice"]),n.stopPrice=this.priceToPrecision(e,f);else if(p){o=this.omit(o,["trailingPercent"]),n.callbackRate=u;let t=this.numberToString(a);[t,o]=this.handleParamString(o,"trailingTriggerPrice",t),void 0!==t&&(n.activationPrice=this.priceToPrecision(e,t),o=this.omit(o,["trailingTriggerPrice"]))}const m="MARKET"===(t=t.toUpperCase())||"STOP_MARKET"===t||"TAKE_PROFIT_MARKET"===t||"TRAILING_STOP_MARKET"===t;if(m)"MARKET"===t&&(c?t="STOP_MARKET":l?t="TAKE_PROFIT_MARKET":p&&(t="TRAILING_STOP_MARKET"));else{if(void 0===a)throw new r.ArgumentsRequired(this.id+" createOrder() requires a price argument for a "+t+" order");n.price=this.priceToPrecision(e,a),c?t="STOP":l&&(t="TAKE_PROFIT")}n.type=t;let g=!1;[g,o]=this.handleOptionAndParams(o,"createOrder","hedged",g);const v=this.safeBool(o,"reduceOnly",!1);g&&(o=this.omit(o,"reduceOnly"),"buy"===i?n.positionSide=v?"SHORT":"LONG":"sell"===i&&(n.positionSide=v?"LONG":"SHORT"));if(this.safeBool(o,"closePosition",!1)){if("STOP_MARKET"!==t&&"TAKE_PROFIT_MARKET"!==t)throw new r.NotSupported(this.id+" createOrder() closePosition is only supported for stopLoss and takeProfit market orders")}else o=this.omit(o,"closePosition"),n.quantity=this.amountToPrecision(e,s);let y=this.handleTimeInForce(o),b=!1;if([b,o]=this.handlePostOnly(m,"POST_ONLY"===y,o),b&&(y="POST_ONLY"),void 0!==y&&(n.timeInForce=y,o=this.omit(o,"timeInForce")),c||l||p){let e="CONTRACT_PRICE";[e,o]=this.handleOptionAndParams(o,"createOrder","triggerPriceType",e),n.workingType=this.encodeWorkingType(e)}return this.extend(n,o)}encodeWorkingType(e){return this.safeString({markPrice:"MARK_PRICE",mark:"MARK_PRICE",contractPrice:"CONTRACT_PRICE",contract:"CONTRACT_PRICE",last:"CONTRACT_PRICE"},e,e)}async createOrders(e,t={}){await this.loadMarkets();if(e.length>5)throw new r.BadRequest(this.id+" createOrders() accepts a maximum of 5 orders");const i=[];for(let t=0;t5)throw new r.BadRequest(this.id+" editOrders() accepts a maximum of 5 orders");const i=[];for(let t=0;ta?o+a:r}const n={startTime:o,endTime:s};return this.extend(n,i)}parseOrder(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);const s=this.safeInteger2(e,"createTime","ctime"),r=this.safeString(e,"orderType"),a=this.safeStringN(e,["stopPrice","activatePrice","triggerPrice"]),o="STOP"===r||"STOP_MARKET"===r||"TRAILING_STOP_MARKET"===r,n="TAKE_PROFIT"===r||"TAKE_PROFIT_MARKET"===r,d=this.safeString(e,"timeInForce"),c=this.parseOrderTimeInForce(d);let h;"PO"===c&&(h=!0);const l=this.safeString(e,"status"),u={},p=this.safeNumber(e,"quoteFee");return void 0!==p&&(u.cost=p,u.currency=t.quote),this.safeOrder({info:e,id:this.safeString(e,"orderId"),clientOrderId:this.safeString(e,"clientOrderId"),timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,lastUpdateTimestamp:this.safeInteger2(e,"updateTime","mtime"),status:this.parseOrderStatus(l),symbol:t.symbol,type:this.parseOrderType(r),timeInForce:c,postOnly:h,reduceOnly:this.safeBool(e,"reduceOnly"),side:this.safeStringLower(e,"side"),price:this.safeString(e,"price"),triggerPrice:a,stopLossPrice:o?a:void 0,takeProfitPrice:n?a:void 0,amount:this.safeString(e,"origQty"),filled:this.safeString(e,"executedQty"),remaining:void 0,cost:void 0,trades:void 0,fee:u,average:this.omitZero(this.safeString(e,"avgPrice"))},t)}parseOrderType(e){return this.safeString({LIMIT:"limit",MARKET:"market",STOP:"limit",STOP_MARKET:"market",TAKE_PROFIT:"limit",TAKE_PROFIT_MARKET:"market",TRAILING_STOP_MARKET:"market"},e,e)}parseOrderTimeInForce(e){return this.safeString({GTC:"GTC",FOK:"FOK",IOC:"IOC",POST_ONLY:"PO",TRAILING_STOP:"IOC"},e,e)}parseOrderStatus(e){return this.safeString({NEW:"open",PARTIALLY_FILLED:"open",FILLED:"closed",EXPIRED:"canceled",PART_FILLED_CANCELLED:"canceled",CANCELED:"canceled",2:"closed",4:"canceled"},e,e)}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");await this.loadMarkets();const s=this.market(t);let a="W001";[a,i]=this.handleOptionAndParams(i,"setLeverage","wallet",a);const o={symbol:s.id,leverage:e,wallet:a},n=await this.privatePostV1SwapTradeLeverage(this.extend(o,i));return this.safeDict(n,"data",{})}async fetchLeverage(e,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchLeverage() requires a symbol argument");await this.loadMarkets();const i=this.market(e);let s="W001";[s,t]=this.handleOptionAndParams(t,"fetchLeverage","wallet",s);const a={symbol:i.id,wallet:s},o=await this.privateGetV1SwapTradeLeverage(this.extend(a,t)),n=this.safeDict(o,"data",{});return this.parseLeverage(n,i)}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),marginMode:void 0,longLeverage:this.safeInteger(e,"leverage"),shortLeverage:this.safeInteger(e,"leverage")}}async fetchPositions(e=void 0,t={}){await this.loadMarkets();let i="FUTURE";[i,t]=this.handleOptionAndParams(t,"fetchPositions","contractType",i);const s={contractType:i},r=await this.privateGetV1SwapTradePositions(this.extend(s,t)),a=this.safeList(r,"data",[]);return this.parsePositions(a,e)}async fetchPositionsForSymbol(e,t={}){await this.loadMarkets();const i=this.market(e);let s="FUTURE";[s,t]=this.handleOptionAndParams(t,"fetchPositions","contractType",s);const r={contractType:s,symbol:i.id},a=await this.privateGetV1SwapTradePositions(this.extend(r,t)),o=this.safeList(a,"data",[]);return this.parsePositions(o,[i.symbol])}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);const s=this.safeString(e,"side"),r=this.safeStringLower(e,"positionSide");let o,n=this.parsePositionSide(s),d=!1;void 0!==r&&(d=!0,"both"!==r?(n=r,o=!0):o=!1);const c=this.safeString(t,"contractSize");let h=this.safeString2(e,"volume","openPositionVolume");d||(h=a.Y.stringDiv(h,c));const l=this.safeInteger(e,"createTime");return this.safePosition({info:e,id:this.safeString(e,"id"),symbol:t.symbol,entryPrice:this.parseNumber(this.safeString2(e,"avgOpenPositionPrice","avgPrice")),markPrice:this.parseNumber(this.safeString(e,"markPrice")),lastPrice:this.parseNumber(this.safeString(e,"avgClosePositionPrice")),notional:this.parseNumber(this.safeString(e,"closePositionCost")),collateral:void 0,unrealizedPnl:this.parseNumber(this.safeString(e,"unPnl")),realizedPnl:this.parseNumber(this.safeString(e,"positionProfits")),side:n,contracts:this.parseNumber(h),contractSize:this.parseNumber(c),timestamp:l,datetime:this.iso8601(l),lastUpdateTimestamp:this.safeInteger(e,"updateTime"),hedged:o,maintenanceMargin:this.parseNumber(this.safeString(e,"mm")),maintenanceMarginPercentage:void 0,initialMargin:this.parseNumber(this.safeString(e,"im")),initialMarginPercentage:void 0,leverage:this.parseNumber(this.safeString(e,"leverage")),liquidationPrice:this.parseNumber(this.safeString(e,"liqPrice")),marginRatio:void 0,marginMode:void 0,percentage:void 0})}parsePositionSide(e){return this.safeString({BUY:"long",SELL:"short"},e,e)}async fetchPositionHistory(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e);let a="FUTURE";[a,s]=this.handleOptionAndParams(s,"fetchPositionsHistory","contractType",a);const o={symbol:r.id,contractType:a};s=this.handleSinceAndUntil("fetchPositionsHistory",t,s),void 0!==i&&(o.limit=i);const n=await this.privateGetV1SwapTradePositionHistory(this.extend(o,s)),d=this.safeList(n,"data",[]),c=this.parsePositions(d);return this.filterBySinceLimit(c,t,i)}async fetchPositionsHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r="FUTURE";[r,s]=this.handleOptionAndParams(s,"fetchPositionsHistory","contractType",r);const a={contractType:r};s=this.handleSinceAndUntil("fetchPositionsHistory",t,s),void 0!==i&&(a.limit=i);const o=await this.privateGetV1SwapTradePositionHistory(this.extend(a,s)),n=this.safeList(o,"data",[]),d=this.parsePositions(n,e);return this.filterBySinceLimit(d,t,i)}async fetchMarginMode(e,t={}){await this.loadMarkets();const i=this.market(e);let s="FUTURE";[s,t]=this.handleOptionAndParams(t,"fetchMarginMode","contractType",s);let r="W001";[r,t]=this.handleOptionAndParams(t,"fetchMarginMode","wallet",r);const a={contractType:s,symbol:i.id,wallet:r},o=await this.privateGetV1SwapUserDataAssetsMargin(this.extend(a,t)),n=this.safeDict(o,"data",{});return this.parseMarginMode(n,i)}parseMarginMode(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),marginMode:this.safeStringLower(e,"marginType")}}async setMarginMode(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setMarginMode() requires a symbol argument");if("isolated"!==(e=e.toLowerCase())&&"cross"!==e)throw new r.BadRequest(this.id+" setMarginMode() marginMode argument should be isolated or cross");await this.loadMarkets();const s=this.market(t);let a="FUTURE";[a,i]=this.handleOptionAndParams(i,"fetchMarginMode","contractType",a);let o="W001";[o,i]=this.handleOptionAndParams(i,"fetchMarginMode","wallet",o);const n={contractType:a,symbol:s.id,marginType:e.toUpperCase(),wallet:o};return await this.privatePostV1SwapUserDataMarginType(this.extend(n,i))}async setPositionMode(e,t=void 0,i={}){if(void 0!==t)throw new r.NotSupported(this.id+" setPositionMode() does not support a symbol argument. The position mode is set identically for all markets with same settle currency");await this.loadMarkets();const s=e?"HEDGE":"ONEWAY";let a="W001";[a,i]=this.handleOptionAndParams(i,"setPositionMode","wallet",a);let o="FUTURE";[o,i]=this.handleOptionAndParams(i,"setPositionMode","contractType",o);let n="USDT";[n,i]=this.handleOptionAndParams(i,"setPositionMode","settleCoin",n);const d={contractType:o,wallet:a,positionType:s,settleCoin:n};return await this.privatePostV1SwapUserDataPositionSideDual(this.extend(d,i))}async fetchPositionMode(e=void 0,t={}){await this.loadMarkets();let i="W001";[i,t]=this.handleOptionAndParams(t,"fetchPositionMode","wallet",i);let s="FUTURE";[s,t]=this.handleOptionAndParams(t,"fetchPositionMode","contractType",s);let r="USDT";if(void 0===e)[r,t]=this.handleOptionAndParams(t,"fetchPositionMode","settleCoin",r);else{r=this.market(e).settleId}const a={contractType:s,settleCoin:r,wallet:i},o=await this.privateGetV1SwapUserDataPositionSideDual(this.extend(a,t)),n=this.safeDict(o,"data",{});return{info:o,hedged:"HEDGE"===this.safeString(n,"positionType")}}async fetchBalance(e={}){await this.loadMarkets();let t="spot";[t,e]=this.handleOptionAndParams2(e,"fetchBalance","accountType","type",t);const i={};let s;if("swap"!==t){const r=this.safeDict(this.options,"accountsByType",{}),a=this.safeString(r,t,t);i.walletType=a,s=await this.privateGetV1AccountAssets(this.extend(i,e))}else{let t="W001";[t,e]=this.handleOptionAndParams(e,"fetchBalance","wallet",t),i.wallet=t,s=await this.privateGetV1SwapAccountBalance(this.extend(i,e))}const r=this.safeList(s,"data",[]);return this.parseBalance(r)}parseBalance(e){const t=this.milliseconds(),i={info:e,timestamp:t,datetime:this.iso8601(t)};for(let t=0;tl?p+l:h}d.startTime=p,d.endTime=c,void 0!==s&&(d.limit=s),u="deposit"===e?await this.privateGetV1SpotDepositRecords(this.extend(d,a)):await this.privateGetV1SpotWithdrawRecords(this.extend(d,a));const f=this.safeList(u,"data",[]),m={type:e};return a=this.extend(a,m),this.parseTransactions(f,n,i,s,a)}parseTransaction(e,t=void 0){const i=this.safeString(e,"asset"),s=this.safeCurrencyCode(i,t),r=this.safeStringLower(e,"status"),a=this.safeInteger(e,"createTime");let o;const n=this.safeNumber(e,"fee");return void 0!==n&&(o={cost:n,currency:void 0}),{info:e,id:this.safeString(e,"orderId"),txid:this.safeString(e,"txId"),type:void 0,currency:s,network:this.networkIdToCode(this.safeString(e,"network")),amount:this.safeNumber(e,"amount"),status:this.parseTransactionStatus(r),timestamp:a,datetime:this.iso8601(a),address:this.safeString(e,"address"),addressFrom:void 0,addressTo:void 0,tag:this.safeString(e,"addressTag"),tagFrom:void 0,tagTo:void 0,updated:this.safeInteger(e,"finishTime"),comment:void 0,fee:o,internal:!1}}parseTransactionStatus(e){return this.safeString({success:"ok",wait:"pending",failed:"failed"},e,e)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let n=this.urls.api[t],d="/"+e,c="";const h=this.keysort(s);if("GET"===i&&(c=this.urlencode(h),0!==c.length&&(d+="?"+c)),"private"===t){this.checkRequiredCredentials();const e=this.milliseconds().toString();if("GET"===i){const t=this.apiKey+e+c,i=this.hmac(this.encode(t),this.encode(this.secret),o.s,"hex");r={"X-API-KEY":this.apiKey,"X-API-TIMESTAMP":e,"X-API-SIGNATURE":i}}else{a=this.json(h);const t=this.apiKey+e+a,i=this.hmac(this.encode(t),this.encode(this.secret),o.s,"hex");r={"Content-Type":"application/json","X-API-KEY":this.apiKey,"X-API-TIMESTAMP":e,"X-API-SIGNATURE":i}}}return n+=d,{url:n,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.safeString(n,"code"),l=this.safeString(n,"message");if("200"!==h){const e=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwBroadlyMatchedException(this.exceptions.broad,l,e),this.throwExactlyMatchedException(this.exceptions.exact,h,e),new r.ExchangeError(e)}}}},8846:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(5465),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"cex",name:"CEX.IO",countries:["GB","EU","CY","RU"],rateLimit:300,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopOrder:!0,createTriggerOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrder:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFees:!0,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpg",api:{public:"https://trade.cex.io/api/spot/rest-public",private:"https://trade.cex.io/api/spot/rest"},www:"https://cex.io",doc:"https://trade.cex.io/docs/",fees:["https://cex.io/fee-schedule","https://cex.io/limits-commissions"],referral:"https://cex.io/r/0/up105393824/0/"},api:{public:{get:{},post:{get_server_time:1,get_pairs_info:1,get_currencies_info:1,get_processing_info:10,get_ticker:1,get_trade_history:1,get_order_book:1,get_candles:1}},private:{get:{},post:{get_my_current_fee:5,get_fee_strategy:1,get_my_volume:5,do_create_account:1,get_my_account_status_v3:5,get_my_wallet_balance:5,get_my_orders:5,do_my_new_order:1,do_cancel_my_order:1,do_cancel_all_orders:5,get_order_book:1,get_candles:1,get_trade_history:1,get_my_transaction_history:1,get_my_funding_history:5,do_my_internal_transfer:1,get_processing_info:10,get_deposit_address:5,do_deposit_funds_from_wallet:1,do_withdrawal_funds_to_wallet:1}}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!0},hedged:!1,leverage:!1,marketBuyRequiresPrice:!1,marketBuyByCost:!0,selfTradePrevention:!1,trailing:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{},broad:{"You have negative balance on following accounts":r.InsufficientFunds,"Mandatory parameter side should be one of BUY,SELL":r.BadRequest,"API orders from Main account are not allowed":r.BadRequest,"check failed":r.BadRequest,"Insufficient funds":r.InsufficientFunds,"Get deposit address for main account is not allowed":r.PermissionDenied,"Market Trigger orders are not allowed":r.BadRequest,"key not passed or incorrect":r.AuthenticationError}},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","1d":"1d"},options:{networks:{BTC:"bitcoin",ERC20:"ERC20",BSC20:"binancesmartchain",DOGE:"dogecoin",ALGO:"algorand",XLM:"stellar",ATOM:"cosmos",LTC:"litecoin",XRP:"ripple",FTM:"fantom",MINA:"mina",THETA:"theta",XTZ:"tezos",TIA:"celestia",CRONOS:"cronos",MATIC:"polygon",TON:"ton",TRC20:"tron",SOLANA:"solana",SGB:"songbird",DYDX:"dydx",DASH:"dash",ZIL:"zilliqa",EOS:"eos",AVALANCHEC:"avalanche",ETHPOW:"ethereumpow",NEAR:"near",ARB:"arbitrum",DOT:"polkadot",OPT:"optimism",INJ:"injective",ADA:"cardano",ONT:"ontology",ICP:"icp",KAVA:"kava",KSM:"kusama",SEI:"sei",NEO:"neo",NEO3:"neo3",XDC:"xdc"}}})}async fetchCurrencies(e={}){const t=[];t.push(this.publicPostGetCurrenciesInfo(e)),t.push(this.publicPostGetProcessingInfo(e));const i=await Promise.all(t),s=this.safeList(i[0],"data",[]),r=this.safeDict(i[1],"data",{}),a=this.indexBy(s,"currency"),o=this.deepExtend(a,r);return this.parseCurrencies(this.toArray(o))}parseCurrency(e){const t=this.safeString(e,"currency"),i=this.safeCurrencyCode(t),s=this.safeBool(e,"fiat")?"fiat":"crypto",r=this.parseNumber(this.parsePrecision(this.safeString(e,"precision"))),a={},o=this.safeDict(e,"blockchains",{}),n=Object.keys(o);for(let e=0;e=0){const e=this.safeDict(n,"data",{}),t=this.safeString(e,"rejectReason");if(void 0!==t)throw this.throwBroadlyMatchedException(this.exceptions.broad,t,t),new r.ExchangeError(this.id+" createOrder() "+t)}}}},7504:(e,t,i)=>{"use strict";i.d(t,{A:()=>c});var s=i(5661),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(5354);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinbase",name:"Coinbase Advanced",countries:["US"],pro:!0,certified:!1,rateLimit:34,version:"v2",userAgent:this.userAgents.chrome,headers:{"CB-VERSION":"2018-05-30"},has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!0,createConvertTrade:!0,createDepositAddress:!0,createLimitBuyOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrder:!0,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!1,createStopOrder:!0,deposit:!0,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchConvertQuote:!0,fetchConvertTrade:!0,fetchConvertTradeHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:"emulated",fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!0,fetchDepositMethodId:!0,fetchDepositMethodIds:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL2OrderBook:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyBuys:!0,fetchMyLiquidations:!1,fetchMySells:!0,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:"emulated",fetchTradingFees:!0,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg",api:{rest:"https://api.coinbase.com"},www:"https://www.coinbase.com",doc:["https://developers.coinbase.com/api/v2","https://docs.cloud.coinbase.com/advanced-trade/docs/welcome"],fees:["https://support.coinbase.com/customer/portal/articles/2109597-buy-sell-bank-transfer-fees","https://www.coinbase.com/advanced-fees"],referral:"https://www.coinbase.com/join/58cbe25a355148797479dbd2"},requiredCredentials:{apiKey:!0,secret:!0},api:{v2:{public:{get:{currencies:10.6,"currencies/crypto":10.6,time:10.6,"exchange-rates":10.6,"users/{user_id}":10.6,"prices/{symbol}/buy":10.6,"prices/{symbol}/sell":10.6,"prices/{symbol}/spot":10.6}},private:{get:{accounts:10.6,"accounts/{account_id}":10.6,"accounts/{account_id}/addresses":10.6,"accounts/{account_id}/addresses/{address_id}":10.6,"accounts/{account_id}/addresses/{address_id}/transactions":10.6,"accounts/{account_id}/transactions":10.6,"accounts/{account_id}/transactions/{transaction_id}":10.6,"accounts/{account_id}/buys":10.6,"accounts/{account_id}/buys/{buy_id}":10.6,"accounts/{account_id}/sells":10.6,"accounts/{account_id}/sells/{sell_id}":10.6,"accounts/{account_id}/deposits":10.6,"accounts/{account_id}/deposits/{deposit_id}":10.6,"accounts/{account_id}/withdrawals":10.6,"accounts/{account_id}/withdrawals/{withdrawal_id}":10.6,"payment-methods":10.6,"payment-methods/{payment_method_id}":10.6,user:10.6,"user/auth":10.6},post:{accounts:10.6,"accounts/{account_id}/primary":10.6,"accounts/{account_id}/addresses":10.6,"accounts/{account_id}/transactions":10.6,"accounts/{account_id}/transactions/{transaction_id}/complete":10.6,"accounts/{account_id}/transactions/{transaction_id}/resend":10.6,"accounts/{account_id}/buys":10.6,"accounts/{account_id}/buys/{buy_id}/commit":10.6,"accounts/{account_id}/sells":10.6,"accounts/{account_id}/sells/{sell_id}/commit":10.6,"accounts/{account_id}/deposits":10.6,"accounts/{account_id}/deposits/{deposit_id}/commit":10.6,"accounts/{account_id}/withdrawals":10.6,"accounts/{account_id}/withdrawals/{withdrawal_id}/commit":10.6},put:{"accounts/{account_id}":10.6,user:10.6},delete:{"accounts/{id}":10.6,"accounts/{account_id}/transactions/{transaction_id}":10.6}}},v3:{public:{get:{"brokerage/time":3,"brokerage/market/product_book":3,"brokerage/market/products":3,"brokerage/market/products/{product_id}":3,"brokerage/market/products/{product_id}/candles":3,"brokerage/market/products/{product_id}/ticker":3}},private:{get:{"brokerage/accounts":1,"brokerage/accounts/{account_uuid}":1,"brokerage/orders/historical/batch":1,"brokerage/orders/historical/fills":1,"brokerage/orders/historical/{order_id}":1,"brokerage/products":3,"brokerage/products/{product_id}":3,"brokerage/products/{product_id}/candles":3,"brokerage/products/{product_id}/ticker":3,"brokerage/best_bid_ask":3,"brokerage/product_book":3,"brokerage/transaction_summary":3,"brokerage/portfolios":1,"brokerage/portfolios/{portfolio_uuid}":1,"brokerage/convert/trade/{trade_id}":1,"brokerage/cfm/balance_summary":1,"brokerage/cfm/positions":1,"brokerage/cfm/positions/{product_id}":1,"brokerage/cfm/sweeps":1,"brokerage/intx/portfolio/{portfolio_uuid}":1,"brokerage/intx/positions/{portfolio_uuid}":1,"brokerage/intx/positions/{portfolio_uuid}/{symbol}":1,"brokerage/payment_methods":1,"brokerage/payment_methods/{payment_method_id}":1,"brokerage/key_permissions":1},post:{"brokerage/orders":1,"brokerage/orders/batch_cancel":1,"brokerage/orders/edit":1,"brokerage/orders/edit_preview":1,"brokerage/orders/preview":1,"brokerage/portfolios":1,"brokerage/portfolios/move_funds":1,"brokerage/convert/quote":1,"brokerage/convert/trade/{trade_id}":1,"brokerage/cfm/sweeps/schedule":1,"brokerage/intx/allocate":1,"brokerage/orders/close_position":1},put:{"brokerage/portfolios/{portfolio_uuid}":1},delete:{"brokerage/portfolios/{portfolio_uuid}":1,"brokerage/cfm/sweeps":1}}}},fees:{trading:{taker:this.parseNumber("0.012"),maker:this.parseNumber("0.006"),tierBased:!0,percentage:!0,tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.006")],[this.parseNumber("10000"),this.parseNumber("0.004")],[this.parseNumber("50000"),this.parseNumber("0.0025")],[this.parseNumber("100000"),this.parseNumber("0.002")],[this.parseNumber("1000000"),this.parseNumber("0.0018")],[this.parseNumber("15000000"),this.parseNumber("0.0016")],[this.parseNumber("75000000"),this.parseNumber("0.0012")],[this.parseNumber("250000000"),this.parseNumber("0.0008")],[this.parseNumber("400000000"),this.parseNumber("0.0005")]],maker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("10000"),this.parseNumber("0.0025")],[this.parseNumber("50000"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.001")],[this.parseNumber("1000000"),this.parseNumber("0.0008")],[this.parseNumber("15000000"),this.parseNumber("0.0006")],[this.parseNumber("75000000"),this.parseNumber("0.0003")],[this.parseNumber("250000000"),this.parseNumber("0.0")],[this.parseNumber("400000000"),this.parseNumber("0.0")]]}}},precisionMode:o.kb,exceptions:{exact:{two_factor_required:r.AuthenticationError,param_required:r.ExchangeError,validation_error:r.ExchangeError,invalid_request:r.ExchangeError,personal_details_required:r.AuthenticationError,identity_verification_required:r.AuthenticationError,jumio_verification_required:r.AuthenticationError,jumio_face_match_verification_required:r.AuthenticationError,unverified_email:r.AuthenticationError,authentication_error:r.AuthenticationError,invalid_authentication_method:r.AuthenticationError,invalid_token:r.AuthenticationError,revoked_token:r.AuthenticationError,expired_token:r.AuthenticationError,invalid_scope:r.AuthenticationError,not_found:r.ExchangeError,rate_limit_exceeded:r.RateLimitExceeded,internal_server_error:r.ExchangeError,UNSUPPORTED_ORDER_CONFIGURATION:r.BadRequest,INSUFFICIENT_FUND:r.InsufficientFunds,PERMISSION_DENIED:r.PermissionDenied,INVALID_ARGUMENT:r.BadRequest,PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE:r.InvalidOrder,PREVIEW_INSUFFICIENT_FUND:r.InsufficientFunds},broad:{"Insufficient balance in source account":r.InsufficientFunds,"request timestamp expired":r.InvalidNonce,"order with this orderID was not found":r.OrderNotFound}},timeframes:{"1m":"ONE_MINUTE","5m":"FIVE_MINUTE","15m":"FIFTEEN_MINUTE","30m":"THIRTY_MINUTE","1h":"ONE_HOUR","2h":"TWO_HOUR","6h":"SIX_HOUR","1d":"ONE_DAY"},commonCurrencies:{CGLD:"CELO"},options:{usePrivate:!1,brokerId:"ccxt",stablePairs:["BUSD-USD","CBETH-ETH","DAI-USD","GUSD-USD","GYEN-USD","PAX-USD","PAX-USDT","USDC-EUR","USDC-GBP","USDT-EUR","USDT-GBP","USDT-USD","USDT-USDC","WBTC-BTC"],fetchCurrencies:{expires:5e3},accounts:["wallet","fiat"],v3Accounts:["ACCOUNT_TYPE_CRYPTO","ACCOUNT_TYPE_FIAT"],networks:{ERC20:"ethereum",XLM:"stellar"},createMarketBuyOrderRequiresPrice:!0,advanced:!0,fetchMarkets:"fetchMarketsV3",timeDifference:0,adjustForTimeDifference:!1,fetchTicker:"fetchTickerV3",fetchTickers:"fetchTickersV3",fetchAccounts:"fetchAccountsV3",fetchBalance:"v2PrivateGetAccounts",fetchTime:"v2PublicGetTime",user_native_currency:"USD"},features:{default:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!0,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:3e3,daysBack:void 0,untilDays:1e4,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:void 0,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:300}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:{extends:"default"},inverse:void 0}}})}async fetchTime(e={}){const t=this.safeString(this.options,"fetchTime","v2PublicGetTime"),i=this.safeString(e,"method",t);let s;return e=this.omit(e,"method"),"v2PublicGetTime"===i?(s=await this.v2PublicGetTime(e),s=this.safeDict(s,"data",{})):s=await this.v3PublicGetBrokerageTime(e),this.safeTimestamp2(s,"epoch","epochSeconds")}async fetchAccounts(e={}){return"fetchAccountsV3"===this.safeString(this.options,"fetchAccounts","fetchAccountsV3")?await this.fetchAccountsV3(e):await this.fetchAccountsV2(e)}async fetchAccountsV2(e={}){await this.loadMarkets();let t=!1;if([t,e]=this.handleOptionAndParams(e,"fetchAccounts","paginate"),t)return await this.fetchPaginatedCallCursor("fetchAccounts",void 0,void 0,void 0,e,"next_starting_after","starting_after",void 0,100);const i=await this.v2PrivateGetAccounts(this.extend({limit:100},e)),s=this.safeList(i,"data",[]),r=this.safeDict(i,"pagination",{}),a=this.safeString(r,"next_starting_after"),o=this.safeList(i,"data",[]),n=o.length-1,d=this.safeDict(o,n);return void 0!==a&&""!==a&&(d.next_starting_after=a,o[n]=d),this.parseAccounts(s,e)}async fetchAccountsV3(e={}){await this.loadMarkets();let t=!1;if([t,e]=this.handleOptionAndParams(e,"fetchAccounts","paginate"),t)return await this.fetchPaginatedCallCursor("fetchAccounts",void 0,void 0,void 0,e,"cursor","cursor",void 0,250);const i=await this.v3PrivateGetBrokerageAccounts(this.extend({limit:250},e)),s=this.safeList(i,"accounts",[]),r=s.length,a=this.safeString(i,"cursor");if(r>0&&void 0!==a&&""!==a){const e=r-1,t=this.safeDict(s,e);t.cursor=a,s[e]=t}return this.parseAccounts(s,e)}async fetchPortfolios(e={}){const t=await this.v3PrivateGetBrokeragePortfolios(e),i=this.safeList(t,"portfolios",[]),s=[];for(let e=0;e0?s[0]:void 0,b.push(t)}return b}parseSpotMarket(e,t){const i=this.safeString(e,"product_id"),s=this.safeString(e,"base_currency_id"),r=this.safeString(e,"quote_currency_id"),a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r),n=this.safeStringLower(e,"product_type"),d=this.safeBool(e,"trading_disabled"),c=this.safeList(this.options,"stablePairs",[]),h=this.safeNumber(this.fees.trading,"taker"),l=this.safeNumber(this.fees.trading,"maker"),u=this.inArray(i,c)?1e-5:this.safeNumber(t,"taker_fee_rate",h),p=this.inArray(i,c)?0:this.safeNumber(t,"maker_fee_rate",l);return this.safeMarketStructure({id:i,symbol:a+"/"+o,base:a,quote:o,settle:void 0,baseId:s,quoteId:r,settleId:void 0,type:n,spot:"spot"===n,margin:void 0,swap:!1,future:!1,option:!1,active:!d,contract:!1,linear:void 0,inverse:void 0,taker:u,maker:p,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"base_increment"),price:this.safeNumber2(e,"price_increment","quote_increment")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"base_min_size"),max:this.safeNumber(e,"base_max_size")},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"quote_min_size"),max:this.safeNumber(e,"quote_max_size")}},created:void 0,info:e})}parseContractMarket(e,t){const i=this.safeString(e,"product_id"),s=this.safeDict(e,"future_product_details",{}),r=this.safeString(s,"contract_expiry_type"),a=this.safeNumber(s,"contract_size"),o=this.safeString(s,"contract_expiry"),n=this.parse8601(o),d=this.iso8601(n),c="PERPETUAL"===r,h=this.safeString(s,"contract_root_unit"),l=this.safeString(e,"quote_currency_id"),u=this.safeCurrencyCode(h),p=this.safeCurrencyCode(l),f=this.safeBool(e,"is_disabled");let m,g=u+"/"+p;c?(m="swap",g=g+":"+p):(m="future",g=g+":"+p+"-"+this.yymmdd(n));const v=this.safeNumber(t,"taker_fee_rate"),y=this.safeNumber(t,"maker_fee_rate"),b=v||this.parseNumber("0.06"),w=y||this.parseNumber("0.04");return this.safeMarketStructure({id:i,symbol:g,base:u,quote:p,settle:p,baseId:h,quoteId:l,settleId:l,type:m,spot:!1,margin:!1,swap:c,future:!c,option:!1,active:!f,contract:!0,linear:!0,inverse:!1,taker:b,maker:w,contractSize:a,expiry:n,expiryDatetime:d,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(e,"base_increment"),price:this.safeNumber2(e,"price_increment","quote_increment")},limits:{leverage:{min:void 0,max:void 0},amount:{min:this.safeNumber(e,"base_min_size"),max:this.safeNumber(e,"base_max_size")},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"quote_min_size"),max:this.safeNumber(e,"quote_max_size")}},created:void 0,info:e})}async fetchCurrenciesFromCache(e={}){const t=this.safeDict(this.options,"fetchCurrencies",{}),i=this.safeInteger(t,"timestamp"),s=this.safeInteger(t,"expires",1e3),r=this.milliseconds();if(void 0===i||r-i>s){const i=[this.v2PublicGetCurrencies(e),this.v2PublicGetCurrenciesCrypto(e)],s=await Promise.all(i),a=this.safeDict(s,0,{}),o=this.safeDict(s,1,{}),n=this.safeList(a,"data",[]),d=this.safeList(o,"data",[]),c=await this.v2PublicGetExchangeRates(e);this.options.fetchCurrencies=this.extend(t,{currencies:this.arrayConcat(n,d),exchangeRates:c,timestamp:r})}return this.safeDict(this.options,"fetchCurrencies",{})}async fetchCurrencies(e={}){const t=[this.v2PublicGetCurrencies(e),this.v2PublicGetCurrenciesCrypto(e),this.v2PublicGetExchangeRates(e)],i=await Promise.all(t),s=this.safeDict(i,0,{}),r=this.safeDict(i,1,{}),a=this.safeDict(i,2,{}),o=this.safeList(s,"data",[]),n=this.safeList(r,"data",[]),d=this.safeDict(a,"data",{}),c=this.safeDict(d,"rates",{}),h=Object.keys(c),l=this.arrayConcat(o,n),u={},p={},f={};for(let e=0;e3&&(g=e[3])}return this.safeLedgerEntry({info:e,id:u,timestamp:l,datetime:this.iso8601(l),direction:s,account:g,referenceId:void 0,referenceAccount:void 0,type:p,currency:n,amount:this.parseNumber(r),before:void 0,after:void 0,status:f,fee:d},t)}async findAccountId(e,t={}){await this.loadMarkets(),await this.loadAccounts(!1,t);for(let t=0;t0?l:0,wallet_name:s,account_id:r,account_uuid:this.safeString(t,"account_uuid",""),total_balance_fiat:h,total_balance_crypto:this.parseNumber(this.safeString(t,"total_balance_crypto","0")),available_to_trade_fiat:this.parseNumber(this.safeString(t,"available_to_trade_fiat","0")),available_to_trade_crypto:this.parseNumber(this.safeString(t,"available_to_trade_crypto","0")),available_to_transfer_fiat:this.parseNumber(this.safeString(t,"available_to_transfer_fiat","0")),available_to_transfer_crypto:this.parseNumber(this.safeString(t,"available_to_trade_crypto","0")),allocation:this.parseNumber(this.safeString(t,"allocation","0")),cost_basis:this.parseNumber(p),cost_basis_currency:this.safeString(u,"currency","USD"),is_cash:this.safeBool(t,"is_cash",!1),average_entry_price:this.parseNumber(m),average_entry_price_currency:this.safeString(f,"currency","USD"),asset_uuid:this.safeString(t,"asset_uuid",""),unrealized_pnl:this.parseNumber(this.safeString(t,"unrealized_pnl","0")),asset_color:this.safeString(t,"asset_color",""),account_type:this.safeString(t,"account_type","")};o.push(g)}return o}createAuthToken(e,t=void 0,i=void 0,s=!1){let r;if(void 0!==i){r=t+" "+i.replace("https://","");const e=r.indexOf("?");e>0&&(r=r.slice(0,e))}const a=this.randomBytes(16),o={aud:[s?"cdp_service":"retail_rest_api_proxy"],iss:s?"cdp":"coinbase-cloud",nbf:e,exp:e+120,sub:this.apiKey,iat:e};if(void 0!==r&&(s?o.uris=[r]:o.uri=r),s){const e=this.base64ToBinary(this.secret),t=this.arraySlice(e,0,32);return(0,d.a)(o,t,n.s,!1,{kid:this.apiKey,nonce:a,alg:"EdDSA"})}return(0,d.a)(o,this.encode(this.secret),n.s,!1,{kid:this.apiKey,nonce:a,alg:"ES256"})}nonce(){return this.milliseconds()-this.options.timeDifference}sign(e,t=[],i="GET",s={},a=void 0,o=void 0){const d=t[0],c="private"===t[1],h="v3"===d;let l="/"+(h?"api/v3":"v2")+"/"+this.implodeParams(e,s);const u=this.omit(s,this.extractParams(e)),p=l;"GET"===i&&Object.keys(u).length&&(l+="?"+this.urlencodeWithArrayRepeat(u));const f=this.urls.api.rest+l;if(c){const e=this.safeString(this.headers,"Authorization");let t;if(void 0!==e)t=e;else if(this.token&&!this.checkRequiredCredentials(!1))t="Bearer "+this.token;else{this.checkRequiredCredentials();const e=this.seconds();let s="";"GET"!==i?Object.keys(u).length&&(s=o=this.json(u)):h||Object.keys(u).length&&(s+="?"+this.urlencode(u));const d=this.apiKey.indexOf("organizations/")>=0||this.secret.startsWith("-----BEGIN"),c=88===this.secret.length||this.safeBool(this.options,"v2CloudAPiKey",!1)||this.secret.endsWith("=");if(d||c){if(d&&this.apiKey.startsWith("-----BEGIN"))throw new r.ArgumentsRequired(this.id+" apiKey should contain the name (eg: organizations/3b910e93....) and not the public key");t="Bearer "+this.createAuthToken(e,i,f,c)}else{const e=this.nonce(),t=this.parseToInt(e/1e3).toString(),r=t+i+p+s,o=this.hmac(this.encode(r),this.encode(this.secret),n.s);a={"CB-ACCESS-KEY":this.apiKey,"CB-ACCESS-SIGN":o,"CB-ACCESS-TIMESTAMP":t,"Content-Type":"application/json"}}}void 0!==t&&(a={Authorization:t,"Content-Type":"application/json"},"GET"!==i&&Object.keys(u).length&&(o=this.json(u)))}return{url:f,method:i,body:o,headers:a}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.id+" "+o;let l=this.safeString(n,"error");if(void 0!==l){const e=this.safeString2(n,"error_description","error");throw this.throwExactlyMatchedException(this.exceptions.exact,l,h),this.throwBroadlyMatchedException(this.exceptions.broad,e,h),new r.ExchangeError(h)}const u=this.safeDict(n,"error_response");if(void 0!==u){const e=this.safeString2(u,"preview_failure_reason","preview_failure_reason");throw this.throwExactlyMatchedException(this.exceptions.exact,e,h),this.throwBroadlyMatchedException(this.exceptions.broad,e,h),new r.ExchangeError(h)}const p=this.safeList(n,"errors");if(void 0!==p&&Array.isArray(p)){if(p.length>0){l=this.safeString(p[0],"id");const e=this.safeString(p[0],"message");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,h),this.throwBroadlyMatchedException(this.exceptions.broad,e,h),new r.ExchangeError(h)}}const f=this.options.advanced;if(!("data"in n)&&!f)throw new r.ExchangeError(this.id+" failed due to a malformed response "+this.json(n))}async fetchDepositAddresses(e=void 0,t={}){await this.loadMarkets();const i=this.prepareAccountRequest(void 0,t),s=await this.v2PrivateGetAccountsAccountIdAddresses(this.extend(i,t)),r=this.safeList(s,"data",[]);return this.parseDepositAddresses(r,e,!1,{})}}},3278:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var s=i(7504);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinbaseadvanced",name:"Coinbase Advanced",alias:!0})}}},4293:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(1552),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinbaseexchange",name:"Coinbase Exchange",countries:["US"],rateLimit:100,userAgent:this.userAgents.chrome,pro:!0,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!0,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},timeframes:{"1m":60,"5m":300,"15m":900,"1h":3600,"6h":21600,"1d":86400},hostname:"exchange.coinbase.com",urls:{test:{public:"https://api-public.sandbox.exchange.coinbase.com",private:"https://api-public.sandbox.exchange.coinbase.com"},logo:"https://github.com/ccxt/ccxt/assets/43336371/34a65553-88aa-4a38-a714-064bd228b97e",api:{public:"https://api.{hostname}",private:"https://api.{hostname}"},www:"https://coinbase.com/",doc:"https://docs.cloud.coinbase.com/exchange/docs/",fees:["https://docs.pro.coinbase.com/#fees","https://support.pro.coinbase.com/customer/en/portal/articles/2945310-fees"]},requiredCredentials:{apiKey:!0,secret:!0,password:!0},api:{public:{get:["currencies","products","products/{id}","products/{id}/book","products/{id}/candles","products/{id}/stats","products/{id}/ticker","products/{id}/trades","time","products/spark-lines","products/volume-summary"]},private:{get:["address-book","accounts","accounts/{id}","accounts/{id}/holds","accounts/{id}/ledger","accounts/{id}/transfers","coinbase-accounts","fills","funding","fees","margin/profile_information","margin/buying_power","margin/withdrawal_power","margin/withdrawal_power_all","margin/exit_plan","margin/liquidation_history","margin/position_refresh_amounts","margin/status","oracle","orders","orders/{id}","orders/client:{client_oid}","otc/orders","payment-methods","position","profiles","profiles/{id}","reports/{report_id}","transfers","transfers/{transfer_id}","users/self/exchange-limits","users/self/hold-balances","users/self/trailing-volume","withdrawals/fee-estimate","conversions/{conversion_id}","conversions","conversions/fees","loans/lending-overview","loans/lending-overview-xm","loans/loan-preview","loans/loan-preview-xm","loans/repayment-preview","loans/repayment-preview-xm","loans/interest/{loan_id}","loans/interest/history/{loan_id}","loans/interest","loans/assets","loans"],post:["conversions","deposits/coinbase-account","deposits/payment-method","coinbase-accounts/{id}/addresses","funding/repay","orders","position/close","profiles/margin-transfer","profiles/transfer","reports","withdrawals/coinbase","withdrawals/coinbase-account","withdrawals/crypto","withdrawals/payment-method","loans/open","loans/repay-interest","loans/repay-principal"],delete:["orders","orders/client:{client_oid}","orders/{id}"]}},commonCurrencies:{CGLD:"CELO"},precisionMode:o.kb,fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.004"),taker:this.parseNumber("0.006")},funding:{tierBased:!1,percentage:!1,withdraw:{BCH:0,BTC:0,LTC:0,ETH:0,EUR:.15,USD:25},deposit:{BCH:0,BTC:0,LTC:0,ETH:0,EUR:.15,USD:10}}},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:300}},spot:{extends:"default"},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},options:{networks:{BTC:"bitcoin",ETH:"ethereum",SOL:"solana",ARBONE:"arbitrum",AVAXC:"avacchain",MATIC:"polygon",BASE:"base",SUI:"sui",OP:"optimism",NEAR:"near",APT:"aptos",KAVA:"kava",BLAST:"blast",XLM:"stellar",SEI:"sei",ADA:"cardano",CORE:"coredao",ALGO:"algorand",OSMO:"osmosis",CELO:"celo",HBAR:"hedera",ZKSYNC:"zksync",STX:"stacks",XTZ:"tezos",EGLD:"elrond",LTC:"litecoin",ATOM:"cosmos",FIL:"filecoin",DOT:"polkadot",DOGE:"dogecoin",XRP:"ripple",DASH:"dash"}},exceptions:{exact:{"Insufficient funds":r.InsufficientFunds,NotFound:r.OrderNotFound,"Invalid API Key":r.AuthenticationError,"invalid signature":r.AuthenticationError,"Invalid Passphrase":r.AuthenticationError,"Invalid order id":r.InvalidOrder,"Private rate limit exceeded":r.RateLimitExceeded,"Trading pair not available":r.PermissionDenied,"Product not found":r.InvalidOrder},broad:{"Order already done":r.OrderNotFound,"order not found":r.OrderNotFound,"price too small":r.InvalidOrder,"price too precise":r.InvalidOrder,"under maintenance":r.OnMaintenance,"size is too small":r.InvalidOrder,"Cancel only mode":r.OnMaintenance}}})}async fetchCurrencies(e={}){const t=await this.publicGetCurrencies(e),i={};for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(2609),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinbaseinternational",name:"Coinbase International",countries:["US"],certified:!1,pro:!0,rateLimit:100,version:"v1",userAgent:this.userAgents.chrome,headers:{"CB-VERSION":"2018-05-30"},has:{CORS:!0,spot:!0,margin:!0,swap:!0,future:!0,option:!1,addMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!0,createLimitBuyOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrder:!0,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposits:!0,fetchFundingHistory:!0,fetchFundingRate:!1,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyBuys:!0,fetchMySells:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!1,fetchOrders:!1,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!1,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!0,setLeverage:!1,setMargin:!0,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://github.com/ccxt/ccxt/assets/43336371/866ae638-6ab5-4ebf-ab2c-cdcce9545625",api:{rest:"https://api.international.coinbase.com/api"},test:{rest:"https://api-n5e1.coinbase.com/api"},www:"https://international.coinbase.com",doc:["https://docs.cloud.coinbase.com/intx/docs"],fees:["https://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees"],referral:""},requiredCredentials:{apiKey:!0,secret:!0,password:!0},api:{v1:{public:{get:["assets","assets/{assets}","assets/{asset}/networks","instruments","instruments/{instrument}","instruments/{instrument}/quote","instruments/{instrument}/funding","instruments/{instrument}/candles"]},private:{get:["orders","orders/{id}","portfolios","portfolios/{portfolio}","portfolios/{portfolio}/detail","portfolios/{portfolio}/summary","portfolios/{portfolio}/balances","portfolios/{portfolio}/balances/{asset}","portfolios/{portfolio}/positions","portfolios/{portfolio}/positions/{instrument}","portfolios/fills","portfolios/{portfolio}/fills","transfers","transfers/{transfer_uuid}"],post:["orders","portfolios","portfolios/margin","portfolios/transfer","transfers/withdraw","transfers/address","transfers/create-counterparty-id","transfers/validate-counterparty-id","transfers/withdraw/counterparty"],put:["orders/{id}","portfolios/{portfolio}"],delete:["orders","orders/{id}"]}}},fees:{trading:{taker:this.parseNumber("0.004"),maker:this.parseNumber("0.002"),tierBased:!0,percentage:!0,tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("1000000"),this.parseNumber("0.004")],[this.parseNumber("5000000"),this.parseNumber("0.0035")],[this.parseNumber("10000000"),this.parseNumber("0.0035")],[this.parseNumber("50000000"),this.parseNumber("0.003")],[this.parseNumber("250000000"),this.parseNumber("0.0025")]],maker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("1000000"),this.parseNumber("0.0016")],[this.parseNumber("5000000"),this.parseNumber("0.001")],[this.parseNumber("10000000"),this.parseNumber("0.0008")],[this.parseNumber("50000000"),this.parseNumber("0.0005")],[this.parseNumber("250000000"),this.parseNumber("0")]]}}},precisionMode:o.kb,exceptions:{exact:{},broad:{DUPLICATE_CLIENT_ORDER_ID:r.DuplicateOrderId,"Order rejected":r.InvalidOrder,"market orders must be IoC":r.InvalidOrder,"tif is required":r.InvalidOrder,"Invalid replace order request":r.InvalidOrder,Unauthorized:r.PermissionDenied,"invalid result_limit":r.BadRequest,"is a required field":r.BadRequest,"Not Found":r.BadRequest,"ip not allowed":r.AuthenticationError}},timeframes:{"1m":"ONE_MINUTE","5m":"FIVE_MINUTE","15m":"FIFTEEN_MINUTE","30m":"THIRTY_MINUTE","1h":"ONE_HOUR","2h":"TWO_HOUR","6h":"SIX_HOUR","1d":"ONE_DAY"},options:{brokerId:"nfqkvdjp",portfolio:"",withdraw:{method:"v1PrivatePostTransfersWithdraw"},networksById:{ethereum:"ETH",arbitrum:"ARBITRUM",avacchain:"AVAX",optimism:"OPTIMISM",polygon:"MATIC",solana:"SOL",bitcoin:"BTC"}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0,GTC:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!0,selfTradePrevention:!0,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:1e4,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:300}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:void 0,inverse:void 0}}})}async handlePortfolioAndParams(e,t={}){let i;if([i,t]=this.handleOptionAndParams(t,e,"portfolio"),void 0!==i&&""!==i)return[i,t];const s=this.safeString(this.options,"portfolio");if(void 0!==s&&""!==s)return[s,t];const a=await this.fetchAccounts();for(let e=0;e100)throw new r.BadRequest(this.id+" fetchOpenOrders() maximum limit is 100");h.result_limit=i}void 0!==t&&(h.ref_datetime=this.iso8601(t));const u=await this.v1PrivateGetOrders(this.extend(h,s)),p=this.safeList(u,"results",[]);return this.parseOrders(p,l,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let a=!1;[a,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate");const o="ccxtPageKey";let n,d;if([n,s]=this.handleOptionAndParams(s,"fetchMyTrades","maxEntriesPerRequest",100),a)return await this.fetchPaginatedCallIncremental("fetchMyTrades",e,t,i,s,o,n);void 0!==e&&(d=this.market(e));const c=this.safeInteger(s,o,1)-1,h={result_offset:this.safeInteger2(s,"offset","result_offset",c*n)};if(void 0!==i){if(i>100)throw new r.BadRequest(this.id+" fetchMyTrades() maximum limit is 100. Consider setting paginate to true to fetch more trades.");h.result_limit=i}void 0!==t&&(h.time_from=this.iso8601(t));const l=this.safeStringN(s,["until"]);void 0!==l&&(s=this.omit(s,["until"]),h.ref_datetime=this.iso8601(l));const u=await this.v1PrivateGetPortfoliosFills(this.extend(h,s)),p=this.safeList(u,"results",[]);return this.parseTrades(p,d,t,i)}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const a=this.currency(e);let o,n,d;[o,r]=await this.handlePortfolioAndParams("withdraw",r),[n,r]=this.handleOptionAndParams(r,"withdraw","method","v1PrivatePostTransfersWithdraw"),[d,r]=await this.handleNetworkIdAndParams(e,"withdraw",r);const c={portfolio:o,type:"send",asset:a.id,address:i,amount:t,currency:a.id,network_arn_id:d,nonce:this.nonce()},h=await this[n](this.extend(c,r));return this.parseTransaction(h,a)}safeNetwork(e){let t=this.safeBool(e,"withdraw"),i=this.safeBool(e,"deposit");const s=this.safeDict(e,"limits"),r=this.safeDict(s,"withdraw"),a=this.safeNumber(r,"max"),o=this.safeDict(s,"deposit"),n=this.safeNumber(o,"max");void 0===t&&void 0!==a&&(t=a>0),void 0===i&&void 0!==n&&(i=n>0);const d=this.safeString(e,"id"),c=t&&i;return{info:e.info,id:d,name:this.safeString(e,"name"),network:this.safeString(e,"network"),active:this.safeBool(e,"active",c),deposit:i,withdraw:t,fee:this.safeNumber(e,"fee"),precision:this.safeNumber(e,"precision"),limits:{withdraw:{min:this.safeNumber(r,"min"),max:a},deposit:{min:this.safeNumber(o,"min"),max:n}}}}sign(e,t=[],i="GET",s={},r=void 0,a=void 0){const o=t[0],d="private"===t[1];let c="/"+o+"/"+this.implodeParams(e,s);const h=this.omit(s,this.extractParams(e)),l="/api"+c;"GET"!==i&&"DELETE"!==i||Object.keys(h).length&&(c+="?"+this.urlencodeWithArrayRepeat(h));const u=this.urls.api.rest+c;if(d){this.checkRequiredCredentials();const e=this.nonce().toString();let t="";"GET"!==i&&Object.keys(h).length&&(t=a=this.json(h));const s=e+i+l+t;r={"CB-ACCESS-TIMESTAMP":e,"CB-ACCESS-SIGN":this.hmac(this.encode(s),this.base64ToBinary(this.secret),n.s,"base64"),"CB-ACCESS-PASSPHRASE":this.password,"CB-ACCESS-KEY":this.apiKey}}return{url:u,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0===n)return;const h=this.id+" "+o,l=this.safeString(n,"title");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,h),this.throwBroadlyMatchedException(this.exceptions.broad,l,h),new r.ExchangeError(h)}}},570:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(5769),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coincatch",name:"CoinCatch",countries:["VG"],rateLimit:50,version:"v1",certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!1,addMargin:!0,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createLimitBuyOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!1,createMarketSellOrder:!0,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!0,fetchPositions:!0,fetchPositionsForSymbol:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!0,reduceMargin:!0,sandbox:!1,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!0,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m",15:"15m",30:"30m","1h":"1H","2h":"2H","4h":"4H","6h":"6H","12h":"12H","1d":"1D","3d":"3D","1w":"1W","1M":"1M"},urls:{logo:"https://github.com/user-attachments/assets/3d49065f-f05d-4573-88a2-1b5201ec6ff3",api:{public:"https://api.coincatch.com",private:"https://api.coincatch.com"},www:"https://www.coincatch.com/",doc:"https://coincatch.github.io/github.io/en/",fees:"https://www.coincatch.com/en/rate/",referral:{url:"https://partner.coincatch.cc/bg/92hy70391729607848548",discount:.1}},api:{public:{get:{"api/spot/v1/public/time":1,"api/spot/v1/public/currencies":20/3,"api/spot/v1/market/ticker":1,"api/spot/v1/market/tickers":1,"api/spot/v1/market/fills":2,"api/spot/v1/market/fills-history":2,"api/spot/v1/market/candles":1,"api/spot/v1/market/history-candles":1,"api/spot/v1/market/depth":1,"api/spot/v1/market/merge-depth":1,"api/mix/v1/market/contracts":1,"api/mix/v1/market/merge-depth":1,"api/mix/v1/market/depth":1,"api/mix/v1/market/ticker":1,"api/mix/v1/market/tickers":1,"api/mix/v1/market/fills":1,"api/mix/v1/market/fills-history":1,"api/mix/v1/market/candles":1,"pi/mix/v1/market/index":1,"api/mix/v1/market/funding-time":1,"api/mix/v1/market/history-fundRate":1,"api/mix/v1/market/current-fundRate":1,"api/mix/v1/market/open-interest":1,"api/mix/v1/market/mark-price":1,"api/mix/v1/market/symbol-leverage":1,"api/mix/v1/market/queryPositionLever":1}},private:{get:{"api/spot/v1/wallet/deposit-address":4,"pi/spot/v1/wallet/withdrawal-list":1,"api/spot/v1/wallet/withdrawal-list-v2":1,"api/spot/v1/wallet/deposit-list":1,"api/spot/v1/account/getInfo":1,"api/spot/v1/account/assets":2,"api/spot/v1/account/transferRecords":1,"api/mix/v1/account/account":2,"api/mix/v1/account/accounts":2,"api/mix/v1/position/singlePosition-v2":2,"api/mix/v1/position/allPosition-v2":4,"api/mix/v1/account/accountBill":2,"api/mix/v1/account/accountBusinessBill":4,"api/mix/v1/order/current":1,"api/mix/v1/order/marginCoinCurrent":1,"api/mix/v1/order/history":2,"api/mix/v1/order/historyProductType":4,"api/mix/v1/order/detail":2,"api/mix/v1/order/fills":2,"api/mix/v1/order/allFills":2,"api/mix/v1/plan/currentPlan":1,"api/mix/v1/plan/historyPlan":2},post:{"api/spot/v1/wallet/transfer-v2":4,"api/spot/v1/wallet/withdrawal-v2":4,"api/spot/v1/wallet/withdrawal-inner-v2":1,"api/spot/v1/account/bills":2,"api/spot/v1/trade/orders":2,"api/spot/v1/trade/batch-orders":{cost:4,step:10},"api/spot/v1/trade/cancel-order":1,"api/spot/v1/trade/cancel-order-v2":2,"api/spot/v1/trade/cancel-symbol-order":2,"api/spot/v1/trade/cancel-batch-orders":1,"api/spot/v1/trade/cancel-batch-orders-v2":1,"api/spot/v1/trade/orderInfo":1,"api/spot/v1/trade/open-orders":1,"api/spot/v1/trade/history":1,"api/spot/v1/trade/fills":1,"api/spot/v1/plan/placePlan":1,"api/spot/v1/plan/modifyPlan":1,"api/spot/v1/plan/cancelPlan":1,"api/spot/v1/plan/currentPlan":1,"api/spot/v1/plan/historyPlan":1,"api/spot/v1/plan/batchCancelPlan":2,"api/mix/v1/account/open-count":1,"api/mix/v1/account/setLeverage":4,"api/mix/v1/account/setMargin":4,"api/mix/v1/account/setMarginMode":4,"api/mix/v1/account/setPositionMode":4,"api/mix/v1/order/placeOrder":2,"api/mix/v1/order/batch-orders":{cost:4,step:10},"api/mix/v1/order/cancel-order":2,"api/mix/v1/order/cancel-batch-orders":2,"api/mix/v1/order/cancel-symbol-orders":2,"api/mix/v1/order/cancel-all-orders":2,"api/mix/v1/plan/placePlan":2,"api/mix/v1/plan/modifyPlan":2,"api/mix/v1/plan/modifyPlanPreset":2,"api/mix/v1/plan/placeTPSL":2,"api/mix/v1/plan/placeTrailStop":2,"api/mix/v1/plan/placePositionsTPSL":2,"api/mix/v1/plan/modifyTPSLPlan":2,"api/mix/v1/plan/cancelPlan":2,"api/mix/v1/plan/cancelSymbolPlan":2,"api/mix/v1/plan/cancelAllPlan":2}}},requiredCredentials:{apiKey:!0,secret:!0,password:!0},fees:{trading:{spot:{tierBased:!1,percentage:!0,feeSide:"get",maker:this.parseNumber("0.001"),taker:this.parseNumber("0.001")}}},options:{brokerId:"47cfy",createMarketBuyOrderRequiresPrice:!0,timeframes:{spot:{"1m":"1min","5m":"5min","15m":"15min","30m":"30min","1h":"1h","4h":"4h","6h":"6h","12h":"12h","1d":"1day","3d":"3day","1w":"1week","1M":"1M"},swap:{"1m":"1m","3m":"3m","5m":"5m",15:"15m",30:"30m","1h":"1H","2h":"2H","4h":"4H","6h":"6H","12h":"12H","1d":"1D","3d":"3D","1w":"1W","1M":"1M"}},currencyIdsListForParseMarket:void 0,broker:"",networks:{BTC:"BITCOIN",ERC20:"ERC20",TRC20:"TRC20",BEP20:"BEP20",ARB:"ArbitrumOne",OPTIMISM:"Optimism",LTC:"LTC",BCH:"BCH",ETC:"ETC",SOL:"SOL",NEO3:"NEO3",STX:"stacks",EGLD:"Elrond",NEAR:"NEARProtocol",ACA:"AcalaToken",KLAY:"Klaytn",FTM:"Fantom",TERRA:"Terra",WAVES:"WAVES",TAO:"TAO",SUI:"SUI",SEI:"SEI",RUNE:"THORChain",ZIL:"ZIL",SXP:"Solar",FET:"FET",AVAX:"C-Chain",XRP:"XRP",EOS:"EOS",DOGE:"DOGECOIN",CAP20:"CAP20",MATIC:"Polygon",CSPR:"CSPR",GLMR:"Moonbeam",MINA:"MINA",CFX:"CFX",STRAT:"StratisEVM",TIA:"Celestia",ChilizChain:"ChilizChain",APT:"Aptos",ONT:"Ontology",ICP:"ICP",ADA:"Cardano",FIL:"FIL",CELO:"CELO",DOT:"DOT",XLM:"StellarLumens",ATOM:"ATOM",CRO:"CronosChain"},networksById:{TRC20:"TRC20","TRX(TRC20)":"TRC20",ArbitrumOne:"ARB",THORChain:"RUNE",Solar:"SXP","C-Chain":"AVAX",CAP20:"CAP20",CFXeSpace:"CFX",CFX:"CFX",StratisEVM:"STRAT",ChilizChain:"ChilizChain",StellarLumens:"XLM",CronosChain:"CRO",Optimism:"Optimism"}},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:{max:50},fetchMyTrades:{marginMode:!1,limit:500,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!0,trailing:!1,marketType:!0,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!1}},fetchMyTrades:{limit:100}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{22001:r.OrderNotFound,429:r.DDoSProtection,40001:r.AuthenticationError,40002:r.AuthenticationError,40003:r.AuthenticationError,40005:r.InvalidNonce,40006:r.AuthenticationError,40007:r.BadRequest,40008:r.InvalidNonce,40009:r.AuthenticationError,40011:r.AuthenticationError,40012:r.AuthenticationError,40013:r.ExchangeError,40014:r.PermissionDenied,40015:r.ExchangeError,40016:r.PermissionDenied,40017:r.ExchangeError,40018:r.PermissionDenied,40019:r.BadRequest,40020:r.BadRequest,40034:r.BadRequest,400172:r.BadRequest,40912:r.BadRequest,40913:r.BadRequest,40102:r.BadRequest,40200:r.OnMaintenance,40305:r.BadRequest,40409:r.ExchangeError,40704:r.ExchangeError,40724:r.BadRequest,40725:r.ExchangeError,40762:r.InsufficientFunds,40774:r.BadRequest,40808:r.BadRequest,43001:r.OrderNotFound,43002:r.InvalidOrder,43004:r.OrderNotFound,43005:r.RateLimitExceeded,43006:r.BadRequest,43007:r.BadRequest,43008:r.BadRequest,43009:r.BadRequest,43010:r.BadRequest,43011:r.BadRequest,43012:r.InsufficientFunds,43117:r.InsufficientFunds,43118:r.BadRequest,43122:r.BadRequest,45006:r.InsufficientFunds,45110:r.BadRequest},broad:{}},precisionMode:o.kb})}calculateRateLimiterCost(e,t,i,s,r={}){const a=this.safeInteger(r,"step"),o=this.safeInteger(r,"cost",1),n=this.safeList2(s,"orderList","orderDataList",[]).length;if(void 0!==a&&n>a){return o*Math.ceil(n/a)}return o}async fetchTime(e={}){const t=await this.publicGetApiSpotV1PublicTime(e);return this.safeInteger(t,"data")}async fetchCurrencies(e={}){const t=await this.publicGetApiSpotV1PublicCurrencies(e),i=this.safeList(t,"data",[]),s={},r=[];for(let e=0;e-1){const s=e.replace(a,"");0===o?(t=a,i=s):(t=s,i=a);break}}return{baseId:t,quoteId:i}}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id};let a;if(i.spot)a=await this.publicGetApiSpotV1MarketTicker(this.extend(s,t));else{if(!i.swap)throw new r.NotSupported(this.id+" fetchTicker() is not supported for "+i.type+" type of markets");a=await this.publicGetApiMixV1MarketTicker(this.extend(s,t))}const o=this.safeDict(a,"data",{});return this.parseTicker(o,i)}async fetchTickers(e=void 0,t={}){const i="fetchTickers";await this.loadMarkets(),e=this.marketSymbols(e,void 0,!0,!0);const s=this.getMarketFromSymbols(e);let a,o;if([a,t]=this.handleMarketTypeAndParams(i,s,t,a),"spot"===a)o=await this.publicGetApiSpotV1MarketTickers(t);else{if("swap"!==a)throw new r.NotSupported(this.id+" "+i+"() is not supported for "+a+" type of markets");{let e="umcbl";[e,t]=this.handleOptionAndParams(t,i,"productType",e);const s={productType:e};o=await this.publicGetApiMixV1MarketTickers(this.extend(s,t))}}const n=this.safeList(o,"data",[]);return this.parseTickers(n,e)}parseTicker(e,t=void 0){const i=this.safeInteger2(e,"ts","timestamp");let s=this.safeString(e,"symbol","");s.indexOf("_")<0&&(s+="_SPBL"),t=this.safeMarketCustom(s,t);const r=this.safeString2(e,"close","last");return this.safeTicker({symbol:t.symbol,timestamp:i,datetime:this.iso8601(i),high:this.safeString(e,"high24h"),low:this.safeString(e,"low24h"),bid:this.safeString2(e,"buyOne","bestBid"),bidVolume:this.safeString(e,"bidSz"),ask:this.safeString2(e,"sellOne","bestAsk"),askVolume:this.safeString(e,"askSz"),vwap:void 0,open:this.safeString2(e,"openUtc0","openUtc"),close:r,last:r,previousClose:void 0,change:void 0,percentage:a.Y.stringMul(this.safeString2(e,"changeUtc","chgUtc"),"100"),average:void 0,baseVolume:this.safeString2(e,"baseVol","baseVolume"),quoteVolume:this.safeString2(e,"quoteVol","quoteVolume"),indexPrice:this.safeString(e,"indexPrice"),markPrice:void 0,info:e},t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s="fetchOrderBook",a=this.market(e),o={symbol:a.id};let n,d;if(void 0!==t&&(o.limit=t),[n,i]=this.handleOptionAndParams(i,s,"precision"),void 0!==n&&(o.precision=n),a.spot)d=await this.publicGetApiSpotV1MarketMergeDepth(this.extend(o,i));else{if(!a.swap)throw new r.NotSupported(this.id+" "+s+"() is not supported for "+a.type+" type of markets");d=await this.publicGetApiMixV1MarketMergeDepth(this.extend(o,i))}const c=this.safeDict(d,"data",{}),h=this.safeInteger(c,"ts");return this.parseOrderBook(c,e,h,"bids","asks")}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,a={}){const o="fetchOHLCV";await this.loadMarkets();const n=this.market(e),d={symbol:n.id};let c;[c,a]=this.handleOptionAndParams(a,o,"until");const h=n.type,l=this.options.timeframes[h],u=this.safeString(l,t,t);let p,f=s;if(void 0===i&&void 0===c||(f=1e3),void 0!==f&&(d.limit=f),n.spot){d.period=u,void 0!==i&&(d.after=i),void 0!==c&&(d.before=c),p=await this.publicGetApiSpotV1MarketCandles(this.extend(d,a));const e=this.safeList(p,"data",[]);return this.parseOHLCVs(e,n,t,i,s)}if(n.swap){if(d.granularity=u,void 0===c&&(c=this.milliseconds()),void 0===i){i=c-1e3*this.parseTimeframe(t)*1e3}let e;return d.startTime=i,d.endTime=c,[e,a]=this.handleOptionAndParams(a,o,"price"),"mark"===e&&(d.kLineType="market mark index"),p=await this.publicGetApiMixV1MarketCandles(this.extend(d,a)),this.parseOHLCVs(p,n,t,i,s)}throw new r.NotSupported(this.id+" "+o+"() is not supported for "+n.type+" type of markets")}parseOHLCV(e,t=void 0){return[this.safeInteger2(e,"ts",0),this.safeNumber2(e,"open",1),this.safeNumber2(e,"high",2),this.safeNumber2(e,"low",3),this.safeNumber2(e,"close",4),this.safeNumber2(e,"baseVol",5)]}async fetchTrades(e,t=void 0,i=void 0,s={}){const a="fetchTrades";await this.loadMarkets();const o=this.market(e),n={symbol:o.id};let d;[d,s]=this.handleOptionAndParams(s,a,"until");let c,h=i;if(void 0===t&&void 0===d||(h=1e3,void 0!==t&&(n.startTime=t),void 0!==d&&(n.endTime=d)),void 0!==h&&(n.limit=h),o.spot)c=await this.publicGetApiSpotV1MarketFillsHistory(this.extend(n,s));else{if(!o.swap)throw new r.NotSupported(this.id+" "+a+"() is not supported for "+o.type+" type of markets");c=await this.publicGetApiMixV1MarketFillsHistory(this.extend(n,s))}const l=this.safeList(c,"data",[]);return this.parseTrades(l,o,t,i)}parseTrade(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarketCustom(i,t);const s=this.safeIntegerN(e,["fillTime","timestamp","cTime"]),r=this.safeString2(e,"fees","fee");let o;void 0!==r&&(o=a.Y.stringAbs(r));let n=this.safeString(e,"feeCcy");void 0===n&&void 0!==t.settle&&(n=t.settle);const d=this.safeStringLower2(e,"tradeSide","side");return this.safeTrade({id:this.safeString2(e,"tradeId","fillId"),order:this.safeString(e,"orderId"),timestamp:s,datetime:this.iso8601(s),symbol:t.symbol,type:this.safeString(e,"orderType"),side:this.parseOrderSide(d),takerOrMaker:this.safeString(e,"takerMakerFlag"),price:this.safeString2(e,"fillPrice","price"),amount:this.safeStringN(e,["fillQuantity","size","sizeQty"]),cost:this.safeString2(e,"fillTotalAmount","fillAmount"),fee:{cost:o,currency:n},info:e},t)}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e),s=i.id,r=s.split("_"),a={symbol:s,productType:this.safeString(r,1)},o=await this.publicGetApiMixV1MarketCurrentFundRate(this.extend(a,t)),n=this.safeDict(o,"data",{});return this.parseFundingRate(n,i)}parseFundingRate(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarketCustom(i,t);const s=this.safeNumber(e,"fundingRate");return{info:e,symbol:t.symbol,markPrice:void 0,indexPrice:void 0,interestRate:void 0,estimatedSettlePrice:void 0,timestamp:void 0,datetime:void 0,fundingRate:s,fundingTimestamp:void 0,fundingDatetime:void 0,nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0}}handleOptionParamsAndRequest(e,t,i,s,r,a=void 0){const[o,n]=this.handleOptionAndParams(e,t,i,a);return void 0!==o&&(s[r]=o),[s,n]}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={symbol:a.id};let n=i;void 0!==t&&(n=100),void 0!==n&&(o.pageSize=n);const d=await this.publicGetApiMixV1MarketHistoryFundRate(this.extend(o,s)),c=this.safeList(d,"data",[]),h=[];for(let e=0;e1)for(let e=0;e1)throw new r.BadSymbol(this.id+" "+i+"() requires all symbols to belong to the same product type (umcbl or dmcbl)");s=a[0]}else[s,t]=this.handleOptionAndParams(t,i,"productType",s);const a={productType:s};if("dmcbl"===s){let e;if([e,t]=this.handleOptionAndParams(t,i,"marginCoin"),void 0!==e){const t=this.currency(e);a.marginCoin=t.id}}const o=await this.privateGetApiMixV1PositionAllPositionV2(this.extend(a,t)),n=this.safeList(o,"data",[]);return this.parsePositions(n,e)}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeString(e,"marginCoin");t=this.safeMarketCustom(i,t,s);const r=this.safeInteger(e,"cTime"),o=this.safeString(e,"marginMode");let n;const d=this.safeString(e,"holdMode");"double_hold"===d?n=!0:"single_hold"===d&&(n=!1);const c=this.safeNumber(e,"margin"),h=this.safeString(e,"keepMarginRate");return this.safePosition({symbol:t.symbol,id:void 0,timestamp:r,datetime:this.iso8601(r),contracts:this.safeNumber(e,"total"),contractSize:void 0,side:this.safeStringLower(e,"holdSide"),notional:c,leverage:this.safeInteger(e,"leverage"),unrealizedPnl:this.safeNumber(e,"unrealizedPL"),realizedPnl:this.safeNumber(e,"achievedProfits"),collateral:void 0,entryPrice:this.safeNumber(e,"averageOpenPrice"),markPrice:this.safeNumber(e,"marketPrice"),liquidationPrice:this.safeNumber(e,"liquidationPrice"),marginMode:this.parseMarginModeType(o),hedged:n,maintenanceMargin:void 0,maintenanceMarginPercentage:this.parseNumber(a.Y.stringMul(h,"100")),initialMargin:c,initialMarginPercentage:void 0,marginRatio:this.safeNumber(e,"marginRatio"),lastUpdateTimestamp:this.safeInteger(e,"uTime"),lastPrice:void 0,stopLossPrice:void 0,takeProfitPrice:void 0,percentage:void 0,info:e})}safeMarketCustom(e,t=void 0,i=void 0){try{t=this.safeMarket(e,t)}catch(s){const r=this.safeList(this.markets_by_id,e,[]);if(void 0===i)t=r[0];else for(let e=0;e=0){const e=this.safeDict(n,"data",{}),t=this.safeList2(e,"failure","fail_infos",[]);if(!this.isEmpty(t)){p=!1;const e=this.safeDict(t,0,{});u=this.safeString(e,"errorCode"),h=this.safeString(e,"errorMsg")}}if(!p)throw this.throwExactlyMatchedException(this.exceptions.exact,u,l),this.throwBroadlyMatchedException(this.exceptions.broad,h,l),new r.ExchangeError(l)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o="/"+e;if("GET"===i){const e=this.urlencode(s);0!==e.length&&(o+="?"+e)}if("private"===t){this.checkRequiredCredentials();const e=this.numberToString(this.milliseconds());let t="";"GET"!==i&&(t=a=this.json(s));const d=e+i+o+t,c=this.hmac(this.encode(d),this.encode(this.secret),n.s,"base64");r={"ACCESS-KEY":this.apiKey,"ACCESS-SIGN":c,"ACCESS-TIMESTAMP":e,"ACCESS-PASSPHRASE":this.password,"Content-Type":"application/json","X-CHANNEL-API-CODE":this.safeString(this.options,"brokerId","47cfy")}}return{url:this.urls.api[t]+o,method:i,body:a,headers:r}}}},2741:(e,t,i)=>{"use strict";i.d(t,{A:()=>n});var s=i(2938),r=i(2079),a=i(1579),o=i(4852);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coincheck",name:"coincheck",countries:["JP","ID"],rateLimit:1500,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,ws:!0},urls:{logo:"https://user-images.githubusercontent.com/51840849/87182088-1d6d6380-c2ec-11ea-9c64-8ab9f9b289f5.jpg",api:{rest:"https://coincheck.com/api"},www:"https://coincheck.com",doc:"https://coincheck.com/documents/exchange/api",fees:["https://coincheck.com/exchange/fee","https://coincheck.com/info/fee"]},api:{public:{get:["exchange/orders/rate","order_books","rate/{pair}","ticker","trades"]},private:{get:["accounts","accounts/balance","accounts/leverage_balance","bank_accounts","deposit_money","exchange/orders/opens","exchange/orders/transactions","exchange/orders/transactions_pagination","exchange/leverage/positions","lending/borrows/matches","send_money","withdraws"],post:["bank_accounts","deposit_money/{id}/fast","exchange/orders","exchange/transfers/to_leverage","exchange/transfers/from_leverage","lending/borrows","lending/borrows/{id}/repay","send_money","withdraws"],delete:["bank_accounts/{id}","exchange/orders/{id}","withdraws/{id}"]}},markets:{"BTC/JPY":this.safeMarketStructure({id:"btc_jpy",symbol:"BTC/JPY",base:"BTC",quote:"JPY",baseId:"btc",quoteId:"jpy",type:"spot",spot:!0}),"ETC/JPY":this.safeMarketStructure({id:"etc_jpy",symbol:"ETC/JPY",base:"ETC",quote:"JPY",baseId:"etc",quoteId:"jpy",type:"spot",spot:!0}),"FCT/JPY":this.safeMarketStructure({id:"fct_jpy",symbol:"FCT/JPY",base:"FCT",quote:"JPY",baseId:"fct",quoteId:"jpy",type:"spot",spot:!0}),"MONA/JPY":this.safeMarketStructure({id:"mona_jpy",symbol:"MONA/JPY",base:"MONA",quote:"JPY",baseId:"mona",quoteId:"jpy",type:"spot",spot:!0}),"ETC/BTC":this.safeMarketStructure({id:"etc_btc",symbol:"ETC/BTC",base:"ETC",quote:"BTC",baseId:"etc",quoteId:"btc",type:"spot",spot:!0})},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0"),taker:this.parseNumber("0")}},precisionMode:a.kb,exceptions:{exact:{"disabled API Key":r.AuthenticationError,"invalid authentication":r.AuthenticationError},broad:{}}})}parseBalance(e){const t={info:e},i=Object.keys(this.currencies);for(let s=0;s{"use strict";i.d(t,{A:()=>c});var s=i(5277),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(4035);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinex",name:"CoinEx",version:"v2",countries:["CN"],rateLimit:2.5,pro:!0,certified:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!0,borrowCrossMargin:!1,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!0,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createReduceOnlyOrder:!0,createStopLossOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTriggerOrder:!0,editOrder:!0,editOrders:!0,fetchBalance:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFee:!0,fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!0,fetchIsolatedBorrowRates:!1,fetchLeverage:!0,fetchLeverages:!1,fetchLeverageTiers:!0,fetchMarginAdjustmentHistory:!0,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!0,fetchPositionHistory:!0,fetchPositions:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransfer:!1,fetchTransfers:!0,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!0,repayCrossMargin:!1,repayIsolatedMargin:!0,setLeverage:!0,setMarginMode:!0,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1min","3m":"3min","5m":"5min","15m":"15min","30m":"30min","1h":"1hour","2h":"2hour","4h":"4hour","6h":"6hour","12h":"12hour","1d":"1day","3d":"3day","1w":"1week"},urls:{logo:"https://user-images.githubusercontent.com/51840849/87182089-1e05fa00-c2ec-11ea-8da9-cc73b45abbbc.jpg",api:{public:"https://api.coinex.com",private:"https://api.coinex.com",perpetualPublic:"https://api.coinex.com/perpetual",perpetualPrivate:"https://api.coinex.com/perpetual"},www:"https://www.coinex.com",doc:"https://docs.coinex.com/api/v2",fees:"https://www.coinex.com/fees",referral:"https://www.coinex.com/register?refer_code=yw5fz"},api:{v1:{public:{get:{"amm/market":1,"common/currency/rate":1,"common/asset/config":1,"common/maintain/info":1,"common/temp-maintain/info":1,"margin/market":1,"market/info":1,"market/list":1,"market/ticker":1,"market/ticker/all":1,"market/depth":1,"market/deals":1,"market/kline":1,"market/detail":1}},private:{get:{"account/amm/balance":40,"account/investment/balance":40,"account/balance/history":40,"account/market/fee":40,"balance/coin/deposit":40,"balance/coin/withdraw":40,"balance/info":40,"balance/deposit/address/{coin_type}":40,"contract/transfer/history":40,"credit/info":40,"credit/balance":40,"investment/transfer/history":40,"margin/account":1,"margin/config":1,"margin/loan/history":40,"margin/transfer/history":40,"order/deals":40,"order/finished":40,"order/pending":8,"order/status":8,"order/status/batch":8,"order/user/deals":40,"order/stop/finished":40,"order/stop/pending":8,"order/user/trade/fee":1,"order/market/trade/info":1,"sub_account/balance":1,"sub_account/transfer/history":40,"sub_account/auth/api":40,"sub_account/auth/api/{user_auth_id}":40},post:{"balance/coin/withdraw":40,"contract/balance/transfer":40,"margin/flat":40,"margin/loan":40,"margin/transfer":40,"order/limit/batch":40,"order/ioc":13.334,"order/limit":13.334,"order/market":13.334,"order/modify":13.334,"order/stop/limit":13.334,"order/stop/market":13.334,"order/stop/modify":13.334,"sub_account/transfer":40,"sub_account/register":1,"sub_account/unfrozen":40,"sub_account/frozen":40,"sub_account/auth/api":40},put:{"balance/deposit/address/{coin_type}":40,"sub_account/unfrozen":40,"sub_account/frozen":40,"sub_account/auth/api/{user_auth_id}":40,"v1/account/settings":40},delete:{"balance/coin/withdraw":40,"order/pending/batch":40,"order/pending":13.334,"order/stop/pending":40,"order/stop/pending/{id}":13.334,"order/pending/by_client_id":40,"order/stop/pending/by_client_id":40,"sub_account/auth/api/{user_auth_id}":40,"sub_account/authorize/{id}":40}},perpetualPublic:{get:{ping:1,time:1,"market/list":1,"market/limit_config":1,"market/ticker":1,"market/ticker/all":1,"market/depth":1,"market/deals":1,"market/funding_history":1,"market/kline":1}},perpetualPrivate:{get:{"market/user_deals":1,"asset/query":40,"order/pending":8,"order/finished":40,"order/stop_finished":40,"order/stop_pending":8,"order/status":8,"order/stop_status":8,"position/finished":40,"position/pending":40,"position/funding":40,"position/adl_history":40,"market/preference":40,"position/margin_history":40,"position/settle_history":40},post:{"market/adjust_leverage":1,"market/position_expect":1,"order/put_limit":20,"order/put_market":20,"order/put_stop_limit":20,"order/put_stop_market":20,"order/modify":20,"order/modify_stop":20,"order/cancel":20,"order/cancel_all":40,"order/cancel_batch":40,"order/cancel_stop":20,"order/cancel_stop_all":40,"order/close_limit":20,"order/close_market":20,"position/adjust_margin":20,"position/stop_loss":20,"position/take_profit":20,"position/market_close":20,"order/cancel/by_client_id":20,"order/cancel_stop/by_client_id":20,"market/preference":20}}},v2:{public:{get:{"maintain/info":1,ping:1,time:1,"spot/market":1,"spot/ticker":1,"spot/depth":1,"spot/deals":1,"spot/kline":1,"spot/index":1,"futures/market":1,"futures/ticker":1,"futures/depth":1,"futures/deals":1,"futures/kline":1,"futures/index":1,"futures/funding-rate":1,"futures/funding-rate-history":1,"futures/premium-index-history":1,"futures/position-level":1,"futures/liquidation-history":1,"futures/basis-history":1,"assets/deposit-withdraw-config":1,"assets/all-deposit-withdraw-config":1}},private:{get:{"account/subs":1,"account/subs/api-detail":40,"account/subs/info":1,"account/subs/api":40,"account/subs/transfer-history":40,"account/subs/balance":1,"account/subs/spot-balance":1,"account/trade-fee-rate":40,"account/futures-market-settings":1,"account/info":1,"assets/spot/balance":40,"assets/futures/balance":40,"assets/margin/balance":1,"assets/financial/balance":40,"assets/amm/liquidity":40,"assets/credit/info":40,"assets/spot/transcation-history":1,"assets/margin/borrow-history":40,"assets/margin/interest-limit":1,"assets/deposit-address":40,"assets/deposit-history":40,"assets/withdraw":40,"assets/transfer-history":40,"assets/amm/liquidity-pool":40,"assets/amm/income-history":40,"spot/order-status":8,"spot/batch-order-status":8,"spot/pending-order":8,"spot/finished-order":40,"spot/pending-stop-order":8,"spot/finished-stop-order":40,"spot/user-deals":40,"spot/order-deals":40,"futures/order-status":8,"futures/batch-order-status":1,"futures/pending-order":8,"futures/finished-order":40,"futures/pending-stop-order":8,"futures/finished-stop-order":40,"futures/user-deals":1,"futures/order-deals":1,"futures/pending-position":40,"futures/finished-position":1,"futures/position-margin-history":1,"futures/position-funding-history":40,"futures/position-adl-history":1,"futures/position-settle-history":1,"refer/referee":1,"refer/referee-rebate/record":1,"refer/referee-rebate/detail":1,"refer/agent-referee":1,"refer/agent-rebate/record":1,"refer/agent-rebate/detail":1},post:{"account/subs":40,"account/subs/frozen":40,"account/subs/unfrozen":40,"account/subs/api":40,"account/subs/edit-api":40,"account/subs/delete-api":40,"account/subs/transfer":40,"account/settings":40,"account/futures-market-settings":40,"assets/margin/borrow":40,"assets/margin/repay":40,"assets/renewal-deposit-address":40,"assets/withdraw":40,"assets/cancel-withdraw":40,"assets/transfer":40,"assets/amm/add-liquidity":1,"assets/amm/remove-liquidity":1,"spot/order":13.334,"spot/stop-order":13.334,"spot/batch-order":40,"spot/batch-stop-order":1,"spot/modify-order":13.334,"spot/modify-stop-order":13.334,"spot/batch-modify-order":13.334,"spot/cancel-all-order":1,"spot/cancel-order":6.667,"spot/cancel-stop-order":6.667,"spot/cancel-batch-order":10,"spot/cancel-batch-stop-order":10,"spot/cancel-order-by-client-id":1,"spot/cancel-stop-order-by-client-id":1,"futures/order":20,"futures/stop-order":20,"futures/batch-order":1,"futures/batch-stop-order":1,"futures/modify-order":20,"futures/modify-stop-order":20,"futures/batch-modify-order":20,"futures/cancel-all-order":1,"futures/cancel-order":10,"futures/cancel-stop-order":10,"futures/cancel-batch-order":20,"futures/cancel-batch-stop-order":20,"futures/cancel-order-by-client-id":1,"futures/cancel-stop-order-by-client-id":1,"futures/close-position":20,"futures/adjust-position-margin":20,"futures/adjust-position-leverage":20,"futures/set-position-stop-loss":20,"futures/set-position-take-profit":20}}}},fees:{trading:{maker:.001,taker:.001},funding:{withdraw:{BCH:0,BTC:.001,LTC:.001,ETH:.001,ZEC:1e-4,DASH:1e-4}}},limits:{amount:{min:.001,max:void 0}},options:{brokerId:"x-167673045",createMarketBuyOrderRequiresPrice:!0,defaultType:"spot",defaultSubType:"linear",fetchDepositAddress:{fillResponseFromRequest:!0},accountsByType:{spot:"SPOT",margin:"MARGIN",swap:"FUTURES"},accountsById:{SPOT:"spot",MARGIN:"margin",FUTURES:"swap"},networks:{BTC:"BTC",BEP20:"BSC",TRC20:"TRC20",ERC20:"ERC20",BRC20:"BRC20",SOL:"SOL",TON:"TON",BSV:"BSV",AVAXC:"AVA_C",AVAXX:"AVA",SUI:"SUI",ACA:"ACA",CHZ:"CHILIZ",ADA:"ADA",ARB:"ARBITRUM",ARBNOVA:"ARBITRUM_NOVA",OP:"OPTIMISM",APT:"APTOS",ATOM:"ATOM",FTM:"FTM",BCH:"BCH",ASTR:"ASTR",LTC:"LTC",MATIC:"MATIC",CRONOS:"CRONOS",DASH:"DASH",DOT:"DOT",ETC:"ETC",ETHW:"ETHPOW",FIL:"FIL",ZIL:"ZIL",DOGE:"DOGE",TIA:"CELESTIA",SEI:"SEI",XRP:"XRP",XMR:"XMR"}},features:{spot:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!0,iceberg:!0},createOrders:{max:5},fetchMyTrades:{marginMode:!0,limit:1e3,daysBack:void 0,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,limit:1e3,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:1e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},forDerivatives:{extends:"spot",createOrder:{marginMode:!0,stopLossPrice:!0,takeProfitPrice:!0},fetchOpenOrders:{marginMode:!1},fetchClosedOrders:{marginMode:!1}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:void 0,inverse:void 0}},commonCurrencies:{ACM:"Actinium"},precisionMode:o.kb,exceptions:{exact:{23:r.PermissionDenied,24:r.AuthenticationError,25:r.AuthenticationError,34:r.AuthenticationError,35:r.ExchangeNotAvailable,36:r.RequestTimeout,213:r.RateLimitExceeded,107:r.InsufficientFunds,158:r.PermissionDenied,600:r.OrderNotFound,601:r.InvalidOrder,602:r.InvalidOrder,606:r.InvalidOrder,3008:r.RequestTimeout,3109:r.InsufficientFunds,3127:r.InvalidOrder,3600:r.OrderNotFound,3606:r.InvalidOrder,3610:r.ExchangeError,3612:r.InvalidOrder,3613:r.InvalidOrder,3614:r.InvalidOrder,3615:r.InvalidOrder,3616:r.InvalidOrder,3617:r.InvalidOrder,3618:r.InvalidOrder,3619:r.InvalidOrder,3620:r.InvalidOrder,3621:r.InvalidOrder,3622:r.InvalidOrder,3627:r.InvalidOrder,3628:r.InvalidOrder,3629:r.InvalidOrder,3632:r.InvalidOrder,3633:r.InvalidOrder,3634:r.InvalidOrder,3635:r.InvalidOrder,4001:r.ExchangeNotAvailable,4002:r.RequestTimeout,4003:r.ExchangeError,4004:r.BadRequest,4005:r.AuthenticationError,4006:r.AuthenticationError,4007:r.PermissionDenied,4008:r.AuthenticationError,4009:r.ExchangeError,4010:r.ExchangeError,4011:r.PermissionDenied,4017:r.ExchangeError,4115:r.AccountSuspended,4117:r.BadSymbol,4123:r.RateLimitExceeded,4130:r.ExchangeError,4158:r.ExchangeError,4213:r.RateLimitExceeded,4512:r.PermissionDenied},broad:{"ip not allow visit":r.PermissionDenied,"service too busy":r.ExchangeNotAvailable,"Service is not available during funding fee settlement":r.OperationFailed}}})}async fetchCurrencies(e={}){const t=await this.v2PublicGetAssetsAllDepositWithdrawConfig(e),i=this.safeList(t,"data",[]),s={};for(let e=0;e1&&"cfx"!==s[0]?(r=s[0],a=s[1]):r=i,{info:e,currency:this.safeCurrencyCode(void 0,t),network:void 0,address:r,tag:this.safeString(e,"memo",a)}}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const a=this.market(e);let o,n={market:a.id};if(void 0!==i&&(n.limit=i),void 0!==t&&(n.start_time=t),[n,s]=this.handleUntilOption("end_time",n,s),a.swap)n.market_type="FUTURES",o=await this.v2PrivateGetFuturesUserDeals(this.extend(n,s));else{let e;[e,s]=this.handleMarginModeAndParams("fetchMyTrades",s),n.market_type=void 0!==e?"MARGIN":"SPOT",o=await this.v2PrivateGetSpotUserDeals(this.extend(n,s))}const d=this.safeList(o,"data",[]);return this.parseTrades(d,a,t,i)}async fetchPositions(e=void 0,t={}){let i;await this.loadMarkets(),[i,t]=this.handleOptionAndParams(t,"fetchPositions","method","v2PrivateGetFuturesPendingPosition");const s={market_type:"FUTURES"};let a,o;if(void 0!==(e=this.marketSymbols(e))){let t;if(Array.isArray(e)){if(e.length>1)throw new r.BadRequest(this.id+" fetchPositions() symbols argument cannot contain more than 1 symbol");t=e[0]}else t=e;a=this.market(t),s.market=a.id}o="v2PrivateGetFuturesPendingPosition"===i?await this.v2PrivateGetFuturesPendingPosition(this.extend(s,t)):await this.v2PrivateGetFuturesFinishedPosition(this.extend(s,t));const n=this.safeList(o,"data",[]),d=[];for(let e=0;eo)throw new r.BadRequest(this.id+" setMarginMode() leverage should be between 1 and "+o.toString()+" for "+t);const n={market:s.id,market_type:"FUTURES",margin_mode:e,leverage:a};return await this.v2PrivatePostFuturesAdjustPositionLeverage(this.extend(n,i))}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");await this.loadMarkets();const s=this.market(t);if(!s.swap)throw new r.BadSymbol(this.id+" setLeverage() supports swap contracts only");let a;[a,i]=this.handleMarginModeAndParams("setLeverage",i,"cross");const o=this.safeInteger(s.limits.leverage,"min",1),n=this.safeInteger(s.limits.leverage,"max",100);if(en)throw new r.BadRequest(this.id+" setLeverage() leverage should be between "+o.toString()+" and "+n.toString()+" for "+t);const d={market:s.id,market_type:"FUTURES",margin_mode:a,leverage:e};return await this.v2PrivatePostFuturesAdjustPositionLeverage(this.extend(d,i))}async fetchLeverageTiers(e=void 0,t={}){await this.loadMarkets();const i={};if(void 0!==e){const t=this.marketIds(e);i.market=t.join(",")}const s=await this.v2PublicGetFuturesPositionLevel(this.extend(i,t)),r=this.safeList(s,"data",[]);return this.parseLeverageTiers(r,e,"market")}parseMarketLeverageTiers(e,t=void 0){const i=[],s=this.safeList(e,"level",[]);let r=0;for(let a=0;a{"use strict";i.d(t,{A:()=>d});var s=i(8109),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinmate",name:"CoinMate",countries:["GB","CZ","EU"],rateLimit:600,has:{CORS:!0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactions:"emulated",fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/51840849/87460806-1c9f3f00-c616-11ea-8c46-a77018a8f3f4.jpg",api:{rest:"https://coinmate.io/api"},www:"https://coinmate.io",fees:"https://coinmate.io/fees",doc:["https://coinmate.docs.apiary.io","https://coinmate.io/developers"],referral:"https://coinmate.io?referral=YTFkM1RsOWFObVpmY1ZjMGREQmpTRnBsWjJJNVp3PT0"},requiredCredentials:{apiKey:!0,secret:!0,uid:!0},api:{public:{get:["orderBook","ticker","tickerAll","products","transactions","tradingPairs","system/time"]},private:{post:["currencies","balances","bitcoinCashWithdrawal","bitcoinCashDepositAddresses","bitcoinDepositAddresses","bitcoinWithdrawal","bitcoinWithdrawalFees","buyInstant","buyLimit","cancelOrder","cancelOrderWithInfo","createVoucher","dashDepositAddresses","dashWithdrawal","ethereumWithdrawal","ethereumDepositAddresses","litecoinWithdrawal","litecoinDepositAddresses","openOrders","order","orderHistory","orderById","pusherAuth","redeemVoucher","replaceByBuyLimit","replaceByBuyInstant","replaceBySellLimit","replaceBySellInstant","rippleDepositAddresses","rippleWithdrawal","sellInstant","sellLimit","transactionHistory","traderFees","tradeHistory","transfer","transferHistory","unconfirmedBitcoinDeposits","unconfirmedBitcoinCashDeposits","unconfirmedDashDeposits","unconfirmedEthereumDeposits","unconfirmedLitecoinDeposits","unconfirmedRippleDeposits","cancelAllOpenOrders","withdrawVirtualCurrency","virtualCurrencyDepositAddresses","unconfirmedVirtualCurrencyDeposits","adaWithdrawal","adaDepositAddresses","unconfirmedAdaDeposits","solWithdrawal","solDepositAddresses","unconfirmedSolDeposits","bankWireWithdrawal"]}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.006"),maker:this.parseNumber("0.004"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.006")],[this.parseNumber("10000"),this.parseNumber("0.003")],[this.parseNumber("100000"),this.parseNumber("0.0023")],[this.parseNumber("250000"),this.parseNumber("0.0021")],[this.parseNumber("500000"),this.parseNumber("0.0018")],[this.parseNumber("1000000"),this.parseNumber("0.0015")],[this.parseNumber("3000000"),this.parseNumber("0.0012")],[this.parseNumber("15000000"),this.parseNumber("0.001")]],maker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("10000"),this.parseNumber("0.002")],[this.parseNumber("100000"),this.parseNumber("0.0012")],[this.parseNumber("250000"),this.parseNumber("0.0009")],[this.parseNumber("500000"),this.parseNumber("0.0005")],[this.parseNumber("1000000"),this.parseNumber("0.0003")],[this.parseNumber("3000000"),this.parseNumber("0.0002")],[this.parseNumber("15000000"),this.parseNumber("-0.0004")]]}}},options:{withdraw:{fillResponsefromRequest:!0,methods:{BTC:"privatePostBitcoinWithdrawal",LTC:"privatePostLitecoinWithdrawal",BCH:"privatePostBitcoinCashWithdrawal",ETH:"privatePostEthereumWithdrawal",XRP:"privatePostRippleWithdrawal",DASH:"privatePostDashWithdrawal",DAI:"privatePostDaiWithdrawal",ADA:"privatePostAdaWithdrawal",SOL:"privatePostSolWithdrawal"}}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"No order with given ID":r.OrderNotFound},broad:{"Not enough account balance available":r.InsufficientFunds,"Incorrect order ID":r.InvalidOrder,"Minimum Order Size ":r.InvalidOrder,"max allowed precision":r.InvalidOrder,"TOO MANY REQUESTS":r.RateLimitExceeded,"Access denied.":r.AuthenticationError}},precisionMode:o.kb})}async fetchTime(e={}){const t=await this.publicGetSystemTime(e);return this.safeInteger(t,"serverTime")}async fetchMarkets(e={}){const t=await this.publicGetTradingPairs(e),i=this.safeValue(t,"data",[]),s=[];for(let e=0;e{"use strict";i.d(t,{A:()=>n});var s=i(1671),r=i(2079),a=i(1579),o=i(5147);class n extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinmetro",name:"Coinmetro",countries:["EE"],version:"v1",rateLimit:200,certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!0,borrowIsolatedMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!0,createDepositAddress:!1,createOrder:!0,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,deposit:!1,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!1,ws:!1},timeframes:{"1m":"60000","5m":"300000","30m":"1800000","4h":"14400000","1d":"86400000"},urls:{logo:"https://github.com/ccxt/ccxt/assets/43336371/e86f87ec-6ba3-4410-962b-f7988c5db539",api:{public:"https://api.coinmetro.com",private:"https://api.coinmetro.com"},test:{public:"https://api.coinmetro.com/open",private:"https://api.coinmetro.com/open"},www:"https://coinmetro.com/",doc:["https://documenter.getpostman.com/view/3653795/SVfWN6KS"],fees:"https://help.coinmetro.com/hc/en-gb/articles/6844007317789-What-are-the-fees-on-Coinmetro-",referral:"https://go.coinmetro.com/?ref=crypto24"},api:{public:{get:{"demo/temp":1,"exchange/candles/{pair}/{timeframe}/{from}/{to}":3,"exchange/prices":1,"exchange/ticks/{pair}/{from}":3,assets:1,markets:1,"exchange/book/{pair}":3,"exchange/bookUpdates/{pair}/{from}":1}},private:{get:{"users/balances":1,"users/wallets":1,"users/wallets/history/{since}":1.67,"exchange/orders/status/{orderID}":1,"exchange/orders/active":1,"exchange/orders/history/{since}":1.67,"exchange/fills/{since}":1.67,"exchange/margin":1},post:{jwt:1,jwtDevice:1,devices:1,"jwt-read-only":1,"exchange/orders/create":1,"exchange/orders/modify/{orderID}":1,"exchange/swap":1,"exchange/swap/confirm/{swapId}":1,"exchange/orders/close/{orderID}":1,"exchange/orders/hedge":1},put:{jwt:1,"exchange/orders/cancel/{orderID}":1,"users/margin/collateral":1,"users/margin/primary/{currency}":1}}},requiredCredentials:{apiKey:!1,secret:!1,uid:!0,token:!0},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0")}},precisionMode:a.kb,options:{currenciesByIdForParseMarket:void 0,currencyIdsListForParseMarket:["QRDO"]},features:{spot:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!1},timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:1e5,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:void 0,daysBack:1e5,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"Both buyingCurrency and sellingCurrency are required":r.InvalidOrder,"One and only one of buyingQty and sellingQty is required":r.InvalidOrder,"Invalid buyingCurrency":r.InvalidOrder,"Invalid 'from'":r.BadRequest,"Invalid sellingCurrency":r.InvalidOrder,"Invalid buyingQty":r.InvalidOrder,"Invalid sellingQty":r.InvalidOrder,"Insufficient balance":r.InsufficientFunds,"Expiration date is in the past or too near in the future":r.InvalidOrder,Forbidden:r.PermissionDenied,"Order Not Found":r.OrderNotFound,"since must be a millisecond timestamp":r.BadRequest,"This pair is disabled on margin":r.BadSymbol},broad:{"accessing from a new IP":r.PermissionDenied,"available to allocate as collateral":r.InsufficientFunds,"At least":r.BadRequest,"collateral is not allowed":r.BadRequest,"Insufficient liquidity":r.InvalidOrder,"Insufficient order size":r.InvalidOrder,"Invalid quantity":r.InvalidOrder,"Invalid Stop Loss":r.InvalidOrder,"Invalid stop price!":r.InvalidOrder,"Not enough balance":r.InsufficientFunds,"Not enough margin":r.InsufficientFunds,"orderType missing":r.BadRequest,"Server Timeout":r.ExchangeError,"Time in force has to be IOC or FOK for market orders":r.InvalidOrder,"Too many attempts":r.RateLimitExceeded}}})}async fetchCurrencies(e={}){const t=await this.publicGetAssets(e),i={};for(let e=0;e1&&(t=this.parseLedgerEntryType(s[0]),i="-"!==s[1]?s[1]:this.safeString(s,2)),[t,i]}parseLedgerEntryType(e){return this.safeString({Deposit:"transaction",Withdraw:"transaction",Order:"trade"},e,e)}async createOrder(e,t,i,s,a=void 0,n={}){await this.loadMarkets();const d=this.market(e);let c,h={};h.orderType=t,void 0!==s&&(c=this.amountToPrecision(e,s));let l,u=this.safeValue(n,"cost");if(n=this.omit(n,"cost"),"limit"===t){if(void 0===a&&void 0===u)throw new r.ArgumentsRequired(this.id+" createOrder() requires a price or params.cost argument for a "+t+" order");if(void 0!==a&&void 0!==s){const e=o.Y.stringMul(this.numberToString(a),this.numberToString(c));u=this.parseToNumeric(e)}}void 0!==u&&(l=this.costToPrecision(e,u)),"sell"===i?h=this.handleCreateOrderSide(d.baseId,d.quoteId,c,l,h):"buy"===i&&(h=this.handleCreateOrderSide(d.quoteId,d.baseId,l,c,h));const p=this.safeValue(n,"timeInForce");void 0!==p&&(n=this.omit(n,"timeInForce"),h.timeInForce=this.encodeOrderTimeInForce(p));const f=this.safeString2(n,"triggerPrice","stopPrice");void 0!==f&&(n=this.omit(n,["triggerPrice"]),h.stopPrice=this.priceToPrecision(e,f));const m=this.safeValue(n,"userData",{}),g=this.safeString2(n,"clientOrderId","comment");void 0!==g&&(n=this.omit(n,["clientOrderId"]),m.comment=g);const v=this.safeString(n,"stopLossPrice");void 0!==v&&(n=this.omit(n,"stopLossPrice"),m.stopLoss=this.priceToPrecision(e,v));const y=this.safeString(n,"takeProfitPrice");void 0!==y&&(n=this.omit(n,"takeProfitPrice"),m.takeProfit=this.priceToPrecision(e,y)),this.isEmpty(m)||(h.userData=m);const b=await this.privatePostExchangeOrdersCreate(this.extend(h,n));return this.parseOrder(b,d)}handleCreateOrderSide(e,t,i,s,r={}){return r.sellingCurrency=e,r.buyingCurrency=t,void 0!==i&&(r.sellingQty=i),void 0!==s&&(r.buyingQty=s),r}encodeOrderTimeInForce(e){return this.safeValue({GTC:1,IOC:2,GTD:3,FOK:4},e,e)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderID:e};[i,i]=this.handleMarginModeAndParams("cancelOrder",i);const r=this.safeBool(i,"margin",!1);let a;return i=this.omit(i,"margin"),a=r?await this.privatePostExchangeOrdersCloseOrderID(this.extend(s,i)):await this.privatePutExchangeOrdersCancelOrderID(this.extend(s,i)),this.parseOrder(a)}async closePosition(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeString(i,"orderId");if(void 0===s)throw new r.ArgumentsRequired(this.id+" closePosition() requires a orderId parameter");const a={orderID:s},o=await this.privatePostExchangeOrdersCloseOrderID(this.extend(a,i));return this.parseOrder(o)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a=await this.privateGetExchangeOrdersActive(s),o=this.parseOrders(a,r,t,i);for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(6658),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinone",name:"CoinOne",countries:["KR"],rateLimit:50,version:"v2",pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,ws:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg",api:{rest:"https://api.coinone.co.kr",v2Public:"https://api.coinone.co.kr/public/v2",v2Private:"https://api.coinone.co.kr/v2",v2_1Private:"https://api.coinone.co.kr/v2.1"},www:"https://coinone.co.kr",doc:"https://doc.coinone.co.kr"},requiredCredentials:{apiKey:!0,secret:!0},api:{public:{get:["orderbook","ticker","ticker_utc","trades"]},v2Public:{get:["range_units","markets/{quote_currency}","markets/{quote_currency}/{target_currency}","orderbook/{quote_currency}/{target_currency}","trades/{quote_currency}/{target_currency}","ticker_new/{quote_currency}","ticker_new/{quote_currency}/{target_currency}","ticker_utc_new/{quote_currency}","ticker_utc_new/{quote_currency}/{target_currency}","currencies","currencies/{currency}","chart/{quote_currency}/{target_currency}"]},private:{post:["account/deposit_address","account/btc_deposit_address","account/balance","account/daily_balance","account/user_info","account/virtual_account","order/cancel_all","order/cancel","order/limit_buy","order/limit_sell","order/complete_orders","order/limit_orders","order/order_info","transaction/auth_number","transaction/history","transaction/krw/history","transaction/btc","transaction/coin"]},v2Private:{post:["account/balance","account/deposit_address","account/user_info","account/virtual_account","order/cancel","order/limit_buy","order/limit_sell","order/limit_orders","order/complete_orders","order/query_order","transaction/auth_number","transaction/btc","transaction/history","transaction/krw/history"]},v2_1Private:{post:["account/balance/all","account/balance","account/trade_fee","account/trade_fee/{quote_currency}/{target_currency}","order/limit","order/cancel","order/cancel/all","order/open_orders","order/open_orders/all","order/complete_orders","order/complete_orders/all","order/info","transaction/krw/history","transaction/coin/history","transaction/coin/withdrawal/limit"]}},fees:{trading:{tierBased:!1,percentage:!0,taker:.002,maker:.002}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{104:r.OrderNotFound,107:r.BadRequest,108:r.BadSymbol,405:r.OnMaintenance},commonCurrencies:{SOC:"Soda Coin"}})}async fetchCurrencies(e={}){const t=await this.v2PublicGetCurrencies(e),i={},s=this.safeList(t,"currencies",[]);for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(4935),r=i(2079),a=i(1579),o=i(5147),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinsph",name:"Coins.ph",countries:["PH"],version:"v1",rateLimit:50,certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,deposit:!0,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:void 0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchL3OrderBook:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:void 0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawal:void 0,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!1,withdraw:!0,ws:!1},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/225719995-48ab2026-4ddb-496c-9da7-0d7566617c9b.jpg",api:{public:"https://api.pro.coins.ph",private:"https://api.pro.coins.ph"},www:"https://coins.ph/",doc:["https://coins-docs.github.io/rest-api"],fees:"https://support.coins.ph/hc/en-us/sections/4407198694681-Limits-Fees"},api:{public:{get:{"openapi/v1/ping":1,"openapi/v1/time":1,"openapi/v1/user/ip":1,"openapi/quote/v1/ticker/24hr":{cost:1,noSymbolAndNoSymbols:40,byNumberOfSymbols:[[101,40],[21,20],[0,1]]},"openapi/quote/v1/ticker/price":{cost:1,noSymbol:2},"openapi/quote/v1/ticker/bookTicker":{cost:1,noSymbol:2},"openapi/v1/exchangeInfo":10,"openapi/quote/v1/depth":{cost:1,byLimit:[[101,5],[0,1]]},"openapi/quote/v1/klines":1,"openapi/quote/v1/trades":1,"openapi/v1/pairs":1,"openapi/quote/v1/avgPrice":1}},private:{get:{"openapi/v1/check-sys-status":1,"openapi/wallet/v1/config/getall":10,"openapi/wallet/v1/deposit/address":10,"openapi/wallet/v1/deposit/history":1,"openapi/wallet/v1/withdraw/history":1,"openapi/wallet/v1/withdraw/address-whitelist":1,"openapi/v1/account":10,"openapi/v1/api-keys":1,"openapi/v1/openOrders":{cost:3,noSymbol:40},"openapi/v1/asset/tradeFee":1,"openapi/v1/order":2,"openapi/v1/historyOrders":{cost:10,noSymbol:40},"openapi/v1/myTrades":10,"openapi/v1/capital/deposit/history":1,"openapi/v1/capital/withdraw/history":1,"openapi/v3/payment-request/get-payment-request":1,"merchant-api/v1/get-invoices":1,"openapi/account/v3/crypto-accounts":1,"openapi/transfer/v3/transfers/{id}":1,"openapi/v1/sub-account/list":10,"openapi/v1/sub-account/asset":10,"openapi/v1/sub-account/transfer/universal-transfer-history":10,"openapi/v1/sub-account/transfer/sub-history":10,"openapi/v1/sub-account/apikey/ip-restriction":10,"openapi/v1/sub-account/wallet/deposit/address":1,"openapi/v1/sub-account/wallet/deposit/history":1,"openapi/v1/fund-collect/get-fund-record":1,"openapi/v1/asset/transaction/history":20},post:{"openapi/wallet/v1/withdraw/apply":600,"openapi/v1/order/test":1,"openapi/v1/order":1,"openapi/v1/capital/withdraw/apply":1,"openapi/v1/capital/deposit/apply":1,"openapi/v3/payment-request/payment-requests":1,"openapi/v3/payment-request/delete-payment-request":1,"openapi/v3/payment-request/payment-request-reminder":1,"openapi/v1/userDataStream":1,"merchant-api/v1/invoices":1,"merchant-api/v1/invoices-cancel":1,"openapi/convert/v1/get-supported-trading-pairs":1,"openapi/convert/v1/get-quote":1,"openapi/convert/v1/accpet-quote":1,"openapi/convert/v1/query-order-history":1,"openapi/fiat/v1/support-channel":1,"openapi/fiat/v1/cash-out":1,"openapi/fiat/v1/history":1,"openapi/migration/v4/sellorder":1,"openapi/migration/v4/validate-field":1,"openapi/transfer/v3/transfers":1,"openapi/v1/sub-account/create":30,"openapi/v1/sub-account/transfer/universal-transfer":100,"openapi/v1/sub-account/transfer/sub-to-master":100,"openapi/v1/sub-account/apikey/add-ip-restriction":30,"openapi/v1/sub-account/apikey/delete-ip-restriction":30,"openapi/v1/fund-collect/collect-from-sub-account":1},put:{"openapi/v1/userDataStream":1},delete:{"openapi/v1/order":1,"openapi/v1/openOrders":1,"openapi/v1/userDataStream":1}}},fees:{trading:{feeSide:"get",tierBased:!0,percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.003"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.003")],[this.parseNumber("500000"),this.parseNumber("0.0027")],[this.parseNumber("1000000"),this.parseNumber("0.0024")],[this.parseNumber("2500000"),this.parseNumber("0.002")],[this.parseNumber("5000000"),this.parseNumber("0.0018")],[this.parseNumber("10000000"),this.parseNumber("0.0015")],[this.parseNumber("100000000"),this.parseNumber("0.0012")],[this.parseNumber("500000000"),this.parseNumber("0.0009")],[this.parseNumber("1000000000"),this.parseNumber("0.0007")],[this.parseNumber("2500000000"),this.parseNumber("0.0005")]],maker:[[this.parseNumber("0"),this.parseNumber("0.0025")],[this.parseNumber("500000"),this.parseNumber("0.0022")],[this.parseNumber("1000000"),this.parseNumber("0.0018")],[this.parseNumber("2500000"),this.parseNumber("0.0015")],[this.parseNumber("5000000"),this.parseNumber("0.0012")],[this.parseNumber("10000000"),this.parseNumber("0.001")],[this.parseNumber("100000000"),this.parseNumber("0.0008")],[this.parseNumber("500000000"),this.parseNumber("0.0007")],[this.parseNumber("1000000000"),this.parseNumber("0.0006")],[this.parseNumber("2500000000"),this.parseNumber("0.0005")]]}}},precisionMode:a.kb,options:{createMarketBuyOrderRequiresPrice:!0,withdraw:{warning:!1},deposit:{warning:!1},createOrder:{timeInForce:"GTC",newOrderRespType:{market:"FULL",limit:"FULL"}},fetchTicker:{method:"publicGetOpenapiQuoteV1Ticker24hr"},fetchTickers:{method:"publicGetOpenapiQuoteV1Ticker24hr"},networks:{TRC20:"TRX",ERC20:"ETH",BEP20:"BSC",ARB:"ARBITRUM"}},features:{spot:{sandbox:!1,fetchCurrencies:{private:!0},createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!0,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},exceptions:{exact:{"-1000":r.BadRequest,"-1001":r.BadRequest,"-1002":r.AuthenticationError,"-1003":r.RateLimitExceeded,"-1004":r.InvalidOrder,"-1006":r.BadResponse,"-1007":r.BadResponse,"-1014":r.InvalidOrder,"-1015":r.RateLimitExceeded,"-1016":r.NotSupported,"-1020":r.NotSupported,"-1021":r.BadRequest,"-1022":r.BadRequest,"-1023":r.AuthenticationError,"-1024":r.BadRequest,"-1025":r.BadRequest,"-1030":r.ExchangeError,"-1100":r.BadRequest,"-1101":r.BadRequest,"-1102":r.BadRequest,"-1103":r.BadRequest,"-1104":r.BadRequest,"-1105":r.BadRequest,"-1106":r.BadRequest,"-1111":r.BadRequest,"-1112":r.BadResponse,"-1114":r.BadRequest,"-1115":r.InvalidOrder,"-1116":r.InvalidOrder,"-1117":r.InvalidOrder,"-1118":r.InvalidOrder,"-1119":r.InvalidOrder,"-1120":r.BadRequest,"-1121":r.BadSymbol,"-1122":r.InvalidOrder,"-1125":r.BadRequest,"-1127":r.BadRequest,"-1128":r.BadRequest,"-1130":r.BadRequest,"-1131":r.InsufficientFunds,"-1132":r.InvalidOrder,"-1133":r.InvalidOrder,"-1134":r.InvalidOrder,"-1135":r.InvalidOrder,"-1136":r.InvalidOrder,"-1137":r.InvalidOrder,"-1138":r.InvalidOrder,"-1139":r.InvalidOrder,"-1140":r.InvalidOrder,"-1141":r.DuplicateOrderId,"-1142":r.InvalidOrder,"-1143":r.OrderNotFound,"-1144":r.InvalidOrder,"-1145":r.InvalidOrder,"-1146":r.InvalidOrder,"-1147":r.InvalidOrder,"-1148":r.InvalidOrder,"-1149":r.InvalidOrder,"-1150":r.InvalidOrder,"-1151":r.BadSymbol,"-1152":r.NotSupported,"-1153":r.AuthenticationError,"-1154":r.BadRequest,"-1155":r.BadRequest,"-1156":r.InvalidOrder,"-1157":r.BadSymbol,"-1158":r.InvalidOrder,"-1159":r.InvalidOrder,"-1160":r.BadRequest,"-1161":r.BadRequest,"-2010":r.InvalidOrder,"-2013":r.OrderNotFound,"-2011":r.BadRequest,"-2014":r.BadRequest,"-2015":r.AuthenticationError,"-2016":r.BadResponse,"-3126":r.InvalidOrder,"-3127":r.InvalidOrder,"-4001":r.BadRequest,"-100011":r.BadSymbol,"-100012":r.BadSymbol,"-30008":r.InsufficientFunds,"-30036":r.InsufficientFunds,403:r.ExchangeNotAvailable},broad:{"Unknown order sent":r.OrderNotFound,"Duplicate order sent":r.DuplicateOrderId,"Market is closed":r.BadSymbol,"Account has insufficient balance for requested action":r.InsufficientFunds,"Market orders are not supported for this symbol":r.BadSymbol,"Iceberg orders are not supported for this symbol":r.BadSymbol,"Stop loss orders are not supported for this symbol":r.BadSymbol,"Stop loss limit orders are not supported for this symbol":r.BadSymbol,"Take profit orders are not supported for this symbol":r.BadSymbol,"Take profit limit orders are not supported for this symbol":r.BadSymbol,"Price* QTY is zero or less":r.BadRequest,"IcebergQty exceeds QTY":r.BadRequest,"This action disabled is on this account":r.PermissionDenied,"Unsupported order combination":r.InvalidOrder,"Order would trigger immediately":r.InvalidOrder,"Cancel order is invalid. Check origClOrdId and orderId":r.InvalidOrder,"Order would immediately match and take":r.OrderImmediatelyFillable,PRICE_FILTER:r.InvalidOrder,LOT_SIZE:r.InvalidOrder,MIN_NOTIONAL:r.InvalidOrder,MAX_NUM_ORDERS:r.InvalidOrder,MAX_ALGO_ORDERS:r.InvalidOrder,BROKER_MAX_NUM_ORDERS:r.InvalidOrder,BROKER_MAX_ALGO_ORDERS:r.InvalidOrder,ICEBERG_PARTS:r.BadRequest}}})}async fetchCurrencies(e={}){if(!this.checkRequiredCredentials(!1))return{};const t=await this.privateGetOpenapiWalletV1ConfigGetall(e),i={};for(let e=0;e=s[0])return s[1]}}else if("byLimit"in r&&"limit"in s){const e=s.limit,t=r.byLimit;for(let i=0;i=s[0])return s[1]}}return this.safeValue(r,"cost",1)}async fetchStatus(e={}){return{status:"ok",updated:void 0,eta:void 0,url:void 0,info:await this.publicGetOpenapiV1Ping(e)}}async fetchTime(e={}){const t=await this.publicGetOpenapiV1Time(e);return this.safeInteger(t,"serverTime")}async fetchMarkets(e={}){const t=await this.publicGetOpenapiV1ExchangeInfo(e),i=this.safeList(t,"symbols",[]),s=[];for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(9360),r=i(2079),a=i(1579),o=i(7481),n=i(5147);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"coinspot",name:"CoinSpot",countries:["AU"],rateLimit:1e3,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOption:!1,fetchOptionChain:!1,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,ws:!1},urls:{logo:"https://user-images.githubusercontent.com/1294454/28208429-3cacdf9a-6896-11e7-854e-4c79a772a30f.jpg",api:{public:"https://www.coinspot.com.au/pubapi",private:"https://www.coinspot.com.au/api"},www:"https://www.coinspot.com.au",doc:"https://www.coinspot.com.au/api",referral:"https://www.coinspot.com.au/register?code=PJURCU"},api:{public:{get:["latest"]},private:{post:["orders","orders/history","my/coin/deposit","my/coin/send","quote/buy","quote/sell","my/balances","my/orders","my/buy","my/sell","my/buy/cancel","my/sell/cancel","ro/my/balances","ro/my/balances/{cointype}","ro/my/deposits","ro/my/withdrawals","ro/my/transactions","ro/my/transactions/{cointype}","ro/my/transactions/open","ro/my/transactions/{cointype}/open","ro/my/sendreceive","ro/my/affiliatepayments","ro/my/referralpayments"]}},markets:{"ADA/AUD":this.safeMarketStructure({id:"ada",symbol:"ADA/AUD",base:"ADA",quote:"AUD",baseId:"ada",quoteId:"aud",type:"spot",spot:!0}),"BTC/AUD":this.safeMarketStructure({id:"btc",symbol:"BTC/AUD",base:"BTC",quote:"AUD",baseId:"btc",quoteId:"aud",type:"spot",spot:!0}),"ETH/AUD":this.safeMarketStructure({id:"eth",symbol:"ETH/AUD",base:"ETH",quote:"AUD",baseId:"eth",quoteId:"aud",type:"spot",spot:!0}),"XRP/AUD":this.safeMarketStructure({id:"xrp",symbol:"XRP/AUD",base:"XRP",quote:"AUD",baseId:"xrp",quoteId:"aud",type:"spot",spot:!0}),"LTC/AUD":this.safeMarketStructure({id:"ltc",symbol:"LTC/AUD",base:"LTC",quote:"AUD",baseId:"ltc",quoteId:"aud",type:"spot",spot:!0}),"DOGE/AUD":this.safeMarketStructure({id:"doge",symbol:"DOGE/AUD",base:"DOGE",quote:"AUD",baseId:"doge",quoteId:"aud",type:"spot",spot:!0}),"RFOX/AUD":this.safeMarketStructure({id:"rfox",symbol:"RFOX/AUD",base:"RFOX",quote:"AUD",baseId:"rfox",quoteId:"aud",type:"spot",spot:!0}),"POWR/AUD":this.safeMarketStructure({id:"powr",symbol:"POWR/AUD",base:"POWR",quote:"AUD",baseId:"powr",quoteId:"aud",type:"spot",spot:!0}),"NEO/AUD":this.safeMarketStructure({id:"neo",symbol:"NEO/AUD",base:"NEO",quote:"AUD",baseId:"neo",quoteId:"aud",type:"spot",spot:!0}),"TRX/AUD":this.safeMarketStructure({id:"trx",symbol:"TRX/AUD",base:"TRX",quote:"AUD",baseId:"trx",quoteId:"aud",type:"spot",spot:!0}),"EOS/AUD":this.safeMarketStructure({id:"eos",symbol:"EOS/AUD",base:"EOS",quote:"AUD",baseId:"eos",quoteId:"aud",type:"spot",spot:!0}),"XLM/AUD":this.safeMarketStructure({id:"xlm",symbol:"XLM/AUD",base:"XLM",quote:"AUD",baseId:"xlm",quoteId:"aud",type:"spot",spot:!0}),"RHOC/AUD":this.safeMarketStructure({id:"rhoc",symbol:"RHOC/AUD",base:"RHOC",quote:"AUD",baseId:"rhoc",quoteId:"aud",type:"spot",spot:!0}),"GAS/AUD":this.safeMarketStructure({id:"gas",symbol:"GAS/AUD",base:"GAS",quote:"AUD",baseId:"gas",quoteId:"aud",type:"spot",spot:!0})},commonCurrencies:{DRK:"DASH"},options:{fetchBalance:"private_post_my_balances"},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:void 0,fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:a.kb})}parseBalance(e){const t={info:e},i=this.safeValue2(e,"balance","balances");if(Array.isArray(i))for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(4295),r=i(5147),a=i(2079),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"cryptocom",name:"Crypto.com",countries:["MT"],version:"v2",rateLimit:10,certified:!0,pro:!0,has:{CORS:!1,spot:!0,margin:!0,swap:!0,future:!0,option:!0,addMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,cancelOrdersForSymbols:!0,closeAllPositions:!1,closePosition:!0,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:"emulated",fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!0,fetchStatus:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","6h":"6h","12h":"12h","1d":"1D","1w":"7D","2w":"14D","1M":"1M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/147792121-38ed5e36-c229-48d6-b49a-48d05fc19ed4.jpeg",test:{v1:"https://uat-api.3ona.co/exchange/v1",v2:"https://uat-api.3ona.co/v2",derivatives:"https://uat-api.3ona.co/v2"},api:{base:"https://api.crypto.com",v1:"https://api.crypto.com/exchange/v1",v2:"https://api.crypto.com/v2",derivatives:"https://deriv-api.crypto.com/v1"},www:"https://crypto.com/",referral:{url:"https://crypto.com/exch/kdacthrnxt",discount:.75},doc:["https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html","https://exchange-docs.crypto.com/spot/index.html","https://exchange-docs.crypto.com/derivatives/index.html"],fees:"https://crypto.com/exchange/document/fees-limits"},api:{base:{public:{get:{"v1/public/get-announcements":1}}},v1:{public:{get:{"public/auth":10/3,"public/get-instruments":10/3,"public/get-book":1,"public/get-candlestick":1,"public/get-trades":1,"public/get-tickers":1,"public/get-valuations":1,"public/get-expired-settlement-price":10/3,"public/get-insurance":1,"public/get-announcements":1,"public/get-risk-parameters":1},post:{"public/staking/get-conversion-rate":2}},private:{post:{"private/set-cancel-on-disconnect":10/3,"private/get-cancel-on-disconnect":10/3,"private/user-balance":10/3,"private/user-balance-history":10/3,"private/get-positions":10/3,"private/create-order":2/3,"private/amend-order":4/3,"private/create-order-list":10/3,"private/cancel-order":2/3,"private/cancel-order-list":10/3,"private/cancel-all-orders":2/3,"private/close-position":10/3,"private/get-order-history":100,"private/get-open-orders":10/3,"private/get-order-detail":1/3,"private/get-trades":100,"private/change-account-leverage":10/3,"private/get-transactions":10/3,"private/create-subaccount-transfer":10/3,"private/get-subaccount-balances":10/3,"private/get-order-list":10/3,"private/create-withdrawal":10/3,"private/get-currency-networks":10/3,"private/get-deposit-address":10/3,"private/get-accounts":10/3,"private/get-withdrawal-history":10/3,"private/get-deposit-history":10/3,"private/get-fee-rate":2,"private/get-instrument-fee-rate":2,"private/fiat/fiat-deposit-info":10/3,"private/fiat/fiat-deposit-history":10/3,"private/fiat/fiat-withdraw-history":10/3,"private/fiat/fiat-create-withdraw":10/3,"private/fiat/fiat-transaction-quota":10/3,"private/fiat/fiat-transaction-limit":10/3,"private/fiat/fiat-get-bank-accounts":10/3,"private/staking/stake":2,"private/staking/unstake":2,"private/staking/get-staking-position":2,"private/staking/get-staking-instruments":2,"private/staking/get-open-stake":2,"private/staking/get-stake-history":2,"private/staking/get-reward-history":2,"private/staking/convert":2,"private/staking/get-open-convert":2,"private/staking/get-convert-history":2,"private/create-isolated-margin-transfer":10/3,"private/change-isolated-margin-leverage":10/3}}},v2:{public:{get:{"public/auth":1,"public/get-instruments":1,"public/get-book":1,"public/get-candlestick":1,"public/get-ticker":1,"public/get-trades":1,"public/margin/get-transfer-currencies":1,"public/margin/get-load-currenices":1,"public/respond-heartbeat":1}},private:{post:{"private/set-cancel-on-disconnect":10/3,"private/get-cancel-on-disconnect":10/3,"private/create-withdrawal":10/3,"private/get-withdrawal-history":10/3,"private/get-currency-networks":10/3,"private/get-deposit-history":10/3,"private/get-deposit-address":10/3,"private/export/create-export-request":10/3,"private/export/get-export-requests":10/3,"private/export/download-export-output":10/3,"private/get-account-summary":10/3,"private/create-order":2/3,"private/cancel-order":2/3,"private/cancel-all-orders":2/3,"private/create-order-list":10/3,"private/get-order-history":10/3,"private/get-open-orders":10/3,"private/get-order-detail":1/3,"private/get-trades":100,"private/get-accounts":10/3,"private/get-subaccount-balances":10/3,"private/create-subaccount-transfer":10/3,"private/otc/get-otc-user":10/3,"private/otc/get-instruments":10/3,"private/otc/request-quote":100,"private/otc/accept-quote":100,"private/otc/get-quote-history":10/3,"private/otc/get-trade-history":10/3,"private/otc/create-order":10/3}}},derivatives:{public:{get:{"public/auth":10/3,"public/get-instruments":10/3,"public/get-book":1,"public/get-candlestick":1,"public/get-trades":1,"public/get-tickers":1,"public/get-valuations":1,"public/get-expired-settlement-price":10/3,"public/get-insurance":1}},private:{post:{"private/set-cancel-on-disconnect":10/3,"private/get-cancel-on-disconnect":10/3,"private/user-balance":10/3,"private/user-balance-history":10/3,"private/get-positions":10/3,"private/create-order":2/3,"private/create-order-list":10/3,"private/cancel-order":2/3,"private/cancel-order-list":10/3,"private/cancel-all-orders":2/3,"private/close-position":10/3,"private/convert-collateral":10/3,"private/get-order-history":100,"private/get-open-orders":10/3,"private/get-order-detail":1/3,"private/get-trades":100,"private/change-account-leverage":10/3,"private/get-transactions":10/3,"private/create-subaccount-transfer":10/3,"private/get-subaccount-balances":10/3,"private/get-order-list":10/3}}}},fees:{trading:{maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.005"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0025")],[this.parseNumber("10000"),this.parseNumber("0.002")],[this.parseNumber("50000"),this.parseNumber("0.0015")],[this.parseNumber("250000"),this.parseNumber("0.001")],[this.parseNumber("500000"),this.parseNumber("0.0008")],[this.parseNumber("2500000"),this.parseNumber("0.00065")],[this.parseNumber("10000000"),this.parseNumber("0")],[this.parseNumber("25000000"),this.parseNumber("0")],[this.parseNumber("100000000"),this.parseNumber("0")],[this.parseNumber("250000000"),this.parseNumber("0")],[this.parseNumber("500000000"),this.parseNumber("0")]],taker:[[this.parseNumber("0"),this.parseNumber("0.005")],[this.parseNumber("10000"),this.parseNumber("0.004")],[this.parseNumber("50000"),this.parseNumber("0.0025")],[this.parseNumber("250000"),this.parseNumber("0.002")],[this.parseNumber("500000"),this.parseNumber("0.0018")],[this.parseNumber("2500000"),this.parseNumber("0.001")],[this.parseNumber("10000000"),this.parseNumber("0.0005")],[this.parseNumber("25000000"),this.parseNumber("0.0004")],[this.parseNumber("100000000"),this.parseNumber("0.00035")],[this.parseNumber("250000000"),this.parseNumber("0.00031")],[this.parseNumber("500000000"),this.parseNumber("0.00025")]]}}},options:{defaultType:"spot",accountsById:{funding:"SPOT",spot:"SPOT",margin:"MARGIN",derivatives:"DERIVATIVES",swap:"DERIVATIVES",future:"DERIVATIVES"},networks:{BEP20:"BSC",ERC20:"ETH",TRC20:"TRON"},broker:"CCXT"},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,selfTradePrevention:!0,trailing:!1,iceberg:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0},createOrders:{max:10},fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:1,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:void 0,untilDays:1,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:300}},spot:{extends:"default",fetchCurrencies:{private:!0}},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:{extends:"default"},inverse:{extends:"default"}}},commonCurrencies:{USD_STABLE_COIN:"USDC"},precisionMode:o.kb,exceptions:{exact:{219:a.InvalidOrder,306:a.InsufficientFunds,314:a.InvalidOrder,325:a.InvalidOrder,415:a.InvalidOrder,10001:a.ExchangeError,10002:a.PermissionDenied,10003:a.PermissionDenied,10004:a.BadRequest,10005:a.PermissionDenied,10006:a.DDoSProtection,10007:a.InvalidNonce,10008:a.BadRequest,10009:a.BadRequest,20001:a.BadRequest,20002:a.InsufficientFunds,20005:a.AccountNotEnabled,30003:a.BadSymbol,30004:a.BadRequest,30005:a.BadRequest,30006:a.InvalidOrder,30007:a.InvalidOrder,30008:a.InvalidOrder,30009:a.InvalidOrder,30010:a.BadRequest,30013:a.InvalidOrder,30014:a.InvalidOrder,30016:a.InvalidOrder,30017:a.InvalidOrder,30023:a.InvalidOrder,30024:a.InvalidOrder,30025:a.InvalidOrder,40001:a.BadRequest,40002:a.BadRequest,40003:a.BadRequest,40004:a.BadRequest,40005:a.BadRequest,40006:a.BadRequest,40007:a.BadRequest,40101:a.AuthenticationError,40102:a.InvalidNonce,40103:a.AuthenticationError,40104:a.AuthenticationError,40107:a.BadRequest,40401:a.OrderNotFound,40801:a.RequestTimeout,42901:a.RateLimitExceeded,43005:a.InvalidOrder,43003:a.InvalidOrder,43004:a.InvalidOrder,43012:a.BadRequest,50001:a.ExchangeError,9010001:a.OnMaintenance},broad:{}}})}async fetchCurrencies(e={}){if(!this.checkRequiredCredentials(!1))return{};let t=!1;if([t,e]=this.handleOptionAndParams(e,"fetchCurrencies","skipFetchCurrencies",!1),t)return{};let i={};try{i=await this.v1PrivatePostPrivateGetCurrencyNetworks(e)}catch(e){if(e instanceof a.ExchangeError)return{};throw e}const s=this.safeDict(i,"result",{}),r=this.safeDict(s,"currency_map",{}),o=Object.keys(r),n={};for(let e=0;e1)throw new a.BadRequest(this.id+" fetchTickers() symbols argument cannot contain more than 1 symbol");t=e[0]}else t=e;i=this.market(t),s.instrument_name=i.id}const r=await this.v1PublicGetPublicGetTickers(this.extend(s,t)),o=this.safeDict(r,"result",{}),n=this.safeList(o,"data",[]);return this.parseTickers(n,e)}async fetchTicker(e,t={}){await this.loadMarkets(),e=this.symbol(e);const i=await this.fetchTickers([e],t);return this.safeValue(i,e)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchOrders","paginate"),a)return await this.fetchPaginatedCallDynamic("fetchOrders",e,t,i,s);const o={};void 0!==e&&(r=this.market(e),o.instrument_name=r.id),void 0!==t&&(o.start_time=t),void 0!==i&&(o.limit=i);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(o.end_time=n);const d=await this.v1PrivatePostPrivateGetOrderHistory(this.extend(o,s)),c=this.safeDict(d,"result",{}),h=this.safeList(c,"data",[]);return this.parseOrders(h,r,t,i)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchTrades","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchTrades",e,t,i,s);const a=this.market(e),o={instrument_name:a.id};void 0!==t&&(o.start_ts=t),void 0!==i&&(o.count=i);const n=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==n&&(o.end_ts=n);const d=await this.v1PublicGetPublicGetTrades(this.extend(o,s)),c=this.safeDict(d,"result",{}),h=this.safeList(c,"data",[]);return this.parseTrades(h,a,t,i)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();let a=!1;if([a,r]=this.handleOptionAndParams(r,"fetchOHLCV","paginate",!1),a)return await this.fetchPaginatedCallDeterministic("fetchOHLCV",e,i,s,t,r,300);const o=this.market(e),n={instrument_name:o.id,timeframe:this.safeString(this.timeframes,t,t)};void 0!==s&&(s>300&&(s=300),n.count=s);const d=this.microseconds(),c=this.parseTimeframe(t),h=this.safeInteger(r,"until",d);r=this.omit(r,["until"]),void 0!==i?(n.start_ts=i-1e3*c,n.end_ts=void 0!==s?this.sum(i,c*s*1e3):h):n.end_ts=h;const l=await this.v1PublicGetPublicGetCandlestick(this.extend(n,r)),u=this.safeDict(l,"result",{}),p=this.safeList(u,"data",[]);return this.parseOHLCVs(p,o,t,i,s)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={instrument_name:this.market(e).id};t&&(s.depth=Math.min(t,50));const r=await this.v1PublicGetPublicGetBook(this.extend(s,i)),a=this.safeDict(r,"result",{}),o=this.safeList(a,"data",[]),n=this.safeValue(o,0),d=this.safeInteger(n,"t");return this.parseOrderBook(n,e,d)}parseBalance(e){const t=this.safeDict(e,"result",{}),i=this.safeList(t,"data",[]),s=this.safeValue(i[0],"position_balances",[]),r={info:e};for(let e=0;e0){[t,s]=e.split("?");i=s.split("=")[1]}else t=e;return[t,i]}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets();const a=this.safeCurrency(e),o={currency:a.id,amount:t,address:i};let n;void 0!==s&&(o.address_tag=s),[n,r]=this.handleNetworkCodeAndParams(r);const d=this.networkCodeToId(n);void 0!==d&&(o.network_id=d);const c=await this.v1PrivatePostPrivateCreateWithdrawal(this.extend(o,r)),h=this.safeDict(c,"result");return this.parseTransaction(h,a)}async fetchDepositAddressesByNetwork(e,t={}){await this.loadMarkets();const i={currency:this.safeCurrency(e).id},s=await this.v1PrivatePostPrivateGetDepositAddress(this.extend(i,t)),r=this.safeDict(s,"result",{}),o=this.safeList(r,"deposit_address_list",[]),n=o.length;if(0===n)throw new a.ExchangeError(this.id+" fetchDepositAddressesByNetwork() generating address...");const d={};for(let e=0;e1)throw new a.BadRequest(this.id+" fetchPositions() symbols argument cannot contain more than 1 symbol");t=e[0]}else t=e;s=this.market(t),i.instrument_name=s.id}const r=await this.v1PrivatePostPrivateGetPositions(this.extend(i,t)),o=this.safeDict(r,"result",{}),n=this.safeList(o,"data",[]),d=[];for(let e=0;e=3)return e.toString();if("string"==typeof e)return e;let i,s="";if(Array.isArray(e))i=e;else{const t=this.keysort(e);i=Object.keys(t)}for(let r=0;r{"use strict";i.d(t,{A:()=>d});var s=i(3037),r=i(2079),a=i(5147),o=i(1579),n=i(4035);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"cryptomus",name:"Cryptomus",countries:["CA"],rateLimit:100,version:"v2",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!1,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createOrderWithTakeProfitAndStopLossWs:!1,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopLossOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!1,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfers:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,repayMargin:!1,sandbox:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1},timeframes:{},urls:{logo:"https://github.com/user-attachments/assets/8e0b1c48-7c01-4177-9224-f1b01d89d7e7",api:{public:"https://api.cryptomus.com",private:"https://api.cryptomus.com"},www:"https://cryptomus.com",doc:"https://doc.cryptomus.com/personal",fees:"https://cryptomus.com/tariffs",referral:"https://app.cryptomus.com/signup/?ref=JRP4yj"},api:{public:{get:{"v2/user-api/exchange/markets":1,"v2/user-api/exchange/market/price":1,"v1/exchange/market/assets":1,"v1/exchange/market/order-book/{currencyPair}":1,"v1/exchange/market/tickers":1,"v1/exchange/market/trades/{currencyPair}":1}},private:{get:{"v2/user-api/exchange/orders":1,"v2/user-api/exchange/orders/history":1,"v2/user-api/exchange/account/balance":1,"v2/user-api/exchange/account/tariffs":1,"v2/user-api/payment/services":1,"v2/user-api/payout/services":1,"v2/user-api/transaction/list":1},post:{"v2/user-api/exchange/orders":1,"v2/user-api/exchange/orders/market":1},delete:{"v2/user-api/exchange/orders/{orderId}":1}}},fees:{trading:{percentage:!0,feeSide:"get",maker:this.parseNumber("0.02"),taker:this.parseNumber("0.02")}},options:{createMarketBuyOrderRequiresPrice:!0,networks:{BEP20:"bsc",DASH:"dash",POLYGON:"polygon",ARB:"arbitrum",SOL:"sol",TON:"ton",ERC20:"eth",TRC20:"tron",LTC:"ltc",XMR:"xmr",BCH:"bch",DOGE:"doge",AVAX:"avalanche",BTC:"btc",RUB:"rub"},networksById:{bsc:"BEP20",dash:"DASH",polygon:"POLYGON",arbitrum:"ARB",sol:"SOL",ton:"TON",eth:"ERC20",tron:"TRC20",ltc:"LTC",xmr:"XMR",bch:"BCH",doge:"DOGE",avalanche:"AVAX",btc:"BTC",rub:"RUB"},fetchOrderBook:{level:0}},commonCurrencies:{},exceptions:{exact:{500:r.ExchangeError,6:r.InsufficientFunds,"Insufficient funds.":r.InsufficientFunds,"Minimum amount 15 USDT":r.InvalidOrder},broad:{}},precisionMode:o.kb,requiredCredentials:{apiKey:!1,uid:!0},features:{}})}async fetchMarkets(e={}){const t=await this.publicGetV2UserApiExchangeMarkets(e),i=this.safeList(t,"result",[]);return this.parseMarkets(i)}parseMarket(e){const t=this.safeString(e,"symbol"),i=t.split("_"),s=i[0],r=i[1],a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r),n=this.safeDict(this.fees,"trading");return this.safeMarketStructure({id:t,symbol:a+"/"+o,base:a,quote:o,baseId:s,quoteId:r,active:!0,type:"spot",subType:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,contract:!1,settle:void 0,settleId:void 0,contractSize:void 0,linear:void 0,inverse:void 0,taker:this.safeNumber(n,"taker"),maker:this.safeNumber(n,"maker"),percentage:this.safeBool(n,"percentage"),tierBased:void 0,feeSide:this.safeString(n,"feeSide"),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(e,"quotePrec"))),price:this.parseNumber(this.parsePrecision(this.safeString(e,"basePrec")))},limits:{amount:{min:this.safeNumber(e,"quoteMinSize"),max:this.safeNumber(e,"quoteMaxSize")},price:{min:this.safeNumber(e,"baseMinSize"),max:this.safeNumber(e,"baseMaxSize")},leverage:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e})}async fetchCurrencies(e={}){const t=await this.publicGetV1ExchangeMarketAssets(e),i=this.safeList(t,"result"),s=this.groupBy(i,"currency_code"),r=Object.keys(s),a={};for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(1786),r=i(1579),a=i(4852),o=i(5147),n=i(2079);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"deepcoin",name:"DeepCoin",countries:["SG"],rateLimit:200,version:"v1",certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closePosition:!0,createConvertTrade:!1,createDepositAddress:!1,createLimitBuyOrder:!0,createLimitOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!0,createMarketSellOrder:!0,createMarketSellOrderWithCost:!0,createOrder:!0,createOrders:!1,createOrderWithTakeProfitAndStopLoss:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLossOrder:!1,createTakeProfitOrder:!1,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrder:!0,fetchClosedOrders:!0,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDepositAddresses:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!0,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOrder:!1,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsForSymbol:!0,fetchPositionsHistory:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!1,setLeverage:!0,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!1},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1H","4h":"4H","12h":"12H","1d":"1D","1w":"1W","1M":"1M","1y":"1Y"},urls:{logo:"https://github.com/user-attachments/assets/ddf3e178-c3b6-409d-8f9f-af8b7cf80454",api:{public:"https://api.deepcoin.com",private:"https://api.deepcoin.com"},www:"https://www.deepcoin.com/",doc:"https://www.deepcoin.com/docs",referral:{url:"https://s.deepcoin.com/UzkyODgy",discount:.1}},api:{public:{get:{"deepcoin/market/books":1,"deepcoin/market/candles":1,"deepcoin/market/instruments":1,"deepcoin/market/tickers":1,"deepcoin/market/index-candles":1,"deepcoin/market/trades":1,"deepcoin/market/mark-price-candles":1,"deepcoin/market/step-margin":5,"deepcoin/trade/funding-rate":5,"deepcoin/trade/fund-rate/current-funding-rate":5,"deepcoin/trade/fund-rate/history":5}},private:{get:{"deepcoin/account/balances":5,"deepcoin/account/bills":5,"deepcoin/account/positions":5,"deepcoin/trade/fills":5,"deepcoin/trade/orderByID":5,"deepcoin/trade/finishOrderByID":5,"deepcoin/trade/orders-history":5,"deepcoin/trade/v2/orders-pending":5,"deepcoin/trade/trigger-orders-pending":5,"deepcoin/trade/trigger-orders-history":5,"deepcoin/copytrading/support-contracts":5,"deepcoin/copytrading/leader-position":5,"deepcoin/copytrading/estimate-profit":5,"deepcoin/copytrading/history-profit":5,"deepcoin/copytrading/follower-rank":5,"deepcoin/internal-transfer/support":5,"deepcoin/internal-transfer/history-order":5,"deepcoin/rebate/config":5,"deepcoin/agents/users":5,"deepcoin/agents/users/rebate-list":5,"deepcoin/agents/users/rebates":5,"deepcoin/asset/deposit-list":5,"deepcoin/asset/withdraw-list":5,"deepcoin/asset/recharge-chain-list":5,"deepcoin/listenkey/acquire":5,"deepcoin/listenkey/extend":5},post:{"deepcoin/account/set-leverage":5,"deepcoin/trade/order":5,"deepcoin/trade/replace-order":5,"deepcoin/trade/cancel-order":5,"deepcoin/trade/batch-cancel-order":5,"deepcoin/trade/cancel-trigger-order":1/6,"deepcoin/trade/swap/cancel-all":5,"deepcoin/trade/trigger-order":5,"deepcoin/trade/batch-close-position":5,"deepcoin/trade/replace-order-sltp":5,"deepcoin/trade/close-position-by-ids":5,"deepcoin/copytrading/leader-settings":5,"deepcoin/copytrading/set-contracts":5,"deepcoin/internal-transfer":5,"deepcoin/rebate/config":5,"deepcoin/asset/transfer":5}}},fees:{trading:{taker:this.parseNumber("0.0015"),maker:this.parseNumber("0.0010")}},features:{spot:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!1,index:!1},triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:{last:!1,mark:!1,index:!1},price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!0,trailing:!1,marketBuyRequiresPrice:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:60,untilDays:void 0,symbolRequired:!0},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!0,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!0,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:300}},swap:{linear:{extends:"spot"},inverse:{extends:"spot"}}},requiredCredentials:{apiKey:!0,secret:!0,password:!0},precisionMode:r.kb,options:{recvWindow:5e3,defaultNetworks:{ETH:"ERC20",USDT:"TRC20",USDC:"ERC20"},networks:{ERC20:"ERC20",TRC20:"TRC20",ARB:"ARBITRUM",BSC:"BSC(BEP20)",SOL:"SOL",BTC:"Bitcoin",ADA:"Cardano"},networksById:{},fetchMarkets:{types:["spot","swap"]},timeInForce:{GTC:"GTC",IOC:"IOC",PO:"PO"},exchangeType:{spot:"SPOT",swap:"SWAP",SPOT:"SPOT",SWAP:"SWAP"},accountsByType:{spot:1,fund:2,rebate:3,inverse:5,linear:7,demo:10}},commonCurrencies:{},exceptions:{exact:{24:n.OrderNotFound,31:n.InsufficientFunds,36:n.InsufficientFunds,44:n.BadRequest,49:n.InvalidOrder,194:n.InvalidOrder,195:n.InvalidOrder,199:n.BadRequest,100010:n.InsufficientFunds,unsupportedAction:n.BadRequest,localIDNotExist:n.BadRequest},broad:{"no available":n.NotSupported,"field is required":n.ArgumentsRequired,"not in acceptable range":n.BadRequest,'subscription cluster does not "exist"':n.BadRequest,"must be equal or lesser than":n.BadRequest}}})}handleMarketTypeAndParams(e,t=void 0,i={},s=void 0){const r=this.safeString(i,"instType");i=this.omit(i,"instType");return void 0===this.safeString(i,"type")&&void 0!==r&&(i=this.extend(i,{type:r})),super.handleMarketTypeAndParams(e,t,i,s)}convertToInstrumentType(e){const t=this.safeDict(this.options,"exchangeType",{});return this.safeString(t,e,e)}async fetchMarkets(e={}){let t=["spot","swap"];const i=this.safeDict(this.options,"fetchMarkets");t=void 0!==i?this.safeList(i,"types",t):this.safeList(this.options,"fetchMarkets",t);let s=[],r=[];for(let i=0;i1)for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(9872),r=i(5147),a=i(1579),o=i(4852),n=i(2079);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"defx",name:"Defx X",rateLimit:100,version:"v1",certified:!1,pro:!1,hostname:"defx.com",dex:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!0,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelWithdraw:!1,closeAllPositions:!0,closePosition:!0,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopLossOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!0,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!1,reduceMargin:!1,sandbox:!0,setLeverage:!0,setMargin:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://github.com/user-attachments/assets/4e92bace-d7a9-45ea-92be-122168dc87e4",api:{public:"https://api.{hostname}",private:"https://api.{hostname}"},test:{public:"https://api.testnet.{hostname}",private:"https://api.testnet.{hostname}"},www:"https://defx.com/home",doc:["https://docs.defx.com/docs","https://api-docs.defx.com/"],fees:[""],referral:{url:"https://app.defx.com/join/6I2CZ7"}},api:{v1:{public:{get:{"healthcheck/ping":1,"symbols/{symbol}/ohlc":1,"symbols/{symbol}/trades":1,"symbols/{symbol}/prices":1,"symbols/{symbol}/ticker/24hr":1,"symbols/{symbol}/depth/{level}/{slab}":1,"ticker/24HrAgg":1,"c/markets":1,"c/markets/metadata":1,"analytics/market/stats/newUsers":1,"analytics/market/stats/tvl":1,"analytics/market/stats/volumeByInstrument":1,"analytics/market/stats/liquidation":1,"analytics/market/stats/totalVolume":1,"analytics/market/stats/openInterest":1,"analytics/market/stats/totalTrades":1,"analytics/market/stats/basis":1,"analytics/market/stats/insuranceFund":1,"analytics/market/stats/longAndShortRatio":1,"analytics/market/stats/fundingRate":1,"analytics/market/overview":1,"explorer/search":1,"explorer/transactions":1,"explorer/blocks":1}},private:{get:{"api/order/{orderId}":1,"api/orders":1,"api/orders/oco/{parentOrderId}":1,"api/trades":1,"api/position/active":1,"api/users/metadata/leverage":1,"api/users/metadata/feeMultiplier":1,"api/users/metadata/slippage":1,"api/users/referral":1,"api/users/apikeys":1,"connection-signature-message/evm":1,"api/users/profile/wallets":1,"api/notifications":1,"api/wallet/balance":1,"api/wallet/transactions":1,"api/analytics/user/overview":1,"api/analytics/user/pnl":1,"api/analytics/points/overview":1,"api/analytics/points/history":1},post:{"api/order":1,"api/position/oco":1,"api/users/socket/listenKeys":1,"api/users/metadata/leverage":1,"api/users/metadata/feeMultiplier":1,"api/users/metadata/slippage":1,"api/users/referral/recordReferralSignup":1,"api/users/apikeys":1,"api/users/profile/wallets":1,"api/transfers/withdrawal":1,"api/transfers/bridge/withdrawal":1},put:{"api/position/updatePositionMargin":1,"api/users/socket/listenKeys/{listenKey}":1,"api/users/apikeys/{accessKey}/status":1,"api/users/referral":1},patch:{"api/users/apikeys/{accessKey}":1},delete:{"api/orders/allOpen":1,"api/order/{orderId}":1,"api/position/{positionId}":1,"api/position/all":1,"api/users/socket/listenKeys/{listenKey}":1,"api/users/apikeys/{accessKey}":1}}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0002"),taker:this.parseNumber("0.0005")}},options:{sandboxMode:!1},features:{spot:void 0,forDerivatives:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!0,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:{extends:"forDerivatives"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{404:n.BadRequest,missing_auth_signature:n.AuthenticationError,leverage_higher_than_capped_leverage:n.BadRequest,order_rejected:n.InvalidOrder,invalid_order_id:n.InvalidOrder,filter_lotsize_maxqty:n.InvalidOrder,filter_notional_min:n.InvalidOrder,failed_index_price_up_multiplier_filter:n.InvalidOrder,no_open_orders:n.InvalidOrder,active_position_not_found:n.InvalidOrder,position_inactive:n.InvalidOrder,invalid_position_id:n.InvalidOrder,"Internal server error":n.ExchangeError},broad:{"Bad Request":n.BadRequest}},precisionMode:a.kb})}async fetchStatus(e={}){const t=await this.v1PublicGetHealthcheckPing(e);let i;return i=this.safeBool(t,"success")?"ok":"error",{status:i,updated:void 0,eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.v1PublicGetHealthcheckPing(e);return this.safeInteger(t,"t")}async fetchMarkets(e={}){const t={type:"perps"},i=[this.v1PublicGetCMarkets(this.extend(t,e)),this.v1PublicGetCMarketsMetadata(this.extend(t,e))],s=await Promise.all(i),r=this.safeList(s[0],"data"),a=this.indexBy(r,"market"),o=this.safeList(s[1],"data");for(let e=0;e=0?f=this.safeString(e,"stopPrice"):m=this.safeString(e,"stopPrice"));const g=this.parse8601(this.safeString(e,"createdAt")),v=this.parse8601(this.safeString(e,"updatedAt"));return this.safeOrder({id:i,clientOrderId:s,timestamp:g,datetime:this.iso8601(g),lastTradeTimestamp:v,lastUpdateTimestamp:v,status:this.parseOrderStatus(c),symbol:a,type:d,timeInForce:p,postOnly:this.safeBool(e,"postOnly"),reduceOnly:this.safeBool(e,"reduceOnly"),side:h,price:o,triggerPrice:m,takeProfitPrice:f,stopLossPrice:void 0,average:u,amount:n,filled:l,remaining:void 0,cost:void 0,trades:void 0,fee:{cost:this.safeString(e,"totalFee"),currency:"USDC"},info:e},t)}async cancelOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderId:e,idType:"orderId"},r=this.safeStringN(i,["clOrdID","clientOrderId","client_order_id"]),a=void 0!==r;if(a){if(void 0===t)throw new n.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");const e=this.market(t);s.orderId=r,s.idType="clientOrderId",s.symbol=e.id}i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]);const o=await this.v1PrivateDeleteApiOrderOrderId(this.extend(s,i)),d={symbol:t};return a?d.clientOrderId=r:d.id=e,this.extend(this.parseOrder(o),d)}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i={symbols:[this.market(e).id]},s=await this.v1PrivateDeleteApiOrdersAllOpen(this.extend(i,t));return[this.safeOrder({info:s})]}async fetchPosition(e,t={}){if(void 0===e)throw new n.ArgumentsRequired(this.id+" fetchPosition() requires a symbol argument");await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=await this.v1PrivateGetApiPositionActive(this.extend(s,t)),a=this.safeList(r,"data",[]),o=this.safeDict(a,0,{});return this.parsePosition(o,i)}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.v1PrivateGetApiPositionActive(t),s=this.safeList(i,"data",[]);return this.parsePositions(s,e)}parsePosition(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);const s=r.Y.stringAbs(this.safeString(e,"quantity")),a=this.safeStringLower(e,"positionSide"),o=this.omitZero(this.safeString(e,"pnl")),n=this.omitZero(this.safeString(e,"entryPrice")),d=this.safeString(e,"marginAmount");return this.safePosition({info:e,id:this.safeString(e,"positionId"),symbol:t.symbol,timestamp:void 0,datetime:void 0,lastUpdateTimestamp:void 0,initialMargin:this.parseNumber(d),initialMarginPercentage:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,entryPrice:this.parseNumber(n),notional:void 0,leverage:void 0,unrealizedPnl:this.parseNumber(o),realizedPnl:void 0,contracts:this.parseNumber(s),contractSize:this.safeNumber(t,"contractSize"),marginRatio:void 0,liquidationPrice:void 0,markPrice:void 0,lastPrice:void 0,collateral:void 0,marginMode:void 0,side:a,percentage:void 0,stopLossPrice:void 0,takeProfitPrice:void 0,hedged:void 0})}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderId:e,idType:"orderId"},r=this.safeStringN(i,["clOrdID","clientOrderId","client_order_id"]);if(i=this.omit(i,["clOrdID","clientOrderId","client_order_id"]),void 0!==r){if(void 0===t)throw new n.ArgumentsRequired(this.id+" fetchOrder() requires a symbol argument");const e=this.market(t);s.orderId=r,s.idType="clientOrderId",s.symbol=e.id}const a=await this.v1PrivateGetApiOrderOrderId(this.extend(s,i)),o=this.safeDict(a,"data");return this.parseOrder(o)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};if(void 0!==e){const t=this.market(e);r.symbols=t.id}const a=this.safeInteger(s,"until");if(void 0!==a&&(s=this.omit(s,"until"),r.end=this.iso8601(a)),void 0!==t&&(r.start=this.iso8601(t)),void 0!==i){const e=100;i=Math.min(e,i),r.pageSize=i}const o=await this.v1PrivateGetApiOrders(this.extend(r,s)),n=this.safeList(o,"data",[]);return this.parseOrders(n,void 0,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({statuses:"OPEN"},s))}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({statuses:"FILLED"},s))}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrders(e,t,i,this.extend({statuses:"CANCELED"},s))}async closePosition(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeString(i,"positionId");if(void 0===s)throw new n.ArgumentsRequired(this.id+" closePosition() requires a positionId");const r=this.safeStringUpper(i,"type");if(void 0===r)throw new n.ArgumentsRequired(this.id+" closePosition() requires a type");const a=this.safeString(i,"quantity");if(void 0===a)throw new n.ArgumentsRequired(this.id+" closePosition() requires a quantity");const o={positionId:s,type:r,quantity:a};if("MARKET"!==r){const e=this.safeString(i,"price");if(void 0===e)throw new n.ArgumentsRequired(this.id+" closePosition() requires a price");o.price=e}i=this.omit(i,["positionId","type","quantity","price"]);return await this.v1PrivateDeleteApiPositionPositionId(this.extend(o,i))}async closeAllPositions(e={}){await this.loadMarkets();const t=await this.v1PrivateDeleteApiPositionAll(e),i=this.safeList(t,"data",[]);return this.parsePositions(i,void 0,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchLedger","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchLedger",e,t,i,s);const a={};a.start=void 0!==t?t:0;const o=this.safeInteger(s,"until");void 0!==o?(s=this.omit(s,"until"),a.end=o):a.end=this.milliseconds();const n=await this.v1PrivateGetApiWalletTransactions(this.extend(a,s)),d=this.safeList(n,"transactions",[]);return this.parseLedger(d,void 0,t,i)}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"amount"),s=this.safeString(e,"asset"),r=this.safeCurrencyCode(s,t);t=this.safeCurrency(s,t);const a=this.safeInteger(e,"timestamp"),o=this.safeString(e,"type");return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),direction:void 0,account:void 0,referenceAccount:void 0,referenceId:void 0,type:this.parseLedgerEntryType(o),currency:r,amount:this.parseNumber(i),timestamp:a,datetime:this.iso8601(a),before:void 0,after:void 0,status:void 0,fee:void 0},t)}parseLedgerEntryType(e){return this.safeString({FundingFee:"fee",FeeRebate:"fee",FeeKickback:"fee",RealizedPnl:"trade",LiquidationClearance:"trade",Transfer:"transfer",ReferralPayout:"referral",Commission:"commission"},e,e)}async withdraw(e,t,i,s=void 0,r={}){await this.loadMarkets();const a=this.currency(e),o={amount:this.currencyToPrecision(e,t),asset:a.id},n=await this.v1PrivatePostApiTransfersBridgeWithdrawal(this.extend(o,r));return this.parseTransaction(n,a)}parseTransaction(e,t=void 0){return{info:e,id:void 0,txid:this.safeString(e,"transactionId"),timestamp:void 0,datetime:void 0,network:void 0,address:void 0,addressTo:void 0,addressFrom:void 0,tag:void 0,tagTo:void 0,tagFrom:void 0,type:void 0,amount:void 0,currency:this.safeCurrencyCode(void 0,t),status:void 0,updated:void 0,internal:void 0,comment:void 0,fee:void 0}}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new n.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");await this.loadMarkets();const s={leverage:this.numberToString(e)},r=this.market(t);s.symbol=r.id;const a=await this.v1PrivatePostApiUsersMetadataLeverage(this.extend(s,i)),o=this.safeDict(a,"data",{});return this.parseLeverage(o,r)}parseLeverage(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeInteger(e,"leverage");return{info:e,symbol:this.safeSymbol(i,t),marginMode:void 0,longLeverage:s,shortLeverage:s}}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const n=t[0],d=t[1],c=this.implodeParams(e,s);let h=this.implodeHostname(this.urls.api[d]);if(h+="/"+n+"/",s=this.omit(s,this.extractParams(e)),s=this.keysort(s),"public"===d)h+="open/"+c,Object.keys(s).length&&(h+="?"+this.rawencode(s));else{this.checkRequiredCredentials(),r={"X-DEFX-SOURCE":"ccxt"},h+="auth/"+c;const t=this.milliseconds().toString();let n=t;"GET"===i||"api/order/{orderId}"===e?(n+=this.rawencode(s),Object.keys(s).length&&(h+="?"+this.rawencode(s))):(void 0!==s&&(n+=a=this.json(s)),r["Content-Type"]="application/json");const d=this.hmac(this.encode(n),this.encode(this.secret),o.s);r["X-DEFX-APIKEY"]=this.apiKey,r["X-DEFX-TIMESTAMP"]=t,r["X-DEFX-SIGNATURE"]=d}return{url:h,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,a,o,n,d){if(!o)return;const c=this.safeBool(o,"success"),h=this.safeDict(o,"err",o),l=this.safeString2(h,"errorCode","code");if(!c){const e=this.id+" "+this.json(o);this.throwBroadlyMatchedException(this.exceptions.broad,a,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e)}}defaultNetworkCodeForCurrency(e){const t=this.currency(e).networks,i=Object.keys(t);for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(7227),r=i(2079),a=i(1579),o=i(5147),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"delta",name:"Delta Exchange",countries:["VC"],rateLimit:300,version:"v2",has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!0,addMargin:!0,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!0,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!0,editOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDeposit:void 0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:void 0,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!0,fetchGreeks:!0,fetchIndexOHLCV:!0,fetchLedger:!0,fetchLeverage:!0,fetchLeverageTiers:!1,fetchMarginMode:!0,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenOrders:!0,fetchOption:!0,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!0,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTransfer:void 0,fetchTransfers:void 0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:void 0,fetchWithdrawals:void 0,reduceMargin:!0,setLeverage:!0,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","1d":"1d","7d":"7d","1w":"1w","2w":"2w","1M":"30d"},urls:{logo:"https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg",test:{public:"https://testnet-api.delta.exchange",private:"https://testnet-api.delta.exchange"},api:{public:"https://api.delta.exchange",private:"https://api.delta.exchange"},www:"https://www.delta.exchange",doc:["https://docs.delta.exchange"],fees:"https://www.delta.exchange/fees",referral:"https://www.delta.exchange/app/signup/?code=IULYNB"},api:{public:{get:["assets","indices","products","products/{symbol}","tickers","tickers/{symbol}","l2orderbook/{symbol}","trades/{symbol}","stats","history/candles","history/sparklines","settings"]},private:{get:["orders","orders/{order_id}","orders/client_order_id/{client_oid}","products/{product_id}/orders/leverage","positions/margined","positions","orders/history","fills","fills/history/download/csv","wallet/balances","wallet/transactions","wallet/transactions/download","wallets/sub_accounts_transfer_history","users/trading_preferences","sub_accounts","profile","heartbeat","deposits/address"],post:["orders","orders/bracket","orders/batch","products/{product_id}/orders/leverage","positions/change_margin","positions/close_all","wallets/sub_account_balance_transfer","heartbeat/create","heartbeat","orders/cancel_after","orders/leverage"],put:["orders","orders/bracket","orders/batch","positions/auto_topup","users/update_mmp","users/reset_mmp"],delete:["orders","orders/all","orders/batch"]}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0015"),maker:this.parseNumber("0.0010"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0015")],[this.parseNumber("100"),this.parseNumber("0.0013")],[this.parseNumber("250"),this.parseNumber("0.0013")],[this.parseNumber("1000"),this.parseNumber("0.001")],[this.parseNumber("5000"),this.parseNumber("0.0009")],[this.parseNumber("10000"),this.parseNumber("0.00075")],[this.parseNumber("20000"),this.parseNumber("0.00065")]],maker:[[this.parseNumber("0"),this.parseNumber("0.001")],[this.parseNumber("100"),this.parseNumber("0.001")],[this.parseNumber("250"),this.parseNumber("0.0009")],[this.parseNumber("1000"),this.parseNumber("0.00075")],[this.parseNumber("5000"),this.parseNumber("0.0006")],[this.parseNumber("10000"),this.parseNumber("0.0005")],[this.parseNumber("20000"),this.parseNumber("0.0005")]]}}},userAgent:this.userAgents.chrome39,options:{networks:{TRC20:"TRC20(TRON)",BEP20:"BEP20(BSC)"}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!0},timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,iceberg:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:500,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:2e3}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:{extends:"default"},inverse:{extends:"default"}}},precisionMode:a.kb,requiredCredentials:{apiKey:!0,secret:!0},exceptions:{exact:{insufficient_margin:r.InsufficientFunds,order_size_exceed_available:r.InvalidOrder,risk_limits_breached:r.BadRequest,invalid_contract:r.BadSymbol,immediate_liquidation:r.InvalidOrder,out_of_bankruptcy:r.InvalidOrder,self_matching_disrupted_post_only:r.InvalidOrder,immediate_execution_post_only:r.InvalidOrder,bad_schema:r.BadRequest,invalid_api_key:r.AuthenticationError,invalid_signature:r.AuthenticationError,open_order_not_found:r.OrderNotFound,unavailable:r.ExchangeNotAvailable},broad:{}}})}createExpiredOptionMarket(e){const t="USDT",i=e.split("-"),s=e.split("/");let r,a,o;e.indexOf("/")>-1?(r=this.safeString(s,0),a=this.safeString(i,1),o=this.safeString(i,3)):(r=this.safeString(i,1),a=this.safeString(i,3),o=this.safeString(i,0)),void 0!==a&&(a=a.slice(4)+a.slice(2,4)+a.slice(0,2));const n=t,d=this.safeString(i,2),c=this.convertExpireDate(a),h=this.parse8601(c);return{id:o+"-"+r+"-"+d+"-"+a,symbol:r+"/"+t+":"+n+"-"+a+"-"+d+"-"+o,base:r,quote:t,settle:n,baseId:r,quoteId:t,settleId:n,active:!1,type:"option",linear:void 0,inverse:void 0,spot:!1,swap:!1,future:!1,option:!0,margin:!1,contract:!0,contractSize:this.parseNumber("1"),expiry:h,expiryDatetime:c,optionType:"C"===o?"call":"put",strike:this.parseNumber(d),precision:{amount:void 0,price:void 0},limits:{amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:void 0}}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return void 0!==e&&(e.endsWith("-C")||e.endsWith("-P")||e.startsWith("C-")||e.startsWith("P-"))&&!(e in this.markets_by_id)?this.createExpiredOptionMarket(e):super.safeMarket(e,t,i,s)}async fetchTime(e={}){const t=await this.publicGetSettings(e),i=this.safeDict(t,"result",{});return this.safeIntegerProduct(i,"server_time",.001)}async fetchStatus(e={}){const t=await this.publicGetSettings(e),i=this.safeDict(t,"result",{});return{status:"true"===this.safeString(i,"under_maintenance")?"maintenance":"ok",updated:this.safeIntegerProduct(i,"server_time",.001,this.milliseconds()),eta:void 0,url:void 0,info:t}}async fetchCurrencies(e={}){const t=await this.publicGetAssets(e),i=this.safeList(t,"result",[]),s={};for(let e=0;e=0?this.parse8601(r):this.safeIntegerProduct(e,"created_at",.001));const o=this.safeString(e,"product_id"),n=this.safeDict(this.options,"marketsByNumericId",{}),d=void 0===(t=this.safeValue(n,o,t))?o:t.symbol,c=this.parseOrderStatus(this.safeString(e,"state")),h=this.safeString(e,"side");let l=this.safeString(e,"order_type");void 0!==l&&(l=l.replace("_order",""));const u=this.safeString(e,"limit_price"),p=this.safeString(e,"size"),f=this.safeString(e,"unfilled_size"),m=this.safeString(e,"average_fill_price");let g;const v=this.safeString(e,"paid_commission");if(void 0!==v){let e;if(void 0!==t){const i=this.safeDict(t.info,"settling_asset",{}),s=this.safeString(i,"symbol");e=this.safeCurrencyCode(s)}g={cost:v,currency:e}}return this.safeOrder({info:e,id:i,clientOrderId:s,timestamp:a,datetime:this.iso8601(a),lastTradeTimestamp:void 0,symbol:d,type:l,side:h,price:u,amount:p,cost:void 0,average:m,filled:void 0,remaining:f,status:c,fee:g,trades:void 0},t)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=t+"_order",n=this.market(e),d={product_id:n.numericId,size:this.amountToPrecision(n.symbol,s),side:i,order_type:o};"limit"===t&&(d.limit_price=this.priceToPrecision(n.symbol,r));const c=this.safeString2(a,"clientOrderId","client_order_id");a=this.omit(a,["clientOrderId","client_order_id"]),void 0!==c&&(d.client_order_id=c);const h=this.safeBool(a,"reduceOnly");h&&(d.reduce_only=h,a=this.omit(a,"reduceOnly"));const l=await this.privatePostOrders(this.extend(d,a)),u=this.safeDict(l,"result",{});return this.parseOrder(u,n)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets();const n=this.market(t),d={id:parseInt(e),product_id:n.numericId};void 0!==r&&(d.size=parseInt(this.amountToPrecision(t,r))),void 0!==a&&(d.limit_price=this.priceToPrecision(t,a));const c=await this.privatePutOrders(this.extend(d,o)),h=this.safeDict(c,"result");return this.parseOrder(h,n)}async cancelOrder(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" cancelOrder() requires a symbol argument");await this.loadMarkets();const s=this.market(t),a={id:parseInt(e),product_id:s.numericId},o=await this.privateDeleteOrders(this.extend(a,i)),n=this.safeDict(o,"result");return this.parseOrder(n,s)}async cancelAllOrders(e=void 0,t={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" cancelAllOrders() requires a symbol argument");await this.loadMarkets();const i={product_id:this.market(e).numericId},s=this.privateDeleteOrdersAll(this.extend(i,t));return[this.safeOrder({info:s})]}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r=this.safeStringN(i,["clientOrderId","client_oid","clientOid"]);i=this.omit(i,["clientOrderId","client_oid","clientOid"]);const a={};let o;void 0!==r?(a.client_oid=r,o=await this.privateGetOrdersClientOrderIdClientOid(this.extend(a,i))):(a.order_id=e,o=await this.privateGetOrdersOrderId(this.extend(a,i)));const n=this.safeDict(o,"result",{});return this.parseOrder(n,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersWithMethod("privateGetOrders",e,t,i,s)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersWithMethod("privateGetOrdersHistory",e,t,i,s)}async fetchOrdersWithMethod(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={};let o,n;void 0!==t&&(o=this.market(t),a.product_ids=o.numericId),void 0!==i&&(a.start_time=i.toString()+"000"),void 0!==s&&(a.page_size=s),"privateGetOrders"===e?n=await this.privateGetOrders(this.extend(a,r)):"privateGetOrdersHistory"===e&&(n=await this.privateGetOrdersHistory(this.extend(a,r)));const d=this.safeList(n,"result",[]);return this.parseOrders(d,o,i,s)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.market(e),r.product_ids=a.numericId),void 0!==t&&(r.start_time=t.toString()+"000"),void 0!==i&&(r.page_size=i);const o=await this.privateGetFills(this.extend(r,s)),n=this.safeList(o,"result",[]);return this.parseTrades(n,a,t,i)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e),r.asset_id=a.numericId),void 0!==i&&(r.page_size=i);const o=await this.privateGetWalletTransactions(this.extend(r,s)),n=this.safeList(o,"result",[]);return this.parseLedger(n,a,t,i)}parseLedgerEntryType(e){return this.safeString({pnl:"pnl",deposit:"transaction",withdrawal:"transaction",commission:"fee",conversion:"trade",referral_bonus:"referral",commission_rebate:"rebate"},e,e)}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"uuid");let s;const r=this.safeDict(e,"meta_data",{}),a=this.safeString(r,"transaction_id");let n=this.safeString(e,"transaction_type");"deposit"===n||"commission_rebate"===n||"referral_bonus"===n||"pnl"===n||"withdrawal_cancellation"===n||"promo_credit"===n?s="in":"withdrawal"!==n&&"commission"!==n&&"conversion"!==n&&"perpetual_futures_funding"!==n||(s="out"),n=this.parseLedgerEntryType(n);const d=this.safeString(e,"asset_id"),c=this.safeDict(this.options,"currenciesByNumericId"),h=void 0===(t=this.safeValue(c,d,t))?void 0:t.code,l=this.safeString(e,"amount"),u=this.parse8601(this.safeString(e,"created_at")),p=this.safeString(e,"balance"),f=o.Y.stringMax("0",o.Y.stringSub(p,l));return this.safeLedgerEntry({info:e,id:i,direction:s,account:undefined,referenceId:a,referenceAccount:undefined,type:n,currency:h,amount:this.parseNumber(l),before:this.parseNumber(f),after:this.parseNumber(p),status:"ok",timestamp:u,datetime:this.iso8601(u),fee:void 0},t)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={asset_symbol:i.id},r=this.safeStringUpper(t,"network");void 0!==r&&(s.network=this.networkCodeToId(r,e),t=this.omit(t,"network"));const a=await this.privateGetDepositsAddress(this.extend(s,t)),o=this.safeDict(a,"result",{});return this.parseDepositAddress(o,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address"),s=this.safeString(e,"asset_symbol"),r=this.safeString(e,"network");return this.checkAddress(i),{info:e,currency:this.safeCurrencyCode(s,t),network:this.networkIdToCode(r),address:i,tag:this.safeString(e,"memo")}}async fetchFundingRate(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.swap)throw new r.BadSymbol(this.id+" fetchFundingRate() supports swap contracts only");const s={symbol:i.id},a=await this.publicGetTickersSymbol(this.extend(s,t)),o=this.safeDict(a,"result",{});return this.parseFundingRate(o,i)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.publicGetTickers(this.extend({contract_types:"perpetual_futures"},t)),s=this.safeList(i,"result",[]);return this.parseFundingRates(s,e)}parseFundingRate(e,t=void 0){const i=this.safeIntegerProduct(e,"timestamp",.001),s=this.safeString(e,"symbol"),r=this.safeString(e,"funding_rate"),a=o.Y.stringDiv(r,"100");return{info:e,symbol:this.safeSymbol(s,t),markPrice:this.safeNumber(e,"mark_price"),indexPrice:this.safeNumber(e,"spot_price"),interestRate:void 0,estimatedSettlePrice:void 0,timestamp:i,datetime:this.iso8601(i),fundingRate:this.parseNumber(a),fundingTimestamp:void 0,fundingDatetime:void 0,nextFundingRate:void 0,nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:void 0}}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"add",i)}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"reduce",i)}async modifyMarginHelper(e,t,i,s={}){await this.loadMarkets();const r=this.market(e);t=t.toString(),"reduce"===i&&(t=o.Y.stringMul(t,"-1"));const a={product_id:r.numericId,delta_margin:t},n=await this.privatePostPositionsChangeMargin(this.extend(a,s)),d=this.safeDict(n,"result",{});return this.parseMarginModification(d,r)}parseMarginModification(e,t=void 0){const i=this.safeString(e,"product_symbol");return{info:e,symbol:(t=this.safeMarket(i,t)).symbol,type:void 0,marginMode:"isolated",amount:void 0,total:this.safeNumber(e,"margin"),code:void 0,status:void 0,timestamp:void 0,datetime:void 0}}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new r.BadRequest(this.id+" fetchOpenInterest() supports contract markets only");const s={symbol:i.id},a=await this.publicGetTickersSymbol(this.extend(s,t)),o=this.safeDict(a,"result",{});return this.parseOpenInterest(o,i)}parseOpenInterest(e,t=void 0){const i=this.safeIntegerProduct(e,"timestamp",.001),s=this.safeString(e,"symbol");return this.safeOpenInterest({symbol:this.safeSymbol(s,t),baseVolume:this.safeNumber(e,"oi_value"),quoteVolume:this.safeNumber(e,"oi_value_usd"),openInterestAmount:this.safeNumber(e,"oi_contracts"),openInterestValue:this.safeNumber(e,"oi"),timestamp:i,datetime:this.iso8601(i),info:e},t)}async fetchLeverage(e,t={}){await this.loadMarkets();const i=this.market(e),s={product_id:i.numericId},r=await this.privateGetProductsProductIdOrdersLeverage(this.extend(s,t)),a=this.safeDict(r,"result",{});return this.parseLeverage(a,i)}parseLeverage(e,t=void 0){const i=this.safeString(e,"index_symbol"),s=this.safeInteger(e,"leverage");return{info:e,symbol:this.safeSymbol(i,t),marginMode:this.safeStringLower(e,"margin_mode"),longLeverage:s,shortLeverage:s}}async setLeverage(e,t=void 0,i={}){if(void 0===t)throw new r.ArgumentsRequired(this.id+" setLeverage() requires a symbol argument");await this.loadMarkets();const s={product_id:this.market(t).numericId,leverage:e};return await this.privatePostProductsProductIdOrdersLeverage(this.extend(s,i))}async fetchSettlementHistory(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a={states:"expired"};void 0!==i&&(a.page_size=i);const o=await this.publicGetProducts(this.extend(a,s)),n=this.safeList(o,"result",[]),d=this.parseSettlements(n,r),c=this.sortBy(d,"timestamp");return this.filterBySymbolSinceLimit(c,r.symbol,t,i)}parseSettlement(e,t){const i=this.safeString(e,"settlement_time"),s=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(s,t),price:this.safeNumber(e,"settlement_price"),timestamp:this.parse8601(i),datetime:i}}parseSettlements(e,t){const i=[];for(let s=0;s{"use strict";i.d(t,{A:()=>c});var s=i(4012),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(8995);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"deribit",name:"Deribit",countries:["NL"],version:"v2",userAgent:void 0,rateLimit:50,pro:!0,has:{CORS:!0,spot:!1,margin:!1,swap:!0,future:!0,option:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,createDepositAddress:!0,createOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTrailingAmountOrder:!0,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFees:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchGreeks:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverageTiers:!1,fetchLiquidations:!0,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!0,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!0,fetchOptionChain:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!0,fetchWithdrawal:!1,fetchWithdrawals:!0,sandbox:!0,transfer:!0,withdraw:!0},timeframes:{"1m":"1","3m":"3","5m":"5","10m":"10","15m":"15","30m":"30","1h":"60","2h":"120","3h":"180","6h":"360","12h":"720","1d":"1D"},urls:{test:{rest:"https://test.deribit.com"},logo:"https://user-images.githubusercontent.com/1294454/41933112-9e2dd65a-798b-11e8-8440-5bab2959fcb8.jpg",api:{rest:"https://www.deribit.com"},www:"https://www.deribit.com",doc:["https://docs.deribit.com/v2","https://github.com/deribit"],fees:"https://www.deribit.com/pages/information/fees",referral:{url:"https://www.deribit.com/reg-1189.4038",discount:.1}},api:{public:{get:{auth:1,exchange_token:1,fork_token:1,set_heartbeat:1,disable_heartbeat:1,get_time:1,hello:1,status:1,test:1,subscribe:1,unsubscribe:1,unsubscribe_all:1,get_announcements:1,get_book_summary_by_currency:1,get_book_summary_by_instrument:1,get_contract_size:1,get_currencies:1,get_delivery_prices:1,get_funding_chart_data:1,get_funding_rate_history:1,get_funding_rate_value:1,get_historical_volatility:1,get_index:1,get_index_price:1,get_index_price_names:1,get_instrument:1,get_instruments:1,get_last_settlements_by_currency:1,get_last_settlements_by_instrument:1,get_last_trades_by_currency:1,get_last_trades_by_currency_and_time:1,get_last_trades_by_instrument:1,get_last_trades_by_instrument_and_time:1,get_mark_price_history:1,get_order_book:1,get_trade_volumes:1,get_tradingview_chart_data:1,get_volatility_index_data:1,ticker:1}},private:{get:{logout:1,enable_cancel_on_disconnect:1,disable_cancel_on_disconnect:1,get_cancel_on_disconnect:1,subscribe:1,unsubscribe:1,unsubscribe_all:1,change_api_key_name:1,change_scope_in_api_key:1,change_subaccount_name:1,create_api_key:1,create_subaccount:1,disable_api_key:1,disable_tfa_for_subaccount:1,enable_affiliate_program:1,enable_api_key:1,get_access_log:1,get_account_summary:1,get_account_summaries:1,get_affiliate_program_info:1,get_email_language:1,get_new_announcements:1,get_portfolio_margins:1,get_position:1,get_positions:1,get_subaccounts:1,get_subaccounts_details:1,get_transaction_log:1,list_api_keys:1,remove_api_key:1,remove_subaccount:1,reset_api_key:1,set_announcement_as_read:1,set_api_key_as_default:1,set_email_for_subaccount:1,set_email_language:1,set_password_for_subaccount:1,toggle_notifications_from_subaccount:1,toggle_subaccount_login:1,execute_block_trade:4,get_block_trade:1,get_last_block_trades_by_currency:1,invalidate_block_trade_signature:1,verify_block_trade:4,buy:4,sell:4,edit:4,edit_by_label:4,cancel:4,cancel_all:4,cancel_all_by_currency:4,cancel_all_by_instrument:4,cancel_by_label:4,close_position:4,get_margins:1,get_mmp_config:1,get_open_orders_by_currency:1,get_open_orders_by_instrument:1,get_order_history_by_currency:1,get_order_history_by_instrument:1,get_order_margin_by_ids:1,get_order_state:1,get_stop_order_history:1,get_trigger_order_history:1,get_user_trades_by_currency:1,get_user_trades_by_currency_and_time:1,get_user_trades_by_instrument:1,get_user_trades_by_instrument_and_time:1,get_user_trades_by_order:1,reset_mmp:1,set_mmp_config:1,get_settlement_history_by_instrument:1,get_settlement_history_by_currency:1,cancel_transfer_by_id:1,cancel_withdrawal:1,create_deposit_address:1,get_current_deposit_address:1,get_deposits:1,get_transfers:1,get_withdrawals:1,submit_transfer_to_subaccount:1,submit_transfer_to_user:1,withdraw:1}}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,selfTradePrevention:!1,trailing:!0,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:{extends:"default"},inverse:{extends:"default"}}},exceptions:{9999:a.PermissionDenied,1e4:a.AuthenticationError,10001:a.ExchangeError,10002:a.InvalidOrder,10003:a.InvalidOrder,10004:a.OrderNotFound,10005:a.InvalidOrder,10006:a.InvalidOrder,10007:a.InvalidOrder,10008:a.InvalidOrder,10009:a.InsufficientFunds,10010:a.OrderNotFound,10011:a.InvalidOrder,10012:a.InvalidOrder,10013:a.PermissionDenied,10014:a.PermissionDenied,10015:a.PermissionDenied,10016:a.PermissionDenied,10017:a.PermissionDenied,10018:a.PermissionDenied,10019:a.PermissionDenied,10020:a.ExchangeError,10021:a.InvalidOrder,10022:a.InvalidOrder,10023:a.InvalidOrder,10024:a.InvalidOrder,10025:a.InvalidOrder,10026:a.InvalidOrder,10027:a.InvalidOrder,10028:a.DDoSProtection,10029:a.OrderNotFound,10030:a.ExchangeError,10031:a.ExchangeError,10032:a.InvalidOrder,10033:a.NotSupported,10034:a.InvalidOrder,10035:a.InvalidOrder,10036:a.InvalidOrder,10040:a.ExchangeNotAvailable,10041:a.OnMaintenance,10043:a.InvalidOrder,10044:a.InvalidOrder,10045:a.InvalidOrder,10046:a.InvalidOrder,10047:a.DDoSProtection,10048:a.ExchangeError,11008:a.InvalidOrder,11029:a.BadRequest,11030:a.ExchangeError,11031:a.ExchangeError,11035:a.DDoSProtection,11036:a.InvalidOrder,11037:a.BadRequest,11038:a.InvalidOrder,11039:a.InvalidOrder,11041:a.InvalidOrder,11042:a.PermissionDenied,11043:a.BadRequest,11044:a.InvalidOrder,11045:a.BadRequest,11046:a.BadRequest,11047:a.BadRequest,11048:a.ExchangeError,11049:a.BadRequest,11050:a.BadRequest,11051:a.OnMaintenance,11052:a.ExchangeError,11053:a.ExchangeError,11090:a.InvalidAddress,11091:a.InvalidAddress,11092:a.InvalidAddress,11093:a.DDoSProtection,11094:a.ExchangeError,11095:a.ExchangeError,11096:a.ExchangeError,12e3:a.AuthenticationError,12001:a.DDoSProtection,12002:a.ExchangeError,12998:a.AuthenticationError,12003:a.AuthenticationError,12004:a.AuthenticationError,12005:a.AuthenticationError,12100:a.ExchangeError,12999:a.AuthenticationError,13e3:a.AuthenticationError,13001:a.AuthenticationError,13002:a.PermissionDenied,13003:a.AuthenticationError,13004:a.AuthenticationError,13005:a.AuthenticationError,13006:a.AuthenticationError,13007:a.AuthenticationError,13008:a.ExchangeError,13009:a.AuthenticationError,13010:a.BadRequest,13011:a.BadRequest,13012:a.PermissionDenied,13013:a.BadRequest,13014:a.BadRequest,13015:a.BadRequest,13016:a.BadRequest,13017:a.ExchangeError,13018:a.ExchangeError,13019:a.ExchangeError,13020:a.ExchangeError,13021:a.PermissionDenied,13025:a.ExchangeError,"-32602":a.BadRequest,"-32601":a.BadRequest,"-32700":a.BadRequest,"-32000":a.BadRequest,11054:a.InvalidOrder},precisionMode:r.kb,options:{code:"BTC",fetchBalance:{code:"BTC"},transfer:{method:"privateGetSubmitTransferToSubaccount"}}})}createExpiredOptionMarket(e){let t,i="USD";const s=e.split("-"),r=e.split("/");let a,o;e.indexOf("/")>-1?(a=this.safeString(r,0),o=this.safeString(s,1),e.indexOf("USDC")>-1&&(a+="_USDC")):(a=this.safeString(s,0),o=this.convertMarketIdExpireDate(this.safeString(s,1))),e.indexOf("USDC")>-1?(i="USDC",t="USDC"):t=a;let n=a;if(a.indexOf("_")>-1){const e=a.split("_");n=this.safeString(e,0)}const d=this.safeString(s,2),c=this.safeString(s,3),h=this.convertExpireDate(o),l=this.parse8601(h);return{id:a+"-"+this.convertExpireDateToMarketIdDate(o)+"-"+d+"-"+c,symbol:n+"/"+i+":"+t+"-"+o+"-"+d+"-"+c,base:a,quote:i,settle:t,baseId:a,quoteId:i,settleId:t,active:!1,type:"option",linear:void 0,inverse:void 0,spot:!1,swap:!1,future:!1,option:!0,margin:!1,contract:!0,contractSize:void 0,expiry:l,expiryDatetime:h,optionType:"C"===c?"call":"put",strike:this.parseNumber(d),precision:{amount:void 0,price:void 0},limits:{amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:void 0}}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return void 0!==e&&(e.endsWith("-C")||e.endsWith("-P"))&&!(e in this.markets_by_id)?this.createExpiredOptionMarket(e):super.safeMarket(e,t,i,s)}async fetchTime(e={}){const t=await this.publicGetGetTime(e);return this.safeInteger(t,"result")}async fetchCurrencies(e={}){const t=await this.publicGetGetCurrencies(e),i=this.safeList(t,"result",[]),s={};for(let e=0;e=0,g=a.indexOf("option")>=0,v=a.indexOf("combo")>=0,y=this.safeInteger(t,"expiration_timestamp");let b,w,k,S,O=n,T="swap";if(m?T="future":g?T="option":o&&(T="spot"),o)O=l+"/"+u;else if(!v){if(O=l+"/"+u+":"+p,(g||m)&&(O=O+"-"+this.yymmdd(y,""),g)){b=this.safeNumber(t,"strike"),w=this.safeString(t,"option_type");const e="call"===w?"C":"P";O=O+"-"+this.numberToString(b)+"-"+e}k=u!==p,S=p===u}if(this.safeValue(s,O))continue;s[O]=!0;const P=this.safeNumber(t,"min_trade_amount"),I=this.safeNumber(t,"tick_size");i.push({id:n,symbol:O,base:l,quote:u,settle:p,baseId:d,quoteId:c,settleId:h,type:T,spot:o,margin:!1,swap:f,future:m,option:g,active:this.safeValue(t,"is_active"),contract:!o,linear:S,inverse:k,taker:this.safeNumber(t,"taker_commission"),maker:this.safeNumber(t,"maker_commission"),contractSize:this.safeNumber(t,"contract_size"),expiry:y,expiryDatetime:this.iso8601(y),strike:b,optionType:w,precision:{amount:P,price:I},limits:{leverage:{min:void 0,max:void 0},amount:{min:P,max:void 0},price:{min:I,max:void 0},cost:{min:void 0,max:void 0}},created:this.safeInteger(t,"creation_timestamp"),info:t})}}return i}parseBalance(e){const t={info:e};let i=[];i="summaries"in e?this.safeList(e,"summaries"):[e];for(let e=0;e0){const s=t[0],r=t[i-1];s.continuation=e,r.continuation=e,t[0]=s,t[i-1]=r}}return t}async fetchMyLiquidations(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchMyLiquidations() requires a symbol argument");await this.loadMarkets();const r=this.market(e);if(r.spot)throw new a.NotSupported(this.id+" fetchMyLiquidations() does not support "+r.type+" markets");const o={instrument_name:r.id,type:"bankruptcy"};void 0!==t&&(o.search_start_timestamp=t),void 0!==i&&(o.count=i);const n=await this.privateGetGetSettlementHistoryByInstrument(this.extend(o,s)),d=this.safeValue(n,"result",{}),c=this.safeList(d,"settlements",[]);return this.parseLiquidations(c,r,t,i)}parseLiquidation(e,t=void 0){const i=this.safeInteger(e,"timestamp");return this.safeLiquidation({info:e,symbol:this.safeSymbol(void 0,t),contracts:void 0,contractSize:this.safeNumber(t,"contractSize"),price:void 0,baseValue:this.safeNumber(e,"session_bankrupcy"),quoteValue:void 0,timestamp:i,datetime:this.iso8601(i)})}async fetchGreeks(e,t={}){await this.loadMarkets();const i=this.market(e),s={instrument_name:i.id},r=await this.publicGetTicker(this.extend(s,t)),a=this.safeValue(r,"result",{});return this.parseGreeks(a,i)}parseGreeks(e,t=void 0){const i=this.safeInteger(e,"timestamp"),s=this.safeString(e,"instrument_name"),r=this.safeSymbol(s,t),a=this.safeValue(e,"greeks",{});return{symbol:r,timestamp:i,datetime:this.iso8601(i),delta:this.safeNumber(a,"delta"),gamma:this.safeNumber(a,"gamma"),theta:this.safeNumber(a,"theta"),vega:this.safeNumber(a,"vega"),rho:this.safeNumber(a,"rho"),bidSize:this.safeNumber(e,"best_bid_amount"),askSize:this.safeNumber(e,"best_ask_amount"),bidImpliedVolatility:this.safeNumber(e,"bid_iv"),askImpliedVolatility:this.safeNumber(e,"ask_iv"),markImpliedVolatility:this.safeNumber(e,"mark_iv"),bidPrice:this.safeNumber(e,"best_bid_price"),askPrice:this.safeNumber(e,"best_ask_price"),markPrice:this.safeNumber(e,"mark_price"),lastPrice:this.safeNumber(e,"last_price"),underlyingPrice:this.safeNumber(e,"underlying_price"),info:e}}async fetchOption(e,t={}){await this.loadMarkets();const i=this.market(e),s={instrument_name:i.id},r=await this.publicGetGetBookSummaryByInstrument(this.extend(s,t)),a=this.safeList(r,"result",[]),o=this.safeDict(a,0,{});return this.parseOption(o,void 0,i)}async fetchOptionChain(e,t={}){await this.loadMarkets();const i={currency:this.currency(e).id,kind:"option"},s=await this.publicGetGetBookSummaryByCurrency(this.extend(i,t)),r=this.safeList(s,"result",[]);return this.parseOptionChain(r,"base_currency","instrument_name")}parseOption(e,t=void 0,i=void 0){const s=this.safeString(e,"instrument_name");i=this.safeMarket(s,i);const r=this.safeString(e,"base_currency"),a=this.safeCurrencyCode(r,t),o=this.safeInteger(e,"timestamp");return{info:e,currency:a,symbol:i.symbol,timestamp:o,datetime:this.iso8601(o),impliedVolatility:void 0,openInterest:this.safeNumber(e,"open_interest"),bidPrice:this.safeNumber(e,"bid_price"),askPrice:this.safeNumber(e,"ask_price"),midPrice:this.safeNumber(e,"mid_price"),markPrice:this.safeNumber(e,"mark_price"),lastPrice:this.safeNumber(e,"last"),underlyingPrice:this.safeNumber(e,"underlying_price"),change:void 0,percentage:this.safeNumber(e,"price_change"),baseVolume:this.safeNumber(e,"volume"),quoteVolume:this.safeNumber(e,"volume_usd")}}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new a.BadRequest(this.id+" fetchOpenInterest() supports contract markets only");const s={instrument_name:i.id},r=await this.publicGetGetBookSummaryByInstrument(this.extend(s,t)),o=this.safeList(r,"result",[]),n=this.safeDict(o,0,{});return this.parseOpenInterest(n,i)}parseOpenInterest(e,t=void 0){const i=this.safeInteger(e,"creation_timestamp"),s=this.safeString(e,"instrument_name");t=this.safeMarket(s,t);const r=this.safeNumber(e,"open_interest");let a,o;return t.option||t.future&&t.linear?a=r:o=r,this.safeOpenInterest({symbol:this.safeSymbol(s,t),openInterestAmount:a,openInterestValue:o,timestamp:i,datetime:this.iso8601(i),info:e},t)}nonce(){return this.milliseconds()}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o="/api/"+this.version+"/"+t+"/"+e;if("public"===t&&Object.keys(s).length&&(o+="?"+this.urlencode(s)),"private"===t){this.checkRequiredCredentials();const e=this.nonce().toString(),t=this.milliseconds().toString(),a="";Object.keys(s).length&&(o+="?"+this.urlencode(s));const d=t+"\n"+e+"\n"+(i+"\n"+o+"\n"+a+"\n"),c=this.hmac(this.encode(d),this.encode(this.secret),n.s);r={Authorization:"deri-hmac-sha256 id="+this.apiKey+",ts="+t+",sig="+c+",nonce="+e}}return{url:this.urls.api.rest+o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,o,n,d,c){if(!n)return;const h=this.safeValue(n,"error");if(void 0!==h){const e=this.safeString(h,"code"),t=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions,e,t),new a.ExchangeError(t)}}}},1839:(e,t,i)=>{"use strict";i.d(t,{A:()=>h});var s=i(970),r=i(5147),a=i(2079),o=i(8283),n=i(8432),d=i(987),c=i(1579);class h extends s.A{describe(){return this.deepExtend(super.describe(),{id:"derive",name:"derive",countries:[],version:"v1",rateLimit:50,certified:!1,pro:!0,dex:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelOrdersForSymbols:!1,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!1,createReduceOnlyOrder:!1,createStopOrder:!1,createTriggerOrder:!1,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginMode:void 0,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!1,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOrder:!1,fetchOrderBook:!1,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!1},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},hostname:"derive.xyz",urls:{logo:"https://github.com/user-attachments/assets/f835b95f-033a-43dd-b6bb-24e698fc498c",api:{public:"https://api.lyra.finance/public",private:"https://api.lyra.finance/private"},test:{public:"https://api-demo.lyra.finance/public",private:"https://api-demo.lyra.finance/private"},www:"https://www.derive.xyz/",doc:"https://docs.derive.xyz/docs/",fees:"https://docs.derive.xyz/reference/fees-1/",referral:"https://www.derive.xyz/invite/3VB0B"},api:{public:{get:["get_all_currencies"],post:["build_register_session_key_tx","register_session_key","deregister_session_key","login","statistics","get_all_currencies","get_currency","get_instrument","get_all_instruments","get_instruments","get_ticker","get_latest_signed_feeds","get_option_settlement_prices","get_spot_feed_history","get_spot_feed_history_candles","get_funding_rate_history","get_trade_history","get_option_settlement_history","get_liquidation_history","get_interest_rate_history","get_transaction","get_margin","margin_watch","validate_invite_code","get_points","get_all_points","get_points_leaderboard","get_descendant_tree","get_tree_roots","get_swell_percent_points","get_vault_assets","get_etherfi_effective_balances","get_kelp_effective_balances","get_bridge_balances","get_ethena_participants","get_vault_share","get_vault_statistics","get_vault_balances","estimate_integrator_points","create_subaccount_debug","deposit_debug","withdraw_debug","send_quote_debug","execute_quote_debug","get_invite_code","register_invite","get_time","get_live_incidents","get_maker_programs","get_maker_program_scores"]},private:{post:["get_account","create_subaccount","get_subaccount","get_subaccounts","get_all_portfolios","change_subaccount_label","get_notificationsv","update_notifications","deposit","withdraw","transfer_erc20","transfer_position","transfer_positions","order","replace","order_debug","get_order","get_orders","get_open_orders","cancel","cancel_by_label","cancel_by_nonce","cancel_by_instrument","cancel_all","cancel_trigger_order","get_order_history","get_trade_history","get_deposit_history","get_withdrawal_history","send_rfq","cancel_rfq","cancel_batch_rfqs","get_rfqs","poll_rfqs","send_quote","cancel_quote","cancel_batch_quotes","get_quotes","poll_quotes","execute_quote","rfq_get_best_quote","get_margin","get_collaterals","get_positions","get_option_settlement_history","get_subaccount_value_history","expired_and_cancelled_history","get_funding_history","get_interest_history","get_erc20_transfer_history","get_liquidation_history","liquidate","get_liquidator_history","session_keys","edit_session_key","register_scoped_session_key","get_mmp_config","set_mmp_config","reset_mmp","set_cancel_on_disconnect","get_invite_code","register_invite"]}},fees:{},requiredCredentials:{apiKey:!1,secret:!1,walletAddress:!0,privateKey:!0},exceptions:{exact:{"-32000":a.RateLimitExceeded,"-32100":a.RateLimitExceeded,"-32700":a.BadRequest,"-32600":a.BadRequest,"-32601":a.BadRequest,"-32602":a.InvalidOrder,"-32603":a.InvalidOrder,9e3:a.InvalidOrder,1e4:a.BadRequest,10001:a.BadRequest,10002:a.BadRequest,10003:a.BadRequest,10004:a.InvalidOrder,10005:a.BadRequest,10006:a.BadRequest,10007:a.BadRequest,10008:a.BadRequest,10009:a.BadRequest,10010:a.InvalidOrder,10011:a.InsufficientFunds,10012:a.InsufficientFunds,10013:a.ExchangeError,10014:a.ExchangeError,11e3:a.InsufficientFunds,11002:a.InvalidOrder,11003:a.InvalidOrder,11004:a.InvalidOrder,11005:a.InvalidOrder,11006:a.OrderNotFound,11007:a.InvalidOrder,11008:a.InvalidOrder,11009:a.InvalidOrder,11010:a.InvalidOrder,11011:a.InvalidOrder,11012:a.InvalidOrder,11013:a.InvalidOrder,11014:a.InvalidOrder,11015:a.InvalidOrder,11016:a.InvalidOrder,11017:a.InvalidOrder,11018:a.InvalidOrder,11019:a.InvalidOrder,11020:a.InsufficientFunds,11021:a.InvalidOrder,11022:a.InvalidOrder,11023:a.InvalidOrder,11024:a.InvalidOrder,11025:a.InvalidOrder,11026:a.BadRequest,11027:a.InvalidOrder,11028:a.InvalidOrder,11050:a.InvalidOrder,11051:a.InvalidOrder,11052:a.InvalidOrder,11053:a.InvalidOrder,11054:a.InvalidOrder,11055:a.InvalidOrder,11100:a.InvalidOrder,11101:a.InvalidOrder,11102:a.InvalidOrder,11103:a.InvalidOrder,11104:a.InvalidOrder,11105:a.InvalidOrder,11106:a.InvalidOrder,11107:a.InvalidOrder,11200:a.InvalidOrder,11201:a.InvalidOrder,11202:a.InvalidOrder,11203:a.InvalidOrder,12e3:a.InvalidOrder,12001:a.InvalidOrder,12002:a.BadRequest,12003:a.BadRequest,13e3:a.BadRequest,14e3:a.BadRequest,14001:a.InvalidOrder,14002:a.BadRequest,14008:a.BadRequest,14009:a.BadRequest,14010:a.BadRequest,14011:a.BadRequest,14012:a.BadRequest,14013:a.BadRequest,14014:a.InvalidOrder,14015:a.BadRequest,14016:a.BadRequest,14017:a.BadRequest,14018:a.BadRequest,14019:a.BadRequest,14020:a.BadRequest,14021:a.BadRequest,14022:a.AuthenticationError,14023:a.InvalidOrder,14024:a.BadRequest,14025:a.BadRequest,14026:a.BadRequest,14027:a.AuthenticationError,14028:a.BadRequest,14029:a.AuthenticationError,14030:a.BadRequest,14031:a.AuthenticationError,14032:a.BadRequest,16e3:a.AuthenticationError,16001:a.AuthenticationError,16100:a.AuthenticationError,17e3:a.BadRequest,17001:a.BadRequest,17002:a.BadRequest,17003:a.BadRequest,17004:a.BadRequest,17005:a.BadRequest,17006:a.BadRequest,17007:a.BadRequest,18e3:a.BadRequest,18001:a.BadRequest,18002:a.BadRequest,18003:a.BadRequest,18004:a.BadRequest,18005:a.BadRequest,18006:a.BadRequest,18007:a.BadRequest,19e3:a.BadRequest},broad:{}},precisionMode:c.kb,commonCurrencies:{},options:{deriveWalletAddress:"",id:"0x0ad42b8e602c2d3d475ae52d678cf63d84ab2749"}})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}async fetchTime(e={}){const t=await this.publicPostGetTime(e);return this.safeInteger(t,"result")}async fetchCurrencies(e={}){const t={},i=await this.publicGetGetAllCurrencies(e),s=this.safeList(i,"result",[]);for(let e=0;e1e3&&(i=1e3),r.page_size=i),void 0!==t&&(r.from_timestamp=t);const o=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==o&&(r.to_timestamp=o);const n=await this.publicPostGetTradeHistory(this.extend(r,s)),d=this.safeDict(n,"result",{}),c=this.safeList(d,"trades",[]);return this.parseTrades(c,a,t,i)}parseTrade(e,t=void 0){const i=this.safeString(e,"instrument_name"),s=this.safeSymbol(i,t),r=this.safeInteger(e,"timestamp"),a={currency:"USDC",cost:this.safeString(e,"trade_fee")};return this.safeTrade({info:e,id:this.safeString(e,"trade_id"),order:this.safeString(e,"order_id"),symbol:s,side:this.safeStringLower(e,"direction"),type:void 0,takerOrMaker:this.safeString(e,"liquidity_role"),price:this.safeString(e,"trade_price"),amount:this.safeString(e,"trade_amount"),cost:void 0,timestamp:r,datetime:this.iso8601(r),fee:a},t)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={instrument_name:r.id};void 0!==t&&(a.start_timestamp=t);const o=this.safeInteger(s,"until");s=this.omit(s,["until"]),void 0!==o&&(a.to_timestamp=o);const n=await this.publicPostGetFundingRateHistory(this.extend(a,s)),d=this.safeDict(n,"result",{}),c=this.safeList(d,"funding_rate_history",[]),h=[];for(let e=0;ethis.safeInteger(e,"num_pages"))return[]}const u=this.safeList(h,"orders");return this.parseOrders(u,d,t,i)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"open"});return await this.fetchOrders(e,t,i,r)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"filled"});return await this.fetchOrders(e,t,i,r)}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.extend(s,{status:"cancelled"});return await this.fetchOrders(e,t,i,r)}parseTimeInForce(e){return this.safeString({ioc:"IOC",fok:"FOK",gtc:"GTC",post_only:"PO"},e,void 0)}parseOrderStatus(e){if(void 0!==e){const t={open:"open",untriggered:"open",filled:"closed",cancelled:"canceled",expired:"rejected"};return this.safeString(t,e,e)}return e}parseOrder(e,t=void 0){let i=this.safeDict(e,"data");void 0===i&&(i=e);const s=this.safeInteger2(e,"creation_timestamp","nonce"),r=this.safeString(i,"order_id"),a=this.safeString(i,"instrument_name");void 0!==a&&(t=this.safeMarket(a,t));const o=t.symbol,n=this.safeString(i,"limit_price"),d=this.safeString(i,"average_price"),c=this.safeString(i,"desired_amount"),h=this.safeString(i,"filled_amount"),l=this.safeString(i,"order_fee"),u=this.safeStringLower(i,"order_type"),p=this.safeBool(i,"is_bid");let f=this.safeString(i,"direction");void 0===f&&(f=p?"buy":"sell");const m=this.safeString(i,"trigger_type");let g,v,y;void 0!==m&&(y=this.safeString(i,"trigger_price"),"stoploss"===m?g=y:v=y);const b=this.safeInteger(e,"last_update_timestamp"),w=this.safeString(i,"order_status"),k=this.safeString(i,"time_in_force");return this.safeOrder({id:r,clientOrderId:this.safeString(i,"label"),timestamp:s,datetime:this.iso8601(s),lastTradeTimestamp:void 0,lastUpdateTimestamp:b,status:this.parseOrderStatus(w),symbol:o,type:u,timeInForce:this.parseTimeInForce(k),postOnly:void 0,reduceOnly:this.safeBool(i,"reduce_only"),side:f,price:n,triggerPrice:y,takeProfitPrice:v,stopLossPrice:g,average:d,amount:c,filled:h,remaining:void 0,cost:void 0,trades:void 0,fee:{cost:l,currency:"USDC"},info:i},t)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),[a,r]=this.handleDeriveSubaccountId("fetchOrderTrades",r);const o={order_id:e,subaccount_id:a};let n;void 0!==t&&(n=this.market(t),o.instrument_name=n.id),void 0!==s&&(o.page_size=s),void 0!==i&&(o.from_timestamp=i);const d=await this.privatePostGetTradeHistory(this.extend(o,r)),c=this.safeDict(d,"result",{}),h=this.safeList(c,"trades",[]);return this.parseTrades(h,n,i,s,r)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),a)return await this.fetchPaginatedCallIncremental("fetchMyTrades",e,t,i,s,"page",500);[r,s]=this.handleDeriveSubaccountId("fetchMyTrades",s);const o={subaccount_id:r};let n;void 0!==e&&(n=this.market(e),o.instrument_name=n.id),void 0!==i&&(o.page_size=i),void 0!==t&&(o.from_timestamp=t);const d=await this.privatePostGetTradeHistory(this.extend(o,s)),c=this.safeDict(d,"result",{}),h=this.safeInteger(s,"page");if(void 0!==h){const e=this.safeDict(c,"pagination");if(h>this.safeInteger(e,"num_pages"))return[]}const l=this.safeList(c,"trades",[]);return this.parseTrades(l,n,t,i,s)}async fetchPositions(e=void 0,t={}){let i;await this.loadMarkets(),[i,t]=this.handleDeriveSubaccountId("fetchPositions",t);const s={subaccount_id:i};t=this.omit(t,["subaccount_id"]);const r=await this.privatePostGetPositions(this.extend(s,t)),a=this.safeDict(r,"result",{}),o=this.safeList(a,"positions",[]);return this.parsePositions(o,e)}parsePosition(e,t=void 0){const i=this.safeString(e,"instrument_name");t=this.safeMarket(i,t);let s,a=this.safeString(e,"amount");s=r.Y.stringGt(a,"0")?"long":"short";const o=this.safeString(t,"contractSize"),n=this.safeString(e,"mark_price"),d=this.safeInteger(e,"creation_timestamp"),c=this.safeString(e,"unrealized_pnl");a=r.Y.stringAbs(a);const h=r.Y.stringMul(a,n);return this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:d,datetime:this.iso8601(d),lastUpdateTimestamp:void 0,initialMargin:this.safeString(e,"initial_margin"),initialMarginPercentage:void 0,maintenanceMargin:this.safeString(e,"maintenance_margin"),maintenanceMarginPercentage:void 0,entryPrice:void 0,notional:this.parseNumber(h),leverage:this.safeNumber(e,"leverage"),unrealizedPnl:this.parseNumber(c),contracts:this.parseNumber(a),contractSize:this.parseNumber(o),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"liquidation_price"),markPrice:this.parseNumber(n),lastPrice:void 0,collateral:void 0,marginMode:void 0,side:s,percentage:void 0,hedged:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r,a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingHistory","paginate"),a)return await this.fetchPaginatedCallIncremental("fetchFundingHistory",e,t,i,s,"page",500);[r,s]=this.handleDeriveSubaccountId("fetchFundingHistory",s);const o={subaccount_id:r};let n;void 0!==e&&(n=this.market(e),o.instrument_name=n.id),void 0!==t&&(o.start_timestamp=t),void 0!==i&&(o.page_size=i);const d=await this.privatePostGetFundingHistory(this.extend(o,s)),c=this.safeDict(d,"result",{}),h=this.safeInteger(s,"page");if(void 0!==h){const e=this.safeDict(c,"pagination");if(h>this.safeInteger(e,"num_pages"))return[]}const l=this.safeList(c,"events",[]);return this.parseIncomes(l,n,t,i)}parseIncome(e,t=void 0){const i=this.safeString(e,"instrument_name"),s=this.safeSymbol(i,t),r=this.safeString(e,"funding"),a=this.safeCurrencyCode("USDC"),o=this.safeInteger(e,"timestamp");return{info:e,symbol:s,code:a,timestamp:o,datetime:this.iso8601(o),id:void 0,amount:void 0,rate:r}}async fetchBalance(e={}){let t;await this.loadMarkets(),[t,e]=this.handleDeriveWalletAddress("fetchBalance",e);const i={wallet:t},s=await this.privatePostGetAllPortfolios(this.extend(i,e)),r=this.safeList(s,"result");return this.parseBalance(r)}parseBalance(e){const t={info:e};for(let i=0;i Developers tab.")}handleErrors(e,t,i,s,r,o,n,d,c){if(!n)return;const h=this.safeDict(n,"error");if(void 0!==h){const e=this.safeString(h,"code"),t=this.id+" "+this.json(n);throw this.throwBroadlyMatchedException(this.exceptions.broad,o,t),this.throwExactlyMatchedException(this.exceptions.exact,e,t),new a.ExchangeError(t)}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.urls.api[t]+"/"+e;if("POST"===i){if(r={"Content-Type":"application/json"},"private"===t){const e=this.milliseconds().toString(),t=this.signMessage(e,this.privateKey);r["X-LyraWallet"]=this.safeString(this.options,"deriveWalletAddress"),r["X-LyraTimestamp"]=e,r["X-LyraSignature"]=t}a=this.json(s)}return{url:o,method:i,body:a,headers:r}}}},779:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(9420),r=i(2079),a=i(1579),o=i(5147),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"digifinex",name:"DigiFinex",countries:["SG"],version:"v3",rateLimit:900,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!0,cancelOrder:!0,cancelOrders:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCrossBorrowRate:!0,fetchCrossBorrowRates:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!0,fetchMarginMode:!1,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!0,setLeverage:!0,setMargin:!1,setMarginMode:!0,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","4h":"240","12h":"720","1d":"1D","1w":"1W"},urls:{logo:"https://user-images.githubusercontent.com/51840849/87443315-01283a00-c5fe-11ea-8628-c2a0feaf07ac.jpg",api:{rest:"https://openapi.digifinex.com"},www:"https://www.digifinex.com",doc:["https://docs.digifinex.com"],fees:"https://digifinex.zendesk.com/hc/en-us/articles/360000328422-Fee-Structure-on-DigiFinex",referral:"https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp"},api:{public:{spot:{get:["{market}/symbols","kline","margin/currencies","margin/symbols","markets","order_book","ping","spot/symbols","time","trades","trades/symbols","ticker","currencies"]},swap:{get:["public/api_weight","public/candles","public/candles_history","public/depth","public/funding_rate","public/funding_rate_history","public/instrument","public/instruments","public/ticker","public/tickers","public/time","public/trades"]}},private:{spot:{get:["{market}/financelog","{market}/mytrades","{market}/order","{market}/order/detail","{market}/order/current","{market}/order/history","margin/assets","margin/financelog","margin/mytrades","margin/order","margin/order/current","margin/order/history","margin/positions","otc/financelog","spot/assets","spot/financelog","spot/mytrades","spot/order","spot/order/current","spot/order/history","deposit/address","deposit/history","withdraw/history"],post:["{market}/order/cancel","{market}/order/new","{market}/order/batch_new","margin/order/cancel","margin/order/new","margin/position/close","spot/order/cancel","spot/order/new","transfer","withdraw/new","withdraw/cancel"]},swap:{get:["account/balance","account/positions","account/finance_record","account/trading_fee_rate","account/transfer_record","account/funding_fee","trade/history_orders","trade/history_trades","trade/open_orders","trade/order_info"],post:["account/transfer","account/leverage","account/position_mode","account/position_margin","trade/batch_cancel_order","trade/batch_order","trade/cancel_order","trade/order_place","follow/sponsor_order","follow/close_order","follow/cancel_order","follow/user_center_current","follow/user_center_history","follow/expert_current_open_order","follow/add_algo","follow/cancel_algo","follow/account_available","follow/plan_task","follow/instrument_list"]}}},features:{default:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:{max:10},fetchMyTrades:{marginMode:!0,limit:500,daysBack:1e5,untilDays:30,symbolRequired:!1},fetchOrder:{marginMode:!0,trigger:!1,trailing:!1,marketType:!0,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:100,daysBack:1e5,untilDays:30,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:void 0,fetchOHLCV:{limit:500}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrders:{max:20,marginMode:!1},fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5},fetchOrder:{marginMode:!1},fetchOpenOrders:{marginMode:!1,limit:100},fetchOrders:{marginMode:!1,daysBack:1e5},fetchOHLCV:{limit:100}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:void 0,inverse:void 0}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")}},precisionMode:a.kb,exceptions:{exact:{10001:[r.BadRequest,"Wrong request method, please check it's a GET ot POST request"],10002:[r.AuthenticationError,"Invalid ApiKey"],10003:[r.AuthenticationError,"Sign doesn't match"],10004:[r.BadRequest,"Illegal request parameters"],10005:[r.DDoSProtection,"Request frequency exceeds the limit"],10006:[r.PermissionDenied,"Unauthorized to execute this request"],10007:[r.PermissionDenied,"IP address Unauthorized"],10008:[r.InvalidNonce,"Timestamp for this request is invalid, timestamp must within 1 minute"],10009:[r.NetworkError,"Unexist endpoint, please check endpoint URL"],10011:[r.AccountSuspended,"ApiKey expired. Please go to client side to re-create an ApiKey"],20001:[r.PermissionDenied,"Trade is not open for this trading pair"],20002:[r.PermissionDenied,"Trade of this trading pair is suspended"],20003:[r.InvalidOrder,"Invalid price or amount"],20007:[r.InvalidOrder,"Price precision error"],20008:[r.InvalidOrder,"Amount precision error"],20009:[r.InvalidOrder,"Amount is less than the minimum requirement"],20010:[r.InvalidOrder,"Cash Amount is less than the minimum requirement"],20011:[r.InsufficientFunds,"Insufficient balance"],20012:[r.BadRequest,"Invalid trade type, valid value: buy/sell)"],20013:[r.InvalidOrder,"No order info found"],20014:[r.BadRequest,"Invalid date, Valid format: 2018-07-25)"],20015:[r.BadRequest,"Date exceeds the limit"],20018:[r.PermissionDenied,"Your trading rights have been banned by the system"],20019:[r.BadSymbol,'Wrong trading pair symbol. Correct format:"usdt_btc". Quote asset is in the front'],20020:[r.DDoSProtection,"You have violated the API operation trading rules and temporarily forbid trading. At present, we have certain restrictions on the user's transaction rate and withdrawal rate."],5e4:[r.ExchangeError,"Exception error"],20021:[r.BadRequest,"Invalid currency"],20022:[r.BadRequest,"The ending timestamp must be larger than the starting timestamp"],20023:[r.BadRequest,"Invalid transfer type"],20024:[r.BadRequest,"Invalid amount"],20025:[r.BadRequest,"This currency is not transferable at the moment"],20026:[r.InsufficientFunds,"Transfer amount exceed your balance"],20027:[r.PermissionDenied,"Abnormal account status"],20028:[r.PermissionDenied,"Blacklist for transfer"],20029:[r.PermissionDenied,"Transfer amount exceed your daily limit"],20030:[r.BadRequest,"You have no position on this trading pair"],20032:[r.PermissionDenied,"Withdrawal limited"],20033:[r.BadRequest,"Wrong Withdrawal ID"],20034:[r.PermissionDenied,"Withdrawal service of this crypto has been closed"],20035:[r.PermissionDenied,"Withdrawal limit"],20036:[r.ExchangeError,"Withdrawal cancellation failed"],20037:[r.InvalidAddress,"The withdrawal address, Tag or chain type is not included in the withdrawal management list"],20038:[r.InvalidAddress,"The withdrawal address is not on the white list"],20039:[r.ExchangeError,"Can't be canceled in current status"],20040:[r.RateLimitExceeded,"Withdraw too frequently; limitation: 3 times a minute, 100 times a day"],20041:[r.PermissionDenied,"Beyond the daily withdrawal limit"],20042:[r.BadSymbol,"Current trading pair does not support API trading"],400002:[r.BadRequest,"Invalid Parameter"]},broad:{}},options:{defaultType:"spot",types:["spot","margin","otc"],createMarketBuyOrderRequiresPrice:!0,accountsByType:{spot:"1",margin:"2",OTC:"3"},networks:{ARBITRUM:"Arbitrum",AVALANCEC:"AVAX-CCHAIN",AVALANCEX:"AVAX-XCHAIN",BEP20:"BEP20",BSC:"BEP20",CARDANO:"Cardano",CELO:"Celo",CHILIZ:"Chiliz",COSMOS:"COSMOS",CRC20:"Crypto.com",CRONOS:"Crypto.com",DOGECOIN:"DogeChain",ERC20:"ERC20",ETH:"ERC20",ETHW:"ETHW",IOTA:"MIOTA",KLAYTN:"KLAY",MATIC:"Polygon",METIS:"MetisDAO",MOONBEAM:"GLMR",MOONRIVER:"Moonriver",OPTIMISM:"OPETH",POLYGON:"Polygon",RIPPLE:"XRP",SOLANA:"SOL",STELLAR:"Stella",TERRACLASSIC:"TerraClassic",TERRA:"Terra",TON:"Ton",TRC20:"TRC20",TRON:"TRC20",TRX:"TRC20",VECHAIN:"Vechain"},networksById:{TRC20:"TRC20",TRX:"TRC20",BEP20:"BEP20",BSC:"BEP20",ERC20:"ERC20",ETH:"ERC20",Polygon:"POLYGON","Crypto.com":"CRONOS"}},commonCurrencies:{BHT:"Black House Test",EPS:"Epanus",FREE:"FreeRossDAO",MBN:"Mobilian Coin",TEL:"TEL666"}})}async fetchCurrencies(e={}){const t=await this.publicSpotGetCurrencies(e),i=this.safeList(t,"data",[]),s=this.groupBy(i,"currency"),r=Object.keys(s),a={};for(let e=0;e1?(o=e[0],a=e[1]):a="limit"}return this.safeOrder({info:e,id:this.safeString2(e,"order_id","data"),clientOrderId:void 0,timestamp:i,datetime:this.iso8601(i),lastTradeTimestamp:s,symbol:d,type:a,timeInForce:r,postOnly:void 0,side:o,price:this.safeNumber(e,"price"),triggerPrice:void 0,amount:this.safeNumber2(e,"amount","size"),filled:this.safeNumber2(e,"executed_amount","filled_qty"),remaining:void 0,cost:void 0,average:this.safeNumber2(e,"avg_price","price_avg"),status:this.parseOrderStatus(this.safeString2(e,"status","state")),fee:{cost:this.safeNumber(e,"fee")},trades:void 0},t)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let a,o;await this.loadMarkets(),void 0!==e&&(a=this.market(e)),[o,s]=this.handleMarketTypeAndParams("fetchOpenOrders",a,s);const[n,d]=this.handleMarginModeAndParams("fetchOpenOrders",s),c={},h="swap"===o;if(h?(void 0!==t&&(c.start_timestamp=t),void 0!==i&&(c.limit=i)):c.market=o,void 0!==a){c[h?"instrument_id":"symbol"]=a.id}let l;if(void 0!==n||"margin"===o)o="margin",l=await this.privateSpotGetMarginOrderCurrent(this.extend(c,d));else if("spot"===o)l=await this.privateSpotGetSpotOrderCurrent(this.extend(c,d));else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchOpenOrders() not support this market type");l=await this.privateSwapGetTradeOpenOrders(this.extend(c,d))}const u=this.safeList(l,"data",[]);return this.parseOrders(u,a,t,i)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){let a,o;await this.loadMarkets(),void 0!==e&&(a=this.market(e)),[o,s]=this.handleMarketTypeAndParams("fetchOrders",a,s);const[n,d]=this.handleMarginModeAndParams("fetchOrders",s),c={};if("swap"===o?void 0!==t&&(c.start_timestamp=t):(c.market=o,void 0!==t&&(c.start_time=this.parseToInt(t/1e3))),void 0!==a){c["swap"===o?"instrument_id":"symbol"]=a.id}let h;if(void 0!==i&&(c.limit=i),void 0!==n||"margin"===o)o="margin",h=await this.privateSpotGetMarginOrderHistory(this.extend(c,d));else if("spot"===o)h=await this.privateSpotGetSpotOrderHistory(this.extend(c,d));else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchOrders() not support this market type");h=await this.privateSwapGetTradeHistoryOrders(this.extend(c,d))}const l=this.safeList(h,"data",[]);return this.parseOrders(l,a,t,i)}async fetchOrder(e,t=void 0,i={}){let s,a;await this.loadMarkets(),void 0!==t&&(s=this.market(t)),[a,i]=this.handleMarketTypeAndParams("fetchOrder",s,i);const[o,n]=this.handleMarginModeAndParams("fetchOrder",i),d={order_id:e};let c;if("swap"===a?void 0!==s&&(d.instrument_id=s.id):d.market=a,void 0!==o||"margin"===a)a="margin",c=await this.privateSpotGetMarginOrder(this.extend(d,n));else if("spot"===a)c=await this.privateSpotGetSpotOrder(this.extend(d,n));else{if("swap"!==a)throw new r.NotSupported(this.id+" fetchOrder() not support this market type");c=await this.privateSwapGetTradeOrderInfo(this.extend(d,n))}const h=this.safeValue(c,"data"),l="swap"===a?h:this.safeValue(h,0);if(void 0===l)throw new r.OrderNotFound(this.id+" fetchOrder() order "+e.toString()+" not found");return this.parseOrder(l,s)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let a;await this.loadMarkets();const o={};let n;void 0!==e&&(a=this.market(e)),[n,s]=this.handleMarketTypeAndParams("fetchMyTrades",a,s);const[d,c]=this.handleMarginModeAndParams("fetchMyTrades",s);"swap"===n?void 0!==t&&(o.start_timestamp=t):(o.market=n,void 0!==t&&(o.start_time=this.parseToInt(t/1e3)));let h;if(void 0!==e&&(o["swap"===n?"instrument_id":"symbol"]=a.id),void 0!==i&&(o.limit=i),void 0!==d||"margin"===n)n="margin",h=await this.privateSpotGetMarginMytrades(this.extend(o,c));else if("spot"===n)h=await this.privateSpotGetSpotMytrades(this.extend(o,c));else{if("swap"!==n)throw new r.NotSupported(this.id+" fetchMyTrades() not support this market type");h=await this.privateSwapGetTradeHistoryTrades(this.extend(o,c))}const l="swap"===n?"data":"list",u=this.safeList(h,l,[]);return this.parseTrades(u,a,t,i)}parseLedgerEntryType(e){return this.safeString({},e,e)}parseLedgerEntry(e,t=void 0){const i=this.parseLedgerEntryType(this.safeString2(e,"type","finance_type")),s=this.safeString2(e,"currency_mark","currency"),r=this.safeCurrencyCode(s,t);t=this.safeCurrency(s,t);const a=this.safeNumber2(e,"num","change"),o=this.safeNumber(e,"balance");let n=this.safeTimestamp(e,"time");return void 0===n&&(n=this.safeInteger(e,"timestamp")),this.safeLedgerEntry({info:e,id:void 0,direction:void 0,account:void 0,referenceId:void 0,referenceAccount:void 0,type:i,currency:r,amount:a,before:void 0,after:o,status:void 0,timestamp:n,datetime:this.iso8601(n),fee:void 0},t)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const a={};let o;[o,s]=this.handleMarketTypeAndParams("fetchLedger",void 0,s);const[n,d]=this.handleMarginModeAndParams("fetchLedger",s);"swap"===o?void 0!==t&&(a.start_timestamp=t):(a.market=o,void 0!==t&&(a.start_time=this.parseToInt(t/1e3)));const c="swap"===o?"currency":"currency_mark";let h,l,u;if(void 0!==e&&(h=this.currency(e),a[c]=h.id),void 0!==i&&(a.limit=i),void 0!==n||"margin"===o)o="margin",l=await this.privateSpotGetMarginFinancelog(this.extend(a,d));else if("spot"===o)l=await this.privateSpotGetSpotFinancelog(this.extend(a,d));else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchLedger() not support this market type");l=await this.privateSwapGetAccountFinanceRecord(this.extend(a,d))}if("swap"===o)u=this.safeValue(l,"data",[]);else{const e=this.safeValue(l,"data",{});u=this.safeValue(e,"finance",[])}return this.parseLedger(u,h,t,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address"),s=this.safeString(e,"addressTag"),r=this.safeStringUpper(e,"currency");return{info:e,currency:this.safeCurrencyCode(r),network:void 0,address:i,tag:s}}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={currency:i.id},a=await this.privateSpotGetDepositAddress(this.extend(s,t)),o=this.safeValue(a,"data",[]),n=this.parseDepositAddresses(o,[i.code]),d=this.safeValue(n,e);if(void 0===d)throw new r.InvalidAddress(this.id+" fetchDepositAddress() did not return an address for "+e+" - create the deposit address in the user settings on the exchange website first.");return d}async fetchTransactionsByType(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets();const o={};let n;void 0!==t&&(a=this.currency(t),o.currency=a.id),void 0!==s&&(o.size=Math.min(500,s)),n="deposit"===e?await this.privateSpotGetDepositHistory(this.extend(o,r)):await this.privateSpotGetWithdrawHistory(this.extend(o,r));const d=this.safeList(n,"data",[]);return this.parseTransactions(d,a,i,s,{type:e})}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactionsByType("deposit",e,t,i,s)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchTransactionsByType("withdrawal",e,t,i,s)}parseTransactionStatus(e){return this.safeString({1:"pending",2:"pending",3:"ok",4:"failed"},e,e)}parseTransaction(e,t=void 0){const i=this.safeString2(e,"id","withdraw_id"),s=this.safeString(e,"address"),r=this.safeString(e,"memo"),a=this.safeString(e,"hash"),o=this.safeStringUpper(e,"currency"),n=this.safeCurrencyCode(o,t),d=this.parse8601(this.safeString(e,"created_date")),c=this.parse8601(this.safeString(e,"finished_date")),h=this.parseTransactionStatus(this.safeString(e,"state")),l=this.safeNumber(e,"amount"),u=this.safeNumber(e,"fee");let p;void 0!==u&&(p={currency:n,cost:u});const f=this.safeString(e,"chain");return{info:e,id:i,txid:a,timestamp:d,datetime:this.iso8601(d),network:f,address:s,addressTo:s,addressFrom:void 0,tag:r,tagTo:r,tagFrom:void 0,type:void 0,amount:l,currency:n,status:h,updated:c,internal:void 0,comment:void 0,fee:p}}parseTransferStatus(e){return this.safeString({0:"ok"},e,e)}parseTransfer(e,t=void 0){let i,s;const r=this.safeDict(e,"data",e),a=this.safeInteger(r,"type");1===a?(i="spot",s="swap"):2===a&&(i="swap",s="spot");const o=this.safeInteger(e,"timestamp");return{info:e,id:this.safeString(e,"transfer_id"),timestamp:o,datetime:this.iso8601(o),currency:this.safeCurrencyCode(this.safeString(r,"currency"),t),amount:this.safeNumber2(r,"amount","transfer_amount"),fromAccount:i,toAccount:s,status:this.parseTransferStatus(this.safeString(e,"code"))}}async transfer(e,t,i,s,a={}){await this.loadMarkets();const o=this.currency(e),n=o.id,d=this.safeValue(this.options,"accountsByType",{}),c=this.safeString(d,i,i),h=this.safeString(d,s,s),l={},u="swap"===i,p="swap"===s;let f;const m=this.currencyToPrecision(e,t);if(u||p){if("1"!==c&&"1"!==h)throw new r.ExchangeError(this.id+" transfer() supports transferring between spot and swap, spot and margin, spot and OTC only");l.type=p?1:2,l.currency=n,l.transfer_amount=m,f=await this.privateSwapPostAccountTransfer(this.extend(l,a))}else l.currency_mark=n,l.num=m,l.from=c,l.to=h,f=await this.privateSpotPostTransfer(this.extend(l,a));return this.parseTransfer(f,o)}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),this.checkAddress(i),await this.loadMarkets();const a=this.currency(e),o={address:i,amount:this.currencyToPrecision(e,t),currency:a.id};void 0!==s&&(o.memo=s);const n=await this.privateSpotPostWithdrawNew(this.extend(o,r));return this.parseTransaction(n,a)}async fetchBorrowInterest(e=void 0,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={};let o;void 0!==t&&(o=this.market(t),a.symbol=o.id);const n=await this.privateSpotGetMarginPositions(this.extend(a,r)),d=this.safeValue(n,"positions"),c=this.parseBorrowInterests(d,o);return this.filterByCurrencySinceLimit(c,e,i,s)}parseBorrowInterest(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeString(e,"amount"),r=this.safeString(e,"leverage_ratio"),a=o.Y.stringDiv(s,r),n=o.Y.stringSub(s,a),d=void 0===t?void 0:t.base;return{info:e,symbol:this.safeSymbol(i,t),currency:d,interest:void 0,interestRate:.001,amountBorrowed:this.parseNumber(n),marginMode:void 0,timestamp:void 0,datetime:void 0}}async fetchCrossBorrowRate(e,t={}){await this.loadMarkets();const i=await this.privateSpotGetMarginAssets(this.extend({},t)),s=this.safeValue(i,"list",[]);let r=[];for(let t=0;t1)throw new r.BadRequest(this.id+" fetchPositions() symbols argument cannot contain more than 1 symbol");t=e[0]}else t=e;s=this.market(t)}[a,t]=this.handleMarketTypeAndParams("fetchPositions",s,t);const[o,n]=this.handleMarginModeAndParams("fetchPositions",t);if(void 0!==o&&(a="margin"),void 0!==s){i["swap"===a?"instrument_id":"symbol"]=s.id}let d;if("spot"===a||"margin"===a)d=await this.privateSpotGetMarginPositions(this.extend(i,n));else{if("swap"!==a)throw new r.NotSupported(this.id+" fetchPositions() not support this market type");d=await this.privateSwapGetAccountPositions(this.extend(i,n))}const c="swap"===a?"data":"positions",h=this.safeValue(d,c,[]),l=[];for(let e=0;e100)throw new r.BadRequest(this.id+" leverage should be between 1 and 100");const a={instrument_id:s.id,leverage:e},o=this.safeString2(this.options,"marginMode","defaultMarginMode");let n=this.safeStringLower2(i,"marginMode","defaultMarginMode",o);if(void 0!==n&&(n="cross"===n?"crossed":"isolated",a.margin_mode=n,i=this.omit(i,["marginMode","defaultMarginMode"])),"isolated"===n){const e=this.safeString(i,"side");void 0!==e?(a.side=e,i=this.omit(i,"side")):this.checkRequiredArgument("setLeverage",e,"side",["long","short"])}return await this.privateSwapPostAccountLeverage(this.extend(a,i))}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={};void 0!==e&&(r=this.safeCurrencyCode(e),a.currency=r.id),void 0!==t&&(a.start_timestamp=t),void 0!==i&&(a.limit=i);const o=await this.privateSwapGetAccountTransferRecord(this.extend(a,s)),n=this.safeList(o,"data",[]);return this.parseTransfers(n,r,t,i)}async fetchLeverageTiers(e=void 0,t={}){await this.loadMarkets();const i=await this.publicSwapGetPublicInstruments(t),s=this.safeValue(i,"data",[]);return e=this.marketSymbols(e),this.parseLeverageTiers(s,e,"instrument_id")}async fetchMarketLeverageTiers(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.swap)throw new r.BadRequest(this.id+" fetchMarketLeverageTiers() supports swap markets only");const s={instrument_id:i.id},a=await this.publicSwapGetPublicInstrument(this.extend(s,t)),o=this.safeValue(a,"data",{});return this.parseMarketLeverageTiers(o,i)}parseMarketLeverageTiers(e,t=void 0){const i=[],s=this.safeValue(e,"open_max_limits",{});for(let r=0;r{"use strict";i.d(t,{A:()=>h});var s=i(8918),r=i(2079),a=i(1579),o=i(5147),n=i(8432),d=i(987),c=i(8283);class h extends s.A{describe(){return this.deepExtend(super.describe(),{id:"dydx",name:"dYdX",countries:["US"],rateLimit:100,version:"v4",certified:!1,dex:!0,pro:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopLossOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!1,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!1,fetchAccounts:!0,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!0,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactions:!1,fetchTransfers:!0,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!1,setLeverage:!1,setMargin:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1MIN","5m":"5MINS","15m":"15MINS","30m":"30MINS","1h":"1HOUR","4h":"4HOURS","1d":"1DAY"},urls:{logo:"https://github.com/user-attachments/assets/617ea0c1-f05a-4d26-9fcb-a0d1d4091ae1",api:{indexer:"https://indexer.dydx.trade/v4",nodeRpc:"https://dydx-ops-rpc.kingnodes.com",nodeRest:"https://dydx-rest.publicnode.com"},test:{indexer:"https://indexer.v4testnet.dydx.exchange/v4",nodeRpc:"https://test-dydx-rpc.kingnodes.com",nodeRest:"https://test-dydx-rest.kingnodes.com"},www:"https://www.dydx.xyz",doc:["https://docs.dydx.xyz"],fees:["https://docs.dydx.exchange/introduction-trading_fees"],referral:"dydx.trade?ref=ccxt"},api:{indexer:{get:{"addresses/{address}":1,"addresses/{address}/parentSubaccountNumber/{number}":1,"addresses/{address}/subaccountNumber/{subaccountNumber}":1,assetPositions:1,"assetPositions/parentSubaccountNumber":1,"candles/perpetualMarkets/{market}":1,"compliance/screen/{address}":1,fills:1,"fills/parentSubaccountNumber":1,fundingPayments:1,"fundingPayments/parentSubaccount":1,height:.1,"historical-pnl":1,"historical-pnl/parentSubaccountNumber":1,"historicalBlockTradingRewards/{address}":1,"historicalFunding/{market}":1,"historicalTradingRewardAggregations/{address}":1,"orderbooks/perpetualMarket/{market}":1,orders:1,"orders/parentSubaccountNumber":1,"orders/{orderId}":1,perpetualMarkets:1,perpetualPositions:1,"perpetualPositions/parentSubaccountNumber":1,screen:1,sparklines:1,time:1,"trades/perpetualMarket/{market}":1,transfers:1,"transfers/between":1,"transfers/parentSubaccountNumber":1,"vault/v1/megavault/historicalPnl":1,"vault/v1/megavault/positions":1,"vault/v1/vaults/historicalPnl":1,perpetualMarketSparklines:1,"perpetualMarkets/{ticker}":1,"perpetualMarkets/{ticker}/orderbook":1,"trades/perpetualMarket/{ticker}":1,"historicalFunding/{ticker}":1,"candles/{ticker}/{resolution}":1,"addresses/{address}/subaccounts":1,"addresses/{address}/subaccountNumber/{subaccountNumber}/assetPositions":1,"addresses/{address}/subaccountNumber/{subaccountNumber}/perpetualPositions":1,"addresses/{address}/subaccountNumber/{subaccountNumber}/orders":1,"fills/parentSubaccount":1,"historical-pnl/parentSubaccount":1}},nodeRpc:{get:{abci_info:1,block:1,broadcast_tx_async:1,broadcast_tx_sync:1,tx:1}},nodeRest:{get:{"cosmos/auth/v1beta1/account_info/{dydxAddress}":1},post:{"cosmos/tx/v1beta1/encode":1,"cosmos/tx/v1beta1/simulate":1}}},fees:{trading:{tierBased:!0,percentage:!0,maker:this.parseNumber("0.0001"),taker:this.parseNumber("0.0005")}},requiredCredentials:{apiKey:!1,secret:!1,privateKey:!1},options:{mnemonic:void 0,chainName:"dydx-mainnet-1",chainId:1,sandboxMode:!1,defaultFeeDenom:"uusdc",defaultFeeMultiplier:"1.6",feeDenom:{USDC_DENOM:"ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5",USDC_GAS_DENOM:"uusdc",USDC_DECIMALS:6,USDC_GAS_PRICE:"0.025",CHAINTOKEN_DENOM:"adydx",CHAINTOKEN_DECIMALS:18,CHAINTOKEN_GAS_PRICE:"25000000000"}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!1},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:90,untilDays:1e4,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:500,trigger:!0,trailing:!0,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:500,daysBack:void 0,untilDays:1e5,trigger:!0,trailing:!0,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!0,trailing:!0,symbolRequired:!1},fetchOHLCV:{limit:1e3}},forSwap:{extends:"default",createOrder:{hedged:!0}},swap:{linear:{extends:"forSwap"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{9:r.InvalidOrder,10:r.InvalidOrder,11:r.InvalidOrder,12:r.InvalidOrder,13:r.InvalidOrder,14:r.InvalidOrder,15:r.InvalidOrder,16:r.InvalidOrder,17:r.InvalidOrder,18:r.InvalidOrder,19:r.InvalidOrder,20:r.InvalidOrder,21:r.InvalidOrder,22:r.InvalidOrder,23:r.InvalidOrder,24:r.InvalidOrder,25:r.InvalidOrder,26:r.InvalidOrder,27:r.InvalidOrder,28:r.InvalidOrder,29:r.InvalidOrder,30:r.InvalidOrder,31:r.InvalidOrder,32:r.InvalidOrder,33:r.InvalidOrder,34:r.InvalidOrder,35:r.InvalidOrder,36:r.InvalidOrder,37:r.InvalidOrder,39:r.InvalidOrder,40:r.InvalidOrder,41:r.InvalidOrder,42:r.InvalidOrder,43:r.InvalidOrder,44:r.InvalidOrder,45:r.InvalidOrder,46:r.InvalidOrder,47:r.InvalidOrder,48:r.InvalidOrder,49:r.InvalidOrder,50:r.InvalidOrder,1e3:r.BadRequest,1001:r.BadRequest,1002:r.BadRequest,1003:r.InvalidOrder,1004:r.InvalidOrder,1005:r.InvalidOrder,1006:r.InvalidOrder,1007:r.InvalidOrder,1008:r.InvalidOrder,1009:r.InvalidOrder,1010:r.InvalidOrder,1011:r.InvalidOrder,1012:r.InvalidOrder,1013:r.InvalidOrder,1014:r.InvalidOrder,1015:r.InvalidOrder,1017:r.InvalidOrder,1018:r.InvalidOrder,1019:r.InvalidOrder,1020:r.InvalidOrder,1021:r.InvalidOrder,1022:r.InvalidOrder,2e3:r.InvalidOrder,2001:r.InvalidOrder,2002:r.InvalidOrder,2003:r.InvalidOrder,2004:r.InvalidOrder,2005:r.InvalidOrder,3e3:r.InvalidOrder,3001:r.InvalidOrder,3002:r.InvalidOrder,3003:r.InvalidOrder,3004:r.InvalidOrder,3005:r.InvalidOrder,3006:r.InvalidOrder,3007:r.InvalidOrder,3008:r.InvalidOrder,3009:r.InvalidOrder,3010:r.InvalidOrder,4e3:r.InvalidOrder,4001:r.InvalidOrder,4002:r.InvalidOrder,4003:r.InvalidOrder,4004:r.InvalidOrder,4005:r.InvalidOrder,4006:r.InvalidOrder,4007:r.InvalidOrder,4008:r.InvalidOrder,5e3:r.InvalidOrder,5001:r.InvalidOrder,6e3:r.InvalidOrder,6001:r.InvalidOrder,6002:r.InvalidOrder,9e3:r.InvalidOrder,9001:r.InvalidOrder,9002:r.InvalidOrder,9003:r.InvalidOrder,1e4:r.InvalidOrder,10001:r.InvalidOrder,11e3:r.InvalidOrder},broad:{"insufficient funds":r.InsufficientFunds}},precisionMode:a.kb})}async fetchTime(e={}){const t=await this.indexerGetTime(e);return this.safeInteger(t,"epoch")}parseMarket(e){const t="USDC",i=this.safeString(e,"ticker").split("-"),s=this.safeString(i,0),r=this.safeString(e,"baseId",s),a=this.safeCurrencyCode(r),o=this.safeCurrencyCode(t),n="USDC",d=this.safeCurrencyCode(n),c=a+"/"+o+":"+d,h=this.safeString(e,"stepSize"),l=this.safeString(e,"tickSize");let u=!0;return"ACTIVE"!==this.safeString(e,"status")&&(u=!1),this.safeMarketStructure({id:this.safeString(e,"ticker"),symbol:c,base:a,quote:o,settle:d,baseId:r,baseName:s,quoteId:t,settleId:n,type:"swap",spot:!1,margin:void 0,swap:!0,future:!1,option:!1,active:u,contract:!0,contractSize:this.parseNumber("1"),linear:!0,inverse:!1,taker:void 0,maker:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(h),price:this.parseNumber(l)},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:e})}async fetchMarkets(e={}){const t=await this.indexerGetPerpetualMarkets(this.extend({},e)),i=this.safeDict(t,"markets",{}),s=Object.values(i);return this.parseMarkets(s)}parseTrade(e,t=void 0){const i=this.parse8601(this.safeString(e,"createdAt")),s=t.symbol,r=this.safeString(e,"price"),a=this.safeString(e,"size"),o=this.safeStringLower(e,"side"),n=this.safeString(e,"id");return this.safeTrade({id:n,timestamp:i,datetime:this.iso8601(i),symbol:s,side:o,price:r,amount:a,cost:void 0,order:void 0,takerOrMaker:void 0,type:void 0,fee:void 0,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={market:r.id};void 0!==i&&(a.limit=i);const o=await this.indexerGetTradesPerpetualMarketMarket(this.extend(a,s)),n=this.safeList(o,"trades",[]);return this.parseTrades(n,r,t,i)}parseOHLCV(e,t=void 0){return[this.parse8601(this.safeString(e,"startedAt")),this.safeNumber(e,"open"),this.safeNumber(e,"high"),this.safeNumber(e,"low"),this.safeNumber(e,"close"),this.safeNumber(e,"baseTokenVolume")]}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o={market:a.id,resolution:this.safeString(this.timeframes,t,t)};void 0!==s&&(o.limit=Math.min(s,1e3)),void 0!==i&&(o.fromIso=this.iso8601(i));const n=this.safeInteger(r,"until");r=this.omit(r,"until"),void 0!==n&&(o.toIso=this.iso8601(n));const d=await this.indexerGetCandlesPerpetualMarketsMarket(this.extend(o,r)),c=this.safeList(d,"candles",[]);return this.parseOHLCVs(c,a,t,i,s)}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();const a=this.market(e),o={market:a.id};void 0!==i&&(o.limit=i);const n=this.safeInteger(s,"until");void 0!==n&&(o.effectiveBeforeOrAt=this.iso8601(n));const d=await this.indexerGetHistoricalFundingMarket(this.extend(o,s)),c=[],h=this.safeList(d,"historicalFunding",[]);for(let e=0;e-1)throw new r.NotSupported(this.id+" cancelOrder() cancelling using id is not currently supported, please use provide the clientOrderId parameter.");let d,c=this.safeInteger(i,"goodTillBlock"),h=2592e3;[h,i]=this.handleOptionAndParams(i,"cancelOrder","goodTillBlockTimeInSeconds",h);const l=s?32:64,u=this.safeInteger(i,"orderFlags",l);let p=0;if([p,i]=this.handleOptionAndParams(i,"cancelOrder","subAccountId",p),i=this.omit(i,["clientOrderId","orderFlags","goodTillBlock","goodTillBlockTime","goodTillBlockTimeInSeconds","subaccountId","clientId"]),0!==u&&64!==u&&32!==u)throw new r.InvalidOrder(this.id+" invalid orderFlags, allowed values are (0, 64, 32).");if(u>0){if(void 0===h)throw new r.ArgumentsRequired(this.id+" goodTillBlockTimeInSeconds is required in params for long term or conditional order.");if(void 0!==c&&c>0)throw new r.InvalidOrder(this.id+" goodTillBlock should be 0 for long term or conditional order.");d=this.seconds()+h}else if(void 0===c){c=await this.fetchLatestBlockHeight()+20}const f=this.retrieveCredentials(),m=await this.fetchDydxAccount(),g={typeUrl:"/dydxprotocol.clob.MsgCancelOrder",value:{orderId:{subaccountId:{owner:this.getWalletAddress(),number:p},clientId:o,orderFlags:u,clobPairId:a.info.clobPairId},goodTilBlock:c,goodTilBlockTime:d}},v=this.options.chainName,y={tx:this.signDydxTx(f.privateKey,g,"",v,m,void 0)},b=await this.nodeRpcGetBroadcastTxSync(y),w=this.safeDict(b,"result");return this.safeOrder({info:w})}async cancelOrders(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(t),a=this.safeList(i,"clientOrderIds");if(!a)throw new r.NotSupported(this.id+" cancelOrders only support clientOrderIds.");let o=0;[o,i]=this.handleOptionAndParams(i,"cancelOrders","subAccountId",o);let n=this.safeInteger(i,"goodTillBlock");if(void 0===n){n=await this.fetchLatestBlockHeight()+20}i=this.omit(i,["clientOrderIds","goodTillBlock","subaccountId"]);const d=this.retrieveCredentials(),c=await this.fetchDydxAccount(),h={clientIds:a,clobPairId:s.info.clobPairId},l={typeUrl:"/dydxprotocol.clob.MsgBatchCancel",value:{subaccountId:{owner:this.getWalletAddress(),number:o},shortTermCancels:[h],goodTilBlock:n}},u=this.options.chainName,p={tx:this.signDydxTx(d.privateKey,l,"",u,c,void 0)},f=await this.nodeRpcGetBroadcastTxSync(p),m=this.safeDict(f,"result");return[this.safeOrder({info:m})]}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={market:s.id},a=await this.indexerGetOrderbooksPerpetualMarketMarket(this.extend(r,i));return this.parseOrderBook(a,s.symbol,void 0,"bids","asks","price","size")}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeCurrencyCode(i,t);t=this.safeCurrency(i,t);const r=this.safeStringUpper(e,"type");let a;void 0!==r&&("TRANSFER_IN"===r||"DEPOSIT"===r?a="in":"TRANSFER_OUT"!==r&&"WITHDRAWAL"!==r||(a="out"));const o=this.safeString(e,"size"),n=this.parse8601(this.safeString(e,"createdAt")),d=this.safeDict(e,"sender"),c=this.safeDict(e,"recipient");return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),direction:a,account:this.safeString(d,"address"),referenceAccount:this.safeString(c,"address"),referenceId:this.safeString(e,"transactionHash"),type:this.parseLedgerEntryType(r),currency:s,amount:this.parseNumber(o),timestamp:n,datetime:this.iso8601(n),before:void 0,after:void 0,status:void 0,fee:void 0},t)}parseLedgerEntryType(e){return this.safeString({TRANSFER_IN:"transfer",TRANSFER_OUT:"transfer",DEPOSIT:"deposit",WITHDRAWAL:"withdrawal"},e,e)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a=await this.fetchTransactionsHelper(e,t,i,this.extend(s,{methodName:"fetchLedger"}));return this.parseLedger(a,r,t,i)}async estimateTxFee(e,t,i){const s={txBytes:this.encodeDydxTxForSimulation(e,t,i.sequence,i.pub_key)},a=await this.nodeRestPostCosmosTxV1beta1Simulate(s),n=this.safeDict(a,"gas_info");if(void 0===n)throw new r.ExchangeError(this.id+" failed to simulate transaction.");const d=this.safeString(n,"gas_used");if(void 0===d)throw new r.ExchangeError(this.id+" failed to simulate transaction.");const c=this.safeString(this.options,"defaultFeeDenom"),h=this.safeString(this.options,"defaultFeeMultiplier"),l=this.safeDict(this.options,"feeDenom");let u,p;"uusdc"===c?(u=l.USDC_GAS_PRICE,p=l.USDC_DENOM):(u=l.CHAINTOKEN_GAS_PRICE,p=l.CHAINTOKEN_DENOM);const f=Math.ceil(this.parseToNumeric(o.A.stringMul(d,h)));let m=o.A.stringMul(this.numberToString(f),u);m.indexOf(".")>=0&&(m=this.numberToString(Math.ceil(this.parseToNumeric(m))));return{amount:[{amount:m,denom:p}],gasLimit:f}}async transfer(e,t,i,s,a={}){if("USDC"!==e)throw new r.NotSupported(this.id+" transfer() only support USDC");await this.loadMarkets();const n=this.safeInteger(a,"fromSubaccountId"),d=this.safeInteger(a,"toSubaccountId");if("main"!==i){if(void 0===i)throw new r.NotSupported(this.id+" transfer only support main > subaccount and subaccount <> subaccount.");if(void 0===n||void 0===d)throw new r.ArgumentsRequired(this.id+" transfer requires fromSubaccountId and toSubaccountId.")}a=this.omit(a,["fromSubaccountId","toSubaccountId"]);const c=this.retrieveCredentials(),h=await this.fetchDydxAccount(),l=this.parseToInt(o.A.stringMul(this.numberToString(t),"1000000"));let u,p;if("main"===i){if(void 0===d)throw new r.ArgumentsRequired(this.id+" transfer() requeire toSubaccoutnId.");u={sender:this.getWalletAddress(),recipient:{owner:this.getWalletAddress(),number:d},assetId:0,quantums:l},p={typeUrl:"/dydxprotocol.sending.MsgDepositToSubaccount",value:u}}else u={transfer:{sender:{owner:i,number:n},recipient:{owner:s,number:d},assetId:0,amount:l}},p={typeUrl:"/dydxprotocol.sending.MsgCreateTransfer",value:u};const f=await this.estimateTxFee(p,"",h),m=this.options.chainName,g={tx:this.signDydxTx(c.privateKey,p,"",m,h,void 0,f)},v=await this.nodeRpcGetBroadcastTxSync(g);return this.parseTransfer(v)}parseTransfer(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeString(e,"symbol"),r=this.safeCurrencyCode(s,t),a=this.safeNumber(e,"size"),o=this.safeDict(e,"sender"),n=this.safeDict(e,"recipient"),d=this.safeString(o,"address"),c=this.safeString(n,"address"),h=this.parse8601(this.safeString(e,"createdAt"));return{info:e,id:i,timestamp:h,datetime:this.iso8601(h),currency:r,amount:a,fromAccount:d,toAccount:c,status:void 0}}async fetchTransfers(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a=await this.fetchTransactionsHelper(e,t,i,this.extend(s,{methodName:"fetchTransfers"})),o=this.filterBy(a,"type","TRANSFER_IN"),n=this.filterBy(a,"type","TRANSFER_OUT"),d=this.arrayConcat(o,n);return this.parseTransfers(d,r,t,i)}parseTransaction(e,t=void 0){const i=this.safeString(e,"id"),s=this.safeDict(e,"sender"),r=this.safeDict(e,"recipient"),a=this.safeString(r,"address"),o=this.safeString(s,"address"),n=this.safeString(e,"transactionHash"),d=this.safeString(e,"symbol"),c=this.safeCurrencyCode(d,t),h=this.parse8601(this.safeString(e,"createdAt")),l=this.safeNumber(e,"size");return{info:e,id:i,txid:n,timestamp:h,datetime:this.iso8601(h),network:void 0,address:a,addressTo:a,addressFrom:o,tag:void 0,tagTo:void 0,tagFrom:void 0,type:this.safeStringLower(e,"type"),amount:l,currency:c,status:void 0,updated:void 0,internal:void 0,comment:void 0,fee:void 0}}async withdraw(e,t,i,s=void 0,a={}){if("USDC"!==e)throw new r.NotSupported(this.id+" withdraw() only support USDC");await this.loadMarkets(),this.checkAddress(i);const n=this.safeInteger(a,"subaccountId");if(void 0===n)throw new r.ArgumentsRequired(this.id+" withdraw requires subaccountId.");a=this.omit(a,["subaccountId"]);const d=this.currency(e),c=this.retrieveCredentials(),h=await this.fetchDydxAccount(),l=this.parseToInt(o.A.stringMul(this.numberToString(t),"1000000")),u={typeUrl:"/dydxprotocol.sending.MsgWithdrawFromSubaccount",value:{sender:{owner:this.getWalletAddress(),number:n},recipient:i,assetId:0,quantums:l}},p=await this.estimateTxFee(u,s,h),f=this.options.chainName,m={tx:this.signDydxTx(c.privateKey,u,s,f,h,void 0,p)},g=await this.nodeRpcGetBroadcastTxSync(m),v=this.safeDict(g,"result",{});return this.parseTransaction(v,d)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a=await this.fetchTransactionsHelper(e,t,i,this.extend(s,{methodName:"fetchWithdrawals"})),o=this.filterBy(a,"type","WITHDRAWAL");return this.parseTransactions(o,r,t,i)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a=await this.fetchTransactionsHelper(e,t,i,this.extend(s,{methodName:"fetchDeposits"})),o=this.filterBy(a,"type","DEPOSIT");return this.parseTransactions(o,r,t,i)}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a=await this.fetchTransactionsHelper(e,t,i,this.extend(s,{methodName:"fetchDepositsWithdrawals"})),o=this.filterBy(a,"type","WITHDRAWAL"),n=this.filterBy(a,"type","DEPOSIT"),d=this.arrayConcat(o,n);return this.parseTransactions(d,r,t,i)}async fetchTransactionsHelper(e=void 0,t=void 0,i=void 0,s={}){const r=this.safeString(s,"methodName");let a,o;s=this.omit(s,"methodName"),[a,s]=this.handlePublicAddress(r,s),[o,s]=this.handleOptionAndParams(s,r,"subAccountNumber","0");const n={address:a,subaccountNumber:o},d=await this.indexerGetTransfers(this.extend(n,s));return this.safeList(d,"transfers",[])}async fetchAccounts(e={}){let t;[t,e]=this.handlePublicAddress("fetchAccounts",e);const i={address:t},s=await this.indexerGetAddressesAddress(this.extend(i,e)),r=this.safeList(s,"subaccounts",[]),a=[];for(let e=0;e0){const e=this.id+" "+this.json(n);throw this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwBroadlyMatchedException(this.exceptions.broad,o,e),new r.ExchangeError(e)}}}setSandboxMode(e){super.setSandboxMode(e),this.options.chainName="dydx-testnet-4",this.options.chainId=11155111,this.options.feeDenom.CHAINTOKEN_DENOM="adv4tnt"}}},7057:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(1352),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"exmo",name:"EXMO",countries:["LT"],rateLimit:100,version:"v1.1",has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:!0,cancelOrder:!0,cancelOrders:!1,createDepositAddress:!1,createMarketBuyOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!0,createOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledOrders:!0,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:"emulated",fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactionFees:!0,fetchTransactions:"emulated",fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,reduceMargin:!0,setMargin:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"},urls:{logo:"https://user-images.githubusercontent.com/1294454/27766491-1b0ea956-5eda-11e7-9225-40d67b481b8d.jpg",api:{public:"https://api.exmo.com",private:"https://api.exmo.com",web:"https://exmo.me"},www:"https://exmo.me",referral:"https://exmo.me/?ref=131685",doc:["https://exmo.me/en/api_doc?ref=131685"],fees:"https://exmo.com/en/docs/fees"},api:{web:{get:["ctrl/feesAndLimits","en/docs/fees"]},public:{get:["currency","currency/list/extended","order_book","pair_settings","ticker","trades","candles_history","required_amount","payments/providers/crypto/list"]},private:{post:["user_info","order_create","order_cancel","stop_market_order_create","stop_market_order_cancel","user_open_orders","user_trades","user_cancelled_orders","order_trades","deposit_address","withdraw_crypt","withdraw_get_txid","excode_create","excode_load","code_check","wallet_history","wallet_operations","margin/user/order/create","margin/user/order/update","margin/user/order/cancel","margin/user/position/close","margin/user/position/margin_add","margin/user/position/margin_remove","margin/currency/list","margin/pair/list","margin/settings","margin/funding/list","margin/user/info","margin/user/order/list","margin/user/order/history","margin/user/order/trades","margin/user/order/max_quantity","margin/user/position/list","margin/user/position/margin_remove_info","margin/user/position/margin_add_info","margin/user/wallet/list","margin/user/wallet/history","margin/user/trade/list","margin/trades","margin/liquidation/feed"]}},fees:{trading:{feeSide:"get",tierBased:!0,percentage:!0,maker:this.parseNumber("0.004"),taker:this.parseNumber("0.004")},transaction:{tierBased:!1,percentage:!1}},options:{networks:{ETH:"ERC20",TRX:"TRC20"},fetchTradingFees:{method:"fetchPrivateTradingFees"},margin:{fillResponseFromRequest:!0}},features:{spot:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!0,marketBuyByCost:!0,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!0,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{GMT:"GMT Token"},precisionMode:o.kb,exceptions:{exact:{140333:r.InvalidOrder,140434:r.BadRequest,40005:r.AuthenticationError,40009:r.InvalidNonce,40015:r.ExchangeError,40016:r.OnMaintenance,40017:r.AuthenticationError,40032:r.PermissionDenied,40033:r.PermissionDenied,40034:r.RateLimitExceeded,50052:r.InsufficientFunds,50054:r.InsufficientFunds,50304:r.OrderNotFound,50173:r.OrderNotFound,50277:r.InvalidOrder,50319:r.InvalidOrder,50321:r.InvalidOrder,50381:r.InvalidOrder},broad:{"range period is too long":r.BadRequest,"invalid syntax":r.BadRequest,"API rate limit exceeded":r.RateLimitExceeded}}})}async modifyMarginHelper(e,t,i,s={}){await this.loadMarkets();const r=this.market(e),a={position_id:r.id,quantity:t};let o;"add"===i?o=await this.privatePostMarginUserPositionMarginAdd(this.extend(a,s)):"reduce"===i&&(o=await this.privatePostMarginUserPositionMarginRemove(this.extend(a,s)));const n=this.parseMarginModification(o,r),d=this.safeValue(this.options,"margin",{});return this.safeBool(d,"fillResponseFromRequest",!0)&&(n.type=i,n.amount=t),n}parseMarginModification(e,t=void 0){return{info:e,symbol:this.safeSymbol(void 0,t),type:void 0,marginMode:"isolated",amount:void 0,total:void 0,code:this.safeValue(t,"quote"),status:"ok",timestamp:void 0,datetime:void 0}}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"reduce",i)}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,"add",i)}async fetchTradingFees(e={}){const t=this.safeValue(this.options,"fetchTradingFees",{}),i=this.safeString(t,"method","fetchPrivateTradingFees"),s=this.safeString(e,"method",i);return e=this.omit(e,"method"),"fetchPrivateTradingFees"===s?await this.fetchPrivateTradingFees(e):await this.fetchPublicTradingFees(e)}async fetchPrivateTradingFees(e={}){await this.loadMarkets();const t=await this.privatePostMarginPairList(e),i=this.safeValue(t,"pairs",[]),s={};for(let e=0;e=0,i=e.split(" ")[0].replace("%",""),s=parseFloat(i);if(s>0&&t)throw new r.ExchangeError(this.id+" parseFixedFloatValue() detected an unsupported non-zero percentage-based fee "+e);return s}async fetchTransactionFees(e=void 0,t={}){await this.loadMarkets();const i=await this.publicGetPaymentsProvidersCryptoList(t),s={},r=Object.keys(i);for(let t=0;t=2}void 0===this.safeValue(i.networks,n)&&(i.networks[n]={withdraw:{fee:void 0,percentage:void 0},deposit:{fee:void 0,percentage:void 0}}),i.networks[n][a]={fee:this.parseFixedFloatValue(this.safeString(h,0)),percentage:c}}return this.assignDefaultDepositWithdrawFees(i)}async fetchCurrencies(e={}){const t=[];t.push(this.publicGetCurrencyListExtended(e)),t.push(this.publicGetPaymentsProvidersCryptoList(e));const i=await Promise.all(t),s=i[0],r=i[1],a={};for(let e=0;e2048){const e=this.ids.length;throw new r.ExchangeError(this.id+" fetchOrderBooks() has "+e.toString()+" symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchOrderBooks")}}else s=this.marketIds(e),s=s.join(",");const a={pair:s};void 0!==t&&(a.limit=t);const o=await this.publicGetOrderBook(this.extend(a,i)),n={},d=Object.keys(o);for(let e=0;e=0&&(e="canceled"),this.safeString({cancel_started:"canceled"},e,e)}parseSide(e){return this.safeString({limit_buy:"buy",limit_sell:"sell",market_buy:"buy",market_sell:"sell",stop_buy:"buy",stop_sell:"sell",stop_limit_buy:"buy",stop_limit_sell:"sell",trailing_stop_buy:"buy",trailing_stop_sell:"sell",stop_market_sell:"sell",stop_market_buy:"buy",buy:"buy",sell:"sell"},e,e)}parseOrder(e,t=void 0){const i=this.safeString2(e,"order_id","parent_order_id"),s=this.safeIntegerProduct2(e,"event_time","created",1e-6),r=this.safeTimestamp(e,"created",s),a=this.safeString2(e,"type","order_type"),o=this.parseSide(a);let n;"pair"in e?n=e.pair:"in_currency"in e&&"out_currency"in e&&(n="buy"===o?e.in_currency+"_"+e.out_currency:e.out_currency+"_"+e.in_currency);const d=(t=this.safeMarket(n,t)).symbol;let c=this.safeString(e,"quantity");if(void 0===c){const t="buy"===o?"in_amount":"out_amount";c=this.safeString(e,t)}const h=this.safeString(e,"price"),l=this.safeString(e,"amount"),u=this.safeValue(e,"trades",[]),p=this.safeInteger(e,"client_id");let f,m=this.safeString(e,"stop_price");return"0"===m&&(m=void 0),"buy"!==a&&"sell"!==a&&(f=a),this.safeOrder({id:i,clientOrderId:p,datetime:this.iso8601(r),timestamp:r,lastTradeTimestamp:this.safeIntegerProduct(e,"updated",1e-6),status:this.parseStatus(this.safeString(e,"order_status")),symbol:d,type:f,timeInForce:void 0,postOnly:void 0,side:o,price:h,triggerPrice:m,cost:l,amount:c,filled:void 0,remaining:void 0,average:void 0,trades:u,fee:void 0,info:e},t)}async fetchCanceledOrders(e=void 0,t=void 0,i=void 0,s={}){let a;if(await this.loadMarkets(),[a,s]=this.handleMarginModeAndParams("fetchOrders",s),"cross"===a)throw new r.BadRequest(this.id+" only supports isolated margin");void 0===i&&(i=100);const o="isolated"!==a;if(void 0!==e){e=this.market(e).symbol}const n={limit:i};let d,c;if(n.offset=void 0!==t?i:0,n.limit=i,void 0!==e&&(d=this.market(e)),o)return c=await this.privatePostUserCancelledOrders(this.extend(n,s)),s=this.extend(s,{status:"canceled"}),this.parseOrders(c,d,t,i,s);{const e=await this.privatePostMarginUserOrderHistory(this.extend(n,s)),r=this.safeValue(e,"items"),a=this.parseOrders(r,d,t,i,s),o=[];for(let e=0;e1&&(a=e[1])}return this.checkAddress(r),{info:i,currency:e,network:void 0,address:r,tag:a}}getMarketFromTrades(e){const t=this.indexBy(e,"pair"),i=Object.keys(t);if(1===i.length)return this.markets[i[0]]}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets();const a=this.currency(e),o={amount:t,currency:a.id,address:i};void 0!==s&&(o.invoice=s);const n=this.safeValue(this.options,"networks",{});let d=this.safeStringUpper(r,"network");d=this.safeString(n,d,d),void 0!==d&&(o.transport=d,r=this.omit(r,"network"));const c=await this.privatePostWithdrawCrypt(this.extend(o,r));return this.parseTransaction(c,a)}parseTransactionStatus(e){return this.safeString({transferred:"ok",paid:"ok",pending:"pending",processing:"pending",verifying:"pending"},e,e)}parseTransaction(e,t=void 0){const i=this.safeTimestamp2(e,"dt","created");let s=this.safeString(e,"amount");void 0!==s&&(s=a.Y.stringAbs(s));let r=this.safeString(e,"txid");if(void 0===r){const t=this.safeValue(e,"extra",{}),i=this.safeString(t,"txid");""!==i&&(r=i)}const o=this.safeString(e,"type"),n=this.safeString2(e,"curr","currency"),d=this.safeCurrencyCode(n,t);let c,h;const l=this.safeString(e,"account");if("deposit"===o)h=l;else if("withdrawal"===o&&(c=l,void 0!==c)){const e=c.split(":");2===e.length&&(c=this.safeString(e,1),c=c.replace(" ",""))}const u={currency:void 0,cost:void 0,rate:void 0};if(!this.fees.transaction.percentage){const t="withdrawal"===o?"withdraw":"deposit";let i=this.safeString(e,"commission");if(void 0===i){const e=this.safeValue(this.options,"transactionFees",{}),s=this.safeValue(e,d,{});i=this.safeString(s,t)}"cashback"===this.safeString(e,"provider")&&(i="0"),void 0!==i&&("withdrawal"===o&&(s=a.Y.stringSub(s,i)),u.cost=this.parseNumber(i),u.currency=d)}return{info:e,id:this.safeString2(e,"order_id","task_id"),txid:r,type:o,currency:d,network:this.safeString(e,"provider"),amount:this.parseNumber(s),status:this.parseTransactionStatus(this.safeStringLower(e,"status")),timestamp:i,datetime:this.iso8601(i),address:c,addressFrom:void 0,addressTo:c,tag:void 0,tagFrom:void 0,tagTo:void 0,updated:this.safeTimestamp(e,"updated"),comment:h,internal:void 0,fee:u}}async fetchDepositsWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==t&&(r.date=this.parseToInt(t/1e3)),void 0!==e&&(a=this.currency(e));const o=await this.privatePostWalletHistory(this.extend(r,s));return this.parseTransactions(o.history,a,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={type:"withdraw"};void 0!==i&&(a.limit=i),void 0!==e&&(r=this.currency(e),a.currency=r.id);const o=await this.privatePostWalletOperations(this.extend(a,s)),n=this.safeList(o,"items",[]);return this.parseTransactions(n,r,t,i)}async fetchWithdrawal(e,t=void 0,i={}){let s;await this.loadMarkets();const r={order_id:e,type:"withdraw"};void 0!==t&&(s=this.currency(t),r.currency=s.id);const a=await this.privatePostWalletOperations(this.extend(r,i)),o=this.safeValue(a,"items",[]),n=this.safeDict(o,0,{});return this.parseTransaction(n,s)}async fetchDeposit(e,t=void 0,i={}){let s;await this.loadMarkets();const r={order_id:e,type:"deposit"};void 0!==t&&(s=this.currency(t),r.currency=s.id);const a=await this.privatePostWalletOperations(this.extend(r,i)),o=this.safeValue(a,"items",[]),n=this.safeDict(o,0,{});return this.parseTransaction(n,s)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets();const a={type:"deposit"};void 0!==i&&(a.limit=i),void 0!==e&&(r=this.currency(e),a.currency=r.id);const o=await this.privatePostWalletOperations(this.extend(a,s)),n=this.safeList(o,"items",[]);return this.parseTransactions(n,r,t,i)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o=this.urls.api[t]+"/";if("web"!==t&&(o+=this.version+"/"),o+=e,"public"===t||"web"===t)Object.keys(s).length&&(o+="?"+this.urlencode(s));else if("private"===t){this.checkRequiredCredentials();const e=this.nonce();a=this.urlencode(this.extend({nonce:e},s)),r={"Content-Type":"application/x-www-form-urlencoded",Key:this.apiKey,Sign:this.hmac(this.encode(a),this.encode(this.secret),n.Zf)}}return{url:o,method:i,body:a,headers:r}}nonce(){return this.milliseconds()}handleErrors(e,t,i,s,a,o,n,d,c){if(void 0!==n){if("error"in n&&!("result"in n)){const e=this.safeValue(n,"error",{}),t=this.safeString(e,"msg"),i=this.safeString(e,"code"),s=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,i,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}if("result"in n||"errmsg"in n){let e=this.safeBool(n,"result",!1);if("string"==typeof e&&(e="true"===e||"1"===e),!e){let e;const t=this.safeString2(n,"error","errmsg"),i=t.split(":");if(i.length>1){const t=i[0].split(" ");e=t.length>1?t[1]:t[0]}const s=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,e,s),this.throwBroadlyMatchedException(this.exceptions.broad,t,s),new r.ExchangeError(s)}}}}}},3042:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var s=i(7996);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"fmfwio",name:"FMFW.io",countries:["KN"],urls:{logo:"https://user-images.githubusercontent.com/1294454/159177712-b685b40c-5269-4cea-ac83-f7894c49525d.jpg",api:{public:"https://api.fmfw.io/api/3",private:"https://api.fmfw.io/api/3"},www:"https://fmfw.io",doc:"https://api.fmfw.io/",fees:"https://fmfw.io/fees-and-limits",referral:"https://fmfw.io/referral/da948b21d6c92d69"},fees:{trading:{maker:this.parseNumber("0.005"),taker:this.parseNumber("0.005")}}})}}},448:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(5147),r=i(2597),a=i(2079),o=i(1579),n=i(4852);class d extends r.A{describe(){return this.deepExtend(super.describe(),{id:"foxbit",name:"Foxbit",countries:["pt-BR"],rateLimit:33.334,version:"1",comment:"Foxbit Exchange",certified:!1,pro:!1,has:{CORS:!0,spot:!0,margin:void 0,swap:void 0,future:void 0,option:void 0,cancelAllOrders:!0,cancelOrder:!0,createLimitBuyOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketSellOrder:!0,createOrder:!0,fecthOrderBook:!0,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDeposits:!0,fetchL2OrderBook:!0,fetchLedger:!0,fetchMarkets:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrders:!0,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!0,fetchWithdrawals:!0,loadMarkets:!0,sandbox:!1,withdraw:!0,ws:!1},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","12h":"12h","1d":"1d","1w":"1w","2w":"2w","1M":"1M"},urls:{logo:"https://github.com/user-attachments/assets/1f8faca2-ae2f-4222-b33e-5671e7d873dd",api:{public:"https://api.foxbit.com.br",private:"https://api.foxbit.com.br",status:"https://metadata-v2.foxbit.com.br/api"},www:"https://app.foxbit.com.br",doc:["https://docs.foxbit.com.br"]},precisionMode:o.fv,exceptions:{exact:{400:a.BadRequest,429:a.RateLimitExceeded,404:a.BadRequest,500:a.ExchangeError,2001:a.AuthenticationError,2002:a.AuthenticationError,2003:a.AuthenticationError,2004:a.BadRequest,2005:a.PermissionDenied,3001:a.PermissionDenied,3002:a.PermissionDenied,3003:a.AccountSuspended,4001:a.BadRequest,4002:a.InsufficientFunds,4003:a.InvalidOrder,4004:a.BadSymbol,4005:a.BadRequest,4007:a.ExchangeError,4008:a.InvalidOrder,4009:a.PermissionDenied,4011:a.RateLimitExceeded,4012:a.ExchangeError,5001:a.ExchangeNotAvailable,5002:a.OnMaintenance,5003:a.OnMaintenance,5004:a.InvalidOrder,5005:a.InvalidOrder,5006:a.InvalidOrder},broad:{}},requiredCredentials:{apiKey:!0,secret:!0},api:{v3:{public:{get:{currencies:5,markets:5,"markets/ticker/24hr":60,"markets/{market}/orderbook":6,"markets/{market}/candlesticks":12,"markets/{market}/trades/history":12,"markets/{market}/ticker/24hr":15}},private:{get:{accounts:2,"accounts/{symbol}/transactions":60,orders:2,"orders/by-order-id/{id}":2,trades:6,"deposits/address":10,deposits:10,withdrawals:10,"me/fees/trading":60},post:{orders:2,"orders/batch":7.5,"orders/cancel-replace":3,withdrawals:10},put:{"orders/cancel":2}}},status:{public:{get:{status:30}}}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,taker:this.parseNumber("0.005"),maker:this.parseNumber("0.0025")}},options:{sandboxMode:!1,networksById:{algorand:"ALGO",arbitrum:"ARBITRUM",avalanchecchain:"AVAX",bitcoin:"BTC",bitcoincash:"BCH",bsc:"BEP20",cardano:"ADA",cosmos:"ATOM",dogecoin:"DOGE",erc20:"ETH",hedera:"HBAR",litecoin:"LTC",near:"NEAR",optimism:"OPTIMISM",polkadot:"DOT",polygon:"MATIC",ripple:"XRP",solana:"SOL",stacks:"STX",stellar:"XLM",tezos:"XTZ",trc20:"TRC20"},networks:{ALGO:"algorand",ARBITRUM:"arbitrum",AVAX:"avalanchecchain",BTC:"bitcoin",BCH:"bitcoincash",BEP20:"bsc",ADA:"cardano",ATOM:"cosmos",DOGE:"dogecoin",ETH:"erc20",HBAR:"hedera",LTC:"litecoin",NEAR:"near",OPTIMISM:"optimism",DOT:"polkadot",MATIC:"polygon",XRP:"ripple",SOL:"solana",STX:"stacks",XLM:"stellar",XTZ:"tezos",TRC20:"trc20"}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!1,index:!1},triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{GTC:!0,FOK:!0,IOC:!0,PO:!0,GTD:!1},hedged:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:{expire_maker:!0,expire_taker:!0,expire_both:!0,none:!0},trailing:!1,icebergAmount:!1},createOrders:{max:5},fetchMyTrades:{marginMode:!1,limit:100,daysBack:90,untilDays:1e4,symbolRequired:!0},fetchOrder:{marginMode:!1,limit:1,daysBack:90,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,daysBack:90,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!0,limit:100,daysBack:90,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!0,limit:100,daysBack:90,daysBackCanceled:90,untilDays:1e4,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:500}}}})}async fetchCurrencies(e={}){const t=await this.v3PublicGetCurrencies(e),i=this.safeList(t,"data",[]),s={};for(let e=0;e200&&(a.page_size=200));const o=await this.v3PublicGetMarketsMarketTradesHistory(this.extend(a,s)),n=this.safeList(o,"data",[]);return this.parseTrades(n,r,t,i)}async fetchOHLCV(e,t="1m",i=void 0,s=void 0,r={}){await this.loadMarkets();const a=this.market(e),o=this.safeString(this.timeframes,t,t),n={market:a.id,interval:o};void 0!==i&&(n.start_time=this.iso8601(i)),void 0!==s&&(n.limit=s,s>500&&(n.limit=500));const d=await this.v3PublicGetMarketsMarketCandlesticks(this.extend(n,r));return this.parseOHLCVs(d,a,o,i,s)}async fetchBalance(e={}){await this.loadMarkets();const t=await this.v3PrivateGetAccounts(e),i=this.safeList(t,"data",[]),s={info:t};for(let e=0;e100&&(o.page_size=100));const n=await this.v3PrivateGetOrders(this.extend(o,r)),d=this.safeList(n,"data",[]);return this.parseOrders(d)}async createOrder(e,t,i,s,r=void 0,o={}){await this.loadMarkets();const n=this.market(e);if("LIMIT"!==(t=t.toUpperCase())&&"MARKET"!==t&&"STOP_MARKET"!==t&&"STOP_LIMIT"!==t&&"INSTANT"!==t)throw new a.InvalidOrder("Invalid order type: "+t+". Must be one of: limit, market, stop_market, stop_limit, instant.");const d=this.safeStringUpper(o,"timeInForce"),c=this.safeBool(o,"postOnly",!1),h=this.safeNumber(o,"triggerPrice"),l={market_symbol:n.id,side:i.toUpperCase(),type:t};if(("STOP_MARKET"===t||"STOP_LIMIT"===t)&&void 0===h)throw new a.InvalidOrder("Invalid order type: "+t+". Must have triggerPrice.");void 0!==d&&("PO"===d?l.post_only=!0:l.time_in_force=d),c&&(l.post_only=!0),void 0!==h&&(l.stop_price=this.priceToPrecision(e,h)),"INSTANT"===t?l.amount=this.priceToPrecision(e,s):l.quantity=this.amountToPrecision(e,s),"LIMIT"!==t&&"STOP_LIMIT"!==t||(l.price=this.priceToPrecision(e,r));const u=this.safeString(o,"clientOrderId");void 0!==u&&(l.client_order_id=u),o=this.omit(o,["timeInForce","postOnly","triggerPrice","clientOrderId"]);const p=await this.v3PrivatePostOrders(this.extend(l,o));return this.parseOrder(p,n)}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let t=0;t100&&(a.page_size=100));const o=await this.v3PrivateGetOrders(this.extend(a,s)),n=this.safeList(o,"data",[]);return this.parseOrders(n,r,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");await this.loadMarkets();const r=this.market(e),o={market_symbol:r.id};void 0!==t&&(o.start_time=this.iso8601(t)),void 0!==i&&(o.page_size=i,i>100&&(o.page_size=100));const n=await this.v3PrivateGetTrades(this.extend(o,s)),d=this.safeList(n,"data",[]);return this.parseTrades(d,r,t,i)}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),s={currency_symbol:i.id},[r,a]=this.handleNetworkCodeAndParams(t);void 0!==r&&(s.network_code=this.networkCodeToId(r,e));const o=await this.v3PrivateGetDepositsAddress(this.extend(s,a));return this.parseDepositAddress(o,i)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e)),void 0!==i&&(r.page_size=i,i>100&&(r.page_size=100)),void 0!==t&&(r.start_time=this.iso8601(t));const o=await this.v3PrivateGetDeposits(this.extend(r,s)),n=this.safeList(o,"data",[]);return this.parseTransactions(n,a,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};let a;void 0!==e&&(a=this.currency(e)),void 0!==i&&(r.page_size=i,i>100&&(r.page_size=100)),void 0!==t&&(r.start_time=this.iso8601(t));const o=await this.v3PrivateGetWithdrawals(this.extend(r,s)),n=this.safeList(o,"data",[]);return this.parseTransactions(n,a,t,i)}async fetchTransactions(e=void 0,t=void 0,i=void 0,s={}){const r=await this.fetchWithdrawals(e,t,i,s),a=await this.fetchDeposits(e,t,i,s),o=this.arrayConcat(r,a);return this.sortBy(o,"timestamp")}async fetchStatus(e={}){const t=await this.statusPublicGetStatus(e),i=this.safeDict(t,"data",{}),s=this.safeDict(i,"attributes",{}),r=this.safeString(s,"status");return{status:this.safeString({NORMAL:"ok",UNDER_MAINTENANCE:"maintenance"},r,r),updated:this.safeString(s,"updatedAt"),eta:void 0,url:void 0,info:t}}async editOrder(e,t,i,s,r=void 0,o=void 0,n={}){if(void 0===t)throw new a.ArgumentsRequired(this.id+" editOrder() requires a symbol argument");if("LIMIT"!==(i=i.toUpperCase())&&"MARKET"!==i&&"STOP_MARKET"!==i&&"INSTANT"!==i)throw new a.InvalidOrder("Invalid order type: "+i+". Must be one of: LIMIT, MARKET, STOP_MARKET, INSTANT.");await this.loadMarkets();const d=this.market(t),c={mode:"ALLOW_FAILURE",cancel:{type:"ID",id:this.parseNumber(e)},create:{type:i,side:s.toUpperCase(),market_symbol:d.id}};"LIMIT"!==i&&"MARKET"!==i||(c.create.quantity=this.amountToPrecision(t,r),"LIMIT"===i&&(c.create.price=this.priceToPrecision(t,o))),"STOP_MARKET"===i&&(c.create.stop_price=this.priceToPrecision(t,o),c.create.quantity=this.amountToPrecision(t,r)),"INSTANT"===i&&(c.create.amount=this.priceToPrecision(t,r));const h=await this.v3PrivatePostOrdersCancelReplace(this.extend(c,n));return this.parseOrder(h.create,d)}async withdraw(e,t,i,s=void 0,r={}){[s,r]=this.handleWithdrawTagAndParams(s,r),await this.loadMarkets();const a={currency_symbol:this.currency(e).id,amount:this.numberToString(t),destination_address:i};let o;void 0!==s&&(a.destination_tag=s),[o,r]=this.handleNetworkCodeAndParams(r),void 0!==o&&(a.network_code=this.networkCodeToId(o));const n=await this.v3PrivatePostWithdrawals(this.extend(a,r));return this.parseTransaction(n)}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchLedger() requires a code argument");void 0!==i&&(r.page_size=i,i>100&&(r.page_size=100)),void 0!==t&&(r.start_time=this.iso8601(t));const o=this.currency(e);r.symbol=o.id;const n=await this.v3PrivateGetAccountsSymbolTransactions(this.extend(r,s)),d=this.safeList(n,"data",[]);return this.parseLedger(d,o,t,i)}parseMarket(e){const t=this.safeString(e,"symbol"),i=this.safeDict(e,"base"),s=this.safeString(i,"symbol"),r=this.safeDict(e,"quote"),a=this.safeString(r,"symbol"),o=this.safeCurrencyCode(s),n=this.safeCurrencyCode(a),d=o+"/"+n,c=this.safeDict(e,"default_fees");return this.safeMarketStructure({id:t,symbol:d,base:o,quote:n,baseId:s,quoteId:a,active:!0,type:"spot",spot:!0,margin:!1,future:!1,swap:!1,option:!1,contract:!1,settle:void 0,settleId:void 0,contractSize:void 0,linear:void 0,inverse:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,taker:this.safeNumber(c,"taker"),maker:this.safeNumber(c,"maker"),percentage:!0,tierBased:!1,feeSide:"get",precision:{price:this.safeInteger(r,"precision"),amount:this.safeInteger(i,"precision"),cost:this.safeInteger(r,"precision")},limits:{amount:{min:this.safeNumber(e,"quantity_min"),max:void 0},price:{min:this.safeNumber(e,"price_min"),max:void 0},cost:{min:void 0,max:void 0},leverage:{min:void 0,max:void 0}},info:e})}parseTradingFee(e,t=void 0){return{info:e,symbol:t.symbol,maker:this.safeNumber(e,"maker"),taker:this.safeNumber(e,"taker"),percentage:!0,tierBased:!0}}parseTicker(e,t=void 0){const i=this.safeString(e,"market_symbol"),s=this.safeSymbol(i,t,void 0,"spot"),r=e.rolling_24h,a=this.safeDict(e,"best"),o=this.safeDict(a,"ask"),n=this.safeDict(a,"bid"),d=e.last_trade,c=this.safeString(d,"price");return this.safeTicker({symbol:s,timestamp:this.parseDate(this.safeString(d,"date")),datetime:this.iso8601(this.parseDate(this.safeString(d,"date"))),high:this.safeNumber(r,"high"),low:this.safeNumber(r,"low"),bid:this.safeNumber(n,"price"),bidVolume:this.safeNumber(n,"volume"),ask:this.safeNumber(o,"price"),askVolume:this.safeNumber(o,"volume"),vwap:void 0,open:this.safeNumber(r,"open"),close:c,last:c,previousClose:void 0,change:this.safeString(r,"price_change"),percentage:this.safeString(r,"price_change_percent"),average:void 0,baseVolume:this.safeString(r,"volume"),quoteVolume:this.safeString(r,"quote_volume"),info:e},t)}parseOHLCV(e,t=void 0){return[this.safeInteger(e,0),this.safeNumber(e,1),this.safeNumber(e,2),this.safeNumber(e,3),this.safeNumber(e,4),this.safeNumber(e,6)]}parseTrade(e,t=void 0){const i=this.parseDate(this.safeString(e,"created_at")),r=this.safeString(e,"price"),a=this.safeString(e,"volume",this.safeString(e,"quantity")),o=this.safeStringLower(e,"side"),n=this.safeStringLower(e,"taker_side",o),d=s.Y.stringMul(r,a),c={currency:this.safeSymbol(this.safeString(e,"fee_currency_symbol")),cost:this.safeNumber(e,"fee"),rate:void 0};return this.safeTrade({id:this.safeString(e,"id"),info:e,timestamp:i,datetime:this.iso8601(i),symbol:t.symbol,order:void 0,type:void 0,side:n,takerOrMaker:void 0,price:r,amount:a,cost:d,fee:c},t)}parseOrderStatus(e){return this.safeString({PARTIALLY_CANCELED:"open",ACTIVE:"open",PARTIALLY_FILLED:"open",FILLED:"closed",PENDING_CANCEL:"canceled",CANCELED:"canceled"},e,e)}parseOrder(e,t=void 0){let i=this.safeString(e,"market_symbol");void 0===t&&void 0!==i&&(t=this.market(i)),void 0!==t&&(i=t.symbol);const r=this.parseDate(this.safeString(e,"created_at")),a=this.safeString(e,"price"),o=this.safeString(e,"quantity_executed"),n=this.safeString(e,"quantity");let d;void 0!==n&&void 0!==o&&(d=s.Y.stringAdd(n,o));let c=this.safeString(e,"funds_received");if(!c){const t=this.safeString(e,"price_avg"),i=this.safeString(e,"price",t);c=s.Y.stringMul(i,d)}const h=this.safeStringLower(e,"side");let l=this.safeStringUpper(t,"quoteId");return"buy"===h&&(l=this.safeStringUpper(t,"baseId")),this.safeOrder({id:this.safeString(e,"id"),info:e,clientOrderId:this.safeString(e,"client_order_id"),timestamp:r,datetime:this.iso8601(r),lastTradeTimestamp:void 0,status:this.parseOrderStatus(this.safeString(e,"state")),symbol:this.safeString(t,"symbol"),type:this.safeString(e,"type"),timeInForce:this.safeString(e,"time_in_force"),postOnly:this.safeBool(e,"post_only"),reduceOnly:void 0,side:h,price:this.parseNumber(a),triggerPrice:this.safeNumber(e,"stop_price"),takeProfitPrice:void 0,stopLossPrice:void 0,cost:this.parseNumber(c),average:this.safeNumber(e,"price_avg"),amount:this.parseNumber(d),filled:this.parseNumber(o),remaining:this.parseNumber(n),trades:void 0,fee:{currency:l,cost:this.safeNumber(e,"fee_paid")}})}parseDepositAddress(e,t=void 0){const i=this.safeDict(e,"network"),s=this.safeString(i,"code"),r=this.safeCurrencyCode(void 0,t),a=this.networkIdToCode(s,r);return{address:this.safeString(e,"address"),tag:this.safeString(e,"tag"),currency:r,network:a,info:e}}parseTransactionStatus(e){return this.safeString({SUBMITTING:"pending",SUBMITTED:"pending",REJECTED:"failed",CANCELLED:"canceled",ACCEPTED:"ok",WARNING:"pending",UNBLOCKED:"pending",BLOCKED:"pending",PROCESSING:"pending",CANCELED:"canceled",FAILED:"failed",DONE:"ok"},e,e)}parseTransaction(e,t=void 0,i=void 0,r=void 0){const a=this.safeDict(e,"details_crypto"),o=this.safeString2(a,"receiving_address","destination_address"),n=this.safeString(e,"sn");let d="withdrawal";void 0!==n&&"D"===n[0]&&(d="deposit");const c=this.safeString(e,"fee","0"),h=this.safeString(e,"amount"),l=this.safeString(e,"currency_symbol");let u=h;const p=this.safeCurrencyCode(l),f=this.parseTransactionStatus(this.safeString(e,"state")),m=this.safeString(e,"created_at"),g=this.parseDate(m),v=this.iso8601(g);void 0!==c&&void 0!==h&&(u=s.Y.stringSub(h,c));const y=s.Y.stringDiv(c,u),b={cost:this.parseNumber(c),currency:p,rate:this.parseNumber(y)};return{info:e,id:this.safeString(e,"sn"),txid:this.safeString(a,"transaction_id"),timestamp:g,datetime:v,network:this.safeString(e,"network_code"),address:o,addressTo:o,addressFrom:void 0,tag:this.safeString(e,"destination_tag"),tagTo:this.safeString(e,"destination_tag"),tagFrom:void 0,type:d,amount:this.parseNumber(h),currency:p,status:f,updated:void 0,fee:b,comment:void 0,internal:void 0}}parseLedgerEntryType(e){return this.safeString({DEPOSITING:"transaction",WITHDRAWING:"transaction",TRADING:"trade",INTERNAL_TRANSFERING:"transfer",OTHERS:"transaction"},e,e)}parseLedgerEntry(e,t=void 0){const i=this.safeString(e,"uuid"),s=this.safeString(e,"created_at"),r=this.parse8601(s),a=this.safeString(e,"reason_type"),o=this.parseLedgerEntryType(a),n=this.safeString(e,"currency_symbol"),d=this.safeCurrencyCode(n);let c="in";const h=this.safeNumber(e,"amount");let l=h;const u=this.safeNumber(e,"balance"),p={cost:this.safeNumber(e,"fee"),currency:d};return h<0&&(c="out",l=-1*h),{id:i,info:e,timestamp:r,datetime:this.iso8601(r),direction:c,account:void 0,referenceId:void 0,referenceAccount:void 0,type:o,currency:d,amount:l,before:u-h,after:u,status:"ok",fee:p}}sign(e,t=[],i="GET",s={},r=void 0,a=void 0){const o=t[0];let d=t[1],c="/rest/"+o+"/"+this.implodeParams(e,s);"status"===o&&(c="/status",d="status");let h=this.urls.api[d]+c;s=this.omit(s,this.extractParams(e));const l=this.milliseconds();let u="",p="";if("GET"===i){const e=Object.keys(s),t=e.length;t>0&&(u=this.urlencode(s),h+="?"+u);for(let i=0;i{"use strict";i.d(t,{A:()=>d});var s=i(7418),r=i(5147),a=i(1579),o=i(2079),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"gate",name:"Gate",countries:["KR"],rateLimit:50,version:"v4",certified:!0,pro:!0,urls:{logo:"https://github.com/user-attachments/assets/64f988c5-07b6-4652-b5c1-679a6bf67c85",doc:"https://www.gate.com/docs/developers/apiv4/en/",www:"https://gate.com",api:{public:{wallet:"https://api.gateio.ws/api/v4",futures:"https://api.gateio.ws/api/v4",margin:"https://api.gateio.ws/api/v4",delivery:"https://api.gateio.ws/api/v4",spot:"https://api.gateio.ws/api/v4",options:"https://api.gateio.ws/api/v4",sub_accounts:"https://api.gateio.ws/api/v4",earn:"https://api.gateio.ws/api/v4"},private:{withdrawals:"https://api.gateio.ws/api/v4",wallet:"https://api.gateio.ws/api/v4",futures:"https://api.gateio.ws/api/v4",margin:"https://api.gateio.ws/api/v4",delivery:"https://api.gateio.ws/api/v4",spot:"https://api.gateio.ws/api/v4",options:"https://api.gateio.ws/api/v4",subAccounts:"https://api.gateio.ws/api/v4",unified:"https://api.gateio.ws/api/v4",rebate:"https://api.gateio.ws/api/v4",earn:"https://api.gateio.ws/api/v4",account:"https://api.gateio.ws/api/v4",loan:"https://api.gateio.ws/api/v4",otc:"https://api.gateio.ws/api/v4"}},test:{public:{futures:"https://api-testnet.gateapi.io/api/v4",delivery:"https://api-testnet.gateapi.io/api/v4",options:"https://api-testnet.gateapi.io/api/v4",spot:"https://api-testnet.gateapi.io/api/v4",wallet:"https://api-testnet.gateapi.io/api/v4",margin:"https://api-testnet.gateapi.io/api/v4",sub_accounts:"https://api-testnet.gateapi.io/api/v4",account:"https://api-testnet.gateapi.io/api/v4"},private:{futures:"https://api-testnet.gateapi.io/api/v4",delivery:"https://api-testnet.gateapi.io/api/v4",options:"https://api-testnet.gateapi.io/api/v4",spot:"https://api-testnet.gateapi.io/api/v4",wallet:"https://api-testnet.gateapi.io/api/v4",margin:"https://api-testnet.gateapi.io/api/v4",sub_accounts:"https://api-testnet.gateapi.io/api/v4",account:"https://api-testnet.gateapi.io/api/v4"}},referral:{url:"https://www.gate.com/share/CCXTGATE",discount:.2}},has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!0,option:!0,addMargin:!0,borrowCrossMargin:!0,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,cancelOrdersForSymbols:!0,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!1,createStopOrder:!0,createTakeProfitOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchBalance:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!0,fetchIndexOHLCV:!0,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!0,fetchLeverages:!0,fetchLeverageTiers:!0,fetchLiquidations:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyLiquidations:!0,fetchMySettlementHistory:!0,fetchMyTrades:!0,fetchNetworkDepositAddress:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!0,fetchOpenOrders:!0,fetchOption:!0,fetchOptionChain:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!0,fetchPositionHistory:"emulated",fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!0,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactionFees:!0,fetchUnderlyingAssets:!0,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!0,repayCrossMargin:!0,repayIsolatedMargin:!0,sandbox:!0,setLeverage:!0,setMarginMode:!1,setPositionMode:!0,signIn:!1,transfer:!0,withdraw:!0},api:{public:{wallet:{get:{currency_chains:1}},unified:{get:{currencies:1,history_loan_rate:1}},spot:{get:{currencies:1,"currencies/{currency}":1,currency_pairs:1,"currency_pairs/{currency_pair}":1,tickers:1,order_book:1,trades:1,candlesticks:1,time:1,insurance_history:1}},margin:{get:{"uni/currency_pairs":1,"uni/currency_pairs/{currency_pair}":1,loan_margin_tiers:1,currency_pairs:1,"currency_pairs/{currency_pair}":1,funding_book:1,"cross/currencies":1,"cross/currencies/{currency}":1}},flash_swap:{get:{currency_pairs:1,currencies:1}},futures:{get:{"{settle}/contracts":1,"{settle}/contracts/{contract}":1,"{settle}/order_book":1,"{settle}/trades":1,"{settle}/candlesticks":1,"{settle}/premium_index":1,"{settle}/tickers":1,"{settle}/funding_rate":1,"{settle}/insurance":1,"{settle}/contract_stats":1,"{settle}/index_constituents/{index}":1,"{settle}/liq_orders":1,"{settle}/risk_limit_tiers":1}},delivery:{get:{"{settle}/contracts":1,"{settle}/contracts/{contract}":1,"{settle}/order_book":1,"{settle}/trades":1,"{settle}/candlesticks":1,"{settle}/tickers":1,"{settle}/insurance":1,"{settle}/risk_limit_tiers":1}},options:{get:{underlyings:1,expirations:1,contracts:1,"contracts/{contract}":1,settlements:1,"settlements/{contract}":1,order_book:1,tickers:1,"underlying/tickers/{underlying}":1,candlesticks:1,"underlying/candlesticks":1,trades:1}},earn:{get:{"uni/currencies":1,"uni/currencies/{currency}":1,"dual/investment_plan":1,"structured/products":1}},loan:{get:{"collateral/currencies":1,"multi_collateral/currencies":1,"multi_collateral/ltv":1,"multi_collateral/fixed_rate":1,"multi_collateral/current_rate":1}}},private:{withdrawals:{post:{withdrawals:20,push:1},delete:{"withdrawals/{withdrawal_id}":1}},wallet:{get:{deposit_address:1,withdrawals:1,deposits:1,sub_account_transfers:1,order_status:1,withdraw_status:1,sub_account_balances:2.5,sub_account_margin_balances:2.5,sub_account_futures_balances:2.5,sub_account_cross_margin_balances:2.5,saved_address:1,fee:1,total_balance:2.5,small_balance:1,small_balance_history:1,push:1,getLowCapExchangeList:1},post:{transfers:2.5,sub_account_transfers:2.5,sub_account_to_sub_account:2.5,small_balance:1}},subAccounts:{get:{sub_accounts:2.5,"sub_accounts/{user_id}":2.5,"sub_accounts/{user_id}/keys":2.5,"sub_accounts/{user_id}/keys/{key}":2.5},post:{sub_accounts:2.5,"sub_accounts/{user_id}/keys":2.5,"sub_accounts/{user_id}/lock":2.5,"sub_accounts/{user_id}/unlock":2.5},put:{"sub_accounts/{user_id}/keys/{key}":2.5},delete:{"sub_accounts/{user_id}/keys/{key}":2.5}},unified:{get:{accounts:20/15,borrowable:20/15,transferable:20/15,transferables:20/15,batch_borrowable:20/15,loans:20/15,loan_records:20/15,interest_records:20/15,risk_units:20/15,unified_mode:20/15,estimate_rate:20/15,currency_discount_tiers:20/15,loan_margin_tiers:20/15,"leverage/user_currency_config":20/15,"leverage/user_currency_setting":20/15,account_mode:20/15},post:{loans:200/15,portfolio_calculator:20/15,"leverage/user_currency_setting":20/15,collateral_currencies:20/15,account_mode:20/15},put:{unified_mode:20/15}},spot:{get:{fee:1,batch_fee:1,accounts:1,account_book:1,open_orders:1,orders:1,"orders/{order_id}":1,my_trades:1,price_orders:1,"price_orders/{order_id}":1},post:{batch_orders:.4,cross_liquidate_orders:1,orders:.4,cancel_batch_orders:20/75,countdown_cancel_all:20/75,amend_batch_orders:.4,price_orders:.4},delete:{orders:20/75,"orders/{order_id}":20/75,price_orders:20/75,"price_orders/{order_id}":20/75},patch:{"orders/{order_id}":.4}},margin:{get:{accounts:20/15,account_book:20/15,funding_accounts:20/15,auto_repay:20/15,transferable:20/15,"uni/estimate_rate":20/15,"uni/loans":20/15,"uni/loan_records":20/15,"uni/interest_records":20/15,"uni/borrowable":20/15,"user/loan_margin_tiers":20/15,"user/account":20/15,loans:20/15,"loans/{loan_id}":20/15,"loans/{loan_id}/repayment":20/15,loan_records:20/15,"loan_records/{loan_record_id}":20/15,borrowable:20/15,"cross/accounts":20/15,"cross/account_book":20/15,"cross/loans":20/15,"cross/loans/{loan_id}":20/15,"cross/repayments":20/15,"cross/interest_records":20/15,"cross/transferable":20/15,"cross/estimate_rate":20/15,"cross/borrowable":20/15},post:{auto_repay:20/15,"uni/loans":20/15,"leverage/user_market_setting":20/15,loans:20/15,merged_loans:20/15,"loans/{loan_id}/repayment":20/15,"cross/loans":20/15,"cross/repayments":20/15},patch:{"loans/{loan_id}":20/15,"loan_records/{loan_record_id}":20/15},delete:{"loans/{loan_id}":20/15}},flash_swap:{get:{orders:1,"orders/{order_id}":1},post:{orders:1,"orders/preview":1}},futures:{get:{"{settle}/accounts":1,"{settle}/account_book":1,"{settle}/positions":1,"{settle}/positions/{contract}":1,"{settle}/get_leverage/{contract}":1,"{settle}/dual_comp/positions/{contract}":1,"{settle}/orders":1,"{settle}/orders_timerange":1,"{settle}/orders/{order_id}":1,"{settle}/my_trades":1,"{settle}/my_trades_timerange":1,"{settle}/position_close":1,"{settle}/liquidates":1,"{settle}/auto_deleverages":1,"{settle}/fee":1,"{settle}/risk_limit_table":1,"{settle}/price_orders":1,"{settle}/price_orders/{order_id}":1},post:{"{settle}/positions/{contract}/margin":1,"{settle}/positions/{contract}/leverage":1,"{settle}/positions/{contract}/set_leverage":1,"{settle}/positions/{contract}/risk_limit":1,"{settle}/positions/cross_mode":1,"{settle}/dual_comp/positions/cross_mode":1,"{settle}/dual_mode":1,"{settle}/set_position_mode":1,"{settle}/dual_comp/positions/{contract}/margin":1,"{settle}/dual_comp/positions/{contract}/leverage":1,"{settle}/dual_comp/positions/{contract}/risk_limit":1,"{settle}/orders":.4,"{settle}/batch_orders":.4,"{settle}/countdown_cancel_all":.4,"{settle}/batch_cancel_orders":.4,"{settle}/batch_amend_orders":.4,"{settle}/bbo_orders":.4,"{settle}/price_orders":.4},put:{"{settle}/orders/{order_id}":1,"{settle}/price_orders/{order_id}":1},delete:{"{settle}/orders":20/75,"{settle}/orders/{order_id}":20/75,"{settle}/price_orders":20/75,"{settle}/price_orders/{order_id}":20/75}},delivery:{get:{"{settle}/accounts":20/15,"{settle}/account_book":20/15,"{settle}/positions":20/15,"{settle}/positions/{contract}":20/15,"{settle}/orders":20/15,"{settle}/orders/{order_id}":20/15,"{settle}/my_trades":20/15,"{settle}/position_close":20/15,"{settle}/liquidates":20/15,"{settle}/settlements":20/15,"{settle}/price_orders":20/15,"{settle}/price_orders/{order_id}":20/15},post:{"{settle}/positions/{contract}/margin":20/15,"{settle}/positions/{contract}/leverage":20/15,"{settle}/positions/{contract}/risk_limit":20/15,"{settle}/orders":20/15,"{settle}/price_orders":20/15},delete:{"{settle}/orders":20/15,"{settle}/orders/{order_id}":20/15,"{settle}/price_orders":20/15,"{settle}/price_orders/{order_id}":20/15}},options:{get:{my_settlements:20/15,accounts:20/15,account_book:20/15,positions:20/15,"positions/{contract}":20/15,position_close:20/15,orders:20/15,"orders/{order_id}":20/15,my_trades:20/15,mmp:20/15},post:{orders:20/15,countdown_cancel_all:20/15,mmp:20/15,"mmp/reset":20/15},delete:{orders:20/15,"orders/{order_id}":20/15}},earn:{get:{"uni/lends":20/15,"uni/lend_records":20/15,"uni/interests/{currency}":20/15,"uni/interest_records":20/15,"uni/interest_status/{currency}":20/15,"uni/chart":20/15,"uni/rate":20/15,"staking/eth2/rate_records":20/15,"dual/orders":20/15,"dual/balance":20/15,"structured/orders":20/15,"staking/coins":20/15,"staking/order_list":20/15,"staking/award_list":20/15,"staking/assets":20/15,"uni/currencies":20/15,"uni/currencies/{currency}":20/15},post:{"uni/lends":20/15,"staking/eth2/swap":20/15,"dual/orders":20/15,"structured/orders":20/15,"staking/swap":20/15},put:{"uni/interest_reinvest":20/15},patch:{"uni/lends":20/15}},loan:{get:{"collateral/orders":20/15,"collateral/orders/{order_id}":20/15,"collateral/repay_records":20/15,"collateral/collaterals":20/15,"collateral/total_amount":20/15,"collateral/ltv":20/15,"multi_collateral/orders":20/15,"multi_collateral/orders/{order_id}":20/15,"multi_collateral/repay":20/15,"multi_collateral/mortgage":20/15,"multi_collateral/currency_quota":20/15,"collateral/currencies":20/15,"multi_collateral/currencies":20/15,"multi_collateral/ltv":20/15,"multi_collateral/fixed_rate":20/15,"multi_collateral/current_rate":20/15},post:{"collateral/orders":20/15,"collateral/repay":20/15,"collateral/collaterals":20/15,"multi_collateral/orders":20/15,"multi_collateral/repay":20/15,"multi_collateral/mortgage":20/15}},account:{get:{detail:20/15,main_keys:20/15,rate_limit:20/15,stp_groups:20/15,"stp_groups/{stp_id}/users":20/15,"stp_groups/debit_fee":20/15,debit_fee:20/15},post:{stp_groups:20/15,"stp_groups/{stp_id}/users":20/15,debit_fee:20/15},delete:{"stp_groups/{stp_id}/users":20/15}},rebate:{get:{"agency/transaction_history":20/15,"agency/commission_history":20/15,"partner/transaction_history":20/15,"partner/commission_history":20/15,"partner/sub_list":20/15,"broker/commission_history":20/15,"broker/transaction_history":20/15,"user/info":20/15,"user/sub_relation":20/15}},otc:{get:{get_user_def_bank:1,"order/list":1,"stable_coin/order/list":1,"order/detail":1},post:{quote:1,"order/create":1,"stable_coin/order/create":1,"order/paid":1,"order/cancel":1}}}},timeframes:{"10s":"10s","1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","8h":"8h","1d":"1d","7d":"7d","1w":"7d"},commonCurrencies:{ORT:"XREATORS",ASS:"ASSF","88MPH":"MPH",AXIS:"AXISDEFI",BIFI:"BITCOINFILE",BOX:"DEFIBOX",BYN:"BEYONDFI",EGG:"GOOSEFINANCE",GTC:"GAMECOM",GTC_HT:"GAMECOM_HT",GTC_BSC:"GAMECOM_BSC",HIT:"HITCHAIN",MM:"MILLION",MPH:"MORPHER",POINT:"GATEPOINT",RAI:"RAIREFLEXINDEX",RED:"RedLang",SBTC:"SUPERBITCOIN",TNC:"TRINITYNETWORKCREDIT",VAI:"VAIOT",TRAC:"TRACO"},requiredCredentials:{apiKey:!0,secret:!0},headers:{"X-Gate-Channel-Id":"ccxt"},options:{timeDifference:0,adjustForTimeDifference:!1,sandboxMode:!1,unifiedAccount:void 0,createOrder:{expiration:86400},createMarketBuyOrderRequiresPrice:!0,networks:{BTC:"BTC",BRC20:"BTCBRC",ETH:"ETH",ERC20:"ETH",TRX:"TRX",TRC20:"TRX",HECO:"HT",HRC20:"HT",BSC:"BSC",BEP20:"BSC",SOL:"SOL",MATIC:"MATIC",OPTIMISM:"OPETH",ADA:"ADA",AVAXC:"AVAX_C",NEAR:"NEAR",ARBONE:"ARBEVM",BASE:"BASEEVM",SUI:"SUI",CRONOS:"CRO",CRO:"CRO",APT:"APT",SCROLL:"SCROLLETH",TAIKO:"TAIKOETH",HYPE:"HYPE",ALGO:"ALGO",LINEA:"LINEAETH",BLAST:"BLASTETH",XLM:"XLM",RSK:"RBTC",TON:"TON",MNT:"MNT",CELO:"CELO",HBAR:"HBAR",ZKSERA:"ZKSERA",KLAY:"KLAY",EOS:"EOS",ACA:"ACA",XTZ:"XTZ",EGLD:"EGLD",GLMR:"GLMR",AURORA:"AURORAEVM",KON:"KONET",GATECHAIN:"GTEVM",KUSAMA:"KSMSM",OKC:"OKT",POLKADOT:"DOTSM",LUNA:"LUNC"},networksById:{OPETH:"OP",ETH:"ERC20",ERC20:"ERC20",TRX:"TRC20",TRC20:"TRC20",HT:"HRC20",HECO:"HRC20",BSC:"BEP20",BEP20:"BEP20",POLYGON:"MATIC",POL:"MATIC"},timeInForce:{GTC:"gtc",IOC:"ioc",PO:"poc",POC:"poc",FOK:"fok"},accountsByType:{funding:"spot",spot:"spot",margin:"margin",cross_margin:"cross_margin",cross:"cross_margin",isolated:"margin",swap:"futures",future:"delivery",futures:"futures",delivery:"delivery",option:"options",options:"options"},fetchMarkets:{types:["spot","swap","future","option"]},swap:{fetchMarkets:{settlementCurrencies:["usdt","btc"]}},future:{fetchMarkets:{settlementCurrencies:["usdt"]}}},features:{default:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerDirection:!0,triggerPriceType:void 0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,iceberg:!0,selfTradePrevention:!0,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0},createOrders:{max:40},fetchMyTrades:{marginMode:!0,limit:1e3,daysBack:void 0,untilDays:30,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,trigger:!0,trailing:!1,limit:100,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,trigger:!0,trailing:!1,limit:100,untilDays:30,daysBack:void 0,daysBackCanceled:void 0,symbolRequired:!1},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"spot",createOrder:{marginMode:!1,triggerPriceType:{last:!0,mark:!0,index:!0}},createOrders:{max:10},fetchMyTrades:{marginMode:!1,untilDays:void 0},fetchOpenOrders:{marginMode:!1},fetchClosedOrders:{marginMode:!1,untilDays:void 0,limit:1e3},fetchOHLCV:{limit:1999}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}}},precisionMode:a.kb,fees:{trading:{tierBased:!0,feeSide:"get",percentage:!0,maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("1.5"),this.parseNumber("0.00185")],[this.parseNumber("3"),this.parseNumber("0.00175")],[this.parseNumber("6"),this.parseNumber("0.00165")],[this.parseNumber("12.5"),this.parseNumber("0.00155")],[this.parseNumber("25"),this.parseNumber("0.00145")],[this.parseNumber("75"),this.parseNumber("0.00135")],[this.parseNumber("200"),this.parseNumber("0.00125")],[this.parseNumber("500"),this.parseNumber("0.00115")],[this.parseNumber("1250"),this.parseNumber("0.00105")],[this.parseNumber("2500"),this.parseNumber("0.00095")],[this.parseNumber("3000"),this.parseNumber("0.00085")],[this.parseNumber("6000"),this.parseNumber("0.00075")],[this.parseNumber("11000"),this.parseNumber("0.00065")],[this.parseNumber("20000"),this.parseNumber("0.00055")],[this.parseNumber("40000"),this.parseNumber("0.00055")],[this.parseNumber("75000"),this.parseNumber("0.00055")]],taker:[[this.parseNumber("0"),this.parseNumber("0.002")],[this.parseNumber("1.5"),this.parseNumber("0.00195")],[this.parseNumber("3"),this.parseNumber("0.00185")],[this.parseNumber("6"),this.parseNumber("0.00175")],[this.parseNumber("12.5"),this.parseNumber("0.00165")],[this.parseNumber("25"),this.parseNumber("0.00155")],[this.parseNumber("75"),this.parseNumber("0.00145")],[this.parseNumber("200"),this.parseNumber("0.00135")],[this.parseNumber("500"),this.parseNumber("0.00125")],[this.parseNumber("1250"),this.parseNumber("0.00115")],[this.parseNumber("2500"),this.parseNumber("0.00105")],[this.parseNumber("3000"),this.parseNumber("0.00095")],[this.parseNumber("6000"),this.parseNumber("0.00085")],[this.parseNumber("11000"),this.parseNumber("0.00075")],[this.parseNumber("20000"),this.parseNumber("0.00065")],[this.parseNumber("40000"),this.parseNumber("0.00065")],[this.parseNumber("75000"),this.parseNumber("0.00065")]]}},swap:{tierBased:!0,feeSide:"base",percentage:!0,maker:this.parseNumber("0.0"),taker:this.parseNumber("0.0005"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0000")],[this.parseNumber("1.5"),this.parseNumber("-0.00005")],[this.parseNumber("3"),this.parseNumber("-0.00005")],[this.parseNumber("6"),this.parseNumber("-0.00005")],[this.parseNumber("12.5"),this.parseNumber("-0.00005")],[this.parseNumber("25"),this.parseNumber("-0.00005")],[this.parseNumber("75"),this.parseNumber("-0.00005")],[this.parseNumber("200"),this.parseNumber("-0.00005")],[this.parseNumber("500"),this.parseNumber("-0.00005")],[this.parseNumber("1250"),this.parseNumber("-0.00005")],[this.parseNumber("2500"),this.parseNumber("-0.00005")],[this.parseNumber("3000"),this.parseNumber("-0.00008")],[this.parseNumber("6000"),this.parseNumber("-0.01000")],[this.parseNumber("11000"),this.parseNumber("-0.01002")],[this.parseNumber("20000"),this.parseNumber("-0.01005")],[this.parseNumber("40000"),this.parseNumber("-0.02000")],[this.parseNumber("75000"),this.parseNumber("-0.02005")]],taker:[[this.parseNumber("0"),this.parseNumber("0.00050")],[this.parseNumber("1.5"),this.parseNumber("0.00048")],[this.parseNumber("3"),this.parseNumber("0.00046")],[this.parseNumber("6"),this.parseNumber("0.00044")],[this.parseNumber("12.5"),this.parseNumber("0.00042")],[this.parseNumber("25"),this.parseNumber("0.00040")],[this.parseNumber("75"),this.parseNumber("0.00038")],[this.parseNumber("200"),this.parseNumber("0.00036")],[this.parseNumber("500"),this.parseNumber("0.00034")],[this.parseNumber("1250"),this.parseNumber("0.00032")],[this.parseNumber("2500"),this.parseNumber("0.00030")],[this.parseNumber("3000"),this.parseNumber("0.00030")],[this.parseNumber("6000"),this.parseNumber("0.00030")],[this.parseNumber("11000"),this.parseNumber("0.00030")],[this.parseNumber("20000"),this.parseNumber("0.00030")],[this.parseNumber("40000"),this.parseNumber("0.00030")],[this.parseNumber("75000"),this.parseNumber("0.00030")]]}}},exceptions:{exact:{INVALID_PARAM_VALUE:o.InvalidOrder,INVALID_PROTOCOL:o.BadRequest,INVALID_ARGUMENT:o.BadRequest,INVALID_REQUEST_BODY:o.BadRequest,MISSING_REQUIRED_PARAM:o.ArgumentsRequired,BAD_REQUEST:o.BadRequest,INVALID_CONTENT_TYPE:o.BadRequest,NOT_ACCEPTABLE:o.BadRequest,METHOD_NOT_ALLOWED:o.BadRequest,NOT_FOUND:o.ExchangeError,AUTHENTICATION_FAILED:o.AuthenticationError,INVALID_CREDENTIALS:o.AuthenticationError,INVALID_KEY:o.AuthenticationError,IP_FORBIDDEN:o.AuthenticationError,READ_ONLY:o.PermissionDenied,INVALID_SIGNATURE:o.AuthenticationError,MISSING_REQUIRED_HEADER:o.AuthenticationError,REQUEST_EXPIRED:o.AuthenticationError,ACCOUNT_LOCKED:o.AccountSuspended,FORBIDDEN:o.PermissionDenied,SUB_ACCOUNT_NOT_FOUND:o.ExchangeError,SUB_ACCOUNT_LOCKED:o.AccountSuspended,MARGIN_BALANCE_EXCEPTION:o.ExchangeError,MARGIN_TRANSFER_FAILED:o.ExchangeError,TOO_MUCH_FUTURES_AVAILABLE:o.ExchangeError,FUTURES_BALANCE_NOT_ENOUGH:o.InsufficientFunds,ACCOUNT_EXCEPTION:o.ExchangeError,SUB_ACCOUNT_TRANSFER_FAILED:o.ExchangeError,ADDRESS_NOT_USED:o.ExchangeError,TOO_FAST:o.RateLimitExceeded,WITHDRAWAL_OVER_LIMIT:o.ExchangeError,API_WITHDRAW_DISABLED:o.ExchangeNotAvailable,INVALID_WITHDRAW_ID:o.ExchangeError,INVALID_WITHDRAW_CANCEL_STATUS:o.ExchangeError,INVALID_PRECISION:o.InvalidOrder,INVALID_CURRENCY:o.BadSymbol,INVALID_CURRENCY_PAIR:o.BadSymbol,POC_FILL_IMMEDIATELY:o.OrderImmediatelyFillable,ORDER_NOT_FOUND:o.OrderNotFound,CLIENT_ID_NOT_FOUND:o.OrderNotFound,ORDER_CLOSED:o.InvalidOrder,ORDER_CANCELLED:o.InvalidOrder,QUANTITY_NOT_ENOUGH:o.InvalidOrder,BALANCE_NOT_ENOUGH:o.InsufficientFunds,MARGIN_NOT_SUPPORTED:o.InvalidOrder,MARGIN_BALANCE_NOT_ENOUGH:o.InsufficientFunds,AMOUNT_TOO_LITTLE:o.InvalidOrder,AMOUNT_TOO_MUCH:o.InvalidOrder,REPEATED_CREATION:o.InvalidOrder,LOAN_NOT_FOUND:o.OrderNotFound,LOAN_RECORD_NOT_FOUND:o.OrderNotFound,NO_MATCHED_LOAN:o.ExchangeError,NOT_MERGEABLE:o.ExchangeError,REPAY_TOO_MUCH:o.ExchangeError,TOO_MANY_CURRENCY_PAIRS:o.InvalidOrder,TOO_MANY_ORDERS:o.InvalidOrder,TOO_MANY_REQUESTS:o.RateLimitExceeded,MIXED_ACCOUNT_TYPE:o.InvalidOrder,AUTO_BORROW_TOO_MUCH:o.ExchangeError,TRADE_RESTRICTED:o.InsufficientFunds,USER_NOT_FOUND:o.AccountNotEnabled,CONTRACT_NO_COUNTER:o.ExchangeError,CONTRACT_NOT_FOUND:o.BadSymbol,RISK_LIMIT_EXCEEDED:o.ExchangeError,INSUFFICIENT_AVAILABLE:o.InsufficientFunds,LIQUIDATE_IMMEDIATELY:o.InvalidOrder,LEVERAGE_TOO_HIGH:o.InvalidOrder,LEVERAGE_TOO_LOW:o.InvalidOrder,ORDER_NOT_OWNED:o.ExchangeError,ORDER_FINISHED:o.ExchangeError,POSITION_CROSS_MARGIN:o.ExchangeError,POSITION_IN_LIQUIDATION:o.ExchangeError,POSITION_IN_CLOSE:o.ExchangeError,POSITION_EMPTY:o.InvalidOrder,REMOVE_TOO_MUCH:o.ExchangeError,RISK_LIMIT_NOT_MULTIPLE:o.ExchangeError,RISK_LIMIT_TOO_HIGH:o.ExchangeError,RISK_LIMIT_TOO_lOW:o.ExchangeError,PRICE_TOO_DEVIATED:o.InvalidOrder,SIZE_TOO_LARGE:o.InvalidOrder,SIZE_TOO_SMALL:o.InvalidOrder,PRICE_OVER_LIQUIDATION:o.InvalidOrder,PRICE_OVER_BANKRUPT:o.InvalidOrder,ORDER_POC_IMMEDIATE:o.OrderImmediatelyFillable,INCREASE_POSITION:o.InvalidOrder,CONTRACT_IN_DELISTING:o.ExchangeError,INTERNAL:o.ExchangeNotAvailable,SERVER_ERROR:o.ExchangeNotAvailable,TOO_BUSY:o.ExchangeNotAvailable,CROSS_ACCOUNT_NOT_FOUND:o.ExchangeError,RISK_LIMIT_TOO_LOW:o.BadRequest,AUTO_TRIGGER_PRICE_LESS_LAST:o.InvalidOrder,AUTO_TRIGGER_PRICE_GREATE_LAST:o.InvalidOrder,POSITION_HOLDING:o.BadRequest,USER_LOAN_EXCEEDED:o.BadRequest,NO_CHANGE:o.InvalidOrder,PRICE_THRESHOLD_EXCEEDED:o.InvalidOrder},broad:{}}})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}async loadUnifiedStatus(e={}){if(void 0===this.safeBool(this.options,"unifiedAccount"))try{const t=await this.privateAccountGetDetail(e),i=this.safeDict(t,"key",{});this.options.unifiedAccount=2===this.safeInteger(i,"mode")}catch(e){this.options.unifiedAccount=!1}return this.options.unifiedAccount}async upgradeUnifiedTradeAccount(e={}){return await this.privateUnifiedPutUnifiedMode(e)}async fetchTime(e={}){const t=await this.publicSpotGetTime(e);return this.safeInteger(t,"server_time")}createExpiredOptionMarket(e){const t="USDT",i=t,s=e.split("-"),r=e.split("/"),a=e.split("_");let o,n=this.safeString(s,1);e.indexOf("/")>-1?o=this.safeString(r,0):(o=this.safeString(a,0),n=n.slice(2,8));const d=this.safeString(s,2),c=this.safeString(s,3),h=this.convertExpireDate(n),l=this.parse8601(h);return{id:o+"_"+t+"-20"+n+"-"+d+"-"+c,symbol:o+"/"+t+":"+i+"-"+n+"-"+d+"-"+c,base:o,quote:t,settle:i,baseId:o,quoteId:t,settleId:i,active:!1,type:"option",linear:void 0,inverse:void 0,spot:!1,swap:!1,future:!1,option:!0,margin:!1,contract:!0,contractSize:this.parseNumber("1"),expiry:l,expiryDatetime:h,optionType:"C"===c?"call":"put",strike:this.parseNumber(d),precision:{amount:this.parseNumber("1"),price:void 0},limits:{amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:void 0}}safeMarket(e=void 0,t=void 0,i=void 0,s=void 0){return void 0!==e&&(e.indexOf("-C")>-1||e.indexOf("-P")>-1)&&!(e in this.markets_by_id)?this.createExpiredOptionMarket(e):super.safeMarket(e,t,i,s)}async fetchMarkets(e={}){this.options.adjustForTimeDifference&&await this.loadTimeDifference(),this.checkRequiredCredentials(!1)&&await this.loadUnifiedStatus();const t=[],i=this.safeDict(this.options,"fetchMarkets"),s=this.safeList(i,"types",["spot","swap","future","option"]);for(let i=0;i10)throw new o.BadRequest(this.id+" createOrders() accepts a maximum of 10 orders at a time");for(let r=0;r28)throw new o.BadRequest(this.id+" createOrder () clientOrderId or text param must be up to 28 characters");n=this.omit(n,["text","clientOrderId","textIsRequired"]),"t"!==h[0]&&(h="t-"+h),O.text=h}else l&&(O.text="t-"+this.uuid16())}else{if(d.option)throw new o.NotSupported(this.id+" createOrder() conditional option orders are not supported");if(c){if(O={initial:{contract:d.id,size:s},settle:d.settleId},O.initial.price="market"===t||0===a?"0":this.priceToPrecision(e,a),void 0===h){let t,s;f?(t="buy"===i?1:2,s=this.priceToPrecision(e,u)):m&&(t="buy"===i?2:1,s=this.priceToPrecision(e,p));const r=this.safeInteger(n,"price_type",0);if(r<0||r>2)throw new o.BadRequest(this.id+" createOrder () price_type should be 0 latest deal price, 1 mark price, 2 index price");n=this.omit(n,["price_type"]),O.trigger={price_type:r,price:this.priceToPrecision(e,s),rule:t}}void 0!==v&&(O.initial.reduce_only=v),void 0!==w&&(O.initial.tif=w)}else{const r=this.safeValue(this.options,"createOrder",{});let o;if([o,n]=this.getMarginMode(!0,n),void 0===w&&(w="gtc"),O={put:{type:t,side:i,price:this.priceToPrecision(e,a),amount:this.amountToPrecision(e,s),account:o,time_in_force:w},market:d.id},void 0===h){const t=this.safeInteger(r,"expiration"),s=this.safeInteger(n,"expiration",t);let a,o;f?(a="buy"===i?">=":"<=",o=this.priceToPrecision(e,u)):m&&(a="buy"===i?"<=":">=",o=this.priceToPrecision(e,p)),O.trigger={price:this.priceToPrecision(e,o),rule:a,expiration:s}}}}return this.extend(O,n)}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets(),await this.loadUnifiedStatus();if(!this.market(e).spot)throw new o.NotSupported(this.id+" createMarketBuyOrderWithCost() supports spot orders only");return i.createMarketBuyOrderRequiresPrice=!1,await this.createOrder(e,"market","buy",t,void 0,i)}editOrderRequest(e,t,i,s,a=void 0,n=void 0,d={}){const c=this.market(t);let h;[h,d]=this.handleMarketTypeAndParams("editOrder",c,d);let l=this.convertTypeToAccount(h),u=!1;[u,d]=this.handleOptionAndParams(d,"editOrder","unifiedAccount"),u&&(l="unified");if("spot"===l&&!("limit"===i))throw new o.InvalidOrder(this.id+" editOrder() does not support "+i+" orders for "+h+" markets");const p={order_id:e.toString(),currency_pair:c.id,account:l};return void 0!==a&&(c.spot?p.amount=this.amountToPrecision(t,a):p.size="sell"===s?this.parseToNumeric(r.Y.stringNeg(this.amountToPrecision(t,a))):this.parseToNumeric(this.amountToPrecision(t,a))),void 0!==n&&(p.price=this.priceToPrecision(t,n)),c.spot||(p.settle=c.settleId),this.extend(p,d)}async editOrder(e,t,i,s,r=void 0,a=void 0,o={}){await this.loadMarkets(),await this.loadUnifiedStatus();const n=this.market(t),d=this.editOrderRequest(e,t,i,s,r,a,o);let c;return c=n.spot?await this.privateSpotPatchOrdersOrderId(d):await this.privateFuturesPutSettleOrdersOrderId(d),this.parseOrder(c,n)}parseOrderStatus(e){return this.safeString({open:"open",_new:"open",filled:"closed",cancelled:"canceled",liquidated:"closed",ioc:"canceled",failed:"canceled",expired:"canceled",finished:"closed",finish:"closed",succeeded:"closed"},e,e)}parseOrder(e,t=void 0){if(!this.safeBool(e,"succeeded",!0))return this.safeOrder({clientOrderId:this.safeString(e,"text"),info:e,status:"rejected",id:this.safeString(e,"id")});const i=this.safeValue2(e,"put","initial",{}),s=this.safeValue(e,"trigger",{});let a=this.safeString(i,"contract"),o=this.safeString(i,"type"),n=this.safeStringUpper2(i,"time_in_force","tif"),d=this.safeString2(i,"amount","size"),c=this.safeString(i,"side"),h=this.safeString(i,"price");a=this.safeString(e,"contract",a),o=this.safeString(e,"type",o),n=this.safeStringUpper2(e,"time_in_force","tif",n),"POC"===n&&(n="PO");const l="PO"===n;d=this.safeString2(e,"amount","size",d),c=this.safeString(e,"side",c),h=this.safeString(e,"price",h);let u=this.safeString(e,"left"),p=this.safeString(e,"filled_total");const f=this.safeNumber(s,"price");let m=this.safeNumber2(e,"avg_deal_price","fill_price");if(f&&(u=d,p="0"),a){o=r.Y.stringEquals(h,"0")&&"IOC"===n?"market":"limit",c=r.Y.stringGt(d,"0")?"buy":"sell"}const g=this.safeStringN(e,["finish_as","status","open"]);let v=this.safeString(e,"create_time_ms");void 0===v&&(v=this.safeString2(e,"create_time","ctime"),void 0!==v&&(10===v.length||v.indexOf(".")>=0?v=r.Y.stringMul(v,"1000"):16===v.length&&(v=r.Y.stringDiv(v,"1000"))));let y=this.safeString(e,"update_time_ms");void 0===y&&(y=this.safeString2(e,"update_time","finish_time"),void 0!==y&&(10===y.length||y.indexOf(".")>=0?y=r.Y.stringMul(y,"1000"):16===y.length&&(y=r.Y.stringDiv(y,"1000"))));let b="contract";("currency_pair"in e||"market"in e)&&(b="spot");const w=this.safeString2(e,"currency_pair","market",a),k=this.safeSymbol(w,t,"_",b),S=[],O=this.safeString(e,"gt_fee");void 0!==O&&S.push({currency:"GT",cost:O});const T=this.safeString(e,"fee");void 0!==T&&S.push({currency:this.safeCurrencyCode(this.safeString(e,"fee_currency")),cost:T});const P=this.safeString(e,"rebated_fee");void 0!==P&&S.push({currency:this.safeCurrencyCode(this.safeString(e,"rebated_fee_currency")),cost:r.Y.stringNeg(P)});const I=S.length>1,M=this.parseOrderStatus(g);let A=r.Y.stringAbs(u);if("spot"===this.safeString(e,"account")){const t=this.safeString(e,"avg_deal_price");m=this.parseNumber(t),"market"===o&&"buy"===c&&(A=r.Y.stringDiv(u,t),h=void 0,p=d,d=r.Y.stringDiv(d,t))}let x,_;return void 0!==v&&(x=this.parseToInt(v)),void 0!==y&&(_=this.parseToInt(y)),this.safeOrder({id:this.safeString(e,"id"),clientOrderId:this.safeString(e,"text"),timestamp:x,datetime:this.iso8601(x),lastTradeTimestamp:_,status:M,symbol:k,type:o,timeInForce:n,postOnly:l,reduceOnly:this.safeValue(e,"is_reduce_only"),side:c,price:h,triggerPrice:f,average:m,amount:r.Y.stringAbs(d),cost:r.Y.stringAbs(p),filled:void 0,remaining:A,fee:I?void 0:this.safeValue(S,0),fees:I?S:[],trades:void 0,info:e},t)}fetchOrderRequest(e,t=void 0,i={}){const s=void 0===t?void 0:this.market(t),r=this.safeBoolN(i,["trigger","is_stop_order","stop"],!1);i=this.omit(i,["is_stop_order","stop","trigger"]);let a=this.safeString2(i,"text","clientOrderId"),o=e;void 0!==a&&(i=this.omit(i,["text","clientOrderId"]),"t"!==a[0]&&(a="t-"+a),o=a);const[n,d]=this.handleMarketTypeAndParams("fetchOrder",s,i),c="swap"===n||"future"===n||"option"===n,[h,l]=c?this.prepareRequest(s,n,d):this.spotOrderPrepareRequest(s,r,d);return h.order_id=o.toString(),[h,l]}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets(),await this.loadUnifiedStatus();const s=void 0===t?void 0:this.market(t),r=this.handleMarketTypeAndParams("fetchOrder",s,i),a=this.safeString(r,0),n=this.safeBoolN(i,["trigger","is_stop_order","stop"],!1),[d,c]=this.fetchOrderRequest(e,t,i);let h;if("spot"===a||"margin"===a)h=n?await this.privateSpotGetPriceOrdersOrderId(this.extend(d,c)):await this.privateSpotGetOrdersOrderId(this.extend(d,c));else if("swap"===a)h=n?await this.privateFuturesGetSettlePriceOrdersOrderId(this.extend(d,c)):await this.privateFuturesGetSettleOrdersOrderId(this.extend(d,c));else if("future"===a)h=n?await this.privateDeliveryGetSettlePriceOrdersOrderId(this.extend(d,c)):await this.privateDeliveryGetSettleOrdersOrderId(this.extend(d,c));else{if("option"!==a)throw new o.NotSupported(this.id+" fetchOrder() not support this market type");h=await this.privateOptionsGetOrdersOrderId(this.extend(d,c))}return this.parseOrder(h,s)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){return await this.fetchOrdersByStatus("open",e,t,i,s)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets(),await this.loadUnifiedStatus();const r=this.safeInteger(s,"until");let a;void 0!==e&&(a=this.market(e),e=a.symbol);const o=this.handleMarketTypeAndParams("fetchClosedOrders",a,s),n=this.safeString(o,0);let d=!1;if([d,s]=this.handleOptionAndParams(s,"fetchClosedOrders","historical",!1),!d&&(void 0===t&&void 0===r||"swap"!==n))return await this.fetchOrdersByStatus("finished",e,t,i,s);s=this.omit(s,"type");let c={};[c,s]=this.prepareRequest(a,n,s),void 0!==t&&(c.from=this.parseToInt(t/1e3)),void 0!==r&&(s=this.omit(s,"until"),c.to=this.parseToInt(r/1e3)),void 0!==i&&(c.limit=i);const h=await this.privateFuturesGetSettleOrdersTimerange(this.extend(c,s));return this.parseOrders(h,a,t,i)}prepareOrdersByStatusRequest(e,t=void 0,i=void 0,s=void 0,r={}){let a,o,n;void 0!==t&&(a=this.market(t),t=a.symbol),[o,r]=this.handleParamBool2(r,"trigger","stop"),[n,r]=this.handleMarketTypeAndParams("fetchOrdersByStatus",a,r);const d="spot"===n||"margin"===n;let c={};if([c,r]=d?this.multiOrderSpotPrepareRequest(a,o,r):this.prepareRequest(a,n,r),d&&o&&(c=this.omit(c,"account")),"closed"===e&&(e="finished"),c.status=e,void 0!==s&&(c.limit=s),d){void 0!==i&&(c.from=this.parseToInt(i/1e3));const e=this.safeInteger(r,"until");void 0!==e&&(r=this.omit(r,"until"),c.to=this.parseToInt(e/1e3))}const[h,l]=this.handleParamString2(r,"lastId","last_id");return void 0!==h&&(c.last_id=h),[c,l]}async fetchOrdersByStatus(e,t=void 0,i=void 0,s=void 0,r={}){let a;await this.loadMarkets(),await this.loadUnifiedStatus(),void 0!==t&&(a=this.market(t),t=a.symbol);const n=this.safeBool2(r,"trigger","stop"),d=this.handleMarketTypeAndParams("fetchOrdersByStatus",a,r),c=this.safeString(d,0),[h,l]=this.prepareOrdersByStatusRequest(e,t,i,s,r),u="spot"===c||"margin"===c,p="open"===e,f=u&&p&&!n;let m;if(u)m=n?await this.privateSpotGetPriceOrders(this.extend(h,l)):p?await this.privateSpotGetOpenOrders(this.extend(h,l)):await this.privateSpotGetOrders(this.extend(h,l));else if("swap"===c)m=n?await this.privateFuturesGetSettlePriceOrders(this.extend(h,l)):await this.privateFuturesGetSettleOrders(this.extend(h,l));else if("future"===c)m=n?await this.privateDeliveryGetSettlePriceOrders(this.extend(h,l)):await this.privateDeliveryGetSettleOrders(this.extend(h,l));else{if("option"!==c)throw new o.NotSupported(this.id+" fetchOrders() not support this market type");m=await this.privateOptionsGetOrders(this.extend(h,l))}let g=m;if(f){g=[];for(let e=0;e100)throw new o.BadRequest(this.id+" setLeverage() leverage should be between 1 and 100");await this.loadMarkets();const s=this.market(t),[r,a]=this.prepareRequest(s,void 0,i),n=this.safeString2(this.options,"marginMode","defaultMarginMode"),d=this.safeString(a,"cross_leverage_limit");let c,h=this.safeString(a,"marginMode",n),l=this.numberToString(e);if(void 0!==d&&(h="cross",l=d),"cross"===h||"cross_margin"===h?(r.cross_leverage_limit=l,r.leverage="0"):r.leverage=l,s.swap)c=await this.privateFuturesPostSettlePositionsContractLeverage(this.extend(r,a));else{if(!s.future)throw new o.NotSupported(this.id+" setLeverage() not support this market type");c=await this.privateDeliveryPostSettlePositionsContractLeverage(this.extend(r,a))}return c}parsePosition(e,t=void 0){const i=this.safeString(e,"contract");t=this.safeMarket(i,t,"_","contract");const s=this.safeString2(e,"size","accum_size");let a=this.safeString(e,"side");void 0===a&&(r.Y.stringGt(s,"0")?a="long":r.Y.stringLt(s,"0")&&(a="short"));const o=this.safeString(e,"maintenance_rate"),n=this.safeString(e,"value"),d=this.safeString(e,"leverage");let c;void 0!==d&&(c="0"===d?"cross":"isolated");let h,l=this.safeString(e,"pnl_fee");if(void 0===l){const e="0.00075";l=r.Y.stringMul(e,n),h=r.Y.stringAdd(r.Y.stringDiv(n,d),l)}let u=this.safeTimestamp2(e,"open_time","first_open_time");return 0===u&&(u=void 0),this.safePosition({info:e,id:void 0,symbol:this.safeString(t,"symbol"),timestamp:u,datetime:this.iso8601(u),lastUpdateTimestamp:this.safeTimestamp2(e,"update_time","time"),initialMargin:this.parseNumber(h),initialMarginPercentage:this.parseNumber(r.Y.stringDiv(h,n)),maintenanceMargin:this.parseNumber(r.Y.stringMul(o,n)),maintenanceMarginPercentage:this.parseNumber(o),entryPrice:this.safeNumber(e,"entry_price"),notional:this.parseNumber(n),leverage:this.safeNumber(e,"leverage"),unrealizedPnl:this.safeNumber(e,"unrealised_pnl"),realizedPnl:this.safeNumber2(e,"realised_pnl","pnl"),contracts:this.parseNumber(r.Y.stringAbs(s)),contractSize:this.safeNumber(t,"contractSize"),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"liq_price"),markPrice:this.safeNumber(e,"mark_price"),lastPrice:void 0,collateral:this.safeNumber(e,"margin"),marginMode:c,side:a,percentage:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async fetchPosition(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new o.BadRequest(this.id+" fetchPosition() supports contract markets only");let s={};[s,t]=this.prepareRequest(i,i.type,t);const r=this.extend(s,t);let a;return i.swap?a=await this.privateFuturesGetSettlePositionsContract(r):i.future?a=await this.privateDeliveryGetSettlePositionsContract(r):"option"===i.type&&(a=await this.privateOptionsGetPositionsContract(r)),this.parsePosition(a,i)}async fetchPositions(e=void 0,t={}){let i,s;if(await this.loadMarkets(),void 0!==(e=this.marketSymbols(e,void 0,!0,!0,!0))){e.length>0&&(i=this.market(e[0]))}let r,a={};if([s,t]=this.handleMarketTypeAndParams("fetchPositions",i,t),void 0!==s&&"spot"!==s||(s="swap"),"option"===s){if(void 0!==e){const e=i.id.split("-");a.underlying=this.safeString(e,0)}}else[a,t]=this.prepareRequest(void 0,s,t);return"swap"===s?r=await this.privateFuturesGetSettlePositions(this.extend(a,t)):"future"===s?r=await this.privateDeliveryGetSettlePositions(this.extend(a,t)):"option"===s&&(r=await this.privateOptionsGetPositions(this.extend(a,t))),this.parsePositions(r,e)}async fetchLeverageTiers(e=void 0,t={}){await this.loadMarkets();const[i,s]=this.handleMarketTypeAndParams("fetchLeverageTiers",void 0,t),[r,a]=this.prepareRequest(void 0,i,s);if("future"!==i&&"swap"!==i)throw new o.BadRequest(this.id+" fetchLeverageTiers only supports swap and future");let n;if("swap"===i)n=await this.publicFuturesGetSettleContracts(this.extend(r,a));else{if("future"!==i)throw new o.NotSupported(this.id+" fetchLeverageTiers() not support this market type");n=await this.publicDeliveryGetSettleContracts(this.extend(r,a))}return this.parseLeverageTiers(n,e,"name")}async fetchMarketLeverageTiers(e,t={}){await this.loadMarkets();const i=this.market(e),[s,r]=this.handleMarketTypeAndParams("fetchMarketLeverageTiers",i,t),[a,n]=this.prepareRequest(i,s,r);if("future"!==s&&"swap"!==s)throw new o.BadRequest(this.id+" fetchMarketLeverageTiers only supports swap and future");const d=await this.publicFuturesGetSettleRiskLimitTiers(this.extend(a,n));return this.parseMarketLeverageTiers(d,i)}parseEmulatedLeverageTiers(e,t=void 0){const i=this.safeString(e,"name"),s=this.safeString(e,"maintenance_rate"),a=this.safeString(e,"leverage_max"),o=this.safeString(e,"risk_limit_step"),n=this.safeString(e,"risk_limit_max"),d=r.Y.stringDiv("1",a);let c=s,h=d,l="0";const u=[];for(;r.Y.stringLt(l,n);){const a=r.Y.stringAdd(l,o);u.push({tier:this.parseNumber(r.Y.stringDiv(a,o)),symbol:this.safeSymbol(i,t,void 0,"contract"),currency:this.safeString(t,"settle"),minNotional:this.parseNumber(l),maxNotional:this.parseNumber(a),maintenanceMarginRate:this.parseNumber(c),maxLeverage:this.parseNumber(r.Y.stringDiv("1",h)),info:e}),c=r.Y.stringAdd(c,s),h=r.Y.stringAdd(h,d),l=a}return u}parseMarketLeverageTiers(e,t=void 0){if(!Array.isArray(e))return this.parseEmulatedLeverageTiers(e,t);let i=0;const s=[];for(let r=0;r-1&&e.endsWith("batch_cancel_orders")){const t=this.safeDict(s,0);e=this.implodeParams(e,t);const i=[],r=s;for(let e=1;e=0||i.indexOf("positions")>=0}if("GET"===i||"DELETE"===i||o||"PATCH"===i)Object.keys(h).length&&(s=this.rawencode(h),t=this.urlencode(h),t.indexOf("currencies=")>=0&&t.indexOf("%2C")>=0&&(t=t.replaceAll("%2C",",")),p+="?"+t),"PATCH"===i&&(a=this.json(h));else{const e=this.safeValue(h,"query",{});Object.keys(e).length&&(t=this.urlencode(e),p+="?"+t),h=this.omit(h,"query"),a=this.json(h)}const d=void 0===a?"":a,l=this.hash(this.encode(d),n.Zf),f=this.nonce(),m=this.parseToInt(f/1e3).toString(),g="/api/"+this.version+u,v=[i.toUpperCase(),g,s,l,m].join("\n"),y=this.hmac(this.encode(v),this.encode(this.secret),n.Zf);r={KEY:this.apiKey,Timestamp:m,SIGN:y,"Content-Type":"application/json"}}return{url:p,method:i,body:a,headers:r}}async modifyMarginHelper(e,t,i={}){await this.loadMarkets();const s=this.market(e),[r,a]=this.prepareRequest(s,void 0,i);let n;if(r.change=this.numberToString(t),s.swap)n=await this.privateFuturesPostSettlePositionsContractMargin(this.extend(r,a));else{if(!s.future)throw new o.NotSupported(this.id+" modifyMarginHelper() not support this market type");n=await this.privateDeliveryPostSettlePositionsContractMargin(this.extend(r,a))}return this.parseMarginModification(n,s)}parseMarginModification(e,t=void 0){const i=this.safeString(e,"contract");t=this.safeMarket(i,t,"_","contract");const s=this.safeNumber(e,"margin");return{info:e,symbol:t.symbol,type:void 0,marginMode:"isolated",amount:void 0,total:s,code:this.safeValue(t,"quote"),status:"ok",timestamp:void 0,datetime:void 0}}async reduceMargin(e,t,i={}){return await this.modifyMarginHelper(e,-t,i)}async addMargin(e,t,i={}){return await this.modifyMarginHelper(e,t,i)}async fetchOpenInterestHistory(e,t="5m",i=void 0,s=void 0,r={}){await this.loadMarkets();let a=!1;if([a,r]=this.handleOptionAndParams(r,"fetchOpenInterestHistory","paginate",!1),a)return await this.fetchPaginatedCallDeterministic("fetchOpenInterestHistory",e,i,s,t,r,100);const n=this.market(e);if(!n.swap)throw new o.BadRequest(this.id+" fetchOpenInterest() supports swap markets only");const d={contract:n.id,settle:n.settleId,interval:this.safeString(this.timeframes,t,t)};void 0!==s&&(d.limit=s),void 0!==i&&(d.from=i);const c=await this.publicFuturesGetSettleContractStats(this.extend(d,r));return this.parseOpenInterestsHistory(c,n,i,s)}parseOpenInterest(e,t=void 0){const i=this.safeTimestamp(e,"time");return{symbol:this.safeString(t,"symbol"),openInterestAmount:this.safeNumber(e,"open_interest"),openInterestValue:this.safeNumber(e,"open_interest_usd"),timestamp:i,datetime:this.iso8601(i),info:e}}async fetchSettlementHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new o.ArgumentsRequired(this.id+" fetchSettlementHistory() requires a symbol argument");await this.loadMarkets();const r=this.market(e);let a;if([a,s]=this.handleMarketTypeAndParams("fetchSettlementHistory",r,s),"option"!==a)throw new o.NotSupported(this.id+" fetchSettlementHistory() supports option markets only");const n=r.id.split("-"),d={underlying:this.safeString(n,0)};void 0!==t&&(d.from=t),void 0!==i&&(d.limit=i);const c=await this.publicOptionsGetSettlements(this.extend(d,s)),h=this.parseSettlements(c,r),l=this.sortBy(h,"timestamp");return this.filterBySymbolSinceLimit(l,e,t,i)}async fetchMySettlementHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new o.ArgumentsRequired(this.id+" fetchMySettlementHistory() requires a symbol argument");await this.loadMarkets();const r=this.market(e);let a;if([a,s]=this.handleMarketTypeAndParams("fetchMySettlementHistory",r,s),"option"!==a)throw new o.NotSupported(this.id+" fetchMySettlementHistory() supports option markets only");const n=r.id,d=n.split("-"),c={underlying:this.safeString(d,0),contract:n};void 0!==t&&(c.from=t),void 0!==i&&(c.limit=i);const h=await this.privateOptionsGetMySettlements(this.extend(c,s)),l=this.safeValue(h,"result",{}),u=this.safeValue(l,"list",[]),p=this.parseSettlements(u,r),f=this.sortBy(p,"timestamp");return this.filterBySymbolSinceLimit(f,r.symbol,t,i)}parseSettlement(e,t){const i=this.safeTimestamp(e,"time"),s=this.safeString(e,"contract");return{info:e,symbol:this.safeSymbol(s,t),price:this.safeNumber(e,"settle_price"),timestamp:i,datetime:this.iso8601(i)}}parseSettlements(e,t){const i=[];for(let s=0;s10?parseInt(n):1e3*parseInt(n);const c=this.safeString(e,"balance"),h=this.safeString(e,"change"),l=this.parseNumber(r.Y.stringSub(c,h));return this.safeLedgerEntry({info:e,id:this.safeString(e,"id"),direction:i,account:void 0,referenceAccount:void 0,referenceId:void 0,type:this.parseLedgerEntryType(o),currency:this.safeCurrencyCode(a,t),amount:this.parseNumber(s),timestamp:d,datetime:this.iso8601(d),before:l,after:this.safeNumber(e,"balance"),status:void 0,fee:void 0},t)}parseLedgerEntryType(e){return this.safeString({deposit:"deposit",withdraw:"withdrawal",sub_account_transfer:"transfer",margin_in:"transfer",margin_out:"transfer",margin_funding_in:"transfer",margin_funding_out:"transfer",cross_margin_in:"transfer",cross_margin_out:"transfer",copy_trading_in:"transfer",copy_trading_out:"transfer",quant_in:"transfer",quant_out:"transfer",futures_in:"transfer",futures_out:"transfer",delivery_in:"transfer",delivery_out:"transfer",new_order:"trade",order_fill:"trade",referral_fee:"rebate",order_fee:"fee",interest:"interest",lend:"loan",redeem:"loan",profit:"interest",flash_swap_buy:"trade",flash_swap_sell:"trade",unknown:"unknown",set:"settlement",prem:"trade",point_refr:"rebate",point_fee:"fee",point_dnw:"deposit/withdraw",fund:"fee",refr:"rebate",fee:"fee",pnl:"trade",dnw:"deposit/withdraw"},e,e)}async setPositionMode(e,t=void 0,i={}){const s=void 0!==t?this.market(t):void 0,[r,a]=this.prepareRequest(s,"swap",i);return r.dual_mode=e,await this.privateFuturesPostSettleDualMode(this.extend(r,a))}async fetchUnderlyingAssets(e={}){let t;if(await this.loadMarkets(),[t,e]=this.handleMarketTypeAndParams("fetchUnderlyingAssets",void 0,e),void 0!==t&&"spot"!==t||(t="option"),"option"!==t)throw new o.NotSupported(this.id+" fetchUnderlyingAssets() supports option markets only");const i=await this.publicOptionsGetUnderlyings(e),s=[];for(let e=0;e{"use strict";i.d(t,{A:()=>r});var s=i(9403);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"gateio",alias:!0})}}},8823:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(3434),r=i(2079),a=i(5147),o=i(1579),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"gemini",name:"Gemini",countries:["US"],rateLimit:100,version:"v1",pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!0,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",postOnly:!0,reduceMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/1294454/27816857-ce7be644-6096-11e7-82d6-3c257263229c.jpg",api:{public:"https://api.gemini.com",private:"https://api.gemini.com",web:"https://docs.gemini.com",webExchange:"https://exchange.gemini.com"},www:"https://gemini.com/",doc:["https://docs.gemini.com/rest-api","https://docs.sandbox.gemini.com"],test:{public:"https://api.sandbox.gemini.com",private:"https://api.sandbox.gemini.com",web:"https://docs.gemini.com",webExchange:"https://exchange.gemini.com"},fees:["https://gemini.com/api-fee-schedule","https://gemini.com/trading-fees","https://gemini.com/transfer-fees"]},api:{webExchange:{get:[""]},web:{get:["rest-api"]},public:{get:{"v1/symbols":5,"v1/symbols/details/{symbol}":5,"v1/staking/rates":5,"v1/pubticker/{symbol}":5,"v2/ticker/{symbol}":5,"v2/candles/{symbol}/{timeframe}":5,"v1/trades/{symbol}":5,"v1/auction/{symbol}":5,"v1/auction/{symbol}/history":5,"v1/pricefeed":5,"v1/book/{symbol}":5,"v1/earn/rates":5}},private:{post:{"v1/staking/unstake":1,"v1/staking/stake":1,"v1/staking/rewards":1,"v1/staking/history":1,"v1/order/new":1,"v1/order/cancel":1,"v1/wrap/{symbol}":1,"v1/order/cancel/session":1,"v1/order/cancel/all":1,"v1/order/status":1,"v1/orders":1,"v1/mytrades":1,"v1/notionalvolume":1,"v1/tradevolume":1,"v1/clearing/new":1,"v1/clearing/status":1,"v1/clearing/cancel":1,"v1/clearing/confirm":1,"v1/balances":1,"v1/balances/staking":1,"v1/notionalbalances/{currency}":1,"v1/transfers":1,"v1/addresses/{network}":1,"v1/deposit/{network}/newAddress":1,"v1/deposit/{currency}/newAddress":1,"v1/withdraw/{currency}":1,"v1/account/transfer/{currency}":1,"v1/payments/addbank":1,"v1/payments/methods":1,"v1/payments/sen/withdraw":1,"v1/balances/earn":1,"v1/earn/interest":1,"v1/earn/history":1,"v1/approvedAddresses/{network}/request":1,"v1/approvedAddresses/account/{network}":1,"v1/approvedAddresses/{network}/remove":1,"v1/account":1,"v1/account/create":1,"v1/account/list":1,"v1/heartbeat":1,"v1/roles":1}}},precisionMode:o.kb,fees:{trading:{taker:.004,maker:.002}},httpExceptions:{400:r.BadRequest,403:r.PermissionDenied,404:r.OrderNotFound,406:r.InsufficientFunds,429:r.RateLimitExceeded,500:r.ExchangeError,502:r.ExchangeNotAvailable,503:r.OnMaintenance},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1hr","6h":"6hr","1d":"1day"},exceptions:{exact:{AuctionNotOpen:r.BadRequest,ClientOrderIdTooLong:r.BadRequest,ClientOrderIdMustBeString:r.BadRequest,ConflictingOptions:r.BadRequest,EndpointMismatch:r.BadRequest,EndpointNotFound:r.BadRequest,IneligibleTiming:r.BadRequest,InsufficientFunds:r.InsufficientFunds,InvalidJson:r.BadRequest,InvalidNonce:r.InvalidNonce,InvalidApiKey:r.AuthenticationError,InvalidOrderType:r.InvalidOrder,InvalidPrice:r.InvalidOrder,InvalidQuantity:r.InvalidOrder,InvalidSide:r.InvalidOrder,InvalidSignature:r.AuthenticationError,InvalidSymbol:r.BadRequest,InvalidTimestampInPayload:r.BadRequest,Maintenance:r.OnMaintenance,MarketNotOpen:r.InvalidOrder,MissingApikeyHeader:r.AuthenticationError,MissingOrderField:r.InvalidOrder,MissingRole:r.AuthenticationError,MissingPayloadHeader:r.AuthenticationError,MissingSignatureHeader:r.AuthenticationError,NoSSL:r.AuthenticationError,OptionsMustBeArray:r.BadRequest,OrderNotFound:r.OrderNotFound,RateLimit:r.RateLimitExceeded,System:r.ExchangeError,UnsupportedOption:r.BadRequest},broad:{"The Gemini Exchange is currently undergoing maintenance.":r.OnMaintenance,"We are investigating technical issues with the Gemini Exchange.":r.ExchangeNotAvailable,"Internal Server Error":r.ExchangeNotAvailable}},options:{fetchMarketsMethod:"fetch_markets_from_api",fetchMarketFromWebRetries:10,fetchMarketsFromAPI:{fetchDetailsForAllSymbols:!1,quoteCurrencies:["USDT","GUSD","USD","DAI","EUR","GBP","SGD","BTC","ETH","LTC","BCH","SOL","USDC"]},fetchMarkets:{webApiEnable:!0,webApiRetries:10},fetchUsdtMarkets:["btcusdt","ethusdt"],fetchCurrencies:{webApiEnable:!0,webApiRetries:5,webApiMuteFailure:!0},fetchTickerMethod:"fetchTickerV1",networks:{BTC:"bitcoin",ERC20:"ethereum",BCH:"bitcoincash",LTC:"litecoin",ZEC:"zcash",FIL:"filecoin",DOGE:"dogecoin",XTZ:"tezos",AVAXX:"avalanche",SOL:"solana",ATOM:"cosmos",DOT:"polkadot"},nonce:"milliseconds",conflictingMarkets:{paxgusd:{base:"PAXG",quote:"USD"}},brokenPairs:["efilusd","maticrlusd","maticusdc","eurusdc","maticgusd","maticusd","efilfil","eurusd"]},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:500,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:void 0}},spot:{extends:"default"},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:void 0,inverse:void 0}}})}async fetchCurrencies(e={}){return await this.fetchCurrenciesFromWeb(e)}async fetchCurrenciesFromWeb(e={}){const t=await this.fetchWebEndpoint("fetchCurrencies","webExchangeGet",!0,'="currencyData">',"<\/script>");if(void 0===t)return{};const i={};this.options.tradingPairs=this.safeList(t,"tradingPairs");const s=this.safeValue(t,"currencies",[]);for(let e=0;eSymbols and minimums'),i=this.id+" fetchMarketsFromWeb() the API doc HTML markup has changed, breaking the parser of order limits and precision info for markets.",s=t.split("tbody>");if(s.length<2)throw new r.NotSupported(i);const a=s[1].split("\n\n"),o=a.length;if(o<2)throw new r.NotSupported(i);const n=[];for(let e=1;e\n");if(s.length<5)throw new r.NotSupported(i);let o=s[0].replace("","");o=o.replace("*","");const d=s[1].replace("","").split(" "),c=this.safeNumber(d,0),h=s[2].replace("","").split(" "),l=o.length-0,u=l-3,p=s[3].replace("","").split(" "),f=this.safeStringLower(p,1,o.slice(u,l)),m=this.safeStringLower(h,1,o.replace(f,"")),g=this.safeCurrencyCode(m),v=this.safeCurrencyCode(f);n.push({id:o,symbol:g+"/"+v,base:g,quote:v,settle:void 0,baseId:m,quoteId:f,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:void 0,contract:!1,linear:void 0,inverse:void 0,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.safeNumber(h,0),price:this.safeNumber(p,0)},limits:{leverage:{min:void 0,max:void 0},amount:{min:c,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:void 0,info:t})}return n}parseMarketActive(e){return void 0===e||this.safeBool({open:!0,closed:!1,cancel_only:!0,post_only:!0,limit_only:!0},e,!0)}async fetchUSDTMarkets(e={}){if("test"in this.urls)return[];const t=this.safeValue(this.options,"fetchUsdtMarkets",[]),i=[];for(let s=0;s=0,h=d.replace("PERP",""),l=this.safeDict(this.options,"conflictingMarkets",{}),u=h.toLowerCase();if(u in l){const e=l[u];i=e.base,s=e.quote,c&&(r=e.quote)}else{const e=this.handleOption("fetchMarketsFromAPI","quoteCurrencies",[]);for(let t=0;t{"use strict";i.d(t,{A:()=>d});var s=i(9722),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"hashkey",name:"HashKey Global",countries:["BM"],rateLimit:100,version:"v1",certified:!0,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrder:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrderWithTakeProfitAndStopLoss:!1,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!1,createStopMarketOrder:!0,createStopOrder:!0,createTakeProfitOrder:!1,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!0,fetchAccounts:!0,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrder:!0,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLedger:!0,fetchLeverage:!0,fetchLeverages:!1,fetchLeverageTiers:!0,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsForSymbol:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!1,setLeverage:!0,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","6h":"6h","8h":"8h","12h":"12h","1d":"1d","1w":"1w","1M":"1M"},urls:{logo:"https://github.com/user-attachments/assets/6dd6127b-cc19-4a13-9b29-a98d81f80e98",api:{public:"https://api-glb.hashkey.com",private:"https://api-glb.hashkey.com"},test:{public:"https://api-glb.sim.hashkeydev.com",private:"https://api-glb.sim.hashkeydev.com"},www:"https://global.hashkey.com/",doc:"https://hashkeyglobal-apidoc.readme.io/",fees:"https://support.global.hashkey.com/hc/en-us/articles/13199900083612-HashKey-Global-Fee-Structure",referral:"https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN"},api:{public:{get:{"api/v1/exchangeInfo":5,"quote/v1/depth":1,"quote/v1/trades":1,"quote/v1/klines":1,"quote/v1/ticker/24hr":1,"quote/v1/ticker/price":1,"quote/v1/ticker/bookTicker":1,"quote/v1/depth/merged":1,"quote/v1/markPrice":1,"quote/v1/index":1,"api/v1/futures/fundingRate":1,"api/v1/futures/historyFundingRate":1,"api/v1/ping":1,"api/v1/time":1}},private:{get:{"api/v1/spot/order":1,"api/v1/spot/openOrders":1,"api/v1/spot/tradeOrders":5,"api/v1/futures/leverage":1,"api/v1/futures/order":1,"api/v1/futures/openOrders":1,"api/v1/futures/userTrades":1,"api/v1/futures/positions":1,"api/v1/futures/historyOrders":1,"api/v1/futures/balance":1,"api/v1/futures/liquidationAssignStatus":1,"api/v1/futures/riskLimit":1,"api/v1/futures/commissionRate":1,"api/v1/futures/getBestOrder":1,"api/v1/account/vipInfo":1,"api/v1/account":1,"api/v1/account/trades":5,"api/v1/account/type":5,"api/v1/account/checkApiKey":1,"api/v1/account/balanceFlow":5,"api/v1/spot/subAccount/openOrders":1,"api/v1/spot/subAccount/tradeOrders":1,"api/v1/subAccount/trades":1,"api/v1/futures/subAccount/openOrders":1,"api/v1/futures/subAccount/historyOrders":1,"api/v1/futures/subAccount/userTrades":1,"api/v1/account/deposit/address":1,"api/v1/account/depositOrders":1,"api/v1/account/withdrawOrders":1},post:{"api/v1/userDataStream":1,"api/v1/spot/orderTest":1,"api/v1/spot/order":1,"api/v1.1/spot/order":1,"api/v1/spot/batchOrders":5,"api/v1/futures/leverage":1,"api/v1/futures/order":1,"api/v1/futures/position/trading-stop":3,"api/v1/futures/batchOrders":5,"api/v1/account/assetTransfer":1,"api/v1/account/authAddress":1,"api/v1/account/withdraw":1},put:{"api/v1/userDataStream":1},delete:{"api/v1/spot/order":1,"api/v1/spot/openOrders":5,"api/v1/spot/cancelOrderByIds":5,"api/v1/futures/order":1,"api/v1/futures/batchOrders":1,"api/v1/futures/cancelOrderByIds":1,"api/v1/userDataStream":1}}},fees:{trading:{spot:{tierBased:!0,percentage:!0,feeSide:"get",maker:this.parseNumber("0.0012"),taker:this.parseNumber("0.0012"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0012")],[this.parseNumber("1000000"),this.parseNumber("0.00080")],[this.parseNumber("5000000"),this.parseNumber("0.00070")],[this.parseNumber("10000000"),this.parseNumber("0.00060")],[this.parseNumber("50000000"),this.parseNumber("0.00040")],[this.parseNumber("200000000"),this.parseNumber("0.00030")],[this.parseNumber("400000000"),this.parseNumber("0.00010")],[this.parseNumber("800000000"),this.parseNumber("0.00")]],taker:[[this.parseNumber("0"),this.parseNumber("0.0012")],[this.parseNumber("1000000"),this.parseNumber("0.00090")],[this.parseNumber("5000000"),this.parseNumber("0.00085")],[this.parseNumber("10000000"),this.parseNumber("0.00075")],[this.parseNumber("50000000"),this.parseNumber("0.00065")],[this.parseNumber("200000000"),this.parseNumber("0.00045")],[this.parseNumber("400000000"),this.parseNumber("0.00040")],[this.parseNumber("800000000"),this.parseNumber("0.00035")]]}},swap:{tierBased:!0,percentage:!0,feeSide:"get",maker:this.parseNumber("0.00025"),taker:this.parseNumber("0.00060"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.00025")],[this.parseNumber("1000000"),this.parseNumber("0.00016")],[this.parseNumber("5000000"),this.parseNumber("0.00014")],[this.parseNumber("10000000"),this.parseNumber("0.00012")],[this.parseNumber("50000000"),this.parseNumber("0.000080")],[this.parseNumber("200000000"),this.parseNumber("0.000060")],[this.parseNumber("400000000"),this.parseNumber("0.000020")],[this.parseNumber("800000000"),this.parseNumber("0.00")]],taker:[[this.parseNumber("0"),this.parseNumber("0.00060")],[this.parseNumber("1000000"),this.parseNumber("0.00050")],[this.parseNumber("5000000"),this.parseNumber("0.00045")],[this.parseNumber("10000000"),this.parseNumber("0.00040")],[this.parseNumber("50000000"),this.parseNumber("0.00035")],[this.parseNumber("200000000"),this.parseNumber("0.00030")],[this.parseNumber("400000000"),this.parseNumber("0.00025")],[this.parseNumber("800000000"),this.parseNumber("0.00020")]]}}}},options:{broker:"10000700011",recvWindow:void 0,sandboxMode:!1,networks:{BTC:"BTC",ERC20:"ETH",AVAX:"AvalancheC",SOL:"Solana",MATIC:"Polygon",ATOM:"Cosmos",DOT:"Polkadot",LTC:"LTC",OPTIMISM:"Optimism",ARB:"Arbitrum",DOGE:"Dogecoin",TRC20:"Tron",ZKSYNC:"zkSync",TON:"TON",KLAYTN:"Klaytn",MERLINCHAIN:"Merlin Chain"},networksById:{BTC:"BTC",Bitcoin:"BTC",ETH:"ERC20",ERC20:"ERC20",AvalancheC:"AVAX","AVAX C-Chain":"AVAX",Solana:"SOL",Cosmos:"ATOM",Arbitrum:"ARB",Polygon:"MATIC",Optimism:"OPTIMISM",Polkadot:"DOT",LTC:"LTC",Litecoin:"LTC",Dogecoin:"DOGE","Merlin Chain":"MERLINCHAIN",zkSync:"ZKSYNC",TRC20:"TRC20",Tron:"TRC20",TON:"TON","BSC(BEP20)":"BSC",Klaytn:"KLAYTN"},defaultNetwork:"ERC20"},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!0,selfTradePrevention:!0,iceberg:!1},createOrders:{max:20},fetchMyTrades:{marginMode:!1,limit:1e3,daysBack:30,untilDays:30,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{triggerPrice:!0,selfTradePrevention:!0},fetchOpenOrders:{trigger:!0,limit:500}},swap:{linear:{extends:"forDerivatives"},inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},exceptions:{exact:{"0001":r.BadRequest,"0002":r.AuthenticationError,"0003":r.RateLimitExceeded,"0102":r.AuthenticationError,"0103":r.AuthenticationError,"0104":r.PermissionDenied,"0201":r.ExchangeError,"0202":r.PermissionDenied,"0206":r.BadRequest,"0207":r.BadRequest,"0209":r.BadRequest,"0210":r.BadRequest,"0211":r.OrderNotFound,"0401":r.InsufficientFunds,"0402":r.BadRequest,"-1000":r.ExchangeError,"-1001":r.ExchangeError,"-100010":r.BadSymbol,"-100012":r.BadSymbol,"-1002":r.AuthenticationError,"-1004":r.BadRequest,"-1005":r.PermissionDenied,"-1006":r.ExchangeError,"-1007":r.RequestTimeout,"-1014":r.InvalidOrder,"-1015":r.InvalidOrder,"-1020":r.OperationRejected,"-1021":r.InvalidNonce,"-1024":r.BadRequest,"-1101":r.ExchangeNotAvailable,"-1115":r.InvalidOrder,"-1117":r.InvalidOrder,"-1123":r.InvalidOrder,"-1124":r.InvalidOrder,"-1126":r.InvalidOrder,"-1129":r.BadRequest,"-1130":r.BadRequest,"-1132":r.BadRequest,"-1133":r.BadRequest,"-1135":r.BadRequest,"-1136":r.BadRequest,"-1138":r.InvalidOrder,"-1137":r.InvalidOrder,"-1139":r.OrderImmediatelyFillable,"-1140":r.InvalidOrder,"-1141":r.DuplicateOrderId,"-1142":r.OrderNotFillable,"-1143":r.OrderNotFound,"-1144":r.OperationRejected,"-1145":r.NotSupported,"-1146":r.RequestTimeout,"-1147":r.RequestTimeout,"-1148":r.InvalidOrder,"-1149":r.OperationRejected,"-1150":r.OperationFailed,"-1151":r.OperationRejected,"-1152":r.AccountNotEnabled,"-1153":r.InvalidOrder,"-1154":r.InvalidOrder,"-1155":r.OperationRejected,"-1156":r.OperationFailed,"-1157":r.OperationFailed,"-1158":r.OperationFailed,"-1159":r.AccountNotEnabled,"-1160":r.AccountNotEnabled,"-1161":r.OperationFailed,"-1162":r.ContractUnavailable,"-1163":r.InvalidAddress,"-1164":r.OperationFailed,"-1165":r.ArgumentsRequired,"-1166":r.OperationRejected,"-1167":r.BadRequest,"-1168":r.BadRequest,"-1169":r.PermissionDenied,"-1170":r.PermissionDenied,"-1171":r.PermissionDenied,"-1172":r.BadRequest,"-1173":r.BadRequest,"-1174":r.PermissionDenied,"-1175":r.BadRequest,"-1176":r.BadRequest,"-1177":r.InvalidOrder,"-1178":r.AccountNotEnabled,"-1179":r.AccountSuspended,"-1181":r.ExchangeError,"-1193":r.OperationRejected,"-1194":r.OperationRejected,"-1195":r.BadRequest,"-1196":r.BadRequest,"-1200":r.BadRequest,"-1201":r.BadRequest,"-1202":r.BadRequest,"-1203":r.BadRequest,"-1204":r.BadRequest,"-1205":r.AccountNotEnabled,"-1206":r.BadRequest,"-1207":r.BadRequest,"-1208":r.BadRequest,"-1209":r.BadRequest,"-2001":r.ExchangeNotAvailable,"-2002":r.OperationFailed,"-2003":r.OperationFailed,"-2004":r.OperationFailed,"-2005":r.RequestTimeout,"-2010":r.OperationRejected,"-2011":r.OperationRejected,"-2016":r.OperationRejected,"-2017":r.OperationRejected,"-2018":r.OperationRejected,"-2019":r.PermissionDenied,"-2020":r.PermissionDenied,"-2021":r.PermissionDenied,"-2022":r.OperationRejected,"-2023":r.AuthenticationError,"-2024":r.AccountNotEnabled,"-2025":r.AccountNotEnabled,"-2026":r.BadRequest,"-2027":r.OperationRejected,"-2028":r.OperationRejected,"-2029":r.OperationRejected,"-2030":r.InsufficientFunds,"-2031":r.NotSupported,"-2032":r.OperationRejected,"-2033":r.OperationFailed,"-2034":r.InsufficientFunds,"-2035":r.OperationRejected,"-2036":r.NotSupported,"-2037":r.ExchangeError,"-2038":r.InsufficientFunds,"-2039":r.NotSupported,"-2040":r.ExchangeNotAvailable,"-2041":r.BadRequest,"-2042":r.OperationRejected,"-2043":r.OperationRejected,"-2044":r.BadRequest,"-2045":r.BadRequest,"-2046":r.BadRequest,"-2048":r.BadRequest,"-2049":r.BadRequest,"-2050":r.BadRequest,"-2051":r.OperationRejected,"-2052":r.OperationRejected,"-2053":r.OperationRejected,"-2054":r.BadRequest,"-2055":r.BadRequest,"-2056":r.BadRequest,"-2057":r.BadRequest,"-3117":r.PermissionDenied,"-3143":r.PermissionDenied,"-3144":r.PermissionDenied,"-3145":r.DDoSProtection,"-4001":r.BadRequest,"-4002":r.BadRequest,"-4003":r.InsufficientFunds,"-4004":r.BadRequest,"-4005":r.BadRequest,"-4006":r.AccountNotEnabled,"-4007":r.NotSupported,"-4008":r.AccountNotEnabled,"-4009":r.PermissionDenied,"-4010":r.PermissionDenied,"-4011":r.ExchangeError,"-4012":r.ExchangeError,"-4013":r.OperationFailed},broad:{}},precisionMode:o.kb})}async fetchTime(e={}){const t=await this.publicGetApiV1Time(e);return this.safeInteger(t,"serverTime")}async fetchStatus(e={}){return{status:"ok",updated:void 0,eta:void 0,url:void 0,info:await this.publicGetApiV1Ping(e)}}async fetchMarkets(e={}){const t=await this.publicGetApiV1ExchangeInfo(this.extend({},e)),i=this.safeList(t,"symbols",[]),s=this.safeList(t,"contracts",[]);let r=this.arrayConcat(i,s);return this.isEmpty(r)&&(r=[t]),this.parseMarkets(r)}parseMarket(e){const t=this.safeString(e,"symbol"),i=this.safeString(e,"quoteAsset"),s=this.safeCurrencyCode(i),r=this.safeString(e,"marginToken"),o=this.safeCurrencyCode(r);let n=this.safeString(e,"baseAsset"),d="spot",c=!0,h=!1,l="";const u=t.split("-");"PERPETUAL"===this.safeString(u,1)&&(d="swap",c=!1,h=!0,n=this.safeString(e,"underlying"),l+=":"+r);const p=this.safeCurrencyCode(n),f=p+"/"+s+l,m="TRADING"===this.safeString(e,"status");let g,v;const y=this.safeBool(e,"inverse");void 0!==y&&(y?(g=!1,v="inverse"):(g=!0,v="linear"));const b=this.safeList(e,"filters",[]),w=this.indexBy(b,"filterType"),k=this.safeDict(w,"PRICE_FILTER",{}),S=this.safeDict(w,"LOT_SIZE",{}),O=this.safeDict(w,"MIN_NOTIONAL",{}),T=this.omitZero(this.safeString(O,"min_notional")),P=this.safeString(e,"contractMultiplier");let I,M,A=this.safeString(S,"stepSize"),x=this.safeString(S,"minQty"),_=this.safeString(S,"maxQty");if(h){A=a.Y.stringDiv(A,P),x=a.Y.stringDiv(x,P),_=a.Y.stringDiv(_,P);const t=this.safeList(e,"riskLimits");if(void 0!==t){const e=this.safeDict(t,0),i=t.length,s=this.safeDict(t,i-1);let r=this.safeString(e,"initialMargin"),o=this.safeString(s,"initialMargin");a.Y.stringGt(r,o)&&([r,o]=[o,r]),I=this.parseToInt(a.Y.stringDiv("1",o)),M=this.parseToInt(a.Y.stringDiv("1",r))}}const C=this.safeDict(this.fees,"trading"),B=c?this.safeDict(C,"spot"):this.safeDict(C,"swap");return this.safeMarketStructure({id:t,symbol:f,base:p,quote:s,baseId:n,quoteId:i,active:m,type:d,subType:v,spot:c,margin:this.safeBool(e,"allowMargin"),swap:h,future:!1,option:!1,contract:h,settle:o,settleId:r,contractSize:this.parseNumber(P),linear:g,inverse:y,taker:this.safeNumber(B,"taker"),maker:this.safeNumber(B,"maker"),percentage:this.safeBool(B,"percentage"),tierBased:this.safeBool(B,"tierBased"),feeSide:this.safeString(B,"feeSide"),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(A),price:this.safeNumber(k,"tickSize")},limits:{amount:{min:this.parseNumber(x),max:this.parseNumber(_)},price:{min:this.safeNumber(k,"minPrice"),max:this.safeNumber(k,"maxPrice")},leverage:{min:I,max:M},cost:{min:this.parseNumber(T),max:void 0}},created:void 0,info:e})}async fetchCurrencies(e={}){const t=await this.publicGetApiV1ExchangeInfo(e),i=this.safeList(t,"coins"),s={};for(let e=0;e=0&&(h="out");const l=this.safeString(e,"total"),u=this.parseNumber(l);return this.safeLedgerEntry({info:e,id:i,timestamp:r,datetime:this.iso8601(r),account:s,direction:h,referenceId:void 0,referenceAccount:void 0,type:a,currency:n,symbol:void 0,amount:c,before:void 0,after:u,status:"ok",fee:void 0},t)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e);if(n.spot)return await this.createSpotOrder(e,t,i,s,a,o);if(n.swap)return await this.createSwapOrder(e,t,i,s,a,o);throw new r.NotSupported(this.id+" createOrder() is not supported for "+n.type+" type of markets")}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new r.NotSupported(this.id+" createMarketBuyOrderWithCost() is supported for spot markets only");const s={cost:t};return await this.createOrder(e,"market","buy",t,void 0,this.extend(s,i))}async createSpotOrder(e,t,i,s,a=void 0,o={}){if(void 0!==this.safeString2(o,"stopPrice","triggerPrice"))throw new r.NotSupported(this.id+" trigger orders are not supported for spot markets");await this.loadMarkets();const n=this.market(e),d="market"===t&&"buy"===i,c=this.safeString(o,"cost");if(!d&&void 0!==c)throw new r.NotSupported(this.id+" createOrder() supports cost parameter for spot market buy orders only");const h=this.createSpotOrderRequest(e,t,i,s,a,o);let l={};return this.safeBool(o,"test")?(o=this.omit(o,"test"),l=await this.privatePostApiV1SpotOrderTest(h)):l=d&&void 0===c?await this.privatePostApiV11SpotOrder(h):await this.privatePostApiV1SpotOrder(h),this.parseOrder(l,n)}createOrderRequest(e,t,i,s,a=void 0,o={}){const n=this.market(e);if(n.spot)return this.createSpotOrderRequest(e,t,i,s,a,o);if(n.swap)return this.createSwapOrderRequest(e,t,i,s,a,o);throw new r.NotSupported(this.id+" createOrderRequest() is not supported for "+n.type+" type of markets")}createSpotOrderRequest(e,t,i,s,r=void 0,a={}){const o=this.market(e);t=t.toUpperCase();const n={symbol:o.id,side:i.toUpperCase(),type:t};let d;void 0!==s&&(n.quantity=this.amountToPrecision(e,s)),[d,a]=this.handleParamString(a,"cost"),void 0!==d&&(n.quantity=this.costToPrecision(e,d)),void 0!==r&&(n.price=this.priceToPrecision(e,r));const c="MARKET"===t;let h,l=!1;return[l,a]=this.handlePostOnly(c,"LIMIT_MAKER"===t,a),l&&"LIMIT"===t&&(n.type="LIMIT_MAKER"),[h,a]=this.handleParamString(a,"clientOrderId"),void 0!==h&&(a.newClientOrderId=h),this.extend(n,a)}createSwapOrderRequest(e,t,i,s,r=void 0,a={}){const o={symbol:this.market(e).id,type:"LIMIT",quantity:this.amountToPrecision(e,s)},n="market"===t;n&&(o.priceType="MARKET"),void 0!==r&&(o.price=this.priceToPrecision(e,r),o.priceType="INPUT");let d=!1;[d,a]=this.handleParamBool(a,"reduceOnly",d);let c,h="_OPEN";d&&(h="_CLOSE"),o.side=i.toUpperCase()+h,[c,a]=this.handleParamString(a,"timeInForce");let l=!1;[l,a]=this.handlePostOnly(n,"LIMIT_MAKER"===c,a),l&&(c="LIMIT_MAKER"),void 0!==c&&(o.timeInForce=c);void 0===this.safeString(a,"clientOrderId")&&(o.clientOrderId=this.uuid());const u=this.safeString(a,"triggerPrice");return void 0!==u&&(o.stopPrice=this.priceToPrecision(e,u),o.type="STOP",a=this.omit(a,"triggerPrice")),this.extend(o,a)}async createSwapOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.createSwapOrderRequest(e,t,i,s,r,a),d=await this.privatePostApiV1FuturesOrder(this.extend(n,a));return this.parseOrder(d,o)}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let t=0;t{"use strict";i.d(t,{A:()=>h});var s=i(5825),r=i(1579),a=i(8283),o=i(4852),n=i(987),d=i(5147),c=i(2079);class h extends s.A{describe(){return this.deepExtend(super.describe(),{id:"hibachi",name:"Hibachi",countries:["US"],rateLimit:100,userAgent:this.userAgents.chrome,certified:!1,pro:!1,dex:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!1,closeAllPositions:!1,closePosition:!1,createConvertTrade:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!1,createMarketOrder:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopLossOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,createTakeProfitOrder:!1,createTrailingAmountOrder:!1,createTrailingPercentOrder:!1,createTriggerOrder:!1,editOrder:!0,editOrders:!0,fetchAccounts:!1,fetchBalance:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!1,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTradingLimits:!1,fetchTransactions:"emulated",fetchTransfers:!1,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!1,setMargin:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1min","5m":"5min","15m":"15min","1h":"1h","4h":"4h","1d":"1d","1w":"1w"},urls:{logo:"https://github.com/user-attachments/assets/7301bbb1-4f27-4167-8a55-75f74b14e973",api:{public:"https://data-api.hibachi.xyz",private:"https://api.hibachi.xyz"},www:"https://www.hibachi.xyz/",referral:{url:"hibachi.xyz/r/ZBL2YFWIHU"}},api:{public:{get:{"market/exchange-info":1,"market/data/trades":1,"market/data/prices":1,"market/data/stats":1,"market/data/klines":1,"market/data/orderbook":1,"market/data/open-interest":1,"market/data/funding-rates":1,"exchange/utc-timestamp":1}},private:{get:{"capital/deposit-info":1,"capital/history":1,"trade/account/trading_history":1,"trade/account/info":1,"trade/order":1,"trade/account/trades":1,"trade/orders":1},put:{"trade/order":1},delete:{"trade/order":1,"trade/orders":1},post:{"trade/order":1,"trade/orders":1,"capital/withdraw":1}}},requiredCredentials:{apiKey:!0,secret:!1,accountId:!0,privateKey:!0},fees:{trading:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.00015"),taker:this.parseNumber("0.00045")}},currencies:this.hardcodedCurrencies(),options:{},features:{default:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:void 0,fetchOHLCV:{limit:void 0}},swap:{linear:{extends:"default"},inverse:void 0},future:{linear:{extends:"default"},inverse:void 0}},commonCurrencies:{},exceptions:{exact:{2:c.BadRequest,3:c.OrderNotFound,4:c.BadRequest},broad:{}},precisionMode:r.kb})}getAccountId(){this.checkRequiredCredentials();return this.parseToInt(this.accountId)}parseMarket(e){const t=this.safeString(e,"symbol"),i=this.safeNumber(e,"id"),s=this.safeString(e,"underlyingSymbol"),r=this.safeString(e,"settlementSymbol"),a=this.safeCurrencyCode(s),o=this.safeCurrencyCode(r),n=this.safeString(e,"settlementSymbol"),d=this.safeCurrencyCode(n),c=a+"/"+o+":"+d,h=this.safeIntegerProduct(e,"marketCreationTimestamp",1e3);return{id:t,numericId:i,symbol:c,base:a,quote:o,settle:d,baseId:s,quoteId:r,settleId:n,type:"swap",spot:!1,margin:!1,swap:!0,future:!1,option:!1,active:"LIVE"===this.safeString(e,"status"),contract:!0,linear:!0,inverse:!1,contractSize:this.parseNumber("1"),expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:this.parseNumber(this.parsePrecision(this.safeString(e,"underlyingDecimals"))),price:this.parseNumber(this.safeList(e,"orderbookGranularities")[0])/1e4},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(e,"minNotional"),max:void 0}},created:h,info:e}}async fetchMarkets(e={}){const t=await this.publicGetMarketExchangeInfo(e),i=this.safeList(t,"futureContracts");return this.parseMarkets(i)}hardcodedCurrencies(){const e={},t={},i="ARBITRUM";t[i]={id:i,network:i,limits:{withdraw:{min:void 0,max:void 0},deposit:{min:void 0,max:void 0}},active:void 0,deposit:void 0,withdraw:void 0,info:{}};const s=this.safeCurrencyCode("USDT");return e[s]=this.safeCurrencyStructure({id:"USDT",name:"USDT",type:"fiat",code:s,precision:this.parseNumber("0.000001"),active:!0,fee:void 0,networks:t,deposit:!0,withdraw:!0,limits:{deposit:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}},info:{}}),e}parseBalance(e){const t={info:e},i=this.safeCurrencyCode("USDT"),s=this.account();return s.total=this.safeString(e,"balance"),s.free=this.safeString(e,"maximalWithdraw"),t[i]=s,this.safeBalance(t)}async fetchBalance(e={}){const t={accountId:this.getAccountId()},i=await this.privateGetTradeAccountInfo(this.extend(t,e));return this.parseBalance(i)}parseTicker(e,t=void 0){const i=this.safeDict(e,"prices"),s=this.safeDict(e,"stats"),r=this.safeNumber(i,"bidPrice"),a=this.safeNumber(i,"askPrice"),o=this.safeNumber(i,"tradePrice"),n=this.safeNumber(s,"high24h"),d=this.safeNumber(s,"low24h"),c=this.safeNumber(s,"volume24h");return this.safeTicker({symbol:this.safeSymbol(void 0,t),timestamp:void 0,datetime:void 0,bid:r,ask:a,last:o,high:n,low:d,bidVolume:void 0,askVolume:void 0,vwap:void 0,open:void 0,close:o,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:void 0,quoteVolume:c,info:e},t)}parseTrade(e,t=void 0){const i=this.safeString(e,"symbol"),s=(t=this.safeMarket(i,t)).symbol,r=this.safeString(e,"id"),a=this.safeString(e,"price"),o=this.safeString(e,"quantity"),n=this.safeIntegerProduct(e,"timestamp",1e3),c=d.Y.stringMul(a,o);let h,l,u,p,f;return void 0===r?(h=this.safeStringLower(e,"takerSide"),f="taker"):(h=this.safeStringLower(e,"side"),l={cost:this.safeString(e,"fee"),currency:"USDT"},u=this.safeStringLower(e,"orderType"),p="buy"===h?this.safeString(e,"bidOrderId"):this.safeString(e,"askOrderId")),this.safeTrade({id:r,timestamp:n,datetime:this.iso8601(n),symbol:s,side:h,price:a,amount:o,cost:c,order:p,takerOrMaker:f,type:u,fee:l,info:e},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={symbol:r.id},o=await this.publicGetMarketDataTrades(this.extend(a,s)),n=this.safeList(o,"trades",[]);return this.parseTrades(n,r)}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbol:i.id},r=[this.publicGetMarketDataPrices(this.extend(s,t)),this.publicGetMarketDataStats(this.extend(s,t))],a=await Promise.all(r),o={prices:a[0],stats:a[1]};return this.parseTicker(o,i)}parseOrderStatus(e){return this.safeString({PENDING:"open",CHILD_PENDING:"open",SCHEDULED_TWAP:"open",PLACED:"open",PARTIALLY_FILLED:"open",FILLED:"closed",CANCELLED:"canceled",REJECTED:"rejected"},e,e)}parseOrder(e,t=void 0){const i=this.safeString(e,"symbol");t=this.safeMarket(i,t);const s=this.safeString(e,"status"),r=this.safeStringLower(e,"orderType"),a=this.safeString(e,"price"),o=this.safeString(e,"side");let n;"BID"===o?n="buy":"ASK"===o&&(n="sell");const c=this.safeString(e,"totalQuantity"),h=this.safeString(e,"availableQuantity"),l=this.safeString(e,"totalQuantity"),u=this.safeString(e,"availableQuantity");let p;void 0!==l&&void 0!==u&&(p=d.Y.stringSub(l,u));let f="GTC";const m=this.safeValue(e,"orderFlags");let g=!1,v=!1;return"POST_ONLY"===m?(f="PO",g=!0):"IOC"===m?f="IOC":"REDUCE_ONLY"===m&&(v=!0),this.safeOrder({info:e,id:this.safeString(e,"orderId"),clientOrderId:void 0,datetime:void 0,timestamp:void 0,lastTradeTimestamp:void 0,lastUpdateTimestamp:void 0,status:this.parseOrderStatus(s),symbol:t.symbol,type:r,timeInForce:f,side:n,price:a,average:void 0,amount:c,filled:p,remaining:h,cost:void 0,trades:void 0,fee:void 0,reduceOnly:v,postOnly:g,triggerPrice:this.safeNumber(e,"triggerPrice")},t)}async fetchOrder(e,t=void 0,i={}){let s;await this.loadMarkets(),void 0!==t&&(s=this.market(t));const r={orderId:e,accountId:this.getAccountId()},a=await this.privateGetTradeOrder(this.extend(r,i));return this.parseOrder(a,s)}async fetchTradingFees(e={}){await this.loadMarkets();const t={accountId:this.getAccountId()},i=await this.privateGetTradeAccountInfo(this.extend(t,e)),s=this.safeNumber(i,"tradeMakerFeeRate"),r=this.safeNumber(i,"tradeTakerFeeRate"),a={};for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(706),r=i(1579),a=i(5147),o=i(2079),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"hitbtc",name:"HitBTC",countries:["HK"],rateLimit:3.333,version:"3",has:{CORS:!1,spot:!0,margin:!0,swap:!0,future:!1,option:!1,addMargin:!0,cancelAllOrders:!0,cancelOrder:!0,closePosition:!1,createDepositAddress:!0,createOrder:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,editOrder:!0,fetchAccounts:!1,fetchBalance:!0,fetchBorrowRateHistories:void 0,fetchBorrowRateHistory:void 0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:void 0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchGreeks:!1,fetchIndexOHLCV:!0,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!0,fetchLeverageTiers:void 0,fetchLiquidations:!1,fetchMarginMode:"emulated",fetchMarginModes:!0,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenInterests:!0,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrders:!1,fetchOrderTrades:!0,fetchPosition:!0,fetchPositions:!0,fetchPremiumIndexOHLCV:!0,fetchSettlementHistory:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:"emulated",fetchVolatilityHistory:!1,fetchWithdrawals:!0,reduceMargin:!0,sandbox:!0,setLeverage:!0,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!0,withdraw:!0},precisionMode:r.kb,urls:{logo:"https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg",test:{public:"https://api.demo.hitbtc.com/api/3",private:"https://api.demo.hitbtc.com/api/3"},api:{public:"https://api.hitbtc.com/api/3",private:"https://api.hitbtc.com/api/3"},www:"https://hitbtc.com",referral:"https://hitbtc.com/?ref_id=5a5d39a65d466",doc:["https://api.hitbtc.com","https://github.com/hitbtc-com/hitbtc-api/blob/master/APIv2.md"],fees:["https://hitbtc.com/fees-and-limits","https://support.hitbtc.com/hc/en-us/articles/115005148605-Fees-and-limits"]},api:{public:{get:{"public/currency":10,"public/currency/{currency}":10,"public/symbol":10,"public/symbol/{symbol}":10,"public/ticker":10,"public/ticker/{symbol}":10,"public/price/rate":10,"public/price/history":10,"public/price/ticker":10,"public/price/ticker/{symbol}":10,"public/trades":10,"public/trades/{symbol}":10,"public/orderbook":10,"public/orderbook/{symbol}":10,"public/candles":10,"public/candles/{symbol}":10,"public/converted/candles":10,"public/converted/candles/{symbol}":10,"public/futures/info":10,"public/futures/info/{symbol}":10,"public/futures/history/funding":10,"public/futures/history/funding/{symbol}":10,"public/futures/candles/index_price":10,"public/futures/candles/index_price/{symbol}":10,"public/futures/candles/mark_price":10,"public/futures/candles/mark_price/{symbol}":10,"public/futures/candles/premium_index":10,"public/futures/candles/premium_index/{symbol}":10,"public/futures/candles/open_interest":10,"public/futures/candles/open_interest/{symbol}":10}},private:{get:{"spot/balance":15,"spot/balance/{currency}":15,"spot/order":1,"spot/order/{client_order_id}":1,"spot/fee":15,"spot/fee/{symbol}":15,"spot/history/order":15,"spot/history/trade":15,"margin/account":1,"margin/account/isolated/{symbol}":1,"margin/account/cross/{currency}":1,"margin/order":1,"margin/order/{client_order_id}":1,"margin/config":15,"margin/history/order":15,"margin/history/trade":15,"margin/history/positions":15,"margin/history/clearing":15,"futures/balance":15,"futures/balance/{currency}":15,"futures/account":1,"futures/account/isolated/{symbol}":1,"futures/order":1,"futures/order/{client_order_id}":1,"futures/config":15,"futures/fee":15,"futures/fee/{symbol}":15,"futures/history/order":15,"futures/history/trade":15,"futures/history/positions":15,"futures/history/clearing":15,"wallet/balance":30,"wallet/balance/{currency}":30,"wallet/crypto/address":30,"wallet/crypto/address/recent-deposit":30,"wallet/crypto/address/recent-withdraw":30,"wallet/crypto/address/check-mine":30,"wallet/transactions":30,"wallet/transactions/{tx_id}":30,"wallet/crypto/fee/estimate":30,"wallet/airdrops":30,"wallet/amount-locks":30,"sub-account":15,"sub-account/acl":15,"sub-account/balance/{subAccID}":15,"sub-account/crypto/address/{subAccID}/{currency}":15},post:{"spot/order":1,"spot/order/list":1,"margin/order":1,"margin/order/list":1,"futures/order":1,"futures/order/list":1,"wallet/crypto/address":30,"wallet/crypto/withdraw":30,"wallet/convert":30,"wallet/transfer":30,"wallet/internal/withdraw":30,"wallet/crypto/check-offchain-available":30,"wallet/crypto/fees/estimate":30,"wallet/airdrops/{id}/claim":30,"sub-account/freeze":15,"sub-account/activate":15,"sub-account/transfer":15,"sub-account/acl":15},patch:{"spot/order/{client_order_id}":1,"margin/order/{client_order_id}":1,"futures/order/{client_order_id}":1},delete:{"spot/order":1,"spot/order/{client_order_id}":1,"margin/position":1,"margin/position/isolated/{symbol}":1,"margin/order":1,"margin/order/{client_order_id}":1,"futures/position":1,"futures/position/{margin_mode}/{symbol}":1,"futures/order":1,"futures/order/{client_order_id}":1,"wallet/crypto/withdraw/{id}":30},put:{"margin/account/isolated/{symbol}":1,"futures/account/isolated/{symbol}":1,"wallet/crypto/withdraw/{id}":30}}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0009"),maker:this.parseNumber("0.0009"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0009")],[this.parseNumber("10"),this.parseNumber("0.0007")],[this.parseNumber("100"),this.parseNumber("0.0006")],[this.parseNumber("500"),this.parseNumber("0.0005")],[this.parseNumber("1000"),this.parseNumber("0.0003")],[this.parseNumber("5000"),this.parseNumber("0.0002")],[this.parseNumber("10000"),this.parseNumber("0.0001")],[this.parseNumber("20000"),this.parseNumber("0")],[this.parseNumber("50000"),this.parseNumber("-0.0001")],[this.parseNumber("100000"),this.parseNumber("-0.0001")]],taker:[[this.parseNumber("0"),this.parseNumber("0.0009")],[this.parseNumber("10"),this.parseNumber("0.0008")],[this.parseNumber("100"),this.parseNumber("0.0007")],[this.parseNumber("500"),this.parseNumber("0.0007")],[this.parseNumber("1000"),this.parseNumber("0.0006")],[this.parseNumber("5000"),this.parseNumber("0.0006")],[this.parseNumber("10000"),this.parseNumber("0.0005")],[this.parseNumber("20000"),this.parseNumber("0.0004")],[this.parseNumber("50000"),this.parseNumber("0.0003")],[this.parseNumber("100000"),this.parseNumber("0.0002")]]}}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!0},createOrders:void 0,fetchMyTrades:{marginMode:!0,limit:1e3,daysBack:1e5,untilDays:1e5,symbolRequired:!1,marketType:!0},fetchOrder:{marginMode:!0,trigger:!1,trailing:!1,symbolRequired:!1,marketType:!0},fetchOpenOrders:{marginMode:!0,limit:1e3,trigger:!1,trailing:!1,symbolRequired:!1,marketType:!0},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1,marketType:!0},fetchOHLCV:{limit:1e3}},spot:{extends:"default"},forDerivatives:{extends:"default",createOrder:{marginMode:!0},fetchOrder:{marginMode:!1},fetchMyTrades:{marginMode:!1},fetchOpenOrders:{marginMode:!1},fetchClosedOrders:{marginMode:!1}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}}},timeframes:{"1m":"M1","3m":"M3","5m":"M5","15m":"M15","30m":"M30","1h":"H1","4h":"H4","1d":"D1","1w":"D7","1M":"1M"},exceptions:{exact:{429:o.RateLimitExceeded,500:o.ExchangeError,503:o.ExchangeNotAvailable,504:o.ExchangeNotAvailable,600:o.PermissionDenied,800:o.ExchangeError,1002:o.AuthenticationError,1003:o.PermissionDenied,1004:o.AuthenticationError,1005:o.AuthenticationError,2001:o.BadSymbol,2002:o.BadRequest,2003:o.BadRequest,2010:o.BadRequest,2011:o.BadRequest,2012:o.BadRequest,2020:o.BadRequest,2022:o.BadRequest,2024:o.InvalidOrder,10001:o.BadRequest,10021:o.AccountSuspended,10022:o.BadRequest,20001:o.InsufficientFunds,20002:o.OrderNotFound,20003:o.ExchangeError,20004:o.ExchangeError,20005:o.ExchangeError,20006:o.ExchangeError,20007:o.ExchangeError,20008:o.InvalidOrder,20009:o.InvalidOrder,20010:o.OnMaintenance,20011:o.ExchangeError,20012:o.ExchangeError,20014:o.ExchangeError,20016:o.ExchangeError,20018:o.ExchangeError,20031:o.ExchangeError,20032:o.ExchangeError,20033:o.ExchangeError,20034:o.ExchangeError,20040:o.ExchangeError,20041:o.ExchangeError,20042:o.ExchangeError,20043:o.ExchangeError,20044:o.PermissionDenied,20045:o.InvalidOrder,20047:o.InvalidOrder,20048:o.InvalidOrder,20049:o.InvalidOrder,20080:o.ExchangeError,21001:o.ExchangeError,21003:o.AccountSuspended,21004:o.AccountSuspended,22004:o.ExchangeError,22008:o.ExchangeError},broad:{}},options:{defaultNetwork:"ERC20",defaultNetworks:{ETH:"ETH",USDT:"TRC20"},networks:{BTC:"btc",OMNI:"BTC",ETH:"eth",ERC20:"ETH",ETC:"ETC",BEP20:"BSC",TRC20:"TRX",NEAR:"NEAR",DGB:"DGB",AE:"AE",AR:"AR",ADA:"ADA",CHZ:"CHZ",ABBC:"ABBC",ALGO:"ALGO",APT:"APT",ATOM:"ATOM",AVAXC:"AVAC",AVAXX:"AVAX",BSV:"BCHSV",BEP2:"BNB",CELO:"CELO",CKB:"CKB",CTXC:"CTXC",DASH:"DASH",DCR:"DCR",DOGE:"doge",EGLD:"EGLD",EOS:"EOS",ETHW:"ETHW",EVER:"EVER",FET:"FET",FIL:"FIL",FLOW:"FLOW",GLMR:"GLMR",GRIN:"GRIN",HBAR:"HBAR",HIVE:"HIVE",HYDRA:"HYDRA",ICP:"ICP",ICX:"ICX",IOST:"IOST",IOTA:"IOTA",IOTX:"IOTX",KAVA:"KAVA",KLAY:"KIM",KOMODO:"KMD",KSM:"KSM",LSK:"LSK",LTC:"ltc",MINA:"MINA",MOVR:"MOVR",NANO:"NANO",NEO:"NEO",ONE:"ONE",ONT:"ONT",OPTIMISM:"OP",PLCU:"PLCU",MATIC:"POLYGON",QTUM:"QTUM",REI:"REI",OASIS:"ROSE",RVN:"RVN",SC:"SC",SCRT:"SCRT",SOL:"SOL",STEEM:"STEEM",THETA:"Theta",TRUE:"TRUE",VET:"VET",VSYS:"VSYS",WAVES:"WAVES",WAX:"WAX",XCH:"XCH",XEC:"XEC",NEM:"XEM",XLM:"XLM",XMR:"xmr",XRD:"XRD",XRP:"XRP",XTZ:"XTZ",XVG:"XVG",XYM:"XYM",ZEC:"ZEC",ZEN:"ZEN",ZIL:"ZIL"},accountsByType:{spot:"spot",funding:"wallet",swap:"derivatives",future:"derivatives"},withdraw:{includeFee:!1}},commonCurrencies:{AUTO:"Cube",BCC:"BCC",BDP:"BidiPass",BET:"DAO.Casino",BIT:"BitRewards",BOX:"BOX Token",CPT:"Cryptaur",GET:"Themis",GMT:"GMT Token",HSR:"HC",IQ:"IQ.Cash",LNC:"LinkerCoin",PLA:"PlayChip",PNT:"Penta",SBTC:"Super Bitcoin",STEPN:"GMT",STX:"STOX",TV:"Tokenville",XMT:"MTL",XPNT:"PNT"}})}nonce(){return this.milliseconds()}async fetchMarkets(e={}){const t=await this.publicGetPublicSymbol(e),i=[],s=Object.keys(t);for(let e=0;ea)throw new o.BadRequest(this.id+" setLeverage() leverage should be between 1 and "+a.toString()+" for "+t);const n={symbol:s.id,leverage:e.toString(),margin_balance:this.amountToPrecision(t,r)};return await this.privatePutFuturesAccountIsolatedSymbol(this.extend(n,i))}async fetchDepositWithdrawFees(e=void 0,t={}){await this.loadMarkets();const i=await this.publicGetPublicCurrency(t);return this.parseDepositWithdrawFees(i,e)}parseDepositWithdrawFee(e,t=void 0){const i=this.safeValue(e,"networks",[]),s=this.depositWithdrawFee(e);for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(1180),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"hollaex",name:"HollaEx",countries:["KR"],rateLimit:250,version:"v2",pro:!0,has:{CORS:void 0,spot:!0,margin:void 0,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelOrder:!0,createLimitBuyOrder:!0,createLimitSellOrder:!0,createMarketBuyOrder:!0,createMarketSellOrder:!0,createOrder:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:"emulated",fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!0,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!0,setLeverage:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","15m":"15m","1h":"1h","4h":"4h","1d":"1d","1w":"1w"},urls:{logo:"https://user-images.githubusercontent.com/1294454/75841031-ca375180-5ddd-11ea-8417-b975674c23cb.jpg",test:{rest:"https://api.sandbox.hollaex.com"},api:{rest:"https://api.hollaex.com"},www:"https://hollaex.com",doc:"https://apidocs.hollaex.com",referral:"https://pro.hollaex.com/signup?affiliation_code=QSWA6G"},precisionMode:o.kb,requiredCredentials:{apiKey:!0,secret:!0},api:{public:{get:{health:1,constants:1,kit:1,tiers:1,ticker:1,tickers:1,orderbook:1,orderbooks:1,trades:1,chart:1,charts:1,minicharts:1,"oracle/prices":1,"quick-trade":1,"udf/config":1,"udf/history":1,"udf/symbols":1}},private:{get:{user:1,"user/balance":1,"user/deposits":1,"user/withdrawals":1,"user/withdrawal/fee":1,"user/trades":1,orders:1,order:1},post:{"user/withdrawal":1,order:1},delete:{"order/all":1,order:1}}},features:{spot:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!0,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:{marginMode:!1,limit:100,daysBack:1e5,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,limit:100,daysBack:1e5,daysBackCanceled:1,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:1e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},fees:{trading:{tierBased:!0,percentage:!0,taker:.001,maker:.001}},exceptions:{broad:{"API request is expired":r.InvalidNonce,"Invalid token":r.AuthenticationError,"Order not found":r.OrderNotFound,"Insufficient balance":r.InsufficientFunds,"Error 1001 - Order rejected. Order could not be submitted as this order was set to a post only order.":r.OrderImmediatelyFillable},exact:{400:r.BadRequest,403:r.AuthenticationError,404:r.BadRequest,405:r.BadRequest,410:r.BadRequest,429:r.BadRequest,500:r.NetworkError,503:r.NetworkError}},options:{"api-expires":this.parseToInt(this.timeout/1e3),networks:{BTC:"btc",ETH:"eth",ERC20:"eth",TRX:"trx",TRC20:"trx",XRP:"xrp",XLM:"xlm",BNB:"bnb",MATIC:"matic"},networksById:{eth:"ERC20",ETH:"ERC20",ERC20:"ERC20",trx:"TRC20",TRX:"TRC20",TRC20:"TRC20"}}})}async fetchMarkets(e={}){const t=await this.publicGetConstants(e),i=this.safeValue(t,"pairs",{}),s=Object.keys(i),r=[];for(let e=0;e=400&&e<=503){const t=this.id+" "+a,i=this.safeString(o,"message");this.throwBroadlyMatchedException(this.exceptions.broad,i,t);const s=e.toString();this.throwExactlyMatchedException(this.exceptions.exact,s,t)}}}},9946:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(8617),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"htx",name:"HTX",countries:["CN"],rateLimit:100,userAgent:this.userAgents.chrome100,certified:!0,version:"v1",hostname:"api.huobi.pro",pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!0,future:!0,option:void 0,addMargin:void 0,borrowCrossMargin:!0,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!0,createDepositAddress:void 0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTrailingPercentOrder:!0,createTriggerOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:void 0,fetchBorrowInterest:!0,fetchBorrowRateHistories:void 0,fetchBorrowRateHistory:void 0,fetchCanceledOrders:void 0,fetchClosedOrder:void 0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:void 0,fetchDepositAddress:!0,fetchDepositAddresses:void 0,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingHistory:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!0,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!0,fetchL3OrderBook:void 0,fetchLastPrices:!0,fetchLedger:!0,fetchLedgerEntry:void 0,fetchLeverage:!1,fetchLeverageTiers:!0,fetchLiquidations:!0,fetchMarginAdjustmentHistory:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!0,fetchOpenInterests:!0,fetchOpenOrder:void 0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:void 0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!0,fetchPositionHistory:"emulated",fetchPositions:!0,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!0,fetchSettlementHistory:!0,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTradingLimits:!0,fetchTransactionFee:void 0,fetchTransactionFees:void 0,fetchTransactions:void 0,fetchTransfers:void 0,fetchWithdrawAddresses:!0,fetchWithdrawal:void 0,fetchWithdrawals:!0,fetchWithdrawalWhitelist:void 0,reduceMargin:void 0,repayCrossMargin:!0,repayIsolatedMargin:!0,setLeverage:!0,setMarginMode:!1,setPositionMode:!0,signIn:void 0,transfer:!0,withdraw:!0},timeframes:{"1m":"1min","5m":"5min","15m":"15min","30m":"30min","1h":"60min","4h":"4hour","1d":"1day","1w":"1week","1M":"1mon","1y":"1year"},urls:{logo:"https://user-images.githubusercontent.com/1294454/76137448-22748a80-604e-11ea-8069-6e389271911d.jpg",hostnames:{contract:"api.hbdm.com",spot:"api.huobi.pro",status:{spot:"status.huobigroup.com",future:{inverse:"status-dm.huobigroup.com",linear:"status-linear-swap.huobigroup.com"},swap:{inverse:"status-swap.huobigroup.com",linear:"status-linear-swap.huobigroup.com"}}},api:{status:"https://{hostname}",contract:"https://{hostname}",spot:"https://{hostname}",public:"https://{hostname}",private:"https://{hostname}",v2Public:"https://{hostname}",v2Private:"https://{hostname}"},www:"https://www.huobi.com",referral:{url:"https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223",discount:.15},doc:["https://huobiapi.github.io/docs/spot/v1/en/","https://huobiapi.github.io/docs/dm/v1/en/","https://huobiapi.github.io/docs/coin_margined_swap/v1/en/","https://huobiapi.github.io/docs/usdt_swap/v1/en/","https://www.huobi.com/en-us/opend/newApiPages/"],fees:"https://www.huobi.com/about/fee/"},api:{v2Public:{get:{"reference/currencies":1,"market-status":1}},v2Private:{get:{"account/ledger":1,"account/withdraw/quota":1,"account/withdraw/address":1,"account/deposit/address":1,"account/repayment":5,"reference/transact-fee-rate":1,"account/asset-valuation":.2,"point/account":5,"sub-user/user-list":1,"sub-user/user-state":1,"sub-user/account-list":1,"sub-user/deposit-address":1,"sub-user/query-deposit":1,"user/api-key":1,"user/uid":1,"algo-orders/opening":1,"algo-orders/history":1,"algo-orders/specific":1,"c2c/offers":1,"c2c/offer":1,"c2c/transactions":1,"c2c/repayment":1,"c2c/account":1,"etp/reference":1,"etp/transactions":5,"etp/transaction":5,"etp/rebalance":1,"etp/limit":1},post:{"account/transfer":1,"account/repayment":5,"point/transfer":5,"sub-user/management":1,"sub-user/creation":1,"sub-user/tradable-market":1,"sub-user/transferability":1,"sub-user/api-key-generation":1,"sub-user/api-key-modification":1,"sub-user/api-key-deletion":1,"sub-user/deduct-mode":1,"algo-orders":1,"algo-orders/cancel-all-after":1,"algo-orders/cancellation":1,"c2c/offer":1,"c2c/cancellation":1,"c2c/cancel-all":1,"c2c/repayment":1,"c2c/transfer":1,"etp/creation":5,"etp/redemption":5,"etp/{transactId}/cancel":10,"etp/batch-cancel":50}},public:{get:{"common/symbols":1,"common/currencys":1,"common/timestamp":1,"common/exchange":1,"settings/currencys":1}},private:{get:{"account/accounts":.2,"account/accounts/{id}/balance":.2,"account/accounts/{sub-uid}":1,"account/history":4,"cross-margin/loan-info":1,"margin/loan-info":1,"fee/fee-rate/get":1,"order/openOrders":.4,"order/orders":.4,"order/orders/{id}":.4,"order/orders/{id}/matchresults":.4,"order/orders/getClientOrder":.4,"order/history":1,"order/matchresults":1,"query/deposit-withdraw":1,"margin/loan-orders":.2,"margin/accounts/balance":.2,"cross-margin/loan-orders":1,"cross-margin/accounts/balance":1,"points/actions":1,"points/orders":1,"subuser/aggregate-balance":10,"stable-coin/exchange_rate":1,"stable-coin/quote":1},post:{"account/transfer":1,"futures/transfer":1,"order/batch-orders":.4,"order/orders/place":.2,"order/orders/submitCancelClientOrder":.2,"order/orders/batchCancelOpenOrders":.4,"order/orders/{id}/submitcancel":.2,"order/orders/batchcancel":.4,"dw/withdraw/api/create":1,"dw/withdraw-virtual/{id}/cancel":1,"dw/transfer-in/margin":10,"dw/transfer-out/margin":10,"margin/orders":10,"margin/orders/{id}/repay":10,"cross-margin/transfer-in":1,"cross-margin/transfer-out":1,"cross-margin/orders":1,"cross-margin/orders/{id}/repay":1,"stable-coin/exchange":1,"subuser/transfer":10}},status:{public:{spot:{get:{"api/v2/summary.json":1}},future:{inverse:{get:{"api/v2/summary.json":1}},linear:{get:{"api/v2/summary.json":1}}},swap:{inverse:{get:{"api/v2/summary.json":1}},linear:{get:{"api/v2/summary.json":1}}}}},spot:{public:{get:{"v2/market-status":1,"v1/common/symbols":1,"v1/common/currencys":1,"v2/settings/common/currencies":1,"v2/reference/currencies":1,"v1/common/timestamp":1,"v1/common/exchange":1,"v1/settings/common/chains":1,"v1/settings/common/currencys":1,"v1/settings/common/symbols":1,"v2/settings/common/symbols":1,"v1/settings/common/market-symbols":1,"market/history/candles":1,"market/history/kline":1,"market/detail/merged":1,"market/tickers":1,"market/detail":1,"market/depth":1,"market/trade":1,"market/history/trade":1,"market/etp":1,"v2/etp/reference":1,"v2/etp/rebalance":1}},private:{get:{"v1/account/accounts":.2,"v1/account/accounts/{account-id}/balance":.2,"v2/account/valuation":1,"v2/account/asset-valuation":.2,"v1/account/history":4,"v2/account/ledger":1,"v2/point/account":5,"v2/account/deposit/address":1,"v2/account/withdraw/quota":1,"v2/account/withdraw/address":1,"v2/reference/currencies":1,"v1/query/deposit-withdraw":1,"v1/query/withdraw/client-order-id":1,"v2/user/api-key":1,"v2/user/uid":1,"v2/sub-user/user-list":1,"v2/sub-user/user-state":1,"v2/sub-user/account-list":1,"v2/sub-user/deposit-address":1,"v2/sub-user/query-deposit":1,"v1/subuser/aggregate-balance":10,"v1/account/accounts/{sub-uid}":1,"v1/order/openOrders":.4,"v1/order/orders/{order-id}":.4,"v1/order/orders/getClientOrder":.4,"v1/order/orders/{order-id}/matchresult":.4,"v1/order/orders/{order-id}/matchresults":.4,"v1/order/orders":.4,"v1/order/history":1,"v1/order/matchresults":1,"v2/reference/transact-fee-rate":1,"v2/algo-orders/opening":1,"v2/algo-orders/history":1,"v2/algo-orders/specific":1,"v1/margin/loan-info":1,"v1/margin/loan-orders":.2,"v1/margin/accounts/balance":.2,"v1/cross-margin/loan-info":1,"v1/cross-margin/loan-orders":1,"v1/cross-margin/accounts/balance":1,"v2/account/repayment":5,"v1/stable-coin/quote":1,"v1/stable_coin/exchange_rate":1,"v2/etp/transactions":5,"v2/etp/transaction":5,"v2/etp/limit":1},post:{"v1/account/transfer":1,"v1/futures/transfer":1,"v2/point/transfer":5,"v2/account/transfer":1,"v1/dw/withdraw/api/create":1,"v1/dw/withdraw-virtual/{withdraw-id}/cancel":1,"v2/sub-user/deduct-mode":1,"v2/sub-user/creation":1,"v2/sub-user/management":1,"v2/sub-user/tradable-market":1,"v2/sub-user/transferability":1,"v2/sub-user/api-key-generation":1,"v2/sub-user/api-key-modification":1,"v2/sub-user/api-key-deletion":1,"v1/subuser/transfer":10,"v1/trust/user/active/credit":10,"v1/order/orders/place":.2,"v1/order/batch-orders":.4,"v1/order/auto/place":.2,"v1/order/orders/{order-id}/submitcancel":.2,"v1/order/orders/submitCancelClientOrder":.2,"v1/order/orders/batchCancelOpenOrders":.4,"v1/order/orders/batchcancel":.4,"v2/algo-orders/cancel-all-after":1,"v2/algo-orders":1,"v2/algo-orders/cancellation":1,"v2/account/repayment":5,"v1/dw/transfer-in/margin":10,"v1/dw/transfer-out/margin":10,"v1/margin/orders":10,"v1/margin/orders/{order-id}/repay":10,"v1/cross-margin/transfer-in":1,"v1/cross-margin/transfer-out":1,"v1/cross-margin/orders":1,"v1/cross-margin/orders/{order-id}/repay":1,"v1/stable-coin/exchange":1,"v2/etp/creation":5,"v2/etp/redemption":5,"v2/etp/{transactId}/cancel":10,"v2/etp/batch-cancel":50}}},contract:{public:{get:{"api/v1/timestamp":1,"heartbeat/":1,"api/v1/contract_contract_info":1,"api/v1/contract_index":1,"api/v1/contract_query_elements":1,"api/v1/contract_price_limit":1,"api/v1/contract_open_interest":1,"api/v1/contract_delivery_price":1,"market/depth":1,"market/bbo":1,"market/history/kline":1,"index/market/history/mark_price_kline":1,"market/detail/merged":1,"market/detail/batch_merged":1,"v2/market/detail/batch_merged":1,"market/trade":1,"market/history/trade":1,"api/v1/contract_risk_info":1,"api/v1/contract_insurance_fund":1,"api/v1/contract_adjustfactor":1,"api/v1/contract_his_open_interest":1,"api/v1/contract_ladder_margin":1,"api/v1/contract_api_state":1,"api/v1/contract_elite_account_ratio":1,"api/v1/contract_elite_position_ratio":1,"api/v1/contract_liquidation_orders":1,"api/v1/contract_settlement_records":1,"index/market/history/index":1,"index/market/history/basis":1,"api/v1/contract_estimated_settlement_price":1,"api/v3/contract_liquidation_orders":1,"swap-api/v1/swap_contract_info":1,"swap-api/v1/swap_index":1,"swap-api/v1/swap_query_elements":1,"swap-api/v1/swap_price_limit":1,"swap-api/v1/swap_open_interest":1,"swap-ex/market/depth":1,"swap-ex/market/bbo":1,"swap-ex/market/history/kline":1,"index/market/history/swap_mark_price_kline":1,"swap-ex/market/detail/merged":1,"v2/swap-ex/market/detail/batch_merged":1,"index/market/history/swap_premium_index_kline":1,"swap-ex/market/detail/batch_merged":1,"swap-ex/market/trade":1,"swap-ex/market/history/trade":1,"swap-api/v1/swap_risk_info":1,"swap-api/v1/swap_insurance_fund":1,"swap-api/v1/swap_adjustfactor":1,"swap-api/v1/swap_his_open_interest":1,"swap-api/v1/swap_ladder_margin":1,"swap-api/v1/swap_api_state":1,"swap-api/v1/swap_elite_account_ratio":1,"swap-api/v1/swap_elite_position_ratio":1,"swap-api/v1/swap_estimated_settlement_price":1,"swap-api/v1/swap_liquidation_orders":1,"swap-api/v1/swap_settlement_records":1,"swap-api/v1/swap_funding_rate":1,"swap-api/v1/swap_batch_funding_rate":1,"swap-api/v1/swap_historical_funding_rate":1,"swap-api/v3/swap_liquidation_orders":1,"index/market/history/swap_estimated_rate_kline":1,"index/market/history/swap_basis":1,"linear-swap-api/v1/swap_contract_info":1,"linear-swap-api/v1/swap_index":1,"linear-swap-api/v1/swap_query_elements":1,"linear-swap-api/v1/swap_price_limit":1,"linear-swap-api/v1/swap_open_interest":1,"linear-swap-ex/market/depth":1,"linear-swap-ex/market/bbo":1,"linear-swap-ex/market/history/kline":1,"index/market/history/linear_swap_mark_price_kline":1,"linear-swap-ex/market/detail/merged":1,"linear-swap-ex/market/detail/batch_merged":1,"v2/linear-swap-ex/market/detail/batch_merged":1,"linear-swap-ex/market/trade":1,"linear-swap-ex/market/history/trade":1,"linear-swap-api/v1/swap_risk_info":1,"swap-api/v1/linear-swap-api/v1/swap_insurance_fund":1,"linear-swap-api/v1/swap_adjustfactor":1,"linear-swap-api/v1/swap_cross_adjustfactor":1,"linear-swap-api/v1/swap_his_open_interest":1,"linear-swap-api/v1/swap_ladder_margin":1,"linear-swap-api/v1/swap_cross_ladder_margin":1,"linear-swap-api/v1/swap_api_state":1,"linear-swap-api/v1/swap_cross_transfer_state":1,"linear-swap-api/v1/swap_cross_trade_state":1,"linear-swap-api/v1/swap_elite_account_ratio":1,"linear-swap-api/v1/swap_elite_position_ratio":1,"linear-swap-api/v1/swap_liquidation_orders":1,"linear-swap-api/v1/swap_settlement_records":1,"linear-swap-api/v1/swap_funding_rate":1,"linear-swap-api/v1/swap_batch_funding_rate":1,"linear-swap-api/v1/swap_historical_funding_rate":1,"linear-swap-api/v3/swap_liquidation_orders":1,"index/market/history/linear_swap_premium_index_kline":1,"index/market/history/linear_swap_estimated_rate_kline":1,"index/market/history/linear_swap_basis":1,"linear-swap-api/v1/swap_estimated_settlement_price":1}},private:{get:{"api/v1/contract_sub_auth_list":1,"api/v1/contract_api_trading_status":1,"swap-api/v1/swap_sub_auth_list":1,"swap-api/v1/swap_api_trading_status":1,"linear-swap-api/v1/swap_sub_auth_list":1,"linear-swap-api/v1/swap_api_trading_status":1,"linear-swap-api/v1/swap_cross_position_side":1,"linear-swap-api/v1/swap_position_side":1,"linear-swap-api/v3/unified_account_info":1,"linear-swap-api/v3/fix_position_margin_change_record":1,"linear-swap-api/v3/swap_unified_account_type":1,"linear-swap-api/v3/linear_swap_overview_account_info":1,"v5/account/balance":1,"v5/account/asset_mode":1,"v5/trade/position/opens":1,"v5/trade/order/opens":1,"v5/trade/order/details":1,"v5/trade/order/history":1,"v5/trade/order":1,"v5/position/lever":1,"v5/position/mode":1,"v5/position/risk/limit":1,"v5/position/risk/limit_tier":1,"v5/market/risk/limit":1,"v5/market/assets_deduction_currency":1,"v5/market/multi_assets_margin":1},post:{"api/v1/contract_balance_valuation":1,"api/v1/contract_account_info":1,"api/v1/contract_position_info":1,"api/v1/contract_sub_auth":1,"api/v1/contract_sub_account_list":1,"api/v1/contract_sub_account_info_list":1,"api/v1/contract_sub_account_info":1,"api/v1/contract_sub_position_info":1,"api/v1/contract_financial_record":1,"api/v1/contract_financial_record_exact":1,"api/v1/contract_user_settlement_records":1,"api/v1/contract_order_limit":1,"api/v1/contract_fee":1,"api/v1/contract_transfer_limit":1,"api/v1/contract_position_limit":1,"api/v1/contract_account_position_info":1,"api/v1/contract_master_sub_transfer":1,"api/v1/contract_master_sub_transfer_record":1,"api/v1/contract_available_level_rate":1,"api/v3/contract_financial_record":1,"api/v3/contract_financial_record_exact":1,"api/v1/contract-cancel-after":1,"api/v1/contract_order":1,"api/v1/contract_batchorder":1,"api/v1/contract_cancel":1,"api/v1/contract_cancelall":1,"api/v1/contract_switch_lever_rate":30,"api/v1/lightning_close_position":1,"api/v1/contract_order_info":1,"api/v1/contract_order_detail":1,"api/v1/contract_openorders":1,"api/v1/contract_hisorders":1,"api/v1/contract_hisorders_exact":1,"api/v1/contract_matchresults":1,"api/v1/contract_matchresults_exact":1,"api/v3/contract_hisorders":1,"api/v3/contract_hisorders_exact":1,"api/v3/contract_matchresults":1,"api/v3/contract_matchresults_exact":1,"api/v1/contract_trigger_order":1,"api/v1/contract_trigger_cancel":1,"api/v1/contract_trigger_cancelall":1,"api/v1/contract_trigger_openorders":1,"api/v1/contract_trigger_hisorders":1,"api/v1/contract_tpsl_order":1,"api/v1/contract_tpsl_cancel":1,"api/v1/contract_tpsl_cancelall":1,"api/v1/contract_tpsl_openorders":1,"api/v1/contract_tpsl_hisorders":1,"api/v1/contract_relation_tpsl_order":1,"api/v1/contract_track_order":1,"api/v1/contract_track_cancel":1,"api/v1/contract_track_cancelall":1,"api/v1/contract_track_openorders":1,"api/v1/contract_track_hisorders":1,"swap-api/v1/swap_balance_valuation":1,"swap-api/v1/swap_account_info":1,"swap-api/v1/swap_position_info":1,"swap-api/v1/swap_account_position_info":1,"swap-api/v1/swap_sub_auth":1,"swap-api/v1/swap_sub_account_list":1,"swap-api/v1/swap_sub_account_info_list":1,"swap-api/v1/swap_sub_account_info":1,"swap-api/v1/swap_sub_position_info":1,"swap-api/v1/swap_financial_record":1,"swap-api/v1/swap_financial_record_exact":1,"swap-api/v1/swap_user_settlement_records":1,"swap-api/v1/swap_available_level_rate":1,"swap-api/v1/swap_order_limit":1,"swap-api/v1/swap_fee":1,"swap-api/v1/swap_transfer_limit":1,"swap-api/v1/swap_position_limit":1,"swap-api/v1/swap_master_sub_transfer":1,"swap-api/v1/swap_master_sub_transfer_record":1,"swap-api/v3/swap_financial_record":1,"swap-api/v3/swap_financial_record_exact":1,"swap-api/v1/swap-cancel-after":1,"swap-api/v1/swap_order":1,"swap-api/v1/swap_batchorder":1,"swap-api/v1/swap_cancel":1,"swap-api/v1/swap_cancelall":1,"swap-api/v1/swap_lightning_close_position":1,"swap-api/v1/swap_switch_lever_rate":30,"swap-api/v1/swap_order_info":1,"swap-api/v1/swap_order_detail":1,"swap-api/v1/swap_openorders":1,"swap-api/v1/swap_hisorders":1,"swap-api/v1/swap_hisorders_exact":1,"swap-api/v1/swap_matchresults":1,"swap-api/v1/swap_matchresults_exact":1,"swap-api/v3/swap_matchresults":1,"swap-api/v3/swap_matchresults_exact":1,"swap-api/v3/swap_hisorders":1,"swap-api/v3/swap_hisorders_exact":1,"swap-api/v1/swap_trigger_order":1,"swap-api/v1/swap_trigger_cancel":1,"swap-api/v1/swap_trigger_cancelall":1,"swap-api/v1/swap_trigger_openorders":1,"swap-api/v1/swap_trigger_hisorders":1,"swap-api/v1/swap_tpsl_order":1,"swap-api/v1/swap_tpsl_cancel":1,"swap-api/v1/swap_tpsl_cancelall":1,"swap-api/v1/swap_tpsl_openorders":1,"swap-api/v1/swap_tpsl_hisorders":1,"swap-api/v1/swap_relation_tpsl_order":1,"swap-api/v1/swap_track_order":1,"swap-api/v1/swap_track_cancel":1,"swap-api/v1/swap_track_cancelall":1,"swap-api/v1/swap_track_openorders":1,"swap-api/v1/swap_track_hisorders":1,"linear-swap-api/v1/swap_lever_position_limit":1,"linear-swap-api/v1/swap_cross_lever_position_limit":1,"linear-swap-api/v1/swap_balance_valuation":1,"linear-swap-api/v1/swap_account_info":1,"linear-swap-api/v1/swap_cross_account_info":1,"linear-swap-api/v1/swap_position_info":1,"linear-swap-api/v1/swap_cross_position_info":1,"linear-swap-api/v1/swap_account_position_info":1,"linear-swap-api/v1/swap_cross_account_position_info":1,"linear-swap-api/v1/swap_sub_auth":1,"linear-swap-api/v1/swap_sub_account_list":1,"linear-swap-api/v1/swap_cross_sub_account_list":1,"linear-swap-api/v1/swap_sub_account_info_list":1,"linear-swap-api/v1/swap_cross_sub_account_info_list":1,"linear-swap-api/v1/swap_sub_account_info":1,"linear-swap-api/v1/swap_cross_sub_account_info":1,"linear-swap-api/v1/swap_sub_position_info":1,"linear-swap-api/v1/swap_cross_sub_position_info":1,"linear-swap-api/v1/swap_financial_record":1,"linear-swap-api/v1/swap_financial_record_exact":1,"linear-swap-api/v1/swap_user_settlement_records":1,"linear-swap-api/v1/swap_cross_user_settlement_records":1,"linear-swap-api/v1/swap_available_level_rate":1,"linear-swap-api/v1/swap_cross_available_level_rate":1,"linear-swap-api/v1/swap_order_limit":1,"linear-swap-api/v1/swap_fee":1,"linear-swap-api/v1/swap_transfer_limit":1,"linear-swap-api/v1/swap_cross_transfer_limit":1,"linear-swap-api/v1/swap_position_limit":1,"linear-swap-api/v1/swap_cross_position_limit":1,"linear-swap-api/v1/swap_master_sub_transfer":1,"linear-swap-api/v1/swap_master_sub_transfer_record":1,"linear-swap-api/v1/swap_transfer_inner":1,"linear-swap-api/v3/swap_financial_record":1,"linear-swap-api/v3/swap_financial_record_exact":1,"linear-swap-api/v1/swap_order":1,"linear-swap-api/v1/swap_cross_order":1,"linear-swap-api/v1/swap_batchorder":1,"linear-swap-api/v1/swap_cross_batchorder":1,"linear-swap-api/v1/swap_cancel":1,"linear-swap-api/v1/swap_cross_cancel":1,"linear-swap-api/v1/swap_cancelall":1,"linear-swap-api/v1/swap_cross_cancelall":1,"linear-swap-api/v1/swap_switch_lever_rate":30,"linear-swap-api/v1/swap_cross_switch_lever_rate":30,"linear-swap-api/v1/swap_lightning_close_position":1,"linear-swap-api/v1/swap_cross_lightning_close_position":1,"linear-swap-api/v1/swap_order_info":1,"linear-swap-api/v1/swap_cross_order_info":1,"linear-swap-api/v1/swap_order_detail":1,"linear-swap-api/v1/swap_cross_order_detail":1,"linear-swap-api/v1/swap_openorders":1,"linear-swap-api/v1/swap_cross_openorders":1,"linear-swap-api/v1/swap_hisorders":1,"linear-swap-api/v1/swap_cross_hisorders":1,"linear-swap-api/v1/swap_hisorders_exact":1,"linear-swap-api/v1/swap_cross_hisorders_exact":1,"linear-swap-api/v1/swap_matchresults":1,"linear-swap-api/v1/swap_cross_matchresults":1,"linear-swap-api/v1/swap_matchresults_exact":1,"linear-swap-api/v1/swap_cross_matchresults_exact":1,"linear-swap-api/v1/linear-cancel-after":1,"linear-swap-api/v1/swap_switch_position_mode":1,"linear-swap-api/v1/swap_cross_switch_position_mode":1,"linear-swap-api/v3/swap_matchresults":1,"linear-swap-api/v3/swap_cross_matchresults":1,"linear-swap-api/v3/swap_matchresults_exact":1,"linear-swap-api/v3/swap_cross_matchresults_exact":1,"linear-swap-api/v3/swap_hisorders":1,"linear-swap-api/v3/swap_cross_hisorders":1,"linear-swap-api/v3/swap_hisorders_exact":1,"linear-swap-api/v3/swap_cross_hisorders_exact":1,"linear-swap-api/v3/fix_position_margin_change":1,"linear-swap-api/v3/swap_switch_account_type":1,"linear-swap-api/v3/linear_swap_fee_switch":1,"linear-swap-api/v1/swap_trigger_order":1,"linear-swap-api/v1/swap_cross_trigger_order":1,"linear-swap-api/v1/swap_trigger_cancel":1,"linear-swap-api/v1/swap_cross_trigger_cancel":1,"linear-swap-api/v1/swap_trigger_cancelall":1,"linear-swap-api/v1/swap_cross_trigger_cancelall":1,"linear-swap-api/v1/swap_trigger_openorders":1,"linear-swap-api/v1/swap_cross_trigger_openorders":1,"linear-swap-api/v1/swap_trigger_hisorders":1,"linear-swap-api/v1/swap_cross_trigger_hisorders":1,"linear-swap-api/v1/swap_tpsl_order":1,"linear-swap-api/v1/swap_cross_tpsl_order":1,"linear-swap-api/v1/swap_tpsl_cancel":1,"linear-swap-api/v1/swap_cross_tpsl_cancel":1,"linear-swap-api/v1/swap_tpsl_cancelall":1,"linear-swap-api/v1/swap_cross_tpsl_cancelall":1,"linear-swap-api/v1/swap_tpsl_openorders":1,"linear-swap-api/v1/swap_cross_tpsl_openorders":1,"linear-swap-api/v1/swap_tpsl_hisorders":1,"linear-swap-api/v1/swap_cross_tpsl_hisorders":1,"linear-swap-api/v1/swap_relation_tpsl_order":1,"linear-swap-api/v1/swap_cross_relation_tpsl_order":1,"linear-swap-api/v1/swap_track_order":1,"linear-swap-api/v1/swap_cross_track_order":1,"linear-swap-api/v1/swap_track_cancel":1,"linear-swap-api/v1/swap_cross_track_cancel":1,"linear-swap-api/v1/swap_track_cancelall":1,"linear-swap-api/v1/swap_cross_track_cancelall":1,"linear-swap-api/v1/swap_track_openorders":1,"linear-swap-api/v1/swap_cross_track_openorders":1,"linear-swap-api/v1/swap_track_hisorders":1,"linear-swap-api/v1/swap_cross_track_hisorders":1,"v5/account/asset_mode":1,"v5/trade/order":1,"v5/trade/batch_orders":1,"v5/trade/cancel_order":1,"v5/trade/cancel_batch_orders":1,"v5/trade/cancel_all_orders":1,"v5/trade/position":1,"v5/trade/position_all":1,"v5/position/lever":1,"v5/position/mode":1,"v5/account/fee_deduction_currency":1}}}},fees:{trading:{feeSide:"get",tierBased:!1,percentage:!0,maker:this.parseNumber("0.002"),taker:this.parseNumber("0.002")}},exceptions:{broad:{"contract is restricted of closing positions on API. Please contact customer service":r.OnMaintenance,maintain:r.OnMaintenance,"API key has no permission":r.PermissionDenied},exact:{403:r.AuthenticationError,1010:r.AccountNotEnabled,1003:r.AuthenticationError,1013:r.BadSymbol,1017:r.OrderNotFound,1034:r.InvalidOrder,1036:r.InvalidOrder,1039:r.InvalidOrder,1041:r.InvalidOrder,1047:r.InsufficientFunds,1048:r.InsufficientFunds,1061:r.OrderNotFound,1051:r.InvalidOrder,1066:r.BadSymbol,1067:r.InvalidOrder,1094:r.InvalidOrder,1220:r.AccountNotEnabled,1303:r.BadRequest,1461:r.InvalidOrder,4007:r.BadRequest,"bad-request":r.BadRequest,"validation-format-error":r.BadRequest,"validation-constraints-required":r.BadRequest,"base-date-limit-error":r.BadRequest,"api-not-support-temp-addr":r.PermissionDenied,timeout:r.RequestTimeout,"gateway-internal-error":r.ExchangeNotAvailable,"account-frozen-balance-insufficient-error":r.InsufficientFunds,"invalid-amount":r.InvalidOrder,"order-limitorder-amount-min-error":r.InvalidOrder,"order-limitorder-amount-max-error":r.InvalidOrder,"order-marketorder-amount-min-error":r.InvalidOrder,"order-limitorder-price-min-error":r.InvalidOrder,"order-limitorder-price-max-error":r.InvalidOrder,"order-limitorder-price-buy-min-error":r.InvalidOrder,"order-limitorder-price-buy-max-error":r.InvalidOrder,"order-limitorder-price-sell-min-error":r.InvalidOrder,"order-limitorder-price-sell-max-error":r.InvalidOrder,"order-stop-order-hit-trigger":r.InvalidOrder,"order-value-min-error":r.InvalidOrder,"order-invalid-price":r.InvalidOrder,"order-holding-limit-failed":r.InvalidOrder,"order-orderprice-precision-error":r.InvalidOrder,"order-etp-nav-price-max-error":r.InvalidOrder,"order-orderstate-error":r.OrderNotFound,"order-queryorder-invalid":r.OrderNotFound,"order-update-error":r.ExchangeNotAvailable,"api-signature-check-failed":r.AuthenticationError,"api-signature-not-valid":r.AuthenticationError,"base-record-invalid":r.OrderNotFound,"base-symbol-trade-disabled":r.BadSymbol,"base-symbol-error":r.BadSymbol,"system-maintenance":r.OnMaintenance,"base-request-exceed-frequency-limit":r.RateLimitExceeded,"rate-too-many-requests":r.RateLimitExceeded,"invalid symbol":r.BadSymbol,"symbol trade not open now":r.BadSymbol,"require-symbol":r.BadSymbol,"invalid-address":r.BadRequest,"base-currency-chain-error":r.BadRequest,"dw-insufficient-balance":r.InsufficientFunds,"base-withdraw-fee-error":r.BadRequest,"dw-withdraw-min-limit":r.BadRequest,"request limit":r.RateLimitExceeded}},precisionMode:o.kb,options:{include_OS_certificates:!1,fetchMarkets:{types:{spot:!0,linear:!0,inverse:!0}},timeDifference:0,adjustForTimeDifference:!1,fetchOHLCV:{useHistoricalEndpointForSpot:!0},withdraw:{includeFee:!1},defaultType:"spot",defaultSubType:"linear",defaultNetwork:"ERC20",defaultNetworks:{ETH:"ERC20",BTC:"BTC",USDT:"TRC20"},networks:{TRC20:"TRX",BTC:"BTC",ERC20:"ETH",SOL:"SOLANA",HRC20:"HECO",BEP20:"BSC",XMR:"XMR",LTC:"LTC",XRP:"XRP",XLM:"XLM",CRONOS:"CRO",CRO:"CRO",GLMR:"GLMR",POLYGON:"MATIC",MATIC:"MATIC",BTT:"BTT",CUBE:"CUBE",IOST:"IOST",NEO:"NEO",KLAY:"KLAY",EOS:"EOS",THETA:"THETA",NAS:"NAS",NULS:"NULS",QTUM:"QTUM",FTM:"FTM",CELO:"CELO",DOGE:"DOGE",DOGECHAIN:"DOGECHAIN",NEAR:"NEAR",STEP:"STEP",BITCI:"BITCI",CARDANO:"ADA",ADA:"ADA",ETC:"ETC",LUK:"LUK",MINEPLEX:"MINEPLEX",DASH:"DASH",ZEC:"ZEC",IOTA:"IOTA",NEON3:"NEON3",XEM:"XEM",HC:"HC",LSK:"LSK",DCR:"DCR",BTG:"BTG",STEEM:"STEEM",BTS:"BTS",ICX:"ICX",WAVES:"WAVES",CMT:"CMT",BTM:"BTM",VET:"VET",XZC:"XZC",ACT:"ACT",SMT:"SMT",BCD:"BCD",WAX:"WAX1",WICC:"WICC",ELF:"ELF",ZIL:"ZIL",ELA:"ELA",BCX:"BCX",SBTC:"SBTC",BIFI:"BIFI",CTXC:"CTXC",WAN:"WAN",POLYX:"POLYX",PAI:"PAI",WTC:"WTC",DGB:"DGB",XVG:"XVG",AAC:"AAC",AE:"AE",SEELE:"SEELE",BCV:"BCV",GRS:"GRS",ARDR:"ARDR",NANO:"NANO",ZEN:"ZEN",RBTC:"RBTC",BSV:"BSV",GAS:"GAS",XTZ:"XTZ",LAMB:"LAMB",CVNT1:"CVNT1",DOCK:"DOCK",SC:"SC",KMD:"KMD",ETN:"ETN",TOP:"TOP",IRIS:"IRIS",UGAS:"UGAS",TT:"TT",NEWTON:"NEWTON",VSYS:"VSYS",FSN:"FSN",BHD:"BHD",ONE:"ONE",EM:"EM",CKB:"CKB",EOSS:"EOSS",HIVE:"HIVE",RVN:"RVN",DOT:"DOT",KSM:"KSM",BAND:"BAND",OEP4:"OEP4",NBS:"NBS",FIS:"FIS",AR:"AR",HBAR:"HBAR",FIL:"FIL",MASS:"MASS",KAVA:"KAVA",XYM:"XYM",ENJ:"ENJ",CRUST:"CRUST",ICP:"ICP",CSPR:"CSPR",FLOW:"FLOW",IOTX:"IOTX",LAT:"LAT",APT:"APT",XCH:"XCH",MINA:"MINA",XEC:"ECASH",XPRT:"XPRT",CCA:"ACA",AOTI:"COTI",AKT:"AKT",ARS:"ARS",ASTR:"ASTR",AZERO:"AZERO",BLD:"BLD",BRISE:"BRISE",CORE:"CORE",DESO:"DESO",DFI:"DFI",EGLD:"EGLD",ERG:"ERG",ETHF:"ETHFAIR",ETHW:"ETHW",EVMOS:"EVMOS",FIO:"FIO",FLR:"FLR",FINSCHIA:"FINSCHIA",KMA:"KMA",KYVE:"KYVE",MEV:"MEV",MOVR:"MOVR",NODL:"NODL",OAS:"OAS",OSMO:"OSMO",PAYCOIN:"PAYCOIN",POKT:"POKT",PYG:"PYG",REI:"REI",SCRT:"SCRT",SDN:"SDN",SEI:"SEI",SGB:"SGB",SUI:"SUI",SXP:"SOLAR",SYS:"SYS",TENET:"TENET",TON:"TON",UNQ:"UNQ",UYU:"UYU",WEMIX:"WEMIX",XDC:"XDC",XPLA:"XPLA"},fetchOrdersByStatesMethod:"spot_private_get_v1_order_orders",createMarketBuyOrderRequiresPrice:!0,language:"en-US",broker:{id:"AA03022abc"},accountsByType:{spot:"pro",funding:"pro",future:"futures"},accountsById:{spot:"spot",margin:"margin",otc:"otc",point:"point","super-margin":"super-margin",investment:"investment",borrow:"borrow","grid-trading":"grid-trading","deposit-earning":"deposit-earning","otc-options":"otc-options"},typesByAccount:{pro:"spot",futures:"future"},spot:{stopOrderTypes:{"stop-limit":!0,"buy-stop-limit":!0,"sell-stop-limit":!0,"stop-limit-fok":!0,"buy-stop-limit-fok":!0,"sell-stop-limit-fok":!0},limitOrderTypes:{limit:!0,"buy-limit":!0,"sell-limit":!0,ioc:!0,"buy-ioc":!0,"sell-ioc":!0,"limit-maker":!0,"buy-limit-maker":!0,"sell-limit-maker":!0,"stop-limit":!0,"buy-stop-limit":!0,"sell-stop-limit":!0,"limit-fok":!0,"buy-limit-fok":!0,"sell-limit-fok":!0,"stop-limit-fok":!0,"buy-stop-limit-fok":!0,"sell-stop-limit-fok":!0}}},commonCurrencies:{NGL:"GFNGL",GET:"THEMIS",GTC:"GAMECOM",HIT:"HITCHAIN",PNT:"PENTA",SBTC:"SUPERBITCOIN",SOUL:"SOULSAVER",BIFI:"BITCOINFILE",FUD:"FTX Users Debt"},features:{spot:{sandbox:!0,createOrder:{marginMode:!0,triggerPrice:!0,triggerDirection:!0,triggerPriceType:void 0,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,iceberg:!1,selfTradePrevention:!0,leverage:!0,marketBuyByCost:!0,marketBuyRequiresPrice:!0},createOrders:{max:10},fetchMyTrades:{marginMode:!1,limit:500,daysBack:120,untilDays:2,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,trigger:!0,trailing:!1,limit:500,symbolRequired:!1},fetchOrders:{marginMode:!1,trigger:!0,trailing:!1,limit:500,untilDays:2,daysBack:180,symbolRequired:!1},fetchClosedOrders:{marginMode:!1,trigger:!0,trailing:!1,untilDays:2,limit:500,daysBack:180,daysBackCanceled:1/12,symbolRequired:!1},fetchOHLCV:{limit:1e3}},forDerivatives:{extends:"spot",createOrder:{stopLossPrice:!0,takeProfitPrice:!0,trailing:!0,hedged:!0},createOrders:{max:25},fetchOrder:{marginMode:!0},fetchOpenOrders:{marginMode:!0,trigger:!1,trailing:!1,limit:50},fetchOrders:{marginMode:!0,trigger:!1,trailing:!1,limit:50,daysBack:90},fetchClosedOrders:{marginMode:!0,trigger:!1,trailing:!1,untilDays:2,limit:50,daysBack:90,daysBackCanceled:1/12},fetchOHLCV:{limit:2e3}},swap:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}},future:{linear:{extends:"forDerivatives"},inverse:{extends:"forDerivatives"}}}})}async fetchStatus(e={}){let t;await this.loadMarkets(),[t,e]=this.handleMarketTypeAndParams("fetchStatus",void 0,e);const i=this.handleOption("fetchStatus","enableForContracts",!1);let s,r,a,o;if("spot"!==t&&i){const i=this.safeString(e,"subType",this.options.defaultSubType);"swap"===t?"linear"===i?s=await this.statusPublicSwapLinearGetApiV2SummaryJson():"inverse"===i&&(s=await this.statusPublicSwapInverseGetApiV2SummaryJson()):"future"===t?"linear"===i?s=await this.statusPublicFutureLinearGetApiV2SummaryJson():"inverse"===i&&(s=await this.statusPublicFutureInverseGetApiV2SummaryJson()):"contract"===t&&(s=await this.contractPublicGetHeartbeat())}else"spot"===t&&(s=await this.statusPublicSpotGetApiV2SummaryJson());if("contract"===t){const e=this.safeString(s,"status");r=void 0===e?void 0:"ok"===e?"ok":"maintenance",a=this.safeString(s,"ts")}else{const e=this.safeValue(s,"status",{});r="none"===this.safeString(e,"indicator")?"ok":"maintenance";const t=this.safeValue(s,"page",{}),i=this.safeString(t,"updated_at");a=this.parse8601(i),o=this.safeString(t,"url")}return{status:r,updated:a,eta:void 0,url:o,info:s}}async fetchTime(e={}){const t=this.safeValue(this.options,"fetchTime",{}),i=this.safeString(this.options,"defaultType","spot");let s,r=this.safeString(t,"type",i);return r=this.safeString(e,"type",r),s="future"===r||"swap"===r?await this.contractPublicGetApiV1Timestamp(e):await this.spotPublicGetV1CommonTimestamp(e),this.safeInteger2(s,"data","ts")}parseTradingFee(e,t=void 0){const i=this.safeString(e,"symbol");return{info:e,symbol:this.safeSymbol(i,t),maker:this.safeNumber(e,"actualMakerRate"),taker:this.safeNumber(e,"actualTakerRate"),percentage:void 0,tierBased:void 0}}async fetchTradingFee(e,t={}){await this.loadMarkets();const i=this.market(e),s={symbols:i.id},r=await this.spotPrivateGetV2ReferenceTransactFeeRate(this.extend(s,t)),a=this.safeValue(r,"data",[]),o=this.safeValue(a,0,{});return this.parseTradingFee(o,i)}async fetchTradingLimits(e=void 0,t={}){await this.loadMarkets(),void 0===e&&(e=this.symbols);const i={};for(let s=0;s=0?b:this.safeStringN(e,["trade_id","trade-id","id"]),this.safeTrade({id:y,info:e,order:o,timestamp:r,datetime:this.iso8601(r),symbol:s,type:d,side:n,takerOrMaker:c,price:h,amount:l,cost:u,fee:p},t)}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,a={}){let o,n;if(void 0!==t&&(o=this.market(t)),[n,a]=this.handleMarketTypeAndParams("fetchOrderTrades",o,a),"spot"!==n)throw new r.NotSupported(this.id+" fetchOrderTrades() is only supported for spot markets");return await this.fetchSpotOrderTrades(e,t,i,s,a)}async fetchSpotOrderTrades(e,t=void 0,i=void 0,s=void 0,r={}){await this.loadMarkets();const a={"order-id":e},o=await this.spotPrivateGetV1OrderOrdersOrderIdMatchresults(this.extend(a,r));return this.parseTrades(o.data,void 0,i,s)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let a,o,n=!1;if([n,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),n)return await this.fetchPaginatedCallDynamic("fetchMyTrades",e,t,i,s);void 0!==e&&(a=this.market(e)),[o,s]=this.handleMarketTypeAndParams("fetchMyTrades",a,s);let d,c={};if("spot"===o)void 0!==e&&(a=this.market(e),c.symbol=a.id),void 0!==i&&(c.size=i),void 0!==t&&(c["start-time"]=t),[c,s]=this.handleUntilOption("end-time",c,s),d=await this.spotPrivateGetV1OrderMatchresults(this.extend(c,s));else{if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchMyTrades() requires a symbol argument");if(c.contract=a.id,c.trade_type=0,void 0!==t&&(c.start_time=t),[c,s]=this.handleUntilOption("end_time",c,s),void 0!==i&&(c.page_size=i),a.linear){let e;[e,s]=this.handleMarginModeAndParams("fetchMyTrades",s),e=void 0===e?"cross":e,"isolated"===e?d=await this.contractPrivatePostLinearSwapApiV3SwapMatchresultsExact(this.extend(c,s)):"cross"===e&&(d=await this.contractPrivatePostLinearSwapApiV3SwapCrossMatchresultsExact(this.extend(c,s)))}else if(a.inverse)if("future"===o)c.symbol=a.settleId,d=await this.contractPrivatePostApiV3ContractMatchresultsExact(this.extend(c,s));else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchMyTrades() does not support "+o+" markets");d=await this.contractPrivatePostSwapApiV3SwapMatchresultsExact(this.extend(c,s))}}let h=this.safeValue(d,"data");return Array.isArray(h)||(h=this.safeValue(h,"trades")),this.parseTrades(h,a,t,i)}async fetchTrades(e,t=void 0,i=1e3,s={}){await this.loadMarkets();const r=this.market(e),a={};let o;void 0!==i&&(a.size=Math.min(i,2e3)),r.future?r.inverse?(a.symbol=r.id,o=await this.contractPublicGetMarketHistoryTrade(this.extend(a,s))):r.linear&&(a.contract_code=r.id,o=await this.contractPublicGetLinearSwapExMarketHistoryTrade(this.extend(a,s))):r.swap?(a.contract_code=r.id,r.inverse?o=await this.contractPublicGetSwapExMarketHistoryTrade(this.extend(a,s)):r.linear&&(o=await this.contractPublicGetLinearSwapExMarketHistoryTrade(this.extend(a,s)))):(a.symbol=r.id,o=await this.spotPublicGetMarketHistoryTrade(this.extend(a,s)));const n=this.safeValue(o,"data",[]);let d=[];for(let e=0;e=0?h=this.safeString(e,"field-cash-amount"):(l=this.safeString2(e,"volume","amount"),h=this.safeStringN(e,["filled-cash-amount","field-cash-amount","trade_turnover"]));const u=this.safeStringN(e,["filled-amount","field-amount","trade_volume"]),p=this.safeString2(e,"price","order_price");let f,m=this.safeString2(e,"filled-fees","field-fees");if(m=this.safeString(e,"fee",m),void 0!==m){let i;const s=this.safeString(e,"fee_asset");i=void 0!==s?this.safeCurrencyCode(s):"sell"===a?t.quote:t.base,f={cost:m,currency:i}}const g=this.safeString(e,"trade_avg_price"),v=this.safeValue(e,"trades"),y=this.safeInteger(e,"reduce_only");let b;return void 0!==y&&(b=0!==y),this.safeOrder({info:e,id:r,clientOrderId:c,timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,symbol:t.symbol,type:o,timeInForce:void 0,postOnly:void 0,side:a,price:p,triggerPrice:this.safeString2(e,"stop-price","trigger_price"),average:g,cost:h,amount:l,filled:u,remaining:void 0,status:s,reduceOnly:b,fee:f,trades:v},t)}async createMarketBuyOrderWithCost(e,t,i={}){await this.loadMarkets();if(!this.market(e).spot)throw new r.NotSupported(this.id+" createMarketBuyOrderWithCost() supports spot orders only");return i.createMarketBuyOrderRequiresPrice=!1,await this.createOrder(e,"market","buy",t,void 0,i)}async createTrailingPercentOrder(e,t,i,s,a=void 0,o=void 0,n=void 0,d={}){if(void 0===o)throw new r.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingPercent argument");if(void 0===n)throw new r.ArgumentsRequired(this.id+" createTrailingPercentOrder() requires a trailingTriggerPrice argument");return d.trailingPercent=o,d.trailingTriggerPrice=n,await this.createOrder(e,t,i,s,a,d)}async createSpotOrderRequest(e,t,i,s,o=void 0,n={}){await this.loadMarkets(),await this.loadAccounts();const d=this.market(e);let c;[c,n]=this.handleMarginModeAndParams("createOrder",n);const h={"account-id":await this.fetchAccountIdByType(d.type,c,e),symbol:d.id};let l=t.replace("buy-","");l=l.replace("sell-","");const u=this.safeValue(this.options,d.type,{}),p=this.safeStringN(n,["triggerPrice","stopPrice","stop-price"]);if(void 0===p){if(l in this.safeValue(u,"stopOrderTypes",{}))throw new r.ArgumentsRequired(this.id+" createOrder() requires a triggerPrice for a trigger order")}else{const s="sell"===i?"lte":"gte",a=this.safeString(n,"operator",s);if(h["stop-price"]=this.priceToPrecision(e,p),h.operator=a,"limit"===l||"limit-fok"===l)l="stop-"+l;else if("stop-limit"!==l&&"stop-limit-fok"!==l)throw new r.NotSupported(this.id+" createOrder() does not support "+t+" orders")}let f;[f,n]=this.handlePostOnly("market"===l,"limit-maker"===l,n),f&&(l="limit-maker");const m=this.safeString(n,"timeInForce","GTC");"FOK"===m?l+="-fok":"IOC"===m&&(l="ioc"),h.type=i+"-"+l;const g=this.safeString2(n,"clientOrderId","client-order-id");if(void 0===g){const e=this.safeValue(this.options,"broker",{}),t=this.safeString(e,"id");h["client-order-id"]=t+this.uuid()}else h["client-order-id"]=g;if("cross"===c?h.source="super-margin-api":"isolated"===c?h.source="margin-api":"c2c"===c&&(h.source="c2c-margin-api"),"market"===l&&"buy"===i){let t,i=!0;[i,n]=this.handleOptionAndParams(n,"createOrder","createMarketBuyOrderRequiresPrice",!0);const d=this.safeNumber(n,"cost");if(n=this.omit(n,"cost"),void 0!==d)t=this.amountToPrecision(e,d);else if(i){if(void 0===o)throw new r.InvalidOrder(this.id+" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument");{const i=this.numberToString(s),r=this.numberToString(o);t=this.amountToPrecision(e,a.Y.stringMul(i,r))}}else t=this.amountToPrecision(e,s);h.amount=t}else h.amount=this.amountToPrecision(e,s);return l in this.safeValue(u,"limitOrderTypes",{})&&(h.price=this.priceToPrecision(e,o)),n=this.omit(n,["triggerPrice","stopPrice","stop-price","clientOrderId","client-order-id","operator","timeInForce"]),this.extend(h,n)}createContractOrderRequest(e,t,i,s,r=void 0,o={}){const n={contract_code:this.market(e).id,volume:this.amountToPrecision(e,s),direction:i};let d;[d,o]=this.handlePostOnly("market"===t,"post_only"===t,o),d&&(t="post_only");const c=this.safeString(o,"timeInForce","GTC");"FOK"===c?t="fok":"IOC"===c&&(t="ioc");const h=this.safeNumberN(o,["triggerPrice","stopPrice","trigger_price"]),l=this.safeNumber2(o,"stopLossPrice","sl_trigger_price"),u=this.safeNumber2(o,"takeProfitPrice","tp_trigger_price"),p=this.safeString2(o,"trailingPercent","callback_rate"),f=this.safeNumber(o,"trailingTriggerPrice",r),m=void 0!==p,g=void 0!==l,v=void 0!==u;if(void 0!==h){const t=this.safeString2(o,"triggerType","trigger_type","le");n.trigger_type=t,n.trigger_price=this.priceToPrecision(e,h),void 0!==r&&(n.order_price=this.priceToPrecision(e,r))}else if(g||v)g?(n.sl_order_price_type=t,n.sl_trigger_price=this.priceToPrecision(e,l),void 0!==r&&(n.sl_order_price=this.priceToPrecision(e,r))):(n.tp_order_price_type=t,n.tp_trigger_price=this.priceToPrecision(e,u),void 0!==r&&(n.tp_order_price=this.priceToPrecision(e,r)));else if(m){const e=a.Y.stringDiv(p,"100");n.callback_rate=this.parseToNumeric(e),n.active_price=f,n.order_price_type=this.safeString(o,"order_price_type","formula_price")}else{const i=this.safeInteger2(o,"client_order_id","clientOrderId");void 0!==i&&(n.client_order_id=i,o=this.omit(o,["clientOrderId"])),"limit"!==t&&"ioc"!==t&&"fok"!==t&&"post_only"!==t||void 0!==r&&(n.price=this.priceToPrecision(e,r))}const y=this.safeBool2(o,"reduceOnly","reduce_only",!1);g||v||(y&&(n.reduce_only=1),n.lever_rate=this.safeIntegerN(o,["leverRate","lever_rate","leverage"],1),m||(n.order_price_type=t));this.safeBool(o,"hedged",!1)&&(n.offset=y?"close":"open");const b=this.safeValue(this.options,"broker",{}),w=this.safeString(b,"id");return n.channel_code=w,o=this.omit(o,["reduceOnly","triggerPrice","stopPrice","stopLossPrice","takeProfitPrice","triggerType","leverRate","timeInForce","leverage","trailingPercent","trailingTriggerPrice","hedged"]),this.extend(n,o)}async createOrder(e,t,i,s,a=void 0,o={}){await this.loadMarkets();const n=this.market(e),d=this.safeNumberN(o,["triggerPrice","stopPrice","trigger_price"]),c=this.safeNumber2(o,"stopLossPrice","sl_trigger_price"),h=this.safeNumber2(o,"takeProfitPrice","tp_trigger_price"),l=void 0!==this.safeNumber(o,"trailingPercent"),u=void 0!==d,p=void 0!==c,f=void 0!==h;let m,g,v;if(n.spot){if(l)throw new r.NotSupported(this.id+" createOrder() does not support trailing orders for spot markets");const n=await this.createSpotOrderRequest(e,t,i,s,a,o);m=await this.spotPrivatePostV1OrderOrdersPlace(n)}else{let d=this.createContractOrderRequest(e,t,i,s,a,o);if(n.linear){let e;[e,d]=this.handleMarginModeAndParams("createOrder",d),e=void 0===e?"cross":e,"isolated"===e?m=u?await this.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(d):p||f?await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(d):l?await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(d):await this.contractPrivatePostLinearSwapApiV1SwapOrder(d):"cross"===e&&(m=u?await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(d):p||f?await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(d):l?await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder(d):await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(d))}else if(n.inverse){if(void 0===this.safeString(o,"offset"))throw new r.ArgumentsRequired(this.id+' createOrder () requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse markets');n.swap?m=u?await this.contractPrivatePostSwapApiV1SwapTriggerOrder(d):p||f?await this.contractPrivatePostSwapApiV1SwapTpslOrder(d):l?await this.contractPrivatePostSwapApiV1SwapTrackOrder(d):await this.contractPrivatePostSwapApiV1SwapOrder(d):n.future&&(m=u?await this.contractPrivatePostApiV1ContractTriggerOrder(d):p||f?await this.contractPrivatePostApiV1ContractTpslOrder(d):l?await this.contractPrivatePostApiV1ContractTrackOrder(d):await this.contractPrivatePostApiV1ContractOrder(d))}}return n.spot?this.safeOrder({info:m,id:this.safeString(m,"data"),timestamp:void 0,datetime:void 0,lastTradeTimestamp:void 0,status:void 0,symbol:void 0,type:t,side:i,price:a,amount:s,filled:void 0,remaining:void 0,cost:void 0,trades:void 0,fee:void 0,clientOrderId:void 0,average:void 0},n):(p?(g=this.safeValue(m,"data",{}),v=this.safeValue(g,"sl_order",{})):f?(g=this.safeValue(m,"data",{}),v=this.safeValue(g,"tp_order",{})):v=this.safeValue(m,"data",{}),this.parseOrder(v,n))}async createOrders(e,t={}){await this.loadMarkets();const i=[];let s,a,o;for(let t=0;t0?this.parseToInt(e/1e3):0};return await this.v2PrivatePostAlgoOrdersCancelAllAfter(this.extend(i,t))}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address"),s=this.safeString(e,"addressTag"),r=this.safeString(e,"currency");t=this.safeCurrency(r,t);const a=this.safeCurrencyCode(r,t),o=this.safeString(e,"note"),n=this.safeString(e,"chain");return this.checkAddress(i),{currency:a,address:i,tag:s,network:this.networkIdToCode(n),note:o,info:e}}async fetchDepositAddressesByNetwork(e,t={}){await this.loadMarkets();const i=this.currency(e),s={currency:i.id},r=await this.spotPrivateGetV2AccountDepositAddress(this.extend(s,t)),a=this.safeValue(r,"data",[]),o=this.parseDepositAddresses(a,[i.code],!1);return this.indexBy(o,"network")}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e),[s,r]=this.handleNetworkCodeAndParams(t),a=await this.fetchDepositAddressesByNetwork(e,r);return a[this.selectNetworkCodeFromUnifiedNetworks(i.code,s,a)]}async fetchWithdrawAddresses(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.currency(e),a={currency:r.id},o=await this.spotPrivateGetV2AccountWithdrawAddress(this.extend(a,s)),n=this.safeValue(o,"data",[]),d=this.parseDepositAddresses(n,[r.code],!1),c=[];for(let e=0;e100)&&(i=100),await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a={type:"deposit",direct:"next",from:0};void 0!==r&&(a.currency=r.id),void 0!==i&&(a.size=i);const o=await this.spotPrivateGetV1QueryDepositWithdraw(this.extend(a,s));return this.parseTransactions(o.data,r,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){let r;(void 0===i||i>100)&&(i=100),await this.loadMarkets(),void 0!==e&&(r=this.currency(e));const a={type:"withdraw",direct:"next",from:0};void 0!==r&&(a.currency=r.id),void 0!==i&&(a.size=i);const o=await this.spotPrivateGetV1QueryDepositWithdraw(this.extend(a,s));return this.parseTransactions(o.data,r,t,i)}parseTransaction(e,t=void 0){const i=this.safeInteger(e,"created-at"),s=this.safeCurrencyCode(this.safeString(e,"currency"));let r=this.safeString(e,"type");"withdraw"===r&&(r="withdrawal");let o=this.safeString(e,"fee");void 0!==o&&(o=a.Y.stringAbs(o));const n=this.safeString(e,"chain");let d=this.safeString(e,"tx-hash");"ETH"===n&&d.indexOf("0x")<0&&(d="0x"+d);const c="FAST"===this.safeString(e,"sub-type");return{info:e,id:this.safeString2(e,"id","data"),txid:d,timestamp:i,datetime:this.iso8601(i),network:this.networkIdToCode(n),address:this.safeString(e,"address"),addressTo:void 0,addressFrom:void 0,tag:this.safeString(e,"address-tag"),tagTo:void 0,tagFrom:void 0,type:r,amount:this.safeNumber(e,"amount"),currency:s,status:this.parseTransactionStatus(this.safeString(e,"state")),updated:this.safeInteger(e,"updated-at"),comment:void 0,internal:c,fee:{currency:s,cost:this.parseNumber(o),rate:void 0}}}parseTransactionStatus(e){return this.safeString({unknown:"failed",confirming:"pending",confirmed:"ok",safe:"ok",orphan:"failed",submitted:"pending",canceled:"canceled",reexamine:"pending",reject:"failed",pass:"pending","wallet-reject":"failed","confirm-error":"failed",repealed:"failed","wallet-transfer":"pending","pre-transfer":"pending",verifying:"pending"},e,e)}async withdraw(e,t,i,s=void 0,o={}){[s,o]=this.handleWithdrawTagAndParams(s,o),await this.loadMarkets(),this.checkAddress(i);const n=this.currency(e),d={address:i,currency:n.id.toLowerCase()};let c;void 0!==s&&(d["addr-tag"]=s),[c,o]=this.handleNetworkCodeAndParams(o),void 0!==c&&(d.chain=this.networkCodeToId(c,e)),t=parseFloat(this.currencyToPrecision(e,t,c));const h=this.safeValue(this.options,"withdraw",{});if(this.safeBool(h,"includeFee",!1)){let i=this.safeNumber(o,"fee");if(void 0===i){const e=await this.fetchCurrencies();this.currencies=this.mapToSafeMap(this.deepExtend(this.currencies,e));const t=this.safeValue(n.networks,c,{});if(i=this.safeNumber(t,"fee"),void 0===i)throw new r.ArgumentsRequired(this.id+' withdraw() function can not find withdraw fee for chosen network. You need to re-load markets with "exchange.loadMarkets(true)", or provide the "fee" parameter')}const s=this.currencyToPrecision(e,i,c);o=this.omit(o,"fee");const h=this.numberToString(t),l=a.Y.stringSub(h,s),u=parseFloat(l);d.fee=parseFloat(s),t=parseFloat(this.currencyToPrecision(e,u,c))}d.amount=t;const l=await this.spotPrivatePostV1DwWithdrawApiCreate(this.extend(d,o));return this.parseTransaction(l,n)}parseTransfer(e,t=void 0){return{info:e,id:this.safeString(e,"data"),timestamp:void 0,datetime:void 0,currency:this.safeCurrencyCode(void 0,t),amount:void 0,fromAccount:void 0,toAccount:void 0,status:void 0}}async transfer(e,t,i,s,a={}){await this.loadMarkets();const o=this.currency(e),n={currency:o.id,amount:parseFloat(this.currencyToPrecision(e,t))};let d;[d,a]=this.handleSubTypeAndParams("transfer",void 0,a);let c=this.convertTypeToAccount(i),h=this.convertTypeToAccount(s);const l="cross"===h,u="cross"===c,p=this.inArray(h,this.ids),f=this.inArray(c,this.ids),m="pro"===c,g="pro"===h;if(m&&g)throw new r.BadRequest(this.id+" transfer () cannot make a transfer between "+i+" and "+s);let v;if("futures"===c||"futures"===h){let e=c+"-to-"+h;e=this.safeString(a,"type",e),n.type=e,v=await this.spotPrivatePostV1FuturesTransfer(this.extend(n,a))}else if(m&&l)v=await this.privatePostCrossMarginTransferIn(this.extend(n,a));else if(u&&g)v=await this.privatePostCrossMarginTransferOut(this.extend(n,a));else if(m&&p)n.symbol=h,v=await this.privatePostDwTransferInMargin(this.extend(n,a));else if(f&&g)n.symbol=c,v=await this.privatePostDwTransferOutMargin(this.extend(n,a));else{if("linear"===d){"swap"===c||"linear-swap"===i?c="linear-swap":h="linear-swap";let e=this.safeString(a,"symbol");a=this.omit(a,"symbol"),void 0!==e?(e=this.marketId(e),n["margin-account"]=e):n["margin-account"]="USDT"}n.from=m?"spot":c,n.to=g?"spot":h,v=await this.v2PrivatePostAccountTransfer(this.extend(n,a))}return this.parseTransfer(v,o)}async fetchIsolatedBorrowRates(e={}){await this.loadMarkets();const t=await this.spotPrivateGetV1MarginLoanInfo(e),i=this.safeValue(t,"data",[]);return this.parseIsolatedBorrowRates(i)}parseIsolatedBorrowRate(e,t=void 0){const i=this.safeString(e,"symbol"),s=this.safeSymbol(i,t),r=this.safeValue(e,"currencies",[]),a=this.safeValue(r,0),o=this.safeValue(r,1),n=this.safeString(a,"currency"),d=this.safeString(o,"currency");return{symbol:s,base:this.safeCurrencyCode(n),baseRate:this.safeNumber(a,"actual-rate"),quote:this.safeCurrencyCode(d),quoteRate:this.safeNumber(o,"actual-rate"),period:864e5,timestamp:void 0,datetime:void 0,info:e}}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");let a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),a)return await this.fetchPaginatedCallCursor("fetchFundingRateHistory",e,t,i,s,"current_page","page_index",1,50);await this.loadMarkets();const o=this.market(e),n={contract_code:o.id};let d;if(n.page_size=void 0!==i?i:50,o.inverse)d=await this.contractPublicGetSwapApiV1SwapHistoricalFundingRate(this.extend(n,s));else{if(!o.linear)throw new r.NotSupported(this.id+" fetchFundingRateHistory() supports inverse and linear swaps only");d=await this.contractPublicGetLinearSwapApiV1SwapHistoricalFundingRate(this.extend(n,s))}const c=this.safeValue(d,"data"),h=this.safeValue(c,"current_page"),l=this.safeValue(c,"data",[]),u=[];for(let e=0;e0){const t=this.safeString(e,0);i=this.market(t)}}if([s,t]=this.handleMarginModeAndParams("fetchPositions",t,"cross"),[a,t]=this.handleSubTypeAndParams("fetchPositions",i,t,"linear"),[o,t]=this.handleMarketTypeAndParams("fetchPositions",i,t),"spot"===o&&(o="future"),"linear"===a)if("isolated"===s)n=await this.contractPrivatePostLinearSwapApiV1SwapPositionInfo(t);else{if("cross"!==s)throw new r.NotSupported(this.id+" fetchPositions() not support this market type");n=await this.contractPrivatePostLinearSwapApiV1SwapCrossPositionInfo(t)}else if("future"===o)n=await this.contractPrivatePostApiV1ContractPositionInfo(t);else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchPositions() not support this market type");n=await this.contractPrivatePostSwapApiV1SwapPositionInfo(t)}const d=this.safeValue(n,"data",[]),c=this.safeInteger(n,"ts"),h=[];for(let e=0;e0){const t=this.safeString(e,0);i=this.market(t)}}const s={};let r,a,o;[r,t]=this.handleSubTypeAndParams("fetchPositions",i,t,"linear"),[a,t]=this.handleMarketTypeAndParams("fetchPositions",i,t),"future"===a?o=await this.contractPublicGetApiV1ContractOpenInterest(this.extend(s,t)):"inverse"===r?o=await this.contractPublicGetSwapApiV1SwapOpenInterest(this.extend(s,t)):(s.contract_type="swap",o=await this.contractPublicGetLinearSwapApiV1SwapOpenInterest(this.extend(s,t)));const n=this.safeList(o,"data",[]);return this.parseOpenInterests(n,e)}async fetchOpenInterest(e,t={}){await this.loadMarkets();const i=this.market(e);if(!i.contract)throw new r.BadRequest(this.id+" fetchOpenInterest() supports contract markets only");if(i.option)throw new r.NotSupported(this.id+" fetchOpenInterest() does not currently support option markets");const s={contract_code:i.id};let a;i.future?(s.contract_type=this.safeString(i.info,"contract_type"),s.symbol=i.baseId,a=await this.contractPublicGetApiV1ContractOpenInterest(this.extend(s,t))):i.linear?(s.contract_type="swap",a=await this.contractPublicGetLinearSwapApiV1SwapOpenInterest(this.extend(s,t))):a=await this.contractPublicGetSwapApiV1SwapOpenInterest(this.extend(s,t));const o=this.safeValue(a,"data",[]),n=this.parseOpenInterest(o[0],i),d=this.safeInteger(a,"ts");return n.timestamp=d,n.datetime=this.iso8601(d),n}parseOpenInterest(e,t=void 0){const i=this.safeInteger(e,"ts"),s=this.safeNumber(e,"volume"),r=this.safeNumber(e,"value"),a=this.safeString(e,"contract_code");return this.safeOpenInterest({symbol:this.safeSymbol(a,t),baseVolume:s,quoteVolume:r,openInterestAmount:s,openInterestValue:r,timestamp:i,datetime:this.iso8601(i),info:e},t)}async borrowIsolatedMargin(e,t,i,s={}){await this.loadMarkets();const r=this.currency(t),a=this.market(e),o={currency:r.id,amount:this.currencyToPrecision(t,i),symbol:a.id},n=await this.privatePostMarginOrders(this.extend(o,s)),d=this.parseMarginLoan(n,r);return this.extend(d,{amount:i,symbol:e})}async borrowCrossMargin(e,t,i={}){await this.loadMarkets();const s=this.currency(e),r={currency:s.id,amount:this.currencyToPrecision(e,t)},a=await this.privatePostCrossMarginOrders(this.extend(r,i)),o=this.parseMarginLoan(a,s);return this.extend(o,{amount:t})}async repayIsolatedMargin(e,t,i,s={}){await this.loadMarkets();const r=this.currency(t),a=await this.fetchAccountIdByType("spot","isolated",e,s),o={currency:r.id,amount:this.currencyToPrecision(t,i),accountId:a},n=await this.v2PrivatePostAccountRepayment(this.extend(o,s)),d=this.safeValue(n,"Data",[]),c=this.safeValue(d,0),h=this.parseMarginLoan(c,r);return this.extend(h,{amount:i,symbol:e})}async repayCrossMargin(e,t,i={}){await this.loadMarkets();const s=this.currency(e),r=await this.fetchAccountIdByType("spot","cross",void 0,i),a={currency:s.id,amount:this.currencyToPrecision(e,t),accountId:r},o=await this.v2PrivatePostAccountRepayment(this.extend(a,i)),n=this.safeValue(o,"Data",[]),d=this.safeValue(n,0),c=this.parseMarginLoan(d,s);return this.extend(c,{amount:t})}parseMarginLoan(e,t=void 0){const i=this.safeInteger(e,"repayTime");return{id:this.safeString2(e,"repayId","data"),currency:this.safeCurrencyCode(void 0,t),amount:void 0,symbol:void 0,timestamp:i,datetime:this.iso8601(i),info:e}}async fetchSettlementHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new r.ArgumentsRequired(this.id+" fetchSettlementHistory() requires a symbol argument");const a=this.safeInteger(s,"until");s=this.omit(s,["until"]);const o=this.market(e),n={};let d;o.future?n.symbol=o.baseId:n.contract_code=o.id,void 0!==t&&(n.start_at=t),void 0!==i&&(n.page_size=i),void 0!==a&&(n.end_at=a),d=o.swap?o.linear?await this.contractPublicGetLinearSwapApiV1SwapSettlementRecords(this.extend(n,s)):await this.contractPublicGetSwapApiV1SwapSettlementRecords(this.extend(n,s)):await this.contractPublicGetApiV1ContractSettlementRecords(this.extend(n,s));const c=this.safeValue(d,"data"),h=this.safeValue(c,"settlement_record"),l=this.parseSettlements(h,o);return this.sortBy(l,"timestamp")}async fetchDepositWithdrawFees(e=void 0,t={}){await this.loadMarkets();const i=await this.spotPublicGetV2ReferenceCurrencies(t),s=this.safeList(i,"data");return this.parseDepositWithdrawFees(s,e,"currency")}parseDepositWithdrawFee(e,t=void 0){const i=this.safeValue(e,"chains",[]);let s=this.depositWithdrawFee(e);for(let e=0;e{"use strict";i.d(t,{A:()=>r});var s=i(9946);class r extends s.A{describe(){return this.deepExtend(super.describe(),{id:"huobi",alias:!0})}}},1936:(e,t,i)=>{"use strict";i.d(t,{A:()=>h});var s=i(9023),r=i(2079),a=i(5147),o=i(1579),n=i(8432),d=i(987),c=i(8283);class h extends s.A{describe(){return this.deepExtend(super.describe(),{id:"hyperliquid",name:"Hyperliquid",countries:[],version:"v1",rateLimit:50,certified:!0,pro:!0,dex:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!0,future:!0,option:!1,addMargin:!0,borrowCrossMargin:!1,borrowIsolatedMargin:!1,cancelAllOrders:!1,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,cancelOrdersForSymbols:!0,closeAllPositions:!1,closePosition:!1,createMarketBuyOrderWithCost:!1,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!0,editOrders:!0,fetchAccounts:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingRate:!1,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchMarginMode:void 0,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyLiquidations:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenInterestHistory:!1,fetchOpenInterests:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!1,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:"emulated",fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!0,reduceMargin:!0,repayCrossMargin:!1,repayIsolatedMargin:!1,sandbox:!0,setLeverage:!0,setMarginMode:!0,setPositionMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":"1m","3m":"3m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","2h":"2h","4h":"4h","8h":"8h","12h":"12h","1d":"1d","3d":"3d","1w":"1w","1M":"1M"},hostname:"hyperliquid.xyz",urls:{logo:"https://github.com/ccxt/ccxt/assets/43336371/b371bc6c-4a8c-489f-87f4-20a913dd8d4b",api:{public:"https://api.{hostname}",private:"https://api.{hostname}"},test:{public:"https://api.hyperliquid-testnet.xyz",private:"https://api.hyperliquid-testnet.xyz"},www:"https://hyperliquid.xyz",doc:"https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api",fees:"https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees",referral:"https://app.hyperliquid.xyz/"},api:{public:{post:{info:{cost:20,byType:{l2Book:2,allMids:2,clearinghouseState:2,orderStatus:2,spotClearinghouseState:2,exchangeStatus:2,candleSnapshot:4}}}},private:{post:{exchange:1}}},fees:{swap:{taker:this.parseNumber("0.00045"),maker:this.parseNumber("0.00015")},spot:{taker:this.parseNumber("0.0007"),maker:this.parseNumber("0.0004")}},requiredCredentials:{apiKey:!1,secret:!1,walletAddress:!0,privateKey:!0},exceptions:{exact:{},broad:{"Price must be divisible by tick size.":r.InvalidOrder,"Order must have minimum value of $10":r.InvalidOrder,"Insufficient margin to place order.":r.InsufficientFunds,"Reduce only order would increase position.":r.InvalidOrder,"Post only order would have immediately matched,":r.InvalidOrder,"Order could not immediately match against any resting orders.":r.InvalidOrder,"Invalid TP/SL price.":r.InvalidOrder,"No liquidity available for market order.":r.InvalidOrder,"Order was never placed, already canceled, or filled.":r.OrderNotFound,"User or API Wallet ":r.InvalidOrder,"Order has invalid size":r.InvalidOrder,"Order price cannot be more than 80% away from the reference price":r.InvalidOrder,"Order has zero size.":r.InvalidOrder,"Insufficient spot balance asset":r.InsufficientFunds,"Insufficient balance for withdrawal":r.InsufficientFunds,"Insufficient balance for token transfer":r.InsufficientFunds}},precisionMode:o.kb,commonCurrencies:{},options:{defaultType:"swap",sandboxMode:!1,defaultSlippage:.05,marketHelperProps:["hip3TokensByName","cachedCurrenciesById"],zeroAddress:"0x0000000000000000000000000000000000000000",spotCurrencyMapping:{UDZ:"2Z",UBONK:"BONK",UBTC:"BTC",UETH:"ETH",UFART:"FARTCOIN",HPENGU:"PENGU",UPUMP:"PUMP",USOL:"SOL",UUUSPX:"SPX",USDT0:"USDT",XAUT0:"XAUT",UXPL:"XPL"},fetchMarkets:{types:["spot","swap","hip3"],hip3:{limit:10,dexes:[]}}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:{triggerPriceType:{last:!1,mark:!1,index:!1},triggerPrice:!0,type:!0,price:!0},timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:{max:1e3},fetchMyTrades:{marginMode:!1,limit:2e3,daysBack:void 0,untilDays:void 0,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:2e3,trigger:!1,trailing:!1,symbolRequired:!0},fetchOrders:{marginMode:!1,limit:2e3,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:{marginMode:!1,limit:2e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:5e3}},spot:{extends:"default"},forPerps:{extends:"default",createOrder:{stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0}},swap:{linear:{extends:"forPerps"},inverse:{extends:"forPerps"}},future:{linear:{extends:"forPerps"},inverse:{extends:"forPerps"}}}})}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}market(e){if(void 0===this.markets)throw new r.ExchangeError(this.id+" markets not loaded");if(void 0!==e&&!(e in this.markets)){const t=e.split("/"),i=this.safeString(t,0),s=this.safeDict(this.options,"spotCurrencyMapping",{});if(i in s){const e=this.safeString(s,i),r=this.safeString(t,1),a=this.safeCurrencyCode(e)+"/"+r;if(a in this.markets)return this.markets[a]}}return super.market(e)}async fetchStatus(e={}){const t=await this.publicPostInfo(this.extend({type:"exchangeStatus"},e));return{status:void 0===this.safeString(t,"specialStatuses")?"ok":"maintenance",updated:this.safeInteger(t,"time"),eta:void 0,url:void 0,info:t}}async fetchTime(e={}){const t=await this.publicPostInfo(this.extend({type:"exchangeStatus"},e));return this.safeInteger(t,"time")}async fetchCurrencies(e={}){this.checkRequiredCredentials(!1)&&await this.initializeClient();const t=await this.publicPostInfo(this.extend({type:"spotMeta"},e)),i=this.safeList(t,"tokens",[]);this.options.cachedCurrenciesById={};const s={};for(let e=0;e0)d>0&&(s=o);else{const e=t.length;for(let i=1;i=e);i++){const e=this.safeDict(t,i,{});if(void 0===e)continue;const r=this.safeString(e,"name");s.push(r)}}const c=[];for(let t=0;t1)return this.safeString(t,0)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r,a;[r,s]=this.handlePublicAddress("fetchOpenOrders",s),[a,s]=this.handleOptionAndParams(s,"fetchOpenOrders","method","frontendOpenOrders"),await this.loadMarkets();const o={type:a,user:r};let n;if(void 0!==e){n=this.market(e);const t=this.getDexFromHip3Symbol(n);void 0!==t&&(o.dex=t)}const d=await this.publicPostInfo(this.extend(o,s)),c=[];for(let e=0;e=34;o.oid=t?e:this.parseToNumeric(e)}const n=await this.publicPostInfo(this.extend(o,i)),d=this.safeDict(n,"order");return this.parseOrder(d,r)}parseOrder(e,t=void 0){if(void 0!==this.safeString(e,"error"))return this.safeOrder({info:e,status:"rejected"});let i=this.safeDictN(e,["order","resting","filled"]);void 0===i&&(i=e);const s=this.safeDict(e,"filled",{}),r=this.safeString(i,"coin");let o;void 0!==r&&(o=this.coinToMarketId(r));const n=(t=void 0===this.safeString(i,"id")?this.safeMarket(o,void 0):this.safeMarket(o,t)).symbol,d=this.safeInteger(i,"timestamp"),c=this.safeString2(e,"status","ccxtStatus");e=this.omit(e,["ccxtStatus"]);let h=this.safeString(i,"side");void 0!==h&&(h="A"===h?"sell":"buy");const l=this.safeString2(i,"origSz","totalSz"),u=this.safeString(i,"sz"),p=this.safeStringUpper(i,"tif");let f;return void 0!==p&&(f="ALO"===p),this.safeOrder({info:e,id:this.safeString(i,"oid"),clientOrderId:this.safeString(i,"cloid"),timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,lastUpdateTimestamp:this.safeInteger(e,"statusTimestamp"),symbol:n,type:this.parseOrderType(this.safeStringLower(i,"orderType")),timeInForce:p,postOnly:f,reduceOnly:this.safeBool(i,"reduceOnly"),side:h,price:this.safeString(i,"limitPx"),triggerPrice:this.safeBool(i,"isTrigger")?this.safeNumber(i,"triggerPx"):void 0,amount:l,cost:void 0,average:this.safeString(i,"avgPx"),filled:this.safeString(s,"totalSz",a.Y.stringSub(l,u)),remaining:u,status:this.parseOrderStatus(c),fee:void 0,trades:void 0},t)}parseOrderStatus(e){if(void 0===e)return;return e.endsWith("Rejected")?"rejected":e.endsWith("Canceled")?"canceled":this.safeString({triggered:"open",filled:"closed",open:"open",canceled:"canceled",rejected:"rejected",marginCanceled:"canceled"},e,e)}parseOrderType(e){return this.safeString({"stop limit":"limit","stop market":"market"},e,e)}async fetchMyTrades(e=void 0,t=void 0,i=void 0,s={}){let r,a;[r,s]=this.handlePublicAddress("fetchMyTrades",s),await this.loadMarkets(),void 0!==e&&(a=this.market(e));const o={user:r};void 0!==t?(o.type="userFillsByTime",o.startTime=t):o.type="userFills";const n=this.safeInteger(s,"until");s=this.omit(s,"until"),void 0!==n&&(o.endTime=n);const d=await this.publicPostInfo(this.extend(o,s));return this.parseTrades(d,a,t,i)}parseTrade(e,t=void 0){const i=this.safeInteger(e,"time"),s=this.safeString(e,"px"),r=this.safeString(e,"sz"),a=this.safeString(e,"coin"),o=this.coinToMarketId(a),n=(t=this.safeMarket(o,void 0)).symbol,d=this.safeString(e,"tid");let c=this.safeString(e,"side");void 0!==c&&(c="A"===c?"sell":"buy");const h=this.safeString(e,"fee");let l;const u=this.safeBool(e,"crossed");return void 0!==u&&(l=u?"taker":"maker"),this.safeTrade({info:e,timestamp:i,datetime:this.iso8601(i),symbol:n,id:d,order:this.safeString(e,"oid"),type:void 0,side:c,takerOrMaker:l,price:s,amount:r,cost:void 0,fee:{cost:h,currency:this.safeString(e,"feeToken"),rate:void 0}},t)}async fetchPosition(e,t={}){const i=await this.fetchPositions([e],t);return this.safeDict(i,0,{})}getDexFromSymbols(e,t=void 0){if(void 0===t)return;const i=t.length;if(0===i)return;let s;for(let a=0;a swap transfer");let e=this.numberToString(t),i=this.safeString2(o,"vaultAddress","subAccountAddress");void 0!==i&&(i=this.formatVaultAddress(i),e=e+" subaccount:"+i);const a="perp"===s||"swap"===s,c={hyperliquidChain:n?"Testnet":"Mainnet",amount:e,toPerp:a,nonce:d},h=this.buildUsdClassSendSig(c),l={action:{hyperliquidChain:c.hyperliquidChain,signatureChainId:"0x66eee",type:"usdClassTransfer",amount:e,toPerp:a,nonce:d},nonce:d,signature:h};return await this.privatePostExchange(l)}let c,h=!1;if("main"===i)c=s,h=!0;else{if("main"!==s)throw new r.NotSupported(this.id+" transfer() only support main <> subaccount transfer");c=i}if(this.checkAddress(c),void 0===e||"USDC"===e.toUpperCase()){const e={type:"subAccountTransfer",subAccountUser:c,isDeposit:h,usd:this.parseToInt(a.Y.stringMul(this.numberToString(t),"1000000"))},i={action:e,nonce:d,signature:this.signL1Action(e,d)},s=await this.privatePostExchange(i);return this.parseTransfer(s)}{const i={type:"subAccountSpotTransfer",subAccountUser:c,isDeposit:h,token:this.symbol(e),amount:this.numberToString(t)},s={action:i,nonce:d,signature:this.signL1Action(i,d)},r=await this.privatePostExchange(s);return this.parseTransfer(r)}}parseTransfer(e,t=void 0){return{info:e,id:void 0,timestamp:void 0,datetime:void 0,currency:void 0,amount:void 0,fromAccount:void 0,toAccount:void 0,status:"ok"}}async withdraw(e,t,i,s=void 0,a={}){if(this.checkRequiredCredentials(),await this.loadMarkets(),this.checkAddress(i),void 0!==e&&"USDC"!==(e=e.toUpperCase()))throw new r.NotSupported(this.id+" withdraw() only support USDC");let o;[o,a]=this.handleOptionAndParams(a,"withdraw","vaultAddress"),o=this.formatVaultAddress(o),a=this.omit(a,"vaultAddress");const n=this.milliseconds();let d,c={};if(void 0!==o)c={type:"vaultTransfer",vaultAddress:"0x"+o,isDeposit:!1,usd:t},d=this.signL1Action(c,n);else{const e={hyperliquidChain:this.safeBool(this.options,"sandboxMode",!1)?"Testnet":"Mainnet",destination:i,amount:t.toString(),time:n};d=this.buildWithdrawSig(e),c={hyperliquidChain:e.hyperliquidChain,signatureChainId:"0x66eee",destination:i,amount:t.toString(),time:n,type:"withdraw3"}}const h={action:c,nonce:n,signature:d},l=await this.privatePostExchange(h);return this.parseTransaction(l)}parseTransaction(e,t=void 0){const i=this.safeInteger(e,"time"),s=this.safeDict(e,"delta",{});let r;const a=this.safeInteger(s,"fee");let o;void 0!==a&&(r={currency:"USDC",cost:a});const n=this.safeString(s,"type");return void 0!==n&&(o="internalTransfer"===n),{info:e,id:void 0,txid:this.safeString(e,"hash"),timestamp:i,datetime:this.iso8601(i),network:void 0,address:void 0,addressTo:this.safeString(s,"destination"),addressFrom:this.safeString(s,"user"),tag:void 0,tagTo:void 0,tagFrom:void 0,type:void 0,amount:this.safeNumber(s,"usdc"),currency:void 0,status:this.safeString(e,"status"),updated:void 0,comment:void 0,internal:o,fee:r}}async fetchTradingFee(e,t={}){let i;await this.loadMarkets(),[i,t]=this.handlePublicAddress("fetchTradingFee",t);const s=this.market(e),r={type:"userFees",user:i},a=await this.publicPostInfo(this.extend(r,t)),o={userCrossRate:this.safeString(a,"userCrossRate"),userAddRate:this.safeString(a,"userAddRate")};return this.parseTradingFee(o,s)}parseTradingFee(e,t=void 0){return{info:e,symbol:this.safeSymbol(void 0,t),maker:this.safeNumber(e,"userAddRate"),taker:this.safeNumber(e,"userCrossRate"),percentage:void 0,tierBased:void 0}}async fetchLedger(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchLedger",s);const a={type:"userNonFundingLedgerUpdates",user:r};void 0!==t&&(a.startTime=t);const o=this.safeInteger(s,"until");void 0!==o&&(a.endTime=o,s=this.omit(s,["until"]));const n=await this.publicPostInfo(this.extend(a,s));return this.parseLedger(n,void 0,t,i)}parseLedgerEntry(e,t=void 0){const i=this.safeInteger(e,"time"),s=this.safeDict(e,"delta",{});let r;const a=this.safeInteger(s,"fee");void 0!==a&&(r={currency:"USDC",cost:a});const o=this.safeString(s,"type"),n=this.safeString(s,"usdc");return this.safeLedgerEntry({info:e,id:this.safeString(e,"hash"),direction:void 0,account:void 0,referenceAccount:this.safeString(s,"user"),referenceId:this.safeString(e,"hash"),type:this.parseLedgerEntryType(o),currency:void 0,amount:this.parseNumber(n),timestamp:i,datetime:this.iso8601(i),before:void 0,after:void 0,status:void 0,fee:r},t)}parseLedgerEntryType(e){return this.safeString({internalTransfer:"transfer",accountClassTransfer:"transfer"},e,e)}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){let a;await this.loadMarkets(),[a,s]=this.handlePublicAddress("fetchDepositsWithdrawals",s);const o={type:"userNonFundingLedgerUpdates",user:a};void 0!==t&&(o.startTime=t);const n=this.safeInteger(s,"until");if(void 0!==n){if(void 0===t)throw new r.ArgumentsRequired(this.id+" fetchDeposits requires since while until is set");o.endTime=n,s=this.omit(s,["until"])}const d=await this.publicPostInfo(this.extend(o,s)),c=this.extractTypeFromDelta(d);let h;[h,s]=this.handleOptionAndParams(s,"fetchDepositsWithdrawals","vaultAddress"),h=this.formatVaultAddress(h);let l=[];if(void 0!==h)for(let e=0;e-1||e.indexOf("@")>-1?e:(e.indexOf(":")>-1&&(e=e.replace(":","-")),this.safeCurrencyCode(e)+"/USDC:USDC")}handleErrors(e,t,i,s,a,o,n,d,c){if(!n)return;const h=this.safeString(n,"status",""),l=this.safeString(n,"error");let u;if("err"===h)u=this.safeString(n,"response");else{if("unknownOid"===h)throw new r.OrderNotFound(this.id+" "+o);if(void 0!==l)u=l;else{const e=this.safeDict(n,"response",{}),t=this.safeDict(e,"data",{}),i=this.safeList(t,"statuses",[]);for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(359),r=i(5147),a=i(1579),o=i(4852),n=i(2079);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"independentreserve",name:"Independent Reserve",countries:["AU","NZ"],rateLimit:1e3,pro:!0,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchMyTrades:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionForSymbolWs:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsForSymbolWs:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/51840849/87182090-1e9e9080-c2ec-11ea-8e49-563db9a38f37.jpg",api:{public:"https://api.independentreserve.com/Public",private:"https://api.independentreserve.com/Private"},www:"https://www.independentreserve.com",doc:"https://www.independentreserve.com/API"},api:{public:{get:["GetValidPrimaryCurrencyCodes","GetValidSecondaryCurrencyCodes","GetValidLimitOrderTypes","GetValidMarketOrderTypes","GetValidOrderTypes","GetValidTransactionTypes","GetMarketSummary","GetOrderBook","GetAllOrders","GetTradeHistorySummary","GetRecentTrades","GetFxRates","GetOrderMinimumVolumes","GetCryptoWithdrawalFees","GetCryptoWithdrawalFees2","GetNetworks","GetPrimaryCurrencyConfig2"]},private:{post:["GetOpenOrders","GetClosedOrders","GetClosedFilledOrders","GetOrderDetails","GetAccounts","GetTransactions","GetFiatBankAccounts","GetDigitalCurrencyDepositAddress","GetDigitalCurrencyDepositAddress2","GetDigitalCurrencyDepositAddresses","GetDigitalCurrencyDepositAddresses2","GetTrades","GetBrokerageFees","GetDigitalCurrencyWithdrawal","PlaceLimitOrder","PlaceMarketOrder","CancelOrder","SynchDigitalCurrencyDepositAddressWithBlockchain","RequestFiatWithdrawal","WithdrawFiatCurrency","WithdrawDigitalCurrency","WithdrawCrypto"]}},fees:{trading:{taker:this.parseNumber("0.005"),maker:this.parseNumber("0.005"),percentage:!0,tierBased:!1}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!1,FOK:!1,PO:!1,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:{marginMode:!1,limit:100,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:100,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:100,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:void 0},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{PLA:"PlayChip"},precisionMode:a.kb,options:{defaultNetworks:{USDT:"Ethereum",USDC:"Ethereum",BTC:"Bitcoin",BCH:"BitcoinCash",ETH:"Ethereum",LTC:"Litecoin",XRP:"XrpLedger",ZRX:"Ethereum",EOS:"EosIo",XLM:"Stellar",BAT:"Ethereum",ETC:"EthereumClassic",LINK:"Ethereum",MKR:"Ethereum",DAI:"Ethereum",COMP:"Ethereum",SNX:"Ethereum",YFI:"Ethereum",AAVE:"Ethereum",GRT:"Ethereum",DOT:"Polkadot",UNI:"Ethereum",ADA:"Cardano",MATIC:"Ethereum",DOGE:"Dogecoin",SOL:"Solana",MANA:"Ethereum",SAND:"Ethereum",SHIB:"Ethereum",TRX:"Tron",RENDER:"Solana",WIF:"Solana",RLUSD:"Ethereum",PEPE:"Ethereum"},networks:{BTC:"Bitcoin",ETH:"Ethereum",BCH:"BitcoinCash",LTC:"Litecoin",XRP:"XrpLedger",EOS:"EosIo",XLM:"Stellar",ETC:"EthereumClassic",BSV:"BitcoinSV",DOGE:"Dogecoin",DOT:"Polkadot",ADA:"Cardano",SOL:"Solana",TRX:"Tron"}}})}async fetchMarkets(e={}){const t=this.publicGetGetValidPrimaryCurrencyCodes(e),i=this.publicGetGetValidSecondaryCurrencyCodes(e),s=this.publicGetGetOrderMinimumVolumes(e),[r,a,o]=await Promise.all([t,i,s]),n=[];for(let e=0;e=0?d="buy":c.indexOf("Offer")>=0&&(d="sell"),c.indexOf("Market")>=0?c="market":c.indexOf("Limit")>=0&&(c="limit"));const h=this.parse8601(this.safeString(e,"CreatedTimestampUtc")),l=this.safeString(e,"VolumeFilled"),u=this.safeString(e,"FeePercent");let p;return void 0!==u&&void 0!==l&&(p=r.Y.stringMul(u,l)),this.safeOrder({info:e,id:this.safeString(e,"OrderGuid"),clientOrderId:void 0,timestamp:h,datetime:this.iso8601(h),lastTradeTimestamp:void 0,symbol:i,type:c,timeInForce:void 0,postOnly:void 0,side:d,price:this.safeString(e,"Price"),triggerPrice:void 0,cost:this.safeString(e,"Value"),average:this.safeString(e,"AvgPrice"),amount:this.safeString2(e,"VolumeOrdered","Volume"),filled:l,remaining:this.safeString(e,"Outstanding"),status:this.parseOrderStatus(this.safeString(e,"Status")),fee:{rate:u,cost:p,currency:o},trades:void 0},t)}parseOrderStatus(e){return this.safeString({Open:"open",PartiallyFilled:"open",Filled:"closed",PartiallyFilledAndCancelled:"canceled",Cancelled:"canceled",PartiallyFilledAndExpired:"canceled",Expired:"canceled"},e,e)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s=await this.privatePostGetOrderDetails(this.extend({orderGuid:e},i));let r;return void 0!==t&&(r=this.market(t)),this.parseOrder(s,r)}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.ordered({});let a;void 0!==e&&(a=this.market(e),r.primaryCurrencyCode=a.baseId,r.secondaryCurrencyCode=a.quoteId),void 0===i&&(i=50),r.pageIndex=1,r.pageSize=i;const o=await this.privatePostGetOpenOrders(this.extend(r,s)),n=this.safeList(o,"Data",[]);return this.parseOrders(n,a,t,i)}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.ordered({});let a;void 0!==e&&(a=this.market(e),r.primaryCurrencyCode=a.baseId,r.secondaryCurrencyCode=a.quoteId),void 0===i&&(i=50),r.pageIndex=1,r.pageSize=i;const o=await this.privatePostGetClosedOrders(this.extend(r,s)),n=this.safeList(o,"Data",[]);return this.parseOrders(n,a,t,i)}async fetchMyTrades(e=void 0,t=void 0,i=50,s={}){await this.loadMarkets();const r=this.safeInteger(s,"pageIndex",1);void 0===i&&(i=50);const a=this.ordered({pageIndex:r,pageSize:i}),o=await this.privatePostGetTrades(this.extend(a,s));let n;return void 0!==e&&(n=this.market(e)),this.parseTrades(o.Data,n,t,i)}parseTrade(e,t=void 0){const i=this.parse8601(e.TradeTimestampUtc),s=this.safeString(e,"TradeGuid"),a=this.safeString(e,"OrderGuid"),o=this.safeString2(e,"Price","SecondaryCurrencyTradePrice"),n=this.safeString2(e,"VolumeTraded","PrimaryCurrencyAmount"),d=this.parseNumber(o),c=this.parseNumber(n),h=this.parseNumber(r.Y.stringMul(o,n)),l=this.safeString(e,"PrimaryCurrencyCode"),u=this.safeString(e,"SecondaryCurrencyCode");let p;void 0!==l&&void 0!==u&&(p=l+"/"+u);const f=this.safeSymbol(p,t,"/");let m=this.safeString(e,"OrderType");return void 0!==m&&(m.indexOf("Bid")>=0?m="buy":m.indexOf("Offer")>=0&&(m="sell")),this.safeTrade({id:s,info:e,timestamp:i,datetime:this.iso8601(i),symbol:f,order:a,type:void 0,side:m,takerOrMaker:void 0,price:d,amount:c,cost:h,fee:void 0},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a={primaryCurrencyCode:r.baseId,secondaryCurrencyCode:r.quoteId,numberOfRecentTradesToRetrieve:50},o=await this.publicGetGetRecentTrades(this.extend(a,s));return this.parseTrades(o.Trades,r,t,i)}async fetchTradingFees(e={}){await this.loadMarkets();const t=await this.privatePostGetBrokerageFees(e),i={};for(let e=0;e{"use strict";i.d(t,{A:()=>d});var s=i(4558),r=i(2079),a=i(1579),o=i(5147),n=i(7481);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"indodax",name:"INDODAX",countries:["ID"],rateLimit:50,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,borrowCrossMargin:!1,borrowIsolatedMargin:!1,borrowMargin:!1,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchAllGreeks:!1,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDeposit:!1,fetchDepositAddress:"emulated",fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingInterval:!1,fetchFundingIntervals:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchGreeks:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverages:!1,fetchLeverageTiers:!1,fetchLiquidations:!1,fetchLongShortRatio:!1,fetchLongShortRatioHistory:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarginModes:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!1,fetchMarkPrices:!1,fetchMyLiquidations:!1,fetchMySettlementHistory:!1,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenInterests:!1,fetchOpenOrders:!0,fetchOption:!1,fetchOptionChain:!1,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchPosition:!1,fetchPositionForSymbolWs:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsForSymbolWs:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchSettlementHistory:!1,fetchTicker:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFee:!0,fetchTransactionFees:!1,fetchTransactions:"emulated",fetchTransfer:!1,fetchTransfers:!1,fetchUnderlyingAssets:!1,fetchVolatilityHistory:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!1,setLeverage:!1,setMargin:!1,setMarginMode:!1,setPositionMode:!1,transfer:!1,withdraw:!0},version:"2.0",urls:{logo:"https://user-images.githubusercontent.com/51840849/87070508-9358c880-c221-11ea-8dc5-5391afbbb422.jpg",api:{public:"https://indodax.com",private:"https://indodax.com/tapi"},www:"https://www.indodax.com",doc:"https://github.com/btcid/indodax-official-api-docs",referral:"https://indodax.com/ref/testbitcoincoid/1"},api:{public:{get:{"api/server_time":5,"api/pairs":5,"api/price_increments":5,"api/summaries":5,"api/ticker/{pair}":5,"api/ticker_all":5,"api/trades/{pair}":5,"api/depth/{pair}":5,"tradingview/history_v2":5}},private:{post:{getInfo:4,transHistory:4,trade:1,tradeHistory:4,openOrders:4,orderHistory:4,getOrder:4,cancelOrder:4,withdrawFee:4,withdrawCoin:4,listDownline:4,checkDownline:4,createVoucher:4}}},fees:{trading:{tierBased:!1,percentage:!0,maker:0,taker:.003}},exceptions:{exact:{invalid_pair:r.BadSymbol,"Insufficient balance.":r.InsufficientFunds,"invalid order.":r.OrderNotFound,"Invalid credentials. API not found or session has expired.":r.AuthenticationError,"Invalid credentials. Bad sign.":r.AuthenticationError},broad:{"Minimum price":r.InvalidOrder,"Minimum order":r.InvalidOrder}},timeframes:{"1m":"1","15m":"15","30m":"30","1h":"60","4h":"240","1d":"1D","3d":"3D","1w":"1W"},options:{recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,networks:{XLM:"Stellar Token",BSC:"bep20",TRC20:"trc20",MATIC:"polygon"}},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!1,takeProfitPrice:!1,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!1,PO:!1,GTD:!1},hedged:!1,selfTradePrevention:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:1e5,daysBackCanceled:1,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:2e3}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{STR:"XLM",BCHABC:"BCH",BCHSV:"BSV",DRK:"DASH",NEM:"XEM"},precisionMode:a.kb})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicGetApiServerTime(e);return this.safeInteger(t,"server_time")}async fetchMarkets(e={}){const t=await this.publicGetApiPairs(e),i=[];for(let e=0;e=0){e=[];const i=t.split(",");for(let t=0;t{"use strict";i.d(t,{A:()=>c});var s=i(2459),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(7481);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"kraken",name:"Kraken",countries:["US"],version:"0",rateLimit:1e3,certified:!1,pro:!0,has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createOrders:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTrailingAmountOrder:!0,createTrailingPercentOrder:!0,editOrder:!0,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLedger:!0,fetchLedgerEntry:!0,fetchLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderTrades:"emulated",fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchWithdrawals:!0,setLeverage:!1,setMarginMode:!1,transfer:!0,withdraw:!0},timeframes:{"1m":1,"5m":5,"15m":15,"30m":30,"1h":60,"4h":240,"1d":1440,"1w":10080,"2w":21600},urls:{logo:"https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg",api:{public:"https://api.kraken.com",private:"https://api.kraken.com",zendesk:"https://kraken.zendesk.com/api/v2/help_center/en-us/articles"},www:"https://www.kraken.com",doc:"https://docs.kraken.com/rest/",fees:"https://www.kraken.com/en-us/features/fee-schedule"},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0026"),maker:this.parseNumber("0.0016"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0026")],[this.parseNumber("50000"),this.parseNumber("0.0024")],[this.parseNumber("100000"),this.parseNumber("0.0022")],[this.parseNumber("250000"),this.parseNumber("0.0020")],[this.parseNumber("500000"),this.parseNumber("0.0018")],[this.parseNumber("1000000"),this.parseNumber("0.0016")],[this.parseNumber("2500000"),this.parseNumber("0.0014")],[this.parseNumber("5000000"),this.parseNumber("0.0012")],[this.parseNumber("10000000"),this.parseNumber("0.0001")]],maker:[[this.parseNumber("0"),this.parseNumber("0.0016")],[this.parseNumber("50000"),this.parseNumber("0.0014")],[this.parseNumber("100000"),this.parseNumber("0.0012")],[this.parseNumber("250000"),this.parseNumber("0.0010")],[this.parseNumber("500000"),this.parseNumber("0.0008")],[this.parseNumber("1000000"),this.parseNumber("0.0006")],[this.parseNumber("2500000"),this.parseNumber("0.0004")],[this.parseNumber("5000000"),this.parseNumber("0.0002")],[this.parseNumber("10000000"),this.parseNumber("0.0")]]}}},handleContentTypeApplicationZip:!0,api:{zendesk:{get:["360000292886","201893608"]},public:{get:{Assets:1,AssetPairs:1,Depth:1.2,OHLC:1.2,Spread:1,SystemStatus:1,Ticker:1,Time:1,Trades:1.2}},private:{post:{AddOrder:0,AddOrderBatch:0,AddExport:3,AmendOrder:0,Balance:3,CancelAll:3,CancelAllOrdersAfter:3,CancelOrder:0,CancelOrderBatch:0,ClosedOrders:3,DepositAddresses:3,DepositMethods:3,DepositStatus:3,EditOrder:0,ExportStatus:3,GetWebSocketsToken:3,Ledgers:6,OpenOrders:3,OpenPositions:3,QueryLedgers:3,QueryOrders:3,QueryTrades:3,RetrieveExport:3,RemoveExport:3,BalanceEx:3,TradeBalance:3,TradesHistory:6,TradeVolume:3,Withdraw:3,WithdrawCancel:3,WithdrawInfo:3,WithdrawMethods:3,WithdrawAddresses:3,WithdrawStatus:3,WalletTransfer:3,CreateSubaccount:3,AccountTransfer:3,"Earn/Allocate":3,"Earn/Deallocate":3,"Earn/AllocateStatus":3,"Earn/DeallocateStatus":3,"Earn/Strategies":3,"Earn/Allocations":3}}},commonCurrencies:{LUNA:"LUNC",LUNA2:"LUNA",REPV2:"REP",REP:"REPV1",UST:"USTC",XBT:"BTC",XDG:"DOGE",FEE:"KFEE",XETC:"ETC",XETH:"ETH",XLTC:"LTC",XMLN:"MLN",XREP:"REP",XXBT:"BTC",XXDG:"DOGE",XXLM:"XLM",XXMR:"XMR",XXRP:"XRP",XZEC:"ZEC",ZAUD:"AUD",ZCAD:"CAD",ZEUR:"EUR",ZGBP:"GBP",ZJPY:"JPY",ZUSD:"USD"},options:{timeDifference:0,adjustForTimeDifference:!1,marketsByAltname:{},delistedMarketsById:{},inactiveCurrencies:["CAD","USD","JPY","GBP"],networks:{ETH:"ERC20",TRX:"TRC20"},depositMethods:{"1INCH":"1inch (1INCH)",AAVE:"Aave",ADA:"ADA",ALGO:"Algorand",ANKR:"ANKR (ANKR)",ANT:"Aragon (ANT)",ATOM:"Cosmos",AXS:"Axie Infinity Shards (AXS)",BADGER:"Bager DAO (BADGER)",BAL:"Balancer (BAL)",BAND:"Band Protocol (BAND)",BAT:"BAT",BCH:"Bitcoin Cash",BNC:"Bifrost (BNC)",BNT:"Bancor (BNT)",BTC:"Bitcoin",CHZ:"Chiliz (CHZ)",COMP:"Compound (COMP)",CQT:"\tCovalent Query Token (CQT)",CRV:"Curve DAO Token (CRV)",CTSI:"Cartesi (CTSI)",DAI:"Dai",DASH:"Dash",DOGE:"Dogecoin",DOT:"Polkadot",DYDX:"dYdX (DYDX)",ENJ:"Enjin Coin (ENJ)",EOS:"EOS",ETC:"Ether Classic (Hex)",ETH:"Ether (Hex)",EWT:"Energy Web Token",FEE:"Kraken Fee Credit",FIL:"Filecoin",FLOW:"Flow",GHST:"Aavegotchi (GHST)",GNO:"GNO",GRT:"GRT",ICX:"Icon",INJ:"Injective Protocol (INJ)",KAR:"Karura (KAR)",KAVA:"Kava",KEEP:"Keep Token (KEEP)",KNC:"Kyber Network (KNC)",KSM:"Kusama",LINK:"Link",LPT:"Livepeer Token (LPT)",LRC:"Loopring (LRC)",LSK:"Lisk",LTC:"Litecoin",MANA:"MANA",MATIC:"Polygon (MATIC)",MINA:"Mina",MIR:"Mirror Protocol (MIR)",MKR:"Maker (MKR)",MLN:"MLN",MOVR:"Moonriver (MOVR)",NANO:"NANO",OCEAN:"OCEAN",OGN:"Origin Protocol (OGN)",OMG:"OMG",OXT:"Orchid (OXT)",OXY:"Oxygen (OXY)",PAXG:"PAX (Gold)",PERP:"Perpetual Protocol (PERP)",PHA:"Phala (PHA)",QTUM:"QTUM",RARI:"Rarible (RARI)",RAY:"Raydium (RAY)",REN:"Ren Protocol (REN)",REP:"REPv2",REPV1:"REP",SAND:"The Sandbox (SAND)",SC:"Siacoin",SDN:"Shiden (SDN)",SOL:"Solana",SNX:"Synthetix Network (SNX)",SRM:"Serum",STORJ:"Storj (STORJ)",SUSHI:"Sushiswap (SUSHI)",TBTC:"tBTC",TRX:"Tron",UNI:"UNI",USDC:"USDC",USDT:"Tether USD (ERC20)","USDT-TRC20":"Tether USD (TRC20)",WAVES:"Waves",WBTC:"Wrapped Bitcoin (WBTC)",XLM:"Stellar XLM",XMR:"Monero",XRP:"Ripple XRP",XTZ:"XTZ",YFI:"YFI",ZEC:"Zcash (Transparent)",ZRX:"0x (ZRX)"},withdrawMethods:{Lightning:"Lightning",Bitcoin:"BTC",Ripple:"XRP",Litecoin:"LTC",Dogecoin:"DOGE",Stellar:"XLM",Ethereum:"ERC20","Arbitrum One":"Arbitrum",Polygon:"MATIC","Arbitrum Nova":"Arbitrum",Optimism:"Optimism","zkSync Era":"zkSync","Ethereum Classic":"ETC",Zcash:"ZEC",Monero:"XMR",Tron:"TRC20",Solana:"SOL",EOS:"EOS","Bitcoin Cash":"BCH",Cardano:"ADA",Qtum:"QTUM",Tezos:"XTZ",Cosmos:"ATOM",Nano:"NANO",Siacoin:"SC",Lisk:"LSK",Waves:"WAVES",ICON:"ICX",Algorand:"ALGO","Polygon - USDC.e":"MATIC","Arbitrum One - USDC.e":"Arbitrum",Polkadot:"DOT",Kava:"KAVA",Filecoin:"FIL",Kusama:"KSM",Flow:"FLOW","Energy Web":"EW",Mina:"MINA",Centrifuge:"CFG",Karura:"KAR",Moonriver:"MOVR",Shiden:"SDN",Khala:"PHA","Bifrost Kusama":"BNC",Songbird:"SGB","Terra classic":"LUNC",KILT:"KILT",Basilisk:"BSX",Flare:"FLR","Avalanche C-Chain":"AVAX",Kintsugi:"KINT",Altair:"AIR",Moonbeam:"GLMR",Acala:"ACA",Astar:"ASTR",Akash:"AKT",Robonomics:"XRT",Fantom:"FTM",Elrond:"EGLD",THORchain:"RUNE",Secret:"SCRT",Near:"NEAR","Internet Computer Protocol":"ICP",Picasso:"PICA","Crust Shadow":"CSM",Integritee:"TEER","Parallel Finance":"PARA",HydraDX:"HDX",Interlay:"INTR","Fetch.ai":"FET",NYM:"NYM","Terra 2.0":"LUNA2",Juno:"JUNO",Nodle:"NODL",Stacks:"STX","Ethereum PoW":"ETHW",Aptos:"APT",Sui:"SUI",Genshiro:"GENS",Aventus:"AVT",Sei:"SEI",OriginTrail:"OTP",Celestia:"TIA"},marketHelperProps:["marketsByAltname","delistedMarketsById"]},features:{spot:{sandbox:!1,createOrder:{marginMode:!1,triggerPrice:!1,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!0,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!0,iceberg:!0},createOrders:{min:2,max:15,sameSymbolOnly:!0},fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:void 0,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:void 0,daysBack:void 0,daysBackCanceled:void 0,untilDays:1e5,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:720}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},precisionMode:o.kb,exceptions:{exact:{"EQuery:Invalid asset pair":r.BadSymbol,"EAPI:Invalid key":r.AuthenticationError,"EFunding:Unknown withdraw key":r.InvalidAddress,"EFunding:Invalid amount":r.InsufficientFunds,"EService:Unavailable":r.ExchangeNotAvailable,"EDatabase:Internal error":r.ExchangeNotAvailable,"EService:Busy":r.ExchangeNotAvailable,"EQuery:Unknown asset":r.BadSymbol,"EAPI:Rate limit exceeded":r.DDoSProtection,"EOrder:Rate limit exceeded":r.DDoSProtection,"EGeneral:Internal error":r.ExchangeNotAvailable,"EGeneral:Temporary lockout":r.DDoSProtection,"EGeneral:Permission denied":r.PermissionDenied,"EGeneral:Invalid arguments:price":r.InvalidOrder,"EOrder:Unknown order":r.InvalidOrder,"EOrder:Invalid price:Invalid price argument":r.InvalidOrder,"EOrder:Order minimum not met":r.InvalidOrder,"EOrder:Insufficient funds":r.InsufficientFunds,"EGeneral:Invalid arguments":r.BadRequest,"ESession:Invalid session":r.AuthenticationError,"EAPI:Invalid nonce":r.InvalidNonce,"EFunding:No funding method":r.BadRequest,"EFunding:Unknown asset":r.BadSymbol,"EService:Market in post_only mode":r.OnMaintenance,"EGeneral:Too many requests":r.DDoSProtection,"ETrade:User Locked":r.AccountSuspended},broad:{":Invalid order":r.InvalidOrder,":Invalid arguments:volume":r.InvalidOrder,":Invalid arguments:viqc":r.InvalidOrder,":Invalid nonce":r.InvalidNonce,":IInsufficient funds":r.InsufficientFunds,":Cancel pending":r.CancelPending,":Rate limit exceeded":r.RateLimitExceeded}}})}feeToPrecision(e,t){return this.decimalToPrecision(t,o.R3,this.markets[e].precision.amount,this.precisionMode)}async fetchMarkets(e={}){const t=[];t.push(this.publicGetAssetPairs(e)),this.options.adjustForTimeDifference&&t.push(this.loadTimeDifference());const i=(await Promise.all(t))[0],s=this.safeDict(i,"result",{}),r=this.safeDict(this.options,"cachedCurrencies",{}),o=Object.keys(s),n=[];for(let e=0;eP&&(P=t)}const M="online"===this.safeString(i,"status");n.push({id:t,wsId:this.safeString(i,"wsname"),symbol:u+"/"+p,base:u,quote:p,settle:void 0,baseId:h,quoteId:l,settleId:void 0,altname:i.altname,type:"spot",spot:I,margin:O>0,swap:!1,future:!1,option:!1,active:M,contract:!1,linear:void 0,inverse:void 0,taker:k,maker:v,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:P,price:T},limits:{leverage:{min:this.parseNumber("1"),max:this.safeNumber(S,O-1,1)},amount:{min:this.safeNumber(i,"ordermin"),max:void 0},price:{min:void 0,max:void 0},cost:{min:this.safeNumber(i,"costmin"),max:void 0}},created:void 0,info:i})}return this.options.marketsByAltname=this.indexBy(n,"altname"),n}async fetchStatus(e={}){const t=await this.publicGetSystemStatus(e),i=this.safeDict(t,"result");return{status:"online"===this.safeString(i,"status")?"ok":"maintenance",updated:void 0,eta:void 0,url:void 0,info:t}}async fetchCurrencies(e={}){const t=await this.publicGetAssets(e),i=this.safeValue(t,"result",{}),s=Object.keys(i),r={};for(let e=0;e=0;r[o]=this.safeCurrencyStructure({id:t,code:o,info:a,name:this.safeString(a,"altname"),active:"enabled"===this.safeString(a,"status"),type:n?"fiat":"crypto",deposit:void 0,withdraw:void 0,fee:void 0,precision:this.parseNumber(this.parsePrecision(this.safeString(a,"decimals"))),limits:{amount:{min:void 0,max:void 0},withdraw:{min:void 0,max:void 0}},networks:{}})}return r}safeCurrencyCode(e,t=void 0){if(void 0===e)return e;if(e.indexOf(".")>0){const i=e.split("."),s=this.safeString(i,0),r=this.safeString(i,1);return super.safeCurrencyCode(s,t)+"."+r}return super.safeCurrencyCode(e,t)}async fetchTradingFee(e,t={}){await this.loadMarkets();const i=this.market(e),s={pair:i.id,"fee-info":!0},r=await this.privatePostTradeVolume(this.extend(s,t)),a=this.safeValue(r,"result",{});return this.parseTradingFee(a,i)}parseTradingFee(e,t){const i=this.safeValue(e,"fees_maker",{}),s=this.safeValue(e,"fees",{}),r=this.safeValue(i,t.id,{}),o=this.safeValue(s,t.id,{});return{info:e,symbol:t.symbol,maker:this.parseNumber(a.Y.stringDiv(this.safeString(r,"fee"),"100")),taker:this.parseNumber(a.Y.stringDiv(this.safeString(o,"fee"),"100")),percentage:!0,tierBased:!0}}parseBidAsk(e,t=0,i=1,s=2){return[this.safeNumber(e,t),this.safeNumber(e,i),this.safeInteger(e,2)]}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s=this.market(e),r={pair:s.id};void 0!==t&&(r.count=t);const a=await this.publicGetDepth(this.extend(r,i)),o=this.safeValue(a,"result",{});let n=this.safeValue(o,s.id);const d=this.safeValue(s,"info",{}),c=this.safeValue(d,"wsname");return void 0!==c&&(n=this.safeValue(o,c,n)),this.parseOrderBook(n,e)}parseTicker(e,t=void 0){const i=this.safeSymbol(void 0,t),s=this.safeValue(e,"v",[]),r=this.safeString(s,1),o=this.safeValue(e,"p",[]),n=this.safeString(o,1),d=a.Y.stringMul(r,n),c=this.safeValue(e,"c",[]),h=this.safeString(c,0),l=this.safeValue(e,"h",[]),u=this.safeValue(e,"l",[]),p=this.safeValue(e,"b",[]),f=this.safeValue(e,"a",[]);return this.safeTicker({symbol:i,timestamp:void 0,datetime:void 0,high:this.safeString(l,1),low:this.safeString(u,1),bid:this.safeString(p,0),bidVolume:this.safeString(p,2),ask:this.safeString(f,0),askVolume:this.safeString(f,2),vwap:n,open:this.safeString(e,"o"),close:h,last:h,previousClose:void 0,change:void 0,percentage:void 0,average:void 0,baseVolume:r,quoteVolume:d,info:e},t)}async fetchTickers(e=void 0,t={}){await this.loadMarkets();const i={};if(void 0!==e){e=this.marketSymbols(e);const t=[];for(let i=0;i6&&(d=this.safeString(e,6))}else if("string"==typeof e)d=e;else if("ordertxid"in e){const s=this.safeString(e,"pair"),l=this.findMarketByAltnameOrId(s);if(void 0!==l?t=l:void 0!==s&&(t=this.getDelistedMarketById(s)),c=this.safeString(e,"ordertxid"),d=this.safeString2(e,"id","postxid"),i=this.safeTimestamp(e,"time"),r=this.safeString(e,"type"),a=this.safeString(e,"ordertype"),o=this.safeString(e,"price"),n=this.safeString(e,"vol"),"fee"in e){let i;void 0!==t&&(i=t.quote),h={cost:this.safeString(e,"fee"),currency:i}}}else l=this.safeString(e,"symbol"),s=this.safeString(e,"timestamp"),d=this.safeString(e,"trade_id"),r=this.safeString(e,"side"),a=this.safeString(e,"ord_type"),o=this.safeString(e,"price"),n=this.safeString(e,"qty");void 0!==t&&(l=t.symbol);const u=this.safeString(e,"cost"),p=this.safeBool(e,"maker");let f;return void 0!==p&&(f=p?"maker":"taker"),void 0===s?s=this.iso8601(i):i=this.parse8601(s),this.safeTrade({id:d,order:c,info:e,timestamp:i,datetime:s,symbol:l,type:a,side:r,takerOrMaker:f,price:o,amount:n,cost:u,fee:h},t)}async fetchTrades(e,t=void 0,i=void 0,s={}){await this.loadMarkets();const r=this.market(e),a=r.id,o={pair:a};void 0!==t&&(o.since=this.numberToString(this.parseToInt(t/1e3))),void 0!==i&&(o.count=i);const n=(await this.publicGetTrades(this.extend(o,s))).result,d=n[a],c=d.length;if(c<=0)return[];const h=d[c-1],l=this.safeString(n,"last");return h.push(l),d[c-1]=h,this.parseTrades(d,r,t,i)}parseBalance(e){const t=this.safeValue(e,"result",{}),i={info:e,timestamp:void 0,datetime:void 0},s=Object.keys(t);for(let e=0;e-1,c=await this.privatePostAddOrder(this.extend(n[0],n[1])),h=this.safeDict(c,"result");return h.usingCost=d,this.parseOrder(h)}async createOrders(e,t={}){await this.loadMarkets();const i=[];let s,a,o,n=[];for(let t=0;t-1;const k=this.safeNumber(e,"price");if(void 0!==t&&(m=t.symbol,"fee"in e)){y={cost:this.safeString(e,"fee"),rate:void 0},b.indexOf("fciq")>=0?y.currency=t.quote:b.indexOf("fcib")>=0&&(y.currency=t.base)}const S=this.parseOrderStatus(this.safeString(e,"status"));let O=this.safeStringN(e,["id","txid","order_id","amend_id"]);if(void 0===O||O.startsWith("[")){const t=this.safeList(e,"txid");O=this.safeString(t,0)}const T=this.safeString(e,"userref"),P=this.safeString(e,"cl_ord_id",T),I=this.safeValue(e,"trades",[]),M=[];for(let e=0;e-1;if(w&&(void 0!==k||O)){s.volume=void 0===k&&void 0!==r?this.costToPrecision(t,this.numberToString(r)):this.costToPrecision(t,k);const e=void 0!==S?S+",viqc":"viqc";s.oflags=e}else!b||v||y||(s.price=this.priceToPrecision(t,a));const T=this.safeBool2(o,"reduceOnly","reduce_only");if(u)h?(s.price=this.priceToPrecision(t,d),s.ordertype=b?"stop-loss-limit":"stop-loss"):l&&(s.price=this.priceToPrecision(t,c),s.ordertype=b?"take-profit-limit":"take-profit"),b&&(s.price2=this.priceToPrecision(t,a));else if(v||y){let e;void 0!==f&&(e=f.endsWith("%")?"+"+f:"+"+f+"%");const t=void 0!==p?"+"+p:void 0,i=this.safeString(o,"offset","-"),r=void 0!==m?i+this.numberToString(m):void 0,a=this.safeString(o,"trigger","last");if(s.trigger=a,b||void 0!==m||void 0!==g)if(s.ordertype="trailing-stop-limit",void 0!==g){const t=g.endsWith("%")?i+g:i+g+"%";s.price=e,s.price2=t}else void 0!==m&&(s.price=t,s.price2=r);else s.ordertype="trailing-stop",s.price=void 0!==f?e:t}T&&(s.reduce_only="createOrderWs"===e||"true");let P=this.safeDict(o,"close");if(void 0!==P){P=this.extend({},P);const e=this.safeValue(P,"price");void 0!==e&&(P.price=this.priceToPrecision(t,e));const i=this.safeValue(P,"price2");void 0!==i&&(P.price2=this.priceToPrecision(t,i)),s.close=P}const I=this.safeString2(o,"timeInForce","timeinforce");void 0!==I&&(s.timeinforce=I);const M="market"===i;let A;if([A,o]=this.handlePostOnly(M,!1,o),A){const e=void 0!==S?S+",post":"post";s.oflags=e}return void 0===S||"oflags"in s||(s.oflags=S),[s,o=this.omit(o,["timeInForce","reduceOnly","stopLossPrice","takeProfitPrice","trailingAmount","trailingPercent","trailingLimitAmount","trailingLimitPercent","offset"])]}async editOrder(e,t,i,s,a=void 0,o=void 0,n={}){await this.loadMarkets();const d=this.market(t);if(!d.spot)throw new r.NotSupported(this.id+" editOrder() does not support "+d.type+" orders, only spot orders are accepted");let c={txid:e};const h=this.safeString2(n,"clientOrderId","cl_ord_id");void 0!==h&&(c.cl_ord_id=h,n=this.omit(n,["clientOrderId","cl_ord_id"]),c=this.omit(c,"txid"));const l="market"===i;let u;[u,n]=this.handlePostOnly(l,!1,n),u&&(c.post_only="true"),void 0!==a&&(c.order_qty=this.amountToPrecision(t,a)),void 0!==o&&(c.limit_price=this.priceToPrecision(t,o));let p=this.safeStringN(n,["stopLossPrice","takeProfitPrice","trailingAmount","trailingPercent","trailingLimitAmount","trailingLimitPercent"]);if(void 0!==p){const e=this.safeString(n,"offset");n=this.omit(n,["stopLossPrice","takeProfitPrice","trailingAmount","trailingPercent","trailingLimitAmount","trailingLimitPercent","offset"]),void 0!==e?(p=e+p,c.trigger_price=p):c.trigger_price=this.priceToPrecision(t,p)}const f=await this.privatePostAmendOrder(this.extend(c,n)),m=this.safeDict(f,"result",{});return this.parseOrder(m,d)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s=this.safeValue2(i,"userref","clientOrderId"),a={trades:!0,txid:e};let o=i;void 0!==s&&(a.userref=s,o=this.omit(i,["userref","clientOrderId"]));const n=await this.privatePostQueryOrders(this.extend(a,o)),d=this.safeValue(n,"result",[]);if(!(e in d))throw new r.OrderNotFound(this.id+" fetchOrder() could not find order id "+e);return this.parseOrder(this.extend({id:e},d[e]))}async fetchOrderTrades(e,t=void 0,i=void 0,s=void 0,a={}){const o=this.safeValue(a,"trades"),n=[];if(void 0===o)throw new r.ArgumentsRequired(this.id+" fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)");for(let e=0;e=0)throw new r.OrderNotFound(this.id+" cancelOrder() error "+this.last_http_response);throw e}return this.safeOrder({info:s})}async cancelOrders(e,t=void 0,i={}){const s={orders:e},r=await this.privatePostCancelOrderBatch(this.extend(s,i));return[this.safeOrder({info:r})]}async cancelAllOrders(e=void 0,t={}){await this.loadMarkets();const i=await this.privatePostCancelAll(t);return[this.safeOrder({info:i})]}async cancelAllOrdersAfter(e,t={}){if(e>864e5)throw new r.BadRequest(this.id+" cancelAllOrdersAfter timeout should be less than 86400000 milliseconds");await this.loadMarkets();const i={timeout:e>0?this.parseToInt(e/1e3):0};return await this.privatePostCancelAllOrdersAfter(this.extend(i,t))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();const r={};void 0!==t&&(r.start=this.parseToInt(t/1e3));const a=this.safeInteger(s,"userref");void 0!==a&&(r.userref=a,s=this.omit(s,"userref"));const o=this.safeString(s,"clientOrderId");void 0!==o&&(r.cl_ord_id=o,s=this.omit(s,"clientOrderId"));const n=await this.privatePostOpenOrders(this.extend(r,s));let d;void 0!==e&&(d=this.market(e));const c=this.safeDict(n,"result",{}),h=this.safeDict(c,"open",{}),l=[],u=Object.keys(h);for(let e=0;e0){const e=i[s-1];e.next_cursor=t,i[s-1]=e}return i}async createDepositAddress(e,t={}){return await this.fetchDepositAddress(e,this.extend({new:"true"},t))}async fetchDepositMethods(e,t={}){await this.loadMarkets();const i={asset:this.currency(e).id},s=await this.privatePostDepositMethods(this.extend(i,t));return this.safeValue(s,"result")}async fetchDepositAddress(e,t={}){await this.loadMarkets();const i=this.currency(e);let s=this.safeStringUpper(t,"network");const a=this.safeValue(this.options,"networks",{});s=this.safeString(a,s,s),t=this.omit(t,"network"),"USDT"===e&&"TRC20"===s&&(e=e+"-"+s);const o=this.safeValue(this.options,"depositMethods",{}),n=this.safeString(o,e);let d=this.safeString(t,"method",n);if(void 0===d){const t=await this.fetchDepositMethods(e);if(void 0!==s)for(let e=0;e=0){d=i;break}}if(void 0===d){const e=this.safeValue(t,0,{});d=this.safeString(e,"method")}}const c={asset:i.id,method:d},h=await this.privatePostDepositAddresses(this.extend(c,t)),l=this.safeValue(h,"result",[]),u=this.safeValue(l,0,{});if(void 0===u)throw new r.InvalidAddress(this.id+" privatePostDepositAddresses() returned no addresses for "+e);return this.parseDepositAddress(u,i)}parseDepositAddress(e,t=void 0){const i=this.safeString(e,"address"),s=this.safeString(e,"tag"),r=(t=this.safeCurrency(void 0,t)).code;return this.checkAddress(i),{info:e,currency:r,network:void 0,address:i,tag:s}}async withdraw(e,t,i,s=void 0,a={}){if([s,a]=this.handleWithdrawTagAndParams(s,a),"key"in a){await this.loadMarkets();const s=this.currency(e),r={asset:s.id,amount:t};void 0!==i&&""!==i&&(r.address=i,this.checkAddress(i));const o=await this.privatePostWithdraw(this.extend(r,a)),n=this.safeDict(o,"result",{});return this.parseTransaction(n,s)}throw new r.ExchangeError(this.id+" withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)")}async fetchPositions(e=void 0,t={}){await this.loadMarkets();const i=await this.privatePostOpenPositions(this.extend({docalcs:"true",consolidation:"market"},t));e=this.marketSymbols(e);const s=this.safeList(i,"result"),r=this.parsePositions(s,e);return this.filterByArrayPositions(r,"symbol",e,!1)}parsePosition(e,t=void 0){const i=this.safeString(e,"pair"),s="buy"===this.safeString(e,"type")?"long":"short";return this.safePosition({info:e,id:void 0,symbol:this.safeSymbol(i,t),notional:void 0,marginMode:void 0,liquidationPrice:void 0,entryPrice:void 0,unrealizedPnl:this.safeNumber(e,"net"),realizedPnl:void 0,percentage:void 0,contracts:this.safeNumber(e,"vol"),contractSize:void 0,markPrice:void 0,lastPrice:void 0,side:s,hedged:void 0,timestamp:void 0,datetime:void 0,lastUpdateTimestamp:void 0,maintenanceMargin:void 0,maintenanceMarginPercentage:void 0,collateral:void 0,initialMargin:this.safeNumber(e,"margin"),initialMarginPercentage:void 0,leverage:this.safeNumber(e,"leverage"),marginRatio:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}parseAccountType(e){return this.safeString({spot:"Spot Wallet",swap:"Futures Wallet",future:"Futures Wallet"},e,e)}async transferOut(e,t,i={}){return await this.transfer(e,t,"spot","swap",i)}async transfer(e,t,i,s,a={}){await this.loadMarkets();const o=this.currency(e);i=this.parseAccountType(i),s=this.parseAccountType(s);const n={amount:this.currencyToPrecision(e,t),from:i,to:s,asset:o.id};if("Spot Wallet"!==i)throw new r.BadRequest(this.id+" transfer cannot transfer from "+i+" to "+s+". Use krakenfutures instead to transfer from the futures account.");const d=await this.privatePostWalletTransfer(this.extend(n,a)),c=this.parseTransfer(d,o);return this.extend(c,{amount:t,fromAccount:i,toAccount:s})}parseTransfer(e,t=void 0){const i=this.safeValue(e,"result",{});return{info:e,id:this.safeString(i,"refid"),timestamp:void 0,datetime:void 0,currency:this.safeString(t,"code"),amount:void 0,fromAccount:void 0,toAccount:void 0,status:"sucess"}}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){let o="/"+this.version+"/"+t+"/"+e;if("public"===t)Object.keys(s).length&&(o+="?"+this.urlencodeNested(s));else if("private"===t){const t=this.safeString(s,"price");let i=!1;void 0!==t&&(i=!!t.endsWith("%"));const c="CancelOrderBatch"===e,h="AddOrderBatch"===e;this.checkRequiredCredentials();const l=this.nonce().toString();a=c||i||h?this.json(this.extend({nonce:l},s)):this.urlencodeNested(this.extend({nonce:l},s));const u=this.encode(l+a),p=this.hash(u,n.s,"binary"),f=this.encode(o),m=this.binaryConcat(f,p),g=this.base64ToBinary(this.secret),v=this.hmac(m,g,d.Zf,"base64");(r={"API-Key":this.apiKey,"API-Sign":v})["Content-Type"]=c||i||h?"application/json":"application/x-www-form-urlencoded"}else o="/"+e;return o=this.urls.api[t]+o,{url:o,method:i,body:a,headers:r}}nonce(){return this.milliseconds()-this.options.timeDifference}handleErrors(e,t,i,s,a,o,n,d,c){if(520===e)throw new r.ExchangeNotAvailable(this.id+" "+e.toString()+" "+t);if(void 0!==n&&"{"===o[0]&&"string"!=typeof n){const e=this.id+" "+o;if("error"in n){if(n.error.length){for(let t=0;t{"use strict";i.d(t,{A:()=>c});var s=i(1359),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(7481);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"krakenfutures",name:"Kraken Futures",countries:["US"],version:"v3",userAgent:void 0,rateLimit:600,pro:!0,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!0,option:!1,cancelAllOrders:!0,cancelAllOrdersAfter:!0,cancelOrder:!0,cancelOrders:!0,createMarketOrder:!0,createOrder:!0,createPostOnlyOrder:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchFundingHistory:void 0,fetchFundingRate:"emulated",fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchIsolatedPositions:!1,fetchLeverage:!0,fetchLeverages:!0,fetchLeverageTiers:!0,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPositions:!0,fetchPremiumIndexOHLCV:!1,fetchTickers:!0,fetchTrades:!0,sandbox:!0,setLeverage:!0,setMarginMode:!1,transfer:!0},urls:{test:{public:"https://demo-futures.kraken.com/derivatives/api/",private:"https://demo-futures.kraken.com/derivatives/api/",charts:"https://demo-futures.kraken.com/api/charts/",history:"https://demo-futures.kraken.com/api/history/",www:"https://demo-futures.kraken.com"},logo:"https://user-images.githubusercontent.com/24300605/81436764-b22fd580-9172-11ea-9703-742783e6376d.jpg",api:{charts:"https://futures.kraken.com/api/charts/",history:"https://futures.kraken.com/api/history/",feeschedules:"https://futures.kraken.com/api/feeschedules/",public:"https://futures.kraken.com/derivatives/api/",private:"https://futures.kraken.com/derivatives/api/"},www:"https://futures.kraken.com/",doc:["https://docs.kraken.com/api/docs/futures-api/trading/market-data/"],fees:"https://support.kraken.com/hc/en-us/articles/360022835771-Transaction-fees-and-rebates-for-Kraken-Futures",referral:void 0},api:{public:{get:["feeschedules","instruments","orderbook","tickers","history","historicalfundingrates"]},private:{get:["feeschedules/volumes","openpositions","notifications","accounts","openorders","recentorders","fills","transfers","leveragepreferences","pnlpreferences","assignmentprogram/current","assignmentprogram/history","orders/status"],post:["sendorder","editorder","cancelorder","transfer","batchorder","cancelallorders","cancelallordersafter","withdrawal","assignmentprogram/add","assignmentprogram/delete"],put:["leveragepreferences","pnlpreferences"]},charts:{get:["{price_type}/{symbol}/{interval}"]},history:{get:["orders","executions","triggers","accountlogcsv","account-log","market/{symbol}/orders","market/{symbol}/executions"]}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0005"),maker:this.parseNumber("0.0002"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0005")],[this.parseNumber("100000"),this.parseNumber("0.0004")],[this.parseNumber("1000000"),this.parseNumber("0.0003")],[this.parseNumber("5000000"),this.parseNumber("0.00025")],[this.parseNumber("10000000"),this.parseNumber("0.0002")],[this.parseNumber("20000000"),this.parseNumber("0.00015")],[this.parseNumber("50000000"),this.parseNumber("0.000125")],[this.parseNumber("100000000"),this.parseNumber("0.0001")]],maker:[[this.parseNumber("0"),this.parseNumber("0.0002")],[this.parseNumber("100000"),this.parseNumber("0.0015")],[this.parseNumber("1000000"),this.parseNumber("0.000125")],[this.parseNumber("5000000"),this.parseNumber("0.0001")],[this.parseNumber("10000000"),this.parseNumber("0.000075")],[this.parseNumber("20000000"),this.parseNumber("0.00005")],[this.parseNumber("50000000"),this.parseNumber("0.000025")],[this.parseNumber("100000000"),this.parseNumber("0")]]}}},exceptions:{exact:{apiLimitExceeded:a.RateLimitExceeded,marketUnavailable:a.ContractUnavailable,requiredArgumentMissing:a.BadRequest,unavailable:a.ExchangeNotAvailable,authenticationError:a.AuthenticationError,accountInactive:a.ExchangeError,invalidAccount:a.BadRequest,invalidAmount:a.BadRequest,insufficientFunds:a.InsufficientFunds,"Bad Request":a.BadRequest,Unavailable:a.ExchangeNotAvailable,invalidUnit:a.BadRequest,"Json Parse Error":a.ExchangeError,nonceBelowThreshold:a.InvalidNonce,nonceDuplicate:a.InvalidNonce,notFound:a.BadRequest,"Server Error":a.ExchangeError,unknownError:a.ExchangeError},broad:{invalidArgument:a.BadRequest,nonceBelowThreshold:a.InvalidNonce,nonceDuplicate:a.InvalidNonce}},precisionMode:r.kb,options:{access:{history:{GET:{orders:"private",executions:"private",triggers:"private",accountlogcsv:"private","account-log":"private"}}},settlementCurrencies:{flex:["USDT","BTC","USD","GBP","EUR","USDC"]},symbol:{quoteIds:["USD","XBT"],reversed:!1},versions:{public:{GET:{historicalfundingrates:"v4"}},charts:{GET:{"{price_type}/{symbol}/{interval}":"v1"}},history:{GET:{orders:"v2",executions:"v2",triggers:"v2",accountlogcsv:"v2"}}},fetchTrades:{method:"historyGetMarketSymbolExecutions"}},features:{default:{sandbox:!0,createOrder:{marginMode:!1,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!1,marketBuyRequiresPrice:!1,selfTradePrevention:!1,iceberg:!1},createOrders:{max:100},fetchMyTrades:{marginMode:!1,limit:void 0,daysBack:void 0,untilDays:1e5,symbolRequired:!1},fetchOrder:void 0,fetchOpenOrders:{marginMode:!1,limit:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:void 0,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:2e3}},spot:void 0,swap:{linear:{extends:"default"},inverse:{extends:"default"}},future:{linear:{extends:"default"},inverse:{extends:"default"}}},timeframes:{"1m":"1m","5m":"5m","15m":"15m","30m":"30m","1h":"1h","4h":"4h","12h":"12h","1d":"1d","1w":"1w"}})}async fetchMarkets(e={}){const t=await this.publicGetInstruments(e),i=this.safeValue(t,"instruments",[]),s=[];for(let e=0;e=0;let d,c,h;if(n)o="index";else{d=a.indexOf("_vanilla")>=0,c=!d;const e=this.safeString(t,"lastTradingTime");o=void 0===e?"swap":"future",h=this.parse8601(e)}const l="swap"===o,u="future"===o;let p=r;const f=r.split("_"),m=this.safeString(f,1),g=m.slice(0,m.length-3),v="usd",y=this.safeCurrencyCode(g),b=this.safeCurrencyCode(v);let w,k;const S=this.safeString(t,"contractValueTradePrecision"),O=this.parseNumber(this.integerPrecisionToAmount(S)),T=this.safeNumber(t,"tickSize"),P=l||u||n;if(l||u){"futures_inverse"===this.safeString(t,"type")?(w=y,k=g,c=!0):(w=b,k=v,c=!1),d=!c,p=y+"/"+b+":"+w,u&&(p=p+"-"+this.yymmdd(h))}s.push({id:r,symbol:p,base:y,quote:b,settle:w,baseId:g,quoteId:v,settleId:k,type:o,spot:!1,margin:!1,swap:l,future:u,option:!1,index:n,active:this.safeBool(t,"tradeable"),contract:P,linear:d,inverse:c,contractSize:this.safeNumber(t,"contractSize"),maintenanceMarginRate:void 0,expiry:h,expiryDatetime:this.iso8601(h),strike:void 0,optionType:void 0,precision:{amount:O,price:T},limits:{leverage:{min:void 0,max:void 0},amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},created:this.parse8601(this.safeString(t,"openingDate")),info:t})}const r=this.options.settlementCurrencies.flex,a=[];for(let e=0;e=0?m="taker":g.indexOf("maker")>=0&&(m="maker"));if("takerOrder"in e){i=this.safeInteger(e,"timestamp");const t=this.safeDict(e,"takerOrder",{});void 0!==t&&(h=this.safeStringLower(t,"direction"),m="taker")}return this.safeTrade({info:e,id:a,symbol:this.safeString(t,"symbol"),timestamp:i,datetime:this.iso8601(i),order:d,type:n,side:h,takerOrMaker:m,price:s,amount:f?r:void 0,cost:p,fee:void 0})}createOrderRequest(e,t,i,s,r=void 0,a={}){const o=this.market(e);e=o.symbol,t=this.safeString(a,"orderType",t);const n=this.safeString(a,"timeInForce");let d=!1;[d,a]=this.handlePostOnly("market"===t,"post"===t,a),d?t="post":"ioc"===n?t="ioc":"limit"===t?t="lmt":"market"===t&&(t="mkt");const c={symbol:o.id,side:i,size:this.amountToPrecision(e,s)},h=this.safeString2(a,"clientOrderId","cliOrdId");void 0!==h&&(c.cliOrdId=h);const l=this.safeString2(a,"triggerPrice","stopPrice"),u=void 0!==l,p=this.safeString(a,"stopLossPrice"),f=this.safeString(a,"takeProfitPrice"),m=void 0!==p,g=void 0!==f,v=m||g,y=this.safeString(a,"triggerSignal","last");let b=this.safeValue(a,"reduceOnly");return(v||u)&&(c.triggerSignal=y),u?(t="stp",c.stopPrice=this.priceToPrecision(e,l)):v&&(b=!0,m?(t="stp",c.stopPrice=this.priceToPrecision(e,p)):g&&(t="take_profit",c.stopPrice=this.priceToPrecision(e,f))),b&&(c.reduceOnly=!0),c.orderType=t,void 0!==r&&(c.limitPrice=this.priceToPrecision(e,r)),a=this.omit(a,["clientOrderId","timeInForce","triggerPrice","stopLossPrice","takeProfitPrice"]),this.extend(c,a)}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.createOrderRequest(e,t,i,s,r,a),d=await this.privatePostSendorder(n),c=this.safeValue(d,"sendStatus"),h=this.safeString(c,"status");return this.verifyOrderActionSuccess(h,"createOrder",["filled"]),this.parseOrder(c,o)}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let s=0;s0)for(let e=0;e0?this.parseToInt(e/1e3):0};return await this.privatePostCancelallordersafter(this.extend(i,t))}async fetchOpenOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a=await this.privateGetOpenorders(s),o=this.safeList(a,"openOrders",[]);return this.parseOrders(o,r,t,i)}async fetchOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a=await this.privateGetOrdersStatus(s),o=this.safeList(a,"orders",[]);return this.parseOrders(o,r,t,i)}async fetchOrder(e,t=void 0,i={}){await this.loadMarkets();const s={orderIds:[e]},r=await this.fetchOrders(void 0,void 0,void 0,this.extend(s,i)),o=this.safeDict(r,0);if(void 0===o)throw new a.OrderNotFound(this.id+" fetchOrder could not find order id "+e);return o}async fetchClosedOrders(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),void 0!==e&&(r=this.market(e));const a={};void 0!==i&&(a.count=i),void 0!==t&&(a.from=t);const o=await this.historyGetOrders(this.extend(a,s)),n=this.safeList(o,"elements",[]),d=[];for(let e=0;e0){let e="0.0";for(let t=0;t1)continue;const h=this.account();if(i)h.total=this.safeString(d,"quantity"),h.free=this.safeString(d,"available");else if(s)h.used="0.0",h.total=d;else{const t=this.safeValue(e,"auxiliary");h.free=this.safeString(t,"af"),h.total=this.safeString(t,"pv")}a[c]=h}return this.safeBalance(a)}async fetchFundingRates(e=void 0,t={}){await this.loadMarkets();const i=this.marketIds(e),s=await this.publicGetTickers(t),r=this.safeList(s,"tickers",[]),a=[];for(let e=0;e"0.25"?d="0.25":d>"-0.25"&&(d="-0.25"),h>"0.25"?h="0.25":h>"-0.25"&&(h="-0.25"),{info:e,symbol:s,markPrice:this.parseNumber(a),indexPrice:this.safeNumber(e,"indexPrice"),interestRate:void 0,estimatedSettlePrice:void 0,timestamp:r,datetime:this.iso8601(r),fundingRate:this.parseNumber(d),fundingTimestamp:void 0,fundingDatetime:void 0,nextFundingRate:this.parseNumber(h),nextFundingTimestamp:void 0,nextFundingDatetime:void 0,previousFundingRate:void 0,previousFundingTimestamp:void 0,previousFundingDatetime:void 0,interval:"1h"}}async fetchFundingRateHistory(e=void 0,t=void 0,i=void 0,s={}){if(void 0===e)throw new a.ArgumentsRequired(this.id+" fetchFundingRateHistory() requires a symbol argument");await this.loadMarkets();const r=this.market(e);if(!r.swap)throw new a.BadRequest(this.id+" fetchFundingRateHistory() supports swap contracts only");const o={symbol:r.id.toUpperCase()},n=await this.publicGetHistoricalfundingrates(this.extend(o,s)),d=this.safeValue(n,"rates"),c=[];for(let t=0;t{"use strict";i.d(t,{A:()=>d});var s=i(3548),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"kucoin",name:"KuCoin",countries:["SC"],rateLimit:10,version:"v2",certified:!0,pro:!0,comment:"Platform 2.0",quoteJsonNumbers:!1,has:{CORS:void 0,spot:!0,margin:!0,swap:!1,future:!1,option:!1,borrowCrossMargin:!0,borrowIsolatedMargin:!0,cancelAllOrders:!0,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createDepositAddress:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!0,createMarketSellOrderWithCost:!0,createOrder:!0,createOrders:!0,createPostOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTriggerOrder:!0,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBorrowInterest:!0,fetchBorrowRateHistories:!0,fetchBorrowRateHistory:!0,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositWithdrawFee:!0,fetchDepositWithdrawFees:!0,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!0,fetchLedger:!0,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarketLeverageTiers:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!0,fetchMarkPrices:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!1,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrdersByStatus:!0,fetchOrderTrades:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactionFee:!0,fetchTransfers:!0,fetchWithdrawals:!0,repayCrossMargin:!0,repayIsolatedMargin:!0,setLeverage:!0,setMarginMode:!1,setPositionMode:!1,signIn:!1,transfer:!0,withdraw:!0},urls:{logo:"https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg",referral:"https://www.kucoin.com/ucenter/signup?rcode=E5wkqe",api:{public:"https://api.kucoin.com",private:"https://api.kucoin.com",futuresPrivate:"https://api-futures.kucoin.com",futuresPublic:"https://api-futures.kucoin.com",webExchange:"https://kucoin.com/_api",broker:"https://api-broker.kucoin.com",earn:"https://api.kucoin.com",uta:"https://api.kucoin.com"},www:"https://www.kucoin.com",doc:["https://docs.kucoin.com"]},requiredCredentials:{apiKey:!0,secret:!0,password:!0},api:{public:{get:{currencies:4.5,"currencies/{currency}":4.5,symbols:6,"market/orderbook/level1":3,"market/allTickers":22.5,"market/stats":22.5,markets:4.5,"market/orderbook/level{level}_{limit}":6,"market/orderbook/level2_20":3,"market/orderbook/level2_100":6,"market/histories":4.5,"market/candles":4.5,prices:4.5,timestamp:4.5,status:4.5,"mark-price/{symbol}/current":3,"mark-price/all-symbols":3,"margin/config":25,announcements:20,"margin/collateralRatio":10,"convert/symbol":5,"convert/currencies":5},post:{"bullet-public":15}},private:{get:{"user-info":30,"user/api-key":30,accounts:7.5,"accounts/{accountId}":7.5,"accounts/ledgers":3,"hf/accounts/ledgers":2,"hf/margin/account/ledgers":2,"transaction-history":3,"sub/user":30,"sub-accounts/{subUserId}":22.5,"sub-accounts":30,"sub/api-key":30,"margin/account":40,"margin/accounts":15,"isolated/accounts":15,"deposit-addresses":7.5,deposits:7.5,"hist-deposits":7.5,withdrawals:30,"hist-withdrawals":30,"withdrawals/quotas":30,"accounts/transferable":30,"transfer-list":30,"base-fee":3,"trade-fees":3,"market/orderbook/level{level}":3,"market/orderbook/level2":3,"market/orderbook/level3":3,"hf/accounts/opened":2,"hf/orders/active":2,"hf/orders/active/symbols":2,"hf/margin/order/active/symbols":2,"hf/orders/done":2,"hf/orders/{orderId}":2,"hf/orders/client-order/{clientOid}":2,"hf/orders/dead-cancel-all/query":2,"hf/fills":2,orders:2,"limit/orders":3,"orders/{orderId}":2,"order/client-order/{clientOid}":3,fills:10,"limit/fills":20,"stop-order":8,"stop-order/{orderId}":3,"stop-order/queryOrderByClientOid":3,"oco/order/{orderId}":2,"oco/order/details/{orderId}":2,"oco/client-order/{clientOid}":2,"oco/orders":2,"hf/margin/orders/active":4,"hf/margin/orders/done":10,"hf/margin/orders/{orderId}":4,"hf/margin/orders/client-order/{clientOid}":5,"hf/margin/fills":5,"etf/info":25,"margin/currencies":20,"risk/limit/strategy":20,"isolated/symbols":20,"margin/symbols":5,"isolated/account/{symbol}":50,"margin/borrow":15,"margin/repay":15,"margin/interest":20,"project/list":10,"project/marketInterestRate":7.5,"redeem/orders":10,"purchase/orders":10,"broker/api/rebase/download":3,"broker/queryMyCommission":3,"broker/queryUser":3,"broker/queryDetailByUid":3,"migrate/user/account/status":3,"convert/quote":20,"convert/order/detail":5,"convert/order/history":5,"convert/limit/quote":20,"convert/limit/order/detail":5,"convert/limit/orders":5,"affiliate/inviter/statistics":30,"earn/redeem-preview":5},post:{"sub/user/created":22.5,"sub/api-key":30,"sub/api-key/update":45,"deposit-addresses":30,withdrawals:7.5,"accounts/universal-transfer":6,"accounts/sub-transfer":45,"accounts/inner-transfer":15,"transfer-out":30,"transfer-in":30,"hf/orders":1,"hf/orders/test":1,"hf/orders/sync":1,"hf/orders/multi":1,"hf/orders/multi/sync":1,"hf/orders/alter":3,"hf/orders/dead-cancel-all":2,orders:2,"orders/test":2,"orders/multi":3,"stop-order":2,"oco/order":2,"hf/margin/order":5,"hf/margin/order/test":5,"margin/order":5,"margin/order/test":5,"margin/borrow":15,"margin/repay":10,purchase:15,redeem:15,"lend/purchase/update":10,"convert/order":20,"convert/limit/order":20,"bullet-private":10,"position/update-user-leverage":5,"deposit-address/create":20},delete:{"sub/api-key":45,"withdrawals/{withdrawalId}":30,"hf/orders/{orderId}":1,"hf/orders/sync/{orderId}":1,"hf/orders/client-order/{clientOid}":1,"hf/orders/sync/client-order/{clientOid}":1,"hf/orders/cancel/{orderId}":2,"hf/orders":2,"hf/orders/cancelAll":30,"orders/{orderId}":3,"order/client-order/{clientOid}":5,orders:20,"stop-order/{orderId}":3,"stop-order/cancelOrderByClientOid":5,"stop-order/cancel":3,"oco/order/{orderId}":3,"oco/client-order/{clientOid}":3,"oco/orders":3,"hf/margin/orders/{orderId}":5,"hf/margin/orders/client-order/{clientOid}":5,"hf/margin/orders":10,"convert/limit/order/cancel":5}},futuresPublic:{get:{"contracts/active":4.5,"contracts/{symbol}":4.5,ticker:3,"level2/snapshot":4.5,"level2/depth20":7.5,"level2/depth100":15,"trade/history":7.5,"kline/query":4.5,"interest/query":7.5,"index/query":3,"mark-price/{symbol}/current":4.5,"premium/query":4.5,"trade-statistics":4.5,"funding-rate/{symbol}/current":3,"contract/funding-rates":7.5,timestamp:3,status:6,"level2/message/query":1.3953},post:{"bullet-public":15}},futuresPrivate:{get:{"transaction-history":3,"account-overview":7.5,"account-overview-all":9,"transfer-list":30,orders:3,stopOrders:9,recentDoneOrders:7.5,"orders/{orderId}":7.5,"orders/byClientOid":7.5,fills:7.5,recentFills:4.5,openOrderStatistics:15,position:3,positions:3,"margin/maxWithdrawMargin":15,"contracts/risk-limit/{symbol}":7.5,"funding-history":7.5,"copy-trade/futures/get-max-open-size":6,"copy-trade/futures/position/margin/max-withdraw-margin":15},post:{"transfer-out":30,"transfer-in":30,orders:3,"orders/test":3,"orders/multi":4.5,"position/margin/auto-deposit-status":6,"margin/withdrawMargin":15,"position/margin/deposit-margin":6,"position/risk-limit-level/change":6,"copy-trade/futures/orders":3,"copy-trade/futures/orders/test":3,"copy-trade/futures/st-orders":3,"copy-trade/futures/position/margin/deposit-margin":6,"copy-trade/futures/position/margin/withdraw-margin":15,"copy-trade/futures/position/risk-limit-level/change":3,"copy-trade/futures/position/margin/auto-deposit-status":6,"copy-trade/futures/position/changeMarginMode":3,"copy-trade/futures/position/changeCrossUserLeverage":3,"copy-trade/getCrossModeMarginRequirement":4.5,"copy-trade/position/switchPositionMode":3,"bullet-private":15},delete:{"orders/{orderId}":1.5,"orders/client-order/{clientOid}":1.5,orders:45,stopOrders:22.5,"copy-trade/futures/orders":1.5,"copy-trade/futures/orders/client-order":1.5}},webExchange:{get:{"currency/currency/chain-info":1}},broker:{get:{"broker/nd/info":2,"broker/nd/account":2,"broker/nd/account/apikey":2,"broker/nd/rebase/download":3,"asset/ndbroker/deposit/list":1,"broker/nd/transfer/detail":1,"broker/nd/deposit/detail":1,"broker/nd/withdraw/detail":1},post:{"broker/nd/transfer":1,"broker/nd/account":3,"broker/nd/account/apikey":3,"broker/nd/account/update-apikey":3},delete:{"broker/nd/account/apikey":3}},earn:{get:{"otc-loan/discount-rate-configs":10,"otc-loan/loan":1,"otc-loan/accounts":1,"earn/redeem-preview":7.5,"earn/saving/products":7.5,"earn/hold-assets":7.5,"earn/promotion/products":7.5,"earn/kcs-staking/products":7.5,"earn/staking/products":7.5,"earn/eth-staking/products":7.5,"struct-earn/dual/products":4.5,"struct-earn/orders":7.5},post:{"earn/orders":7.5,"struct-earn/orders":7.5},delete:{"earn/orders":7.5}},uta:{get:{"market/announcement":20,"market/currency":3,"market/instrument":4,"market/ticker":15,"market/orderbook":3,"market/trade":3,"market/kline":3,"market/funding-rate":2,"market/funding-rate-history":5,"market/cross-config":25,"server/status":3}}},timeframes:{"1m":"1min","3m":"3min","5m":"5min","15m":"15min","30m":"30min","1h":"1hour","2h":"2hour","4h":"4hour","6h":"6hour","8h":"8hour","12h":"12hour","1d":"1day","1w":"1week","1M":"1month"},precisionMode:o.kb,exceptions:{exact:{"Order not exist or not allow to be cancelled":r.OrderNotFound,"The order does not exist.":r.OrderNotFound,"order not exist":r.OrderNotFound,"order not exist.":r.OrderNotFound,order_not_exist:r.OrderNotFound,order_not_exist_or_not_allow_to_cancel:r.InvalidOrder,"Order size below the minimum requirement.":r.InvalidOrder,"Order size increment invalid.":r.InvalidOrder,"The withdrawal amount is below the minimum requirement.":r.ExchangeError,"Unsuccessful! Exceeded the max. funds out-transfer limit":r.InsufficientFunds,"The amount increment is invalid.":r.BadRequest,"The quantity is below the minimum requirement.":r.InvalidOrder,"not in the given range!":r.BadRequest,"recAccountType not in the given range":r.BadRequest,400:r.BadRequest,401:r.AuthenticationError,403:r.NotSupported,404:r.NotSupported,405:r.NotSupported,415:r.NotSupported,429:r.RateLimitExceeded,500:r.ExchangeNotAvailable,503:r.ExchangeNotAvailable,101030:r.PermissionDenied,103e3:r.InvalidOrder,130101:r.BadRequest,130102:r.ExchangeError,130103:r.OrderNotFound,130104:r.ExchangeError,130105:r.InsufficientFunds,130106:r.NotSupported,130107:r.ExchangeError,130108:r.OrderNotFound,130201:r.PermissionDenied,130202:r.ExchangeError,130203:r.InsufficientFunds,130204:r.BadRequest,130301:r.InsufficientFunds,130302:r.PermissionDenied,130303:r.NotSupported,130304:r.NotSupported,130305:r.NotSupported,130306:r.NotSupported,130307:r.NotSupported,130308:r.InvalidOrder,130309:r.InvalidOrder,130310:r.ExchangeError,130311:r.InvalidOrder,130312:r.InvalidOrder,130313:r.InvalidOrder,130314:r.InvalidOrder,130315:r.NotSupported,126e3:r.ExchangeError,126001:r.NotSupported,126002:r.ExchangeError,126003:r.InvalidOrder,126004:r.ExchangeError,126005:r.PermissionDenied,126006:r.ExchangeError,126007:r.ExchangeError,126009:r.ExchangeError,126010:r.ExchangeError,126011:r.ExchangeError,126013:r.InsufficientFunds,126015:r.ExchangeError,126021:r.NotSupported,126022:r.InvalidOrder,126027:r.InvalidOrder,126028:r.InvalidOrder,126029:r.InvalidOrder,126030:r.InvalidOrder,126033:r.InvalidOrder,126034:r.InvalidOrder,126036:r.InvalidOrder,126037:r.ExchangeError,126038:r.ExchangeError,126039:r.ExchangeError,126041:r.ExchangeError,126042:r.ExchangeError,126043:r.OrderNotFound,126044:r.InvalidOrder,126045:r.NotSupported,126046:r.NotSupported,126047:r.PermissionDenied,126048:r.PermissionDenied,135005:r.ExchangeError,135018:r.ExchangeError,200004:r.InsufficientFunds,210014:r.InvalidOrder,210021:r.InsufficientFunds,230003:r.InsufficientFunds,26e4:r.InvalidAddress,260100:r.InsufficientFunds,3e5:r.InvalidOrder,4e5:r.BadSymbol,400001:r.AuthenticationError,400002:r.InvalidNonce,400003:r.AuthenticationError,400004:r.AuthenticationError,400005:r.AuthenticationError,400006:r.AuthenticationError,400007:r.AuthenticationError,400008:r.NotSupported,400100:r.InsufficientFunds,400200:r.InvalidOrder,400330:r.InvalidOrder,400350:r.InvalidOrder,400370:r.InvalidOrder,400400:r.BadRequest,400401:r.AuthenticationError,400500:r.InvalidOrder,400600:r.BadSymbol,400760:r.InvalidOrder,401e3:r.BadRequest,408e3:r.BadRequest,411100:r.AccountSuspended,415e3:r.BadRequest,400303:r.PermissionDenied,5e5:r.ExchangeNotAvailable,260220:r.InvalidAddress,600100:r.InsufficientFunds,600101:r.InvalidOrder,900014:r.BadRequest},broad:{"Exceeded the access frequency":r.RateLimitExceeded,"require more permission":r.PermissionDenied}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.001"),maker:this.parseNumber("0.001"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.001")],[this.parseNumber("50"),this.parseNumber("0.001")],[this.parseNumber("200"),this.parseNumber("0.0009")],[this.parseNumber("500"),this.parseNumber("0.0008")],[this.parseNumber("1000"),this.parseNumber("0.0007")],[this.parseNumber("2000"),this.parseNumber("0.0007")],[this.parseNumber("4000"),this.parseNumber("0.0006")],[this.parseNumber("8000"),this.parseNumber("0.0005")],[this.parseNumber("15000"),this.parseNumber("0.00045")],[this.parseNumber("25000"),this.parseNumber("0.0004")],[this.parseNumber("40000"),this.parseNumber("0.00035")],[this.parseNumber("60000"),this.parseNumber("0.0003")],[this.parseNumber("80000"),this.parseNumber("0.00025")]],maker:[[this.parseNumber("0"),this.parseNumber("0.001")],[this.parseNumber("50"),this.parseNumber("0.0009")],[this.parseNumber("200"),this.parseNumber("0.0007")],[this.parseNumber("500"),this.parseNumber("0.0005")],[this.parseNumber("1000"),this.parseNumber("0.0003")],[this.parseNumber("2000"),this.parseNumber("0")],[this.parseNumber("4000"),this.parseNumber("0")],[this.parseNumber("8000"),this.parseNumber("0")],[this.parseNumber("15000"),this.parseNumber("-0.00005")],[this.parseNumber("25000"),this.parseNumber("-0.00005")],[this.parseNumber("40000"),this.parseNumber("-0.00005")],[this.parseNumber("60000"),this.parseNumber("-0.00005")],[this.parseNumber("80000"),this.parseNumber("-0.00005")]]}},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}},commonCurrencies:{BIFI:"BIFIF",VAI:"VAIOT",WAX:"WAXP",ALT:"APTOSLAUNCHTOKEN",KALT:"ALT",FUD:"FTX Users' Debt"},options:{hf:void 0,version:"v1",symbolSeparator:"-",fetchMyTradesMethod:"private_get_fills",timeDifference:0,adjustForTimeDifference:!1,fetchCurrencies:{webApiEnable:!0,webApiRetries:1,webApiMuteFailure:!0},fetchMarkets:{fetchTickersFees:!0},withdraw:{includeFee:!1},transfer:{fillResponseFromRequest:!0},versions:{public:{GET:{currencies:"v3","currencies/{currency}":"v3",symbols:"v2","mark-price/all-symbols":"v3",announcements:"v3"}},private:{GET:{"user-info":"v2","hf/margin/account/ledgers":"v3","sub/user":"v2","sub-accounts":"v2","margin/accounts":"v3","isolated/accounts":"v3","deposit-addresses":"v1","market/orderbook/level2":"v3","market/orderbook/level3":"v3","market/orderbook/level{level}":"v3","oco/order/{orderId}":"v3","oco/order/details/{orderId}":"v3","oco/client-order/{clientOid}":"v3","oco/orders":"v3","hf/margin/orders/active":"v3","hf/margin/order/active/symbols":"v3","hf/margin/orders/done":"v3","hf/margin/orders/{orderId}":"v3","hf/margin/orders/client-order/{clientOid}":"v3","hf/margin/fills":"v3","etf/info":"v3","margin/currencies":"v3","margin/borrow":"v3","margin/repay":"v3","margin/interest":"v3","project/list":"v3","project/marketInterestRate":"v3","redeem/orders":"v3","purchase/orders":"v3","migrate/user/account/status":"v3","margin/symbols":"v3","affiliate/inviter/statistics":"v2","asset/ndbroker/deposit/list":"v1"},POST:{"sub/user/created":"v2","accounts/universal-transfer":"v3","accounts/sub-transfer":"v2","accounts/inner-transfer":"v2","transfer-out":"v3","deposit-address/create":"v3","oco/order":"v3","hf/margin/order":"v3","hf/margin/order/test":"v3","margin/borrow":"v3","margin/repay":"v3",purchase:"v3",redeem:"v3","lend/purchase/update":"v3","position/update-user-leverage":"v3",withdrawals:"v3"},DELETE:{"hf/margin/orders/{orderId}":"v3","hf/margin/orders/client-order/{clientOid}":"v3","hf/margin/orders":"v3","oco/order/{orderId}":"v3","oco/client-order/{clientOid}":"v3","oco/orders":"v3"}},futuresPrivate:{POST:{"transfer-out":"v3"}}},partner:{spot:{id:"ccxt",key:"9e58cc35-5b5e-4133-92ec-166e3f077cb8"},future:{id:"ccxtfutures",key:"1b327198-f30c-4f14-a0ac-918871282f15"}},accountsByType:{spot:"trade",margin:"margin",cross:"margin",isolated:"isolated",main:"main",funding:"main",future:"contract",swap:"contract",mining:"pool",hf:"trade_hf"},networks:{BRC20:"btc",BTCNATIVESEGWIT:"bech32",ERC20:"eth",TRC20:"trx",HRC20:"heco",MATIC:"matic",KCC:"kcc",SOL:"sol",ALGO:"algo",EOS:"eos",BEP20:"bsc",BEP2:"bnb",ARBONE:"arbitrum",AVAXX:"avax",AVAXC:"avaxc",TLOS:"tlos",CFX:"cfx",ACA:"aca",OPTIMISM:"optimism",ONT:"ont",GLMR:"glmr",CSPR:"cspr",KLAY:"klay",XRD:"xrd",RVN:"rvn",NEAR:"near",APT:"aptos",ETHW:"ethw",TON:"ton",BCH:"bch",BSV:"bchsv",BCHA:"bchabc",OSMO:"osmo",NANO:"nano",XLM:"xlm",VET:"vet",IOST:"iost",ZIL:"zil",XRP:"xrp",TOMO:"tomo",XMR:"xmr",COTI:"coti",XTZ:"xtz",ADA:"ada",WAX:"waxp",THETA:"theta",ONE:"one",IOTEX:"iotx",NULS:"nuls",KSM:"ksm",LTC:"ltc",WAVES:"waves",DOT:"dot",STEEM:"steem",QTUM:"qtum",DOGE:"doge",FIL:"fil",XYM:"xym",FLUX:"flux",ATOM:"atom",XDC:"xdc",KDA:"kda",ICP:"icp",CELO:"celo",LSK:"lsk",VSYS:"vsys",KAR:"kar",XCH:"xch",FLOW:"flow",BAND:"band",EGLD:"egld",HBAR:"hbar",XPR:"xpr",AR:"ar",FTM:"ftm",KAVA:"kava",KMA:"kma",XEC:"xec",IOTA:"iota",HNT:"hnt",ASTR:"astr",PDEX:"pdex",METIS:"metis",ZEC:"zec",POKT:"pokt",OASYS:"oas",OASIS:"oasis",ETC:"etc",AKT:"akt",FSN:"fsn",SCRT:"scrt",CFG:"cfg",ICX:"icx",KMD:"kmd",NEM:"NEM",STX:"stx",DGB:"dgb",DCR:"dcr",CKB:"ckb",ELA:"ela",HYDRA:"hydra",BTM:"btm",KARDIA:"kai",SXP:"sxp",NEBL:"nebl",ZEN:"zen",SDN:"sdn",LTO:"lto",WEMIX:"wemix",EVER:"ever",BNC:"bnc",BNCDOT:"bncdot",AION:"aion",GRIN:"grin",LOKI:"loki",QKC:"qkc",TT:"TT",PIVX:"pivx",SERO:"sero",METER:"meter",STATEMINE:"statemine",DVPN:"dvpn",XPRT:"xprt",MOVR:"movr",ERGO:"ergo",ABBC:"abbc",DIVI:"divi",PURA:"pura",DFI:"dfi",NEON3:"neon3",DOCK:"dock",TRUE:"true",CS:"cs",ORAI:"orai",BASE:"base",TARA:"tara"},marginModes:{cross:"MARGIN_TRADE",isolated:"MARGIN_ISOLATED_TRADE",spot:"TRADE"}},features:{spot:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:void 0,triggerDirection:!1,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:void 0,timeInForce:{IOC:!0,FOK:!0,PO:!0,GTD:!0},hedged:!1,trailing:!1,leverage:!1,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!0,iceberg:!0},createOrders:{max:5},fetchMyTrades:{marginMode:!0,limit:void 0,daysBack:void 0,untilDays:7,symbolRequired:!0},fetchOrder:{marginMode:!1,trigger:!0,trailing:!1,symbolRequired:!0},fetchOpenOrders:{marginMode:!0,limit:500,trigger:!0,trailing:!1,symbolRequired:!0},fetchOrders:void 0,fetchClosedOrders:{marginMode:!0,limit:500,daysBack:void 0,daysBackCanceled:void 0,untilDays:7,trigger:!0,trailing:!1,symbolRequired:!0},fetchOHLCV:{limit:1500}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}}})}nonce(){return this.milliseconds()-this.options.timeDifference}async fetchTime(e={}){const t=await this.publicGetTimestamp(e);return this.safeInteger(t,"data")}async fetchStatus(e={}){let t,i;if([t,e]=this.handleOptionAndParams(e,"fetchStatus","uta",!1),t){const t="spot"===this.safeString(this.options,"defaultType","spot")?"SPOT":"FUTURES",s={tradeType:this.safeStringUpper(e,"tradeType",t)};i=await this.utaGetServerStatus(this.extend(s,e))}else i=await this.publicGetStatus(e);const s=this.safeDict(i,"data",{});return{status:"open"===this.safeString2(s,"status","serverStatus")?"ok":"maintenance",updated:void 0,eta:void 0,url:void 0,info:i}}async fetchMarkets(e={}){let t,i;if([t,e]=this.handleOptionAndParams(e,"fetchMarkets","fetchTickersFees",!0),[i,e]=this.handleOptionAndParams(e,"fetchMarkets","uta",!1),i)return await this.fetchUtaMarkets(e);const s=[];s.push(this.publicGetSymbols(e));const r=this.checkRequiredCredentials(!1),o=r&&this.safeBool(e,"marginables",!0);o&&(s.push(this.privateGetMarginSymbols(e)),s.push(this.privateGetIsolatedSymbols(e))),t&&s.push(this.publicGetMarketAllTickers(e)),r&&s.push(this.loadMigrationStatus());const n=await Promise.all(s),d=this.safeList(n[0],"data"),c=o?this.safeDict(n[1],"data",{}):{},h=this.safeList(c,"items",[]),l=this.indexBy(h,"symbol"),u=o?n[2]:{},p=this.safeList(u,"data",[]),f=this.indexBy(p,"symbol"),m=o?3:1,g=this.safeDict(n,m,{}),v=this.safeList(this.safeDict(g,"data",{}),"ticker",[]),y=this.indexBy(v,"symbol"),b=[];for(let e=0;e1&&void 0===r&&e[1].length>1&&(r=e[1]),n=e[0]}let d=void 0===n?"withdrawal":"deposit";const c=this.safeString(e,"status");let h;const l=this.safeString(e,"fee");if(void 0!==l){let e;void 0!==o&&(e=a.Y.stringDiv(l,o)),h={cost:this.parseNumber(l),rate:this.parseNumber(e),currency:s}}let u=this.safeInteger2(e,"createdAt","createAt"),p=this.safeInteger(e,"updatedAt");!("createdAt"in e)&&(d="address"in e?"withdrawal":"deposit",void 0!==u&&(u*=1e3),void 0!==p&&(p*=1e3));const f=this.safeBool(e,"isInner"),m=this.safeString(e,"memo");return{info:e,id:this.safeString2(e,"id","withdrawalId"),timestamp:u,datetime:this.iso8601(u),network:this.networkIdToCode(this.safeString(e,"chain")),address:r,addressTo:r,addressFrom:void 0,tag:m,tagTo:m,tagFrom:void 0,currency:s,amount:this.parseNumber(o),txid:n,type:d,status:this.parseTransactionStatus(c),comment:this.safeString(e,"remark"),internal:f,fee:h,updated:p}}async fetchDeposits(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchDeposits","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchDeposits",e,t,i,s);let a,o,n={};void 0!==e&&(a=this.currency(e),n.currency=a.id),void 0!==i&&(n.pageSize=i),[n,s]=this.handleUntilOption("endAt",n,s),void 0!==t&&t<1550448e6?(n.startAt=this.parseToInt(t/1e3),o=await this.privateGetHistDeposits(this.extend(n,s))):(void 0!==t&&(n.startAt=t),o=await this.privateGetDeposits(this.extend(n,s)));const d=this.safeDict(o,"data",{}),c=this.safeList(d,"items",[]);return this.parseTransactions(c,a,t,i,{type:"deposit"})}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){await this.loadMarkets();let r=!1;if([r,s]=this.handleOptionAndParams(s,"fetchWithdrawals","paginate"),r)return await this.fetchPaginatedCallDynamic("fetchWithdrawals",e,t,i,s);let a,o,n={};void 0!==e&&(a=this.currency(e),n.currency=a.id),void 0!==i&&(n.pageSize=i),[n,s]=this.handleUntilOption("endAt",n,s),void 0!==t&&t<1550448e6?(n.startAt=this.parseToInt(t/1e3),o=await this.privateGetHistWithdrawals(this.extend(n,s))):(void 0!==t&&(n.startAt=t),o=await this.privateGetWithdrawals(this.extend(n,s)));const d=this.safeDict(o,"data",{}),c=this.safeList(d,"items",[]);return this.parseTransactions(c,a,t,i,{type:"withdrawal"})}parseBalanceHelper(e){const t=this.account();t.used=this.safeString2(e,"holdBalance","hold"),t.free=this.safeString2(e,"availableBalance","available"),t.total=this.safeString2(e,"totalBalance","total");const i=this.safeString(e,"liability"),s=this.safeString(e,"interest");return t.debt=a.Y.stringAdd(i,s),t}async fetchBalance(e={}){await this.loadMarkets();const t=this.safeString(e,"code");let i;void 0!==t&&(i=this.currency(t));const s=this.safeString2(this.options,"fetchBalance","defaultType","spot"),r=this.safeString(e,"type",s),a=this.safeDict(this.options,"accountsByType");let o,n=this.safeString(a,r,r);e=this.omit(e,"type"),[o,e]=this.handleHfAndParams(e),o&&"main"!==n&&(n="trade_hf");const[d,c]=this.handleMarginModeAndParams("fetchBalance",e);let h;const l={},u="isolated"===d||"isolated"===n,p="cross"===d||"margin"===n;let f;u?(void 0!==i&&(l.balanceCurrency=i.id),h=await this.privateGetIsolatedAccounts(this.extend(l,c))):p?h=await this.privateGetMarginAccount(this.extend(l,c)):(void 0!==i&&(l.currency=i.id),l.type=n,h=await this.privateGetAccounts(this.extend(l,c)));const m={info:h,timestamp:void 0,datetime:void 0};if(u){f=this.safeDict(h,"data",{});const e=this.safeValue(f,"assets",f);for(let t=0;t{"use strict";i.d(t,{A:()=>n});var s=i(2079),r=i(5147),a=i(1579),o=i(3942);class n extends o.A{describe(){return this.deepExtend(super.describe(),{id:"kucoinfutures",name:"KuCoin Futures",countries:["SC"],rateLimit:75,version:"v1",certified:!0,pro:!0,comment:"Platform 2.0",quoteJsonNumbers:!1,has:{CORS:void 0,spot:!1,margin:!1,swap:!0,future:!0,option:!1,addMargin:!0,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!0,closeAllPositions:!1,closePosition:!0,closePositions:!1,createDepositAddress:!0,createOrder:!0,createOrders:!0,createOrderWithTakeProfitAndStopLoss:!0,createReduceOnlyOrder:!0,createStopLimitOrder:!0,createStopLossOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,createTakeProfitOrder:!0,createTriggerOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositWithdrawFee:!1,fetchDepositWithdrawFees:!1,fetchFundingHistory:!0,fetchFundingInterval:!0,fetchFundingIntervals:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL3OrderBook:!0,fetchLedger:!0,fetchLeverage:!0,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarketLeverageTiers:!0,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMarkPrice:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!0,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsHistory:!0,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTransactionFee:!1,fetchWithdrawals:!0,setLeverage:!1,setMarginMode:!0,setPositionMode:!0,transfer:!0,withdraw:void 0},urls:{logo:"https://user-images.githubusercontent.com/1294454/147508995-9e35030a-d046-43a1-a006-6fabd981b554.jpg",doc:["https://docs.kucoin.com/futures","https://docs.kucoin.com"],www:"https://futures.kucoin.com/",referral:"https://futures.kucoin.com/?rcode=E5wkqe",api:{public:"https://openapi-v2.kucoin.com",private:"https://openapi-v2.kucoin.com",futuresPrivate:"https://api-futures.kucoin.com",futuresPublic:"https://api-futures.kucoin.com",webExchange:"https://futures.kucoin.com/_api/web-front"}},requiredCredentials:{apiKey:!0,secret:!0,password:!0},api:{futuresPublic:{get:{"contracts/active":1,"contracts/{symbol}":1,"contracts/risk-limit/{symbol}":1,ticker:1,allTickers:1,"level2/snapshot":1.33,"level2/depth{limit}":1,"level2/message/query":1,"level3/message/query":1,"level3/snapshot":1,"trade/history":1,"interest/query":1,"index/query":1,"mark-price/{symbol}/current":1,"premium/query":1,"funding-rate/{symbol}/current":1,timestamp:1,status:1,"kline/query":1},post:{"bullet-public":1}},futuresPrivate:{get:{"account-overview":1.33,"transaction-history":4.44,"deposit-address":1,"deposit-list":1,"withdrawals/quotas":1,"withdrawal-list":1,"transfer-list":1,orders:1.33,stopOrders:1,recentDoneOrders:1,"orders/{orderId}":1,"orders/byClientOid":1,fills:4.44,recentFills:4.44,openOrderStatistics:1,position:1,positions:4.44,"funding-history":4.44,"sub/api-key":1,"trade-statistics":1,"trade-fees":1,"history-positions":1,getMaxOpenSize:1,getCrossUserLeverage:1,"position/getMarginMode":1},post:{withdrawals:1,"transfer-out":1,"transfer-in":1,orders:1.33,"st-orders":1.33,"orders/test":1.33,"position/margin/auto-deposit-status":1,"position/margin/deposit-margin":1,"position/risk-limit-level/change":1,"bullet-private":1,"sub/api-key":1,"sub/api-key/update":1,changeCrossUserLeverage:1,"position/changeMarginMode":1,"position/switchPositionMode":1},delete:{"withdrawals/{withdrawalId}":1,"cancel/transfer-out":1,"orders/{orderId}":1,orders:4.44,stopOrders:1,"sub/api-key":1,"orders/client-order/{clientOid}":1,"orders/multi-cancel":20}},webExchange:{get:{"contract/{symbol}/funding-rates":1}}},precisionMode:a.kb,exceptions:{exact:{400:s.BadRequest,401:s.AuthenticationError,403:s.NotSupported,404:s.NotSupported,405:s.NotSupported,415:s.BadRequest,429:s.RateLimitExceeded,500:s.ExchangeNotAvailable,503:s.ExchangeNotAvailable,100001:s.OrderNotFound,100004:s.BadRequest,101030:s.PermissionDenied,200004:s.InsufficientFunds,230003:s.InsufficientFunds,260100:s.InsufficientFunds,300003:s.InsufficientFunds,300012:s.InvalidOrder,400001:s.AuthenticationError,400002:s.InvalidNonce,400003:s.AuthenticationError,400004:s.AuthenticationError,400005:s.AuthenticationError,400006:s.AuthenticationError,400007:s.AuthenticationError,404e3:s.NotSupported,400100:s.BadRequest,411100:s.AccountSuspended,5e5:s.ExchangeNotAvailable,300009:s.InvalidOrder,330008:s.InsufficientFunds},broad:{"Position does not exist":s.OrderNotFound}},fees:{trading:{tierBased:!0,percentage:!0,taker:this.parseNumber("0.0006"),maker:this.parseNumber("0.0002"),tiers:{taker:[[this.parseNumber("0"),this.parseNumber("0.0006")],[this.parseNumber("50"),this.parseNumber("0.0006")],[this.parseNumber("200"),this.parseNumber("0.0006")],[this.parseNumber("500"),this.parseNumber("0.0005")],[this.parseNumber("1000"),this.parseNumber("0.0004")],[this.parseNumber("2000"),this.parseNumber("0.0004")],[this.parseNumber("4000"),this.parseNumber("0.00038")],[this.parseNumber("8000"),this.parseNumber("0.00035")],[this.parseNumber("15000"),this.parseNumber("0.00032")],[this.parseNumber("25000"),this.parseNumber("0.0003")],[this.parseNumber("40000"),this.parseNumber("0.0003")],[this.parseNumber("60000"),this.parseNumber("0.0003")],[this.parseNumber("80000"),this.parseNumber("0.0003")]],maker:[[this.parseNumber("0"),this.parseNumber("0.02")],[this.parseNumber("50"),this.parseNumber("0.015")],[this.parseNumber("200"),this.parseNumber("0.01")],[this.parseNumber("500"),this.parseNumber("0.01")],[this.parseNumber("1000"),this.parseNumber("0.01")],[this.parseNumber("2000"),this.parseNumber("0")],[this.parseNumber("4000"),this.parseNumber("0")],[this.parseNumber("8000"),this.parseNumber("0")],[this.parseNumber("15000"),this.parseNumber("-0.003")],[this.parseNumber("25000"),this.parseNumber("-0.006")],[this.parseNumber("40000"),this.parseNumber("-0.009")],[this.parseNumber("60000"),this.parseNumber("-0.012")],[this.parseNumber("80000"),this.parseNumber("-0.015")]]}},funding:{tierBased:!1,percentage:!1,withdraw:{},deposit:{}}},commonCurrencies:{HOT:"HOTNOW",EDGE:"DADI",WAX:"WAXP",TRY:"Trias",VAI:"VAIOT",XBT:"BTC"},timeframes:{"1m":1,"3m":void 0,"5m":5,"15m":15,"30m":30,"1h":60,"2h":120,"4h":240,"6h":void 0,"8h":480,"12h":720,"1d":1440,"1w":10080},options:{version:"v1",symbolSeparator:"-",defaultType:"swap",code:"USDT",marginModes:{},marginTypes:{},versions:{futuresPrivate:{GET:{getMaxOpenSize:"v2",getCrossUserLeverage:"v2","position/getMarginMode":"v2"},POST:{"transfer-out":"v2",changeCrossUserLeverage:"v2","position/changeMarginMode":"v2","position/switchPositionMode":"v2"}},futuresPublic:{GET:{"level3/snapshot":"v2"}}},networks:{OMNI:"omni",ERC20:"eth",TRC20:"trx"}},features:{spot:void 0,forDerivs:{sandbox:!1,createOrder:{marginMode:!0,triggerPrice:!0,triggerPriceType:{last:!0,mark:!0,index:!0},triggerDirection:!0,stopLossPrice:!0,takeProfitPrice:!0,attachedStopLossTakeProfit:{triggerPriceType:void 0,price:!0},timeInForce:{IOC:!0,FOK:!1,PO:!0,GTD:!1},hedged:!1,trailing:!1,leverage:!0,marketBuyByCost:!0,marketBuyRequiresPrice:!1,selfTradePrevention:!0,iceberg:!0},createOrders:{max:20},fetchMyTrades:{marginMode:!0,limit:1e3,daysBack:void 0,untilDays:7,symbolRequired:!1},fetchOrder:{marginMode:!1,trigger:!1,trailing:!1,symbolRequired:!1},fetchOpenOrders:{marginMode:!1,limit:1e3,trigger:!0,trailing:!1,symbolRequired:!1},fetchOrders:void 0,fetchClosedOrders:{marginMode:!1,limit:1e3,daysBack:void 0,daysBackCanceled:void 0,untilDays:void 0,trigger:!0,trailing:!1,symbolRequired:!1},fetchOHLCV:{limit:500}},swap:{linear:{extends:"forDerivs"},inverse:{extends:"forDerivs"}},future:{linear:{extends:"forDerivs"},inverse:{extends:"forDerivs"}}}})}async fetchStatus(e={}){const t=await this.futuresPublicGetStatus(e),i=this.safeDict(t,"data",{});return{status:"open"===this.safeString(i,"status")?"ok":"maintenance",updated:void 0,eta:void 0,url:void 0,info:t}}async fetchMarkets(e={}){const t=await this.futuresPublicGetContractsActive(e),i=[],s=this.safeList(t,"data",[]);for(let e=0;e-1?"long":"short");const d=r.Y.stringAbs(this.safeString(e,"posCost")),c=this.safeString(e,"posInit"),h=r.Y.stringDiv(c,d),l=this.safeString(e,"unrealisedPnl"),u=this.safeValue(e,"crossMode");let p;return void 0!==u&&(p=u?"cross":"isolated"),this.safePosition({info:e,id:this.safeString2(e,"id","positionId"),symbol:this.safeString(t,"symbol"),timestamp:s,datetime:this.iso8601(s),lastUpdateTimestamp:this.safeInteger(e,"closeTime"),initialMargin:this.parseNumber(c),initialMarginPercentage:this.parseNumber(h),maintenanceMargin:this.safeNumber(e,"posMaint"),maintenanceMarginPercentage:this.safeNumber(e,"maintMarginReq"),entryPrice:this.safeNumber2(e,"avgEntryPrice","openPrice"),notional:this.parseNumber(d),leverage:this.safeNumber2(e,"realLeverage","leverage"),unrealizedPnl:this.parseNumber(l),contracts:this.parseNumber(r.Y.stringAbs(a)),contractSize:this.safeValue(t,"contractSize"),realizedPnl:this.safeNumber2(e,"realisedPnl","pnl"),marginRatio:void 0,liquidationPrice:this.safeNumber(e,"liquidationPrice"),markPrice:this.safeNumber(e,"markPrice"),lastPrice:void 0,collateral:this.safeNumber(e,"maintMargin"),marginMode:p,side:o,percentage:void 0,stopLossPrice:void 0,takeProfitPrice:void 0})}async createOrder(e,t,i,s,r=void 0,a={}){await this.loadMarkets();const o=this.market(e),n=this.safeBool(a,"test",!1);a=this.omit(a,"test");const d=void 0!==this.safeValue(a,"stopLoss")||void 0!==this.safeValue(a,"takeProfit"),c=this.createContractOrderRequest(e,t,i,s,r,a);let h;h=n?await this.futuresPrivatePostOrdersTest(c):d?await this.futuresPrivatePostStOrders(c):await this.futuresPrivatePostOrders(c);const l=this.safeDict(h,"data",{});return this.parseOrder(l,o)}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let t=0;t