diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 56a28f139526a..49c93dbc250a2 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -6,27 +6,21 @@ body: - type: markdown attributes: value: | - ## If you want your issue to be resolved quickly, we strongly recommend that you - - - Read the [Manual](https://github.com/ccxt/ccxt/wiki/Manual), and give special attention to the following sections: - - [Exchange Properties](https://github.com/ccxt/ccxt/wiki/Manual#exchange-properties) - - [Rate Limit](https://github.com/ccxt/ccxt/wiki/Manual#rate-limit) - - [DDoS Protection](https://github.com/ccxt/ccxt/wiki/Manual#ddos-protection-by-cloudflare--incapsula) - - [Authentication](https://github.com/ccxt/ccxt/wiki/Manual#authentication) - - [API Keys Setup](https://github.com/ccxt/ccxt/wiki/Manual#api-keys-setup) - - Read the [API docs](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) for your exchange. - - --- - - ## Ensure - - You have already searched for [existing issues](https://github.com/ccxt/ccxt/issues) and confirmed that this issue is not a duplicate - - This question is directly related to ccxt - - You have read the [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) for most frequently asked questions - - You have read the [How to submit a good issue](https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue) - - Make sure your local version of CCXT is up to date. Check by comparing the output of `ccxt.version` to https://github.com/ccxt/ccxt/blob/master/package.json#L3 - - You have read the [Troubleshooting](https://github.com/ccxt/ccxt/wiki/Manual#troubleshooting) section of the manual and followed troubleshooting steps - - --- + ## Ensure : + - You have already searched across the existing issues + - Your local CCXT version is up to date (check the [latest available version](https://github.com/ccxt/ccxt/blob/master/package.json#L3) ) + - Read the [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) or search for the specific subject in the [Manual](https://github.com/ccxt/ccxt/wiki/Manual) (eg: `Exchange Properties`, `Rate Limit`, `Authentication`, `API keys`, etc). + - Read the [Troubleshooting](https://github.com/ccxt/ccxt/wiki/Manual#troubleshooting) to better understand your issue. + + ## Please: + - Set `exchange.verbose = true` property before calling exchange functions + - Provide the minimal, reproducible example/code + - Surround your code/output with triple backticks: + ````markdown + ``` + your data here + ``` + - Hide the keys & credentials. - type: input id: operating-system @@ -39,12 +33,13 @@ body: id: language attributes: multiple: true - label: Programming Languages - description: Which language are you using? + label: Programming Language options: - JavaScript - Python - PHP + - C# + - GO validations: required: false @@ -58,18 +53,5 @@ body: - type: textarea attributes: label: Description - description: Describe the issue that you're having precisely. Include clear steps for how to reproduce the issue. - validations: - required: false - - - type: textarea - attributes: - label: Code - description: Don't post your API keys or secret keys! - value: | - ``` -    - - ``` validations: required: false diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index b4bd74e278434..956c8e5be8063 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -126,7 +126,7 @@ jobs: name: shared_env - uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0.x' + dotnet-version: '9.0.x' dotnet-quality: 'preview' - name: Download CS Files uses: actions/download-artifact@v4 diff --git a/.github/workflows/go-app.yml b/.github/workflows/go-app.yml index a03bd9b321f9a..8d14754bae41e 100644 --- a/.github/workflows/go-app.yml +++ b/.github/workflows/go-app.yml @@ -137,6 +137,8 @@ jobs: with: name: go-files path: go/ + - name: Restore shared_env + run: ./utils/restore_shared_env.sh - name: Build tests run: cd go/ && go build ./tests/main.go - name: Install npm dependencies @@ -151,9 +153,13 @@ jobs: # run: go build ./go/tests/main.go # - name: Adjust permissions # run: cd go && chmod +x main + - name: Build + run: cd go && go build ./v4 && cd .. + - name: Build tests + run: cd go && go build ./tests/main.go && cd .. - name: Live tests if: env.important_modified == 'true' - run: cd go/ && npm run live-tests-rest-go + run: node run-tests --go --useProxy - name: Live tests (specific) if: env.important_modified == 'false' run: ./run-tests-simul.sh --go "${{ env.rest_files }}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d69fc0580ea49..fc0fced789c38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,31 +7,8 @@ ## How To Submit An Issue -If you want to submit an issue and you want your issue to be resolved quickly, here's a checklist for you: - -- Read the [Manual](https://github.com/ccxt/ccxt/wiki/Manual), and especially carefully read the following sections: - - [Exchange Properties](https://github.com/ccxt/ccxt/wiki/Manual#exchange-properties) - - [Rate Limit](https://github.com/ccxt/ccxt/wiki/Manual#rate-limit) - - [DDoS Protection](https://github.com/ccxt/ccxt/wiki/Manual#ddos-protection-by-cloudflare--incapsula) - - [Authentication](https://github.com/ccxt/ccxt/wiki/Manual#authentication) - - [API Keys Setup](https://github.com/ccxt/ccxt/wiki/Manual#api-keys-setup) -- Read the [Troubleshooting](https://github.com/ccxt/ccxt/wiki/Manual#troubleshooting) section and follow troubleshooting steps. -- Read the [FAQ](https://github.com/ccxt/ccxt/wiki/FAQ) for most frequently asked questions. -- Read the [API docs](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) for your exchange. -- Search for similar issues first to avoid duplicates. -- If your issue is unique, along with a basic description of the failure, the following **IS REQUIRED**: - - **set `exchange.verbose = true` property on the exchange instance before calling its functions or methods** - - **DON'T POST SCREENSHOTS OF CODE OR ERRORS, POST THE OUTPUT AND CODE IN PLAIN TEXT!** - - **surround code and output with triple backticks: ```GOOD```** - - don't confuse the backtick symbol (`) with the quote symbol (\'): '''BAD''' - - don't confuse a single backtick with triple backticks: `BAD` - - paste a complete code snippet you're having difficulties with, avoid one-liners - - paste the **full verbose output** of the failing method without your keys - - the verbose output should include the request and response from the exchange (not just an error callstack) - - write your language **and version** - - write ccxt library version - - which exchange it is - - which method you're trying to call +Read the notes when opening a [new issue on github](https://github.com/ccxt/ccxt/issues/new/choose) and provide the requested details, so we can assist you better. You can aso read [Troubleshooting](https://github.com/ccxt/ccxt/wiki/Manual#troubleshooting) section. + ### Reporting Vulnerabilities And Critical Issues diff --git a/README.md b/README.md index fe928975f4c46..61487020d55cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # CCXT – CryptoCurrency eXchange Trading Library -[![NPM Downloads](https://img.shields.io/npm/dy/ccxt.svg)](https://www.npmjs.com/package/ccxt) [![npm](https://img.shields.io/npm/v/ccxt.svg)](https://npmjs.com/package/ccxt) [![PyPI](https://img.shields.io/pypi/v/ccxt.svg)](https://pypi.python.org/pypi/ccxt) [![NuGet version](https://img.shields.io/nuget/v/ccxt)](https://www.nuget.org/packages/ccxt) [![GoDoc](https://pkg.go.dev/badge/github.com/ccxt/ccxt/go/v4?utm_source=godoc)](https://godoc.org/github.com/ccxt/ccxt/go/v4) [![Discord](https://img.shields.io/discord/690203284119617602?logo=discord&logoColor=white)](https://discord.gg/ccxt) [![Supported Exchanges](https://img.shields.io/badge/exchanges-105-blue.svg)](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [![Follow CCXT at x.com](https://img.shields.io/twitter/follow/ccxt_official.svg?style=social&label=CCXT)](https://x.com/ccxt_official) +[![NPM Downloads](https://img.shields.io/npm/dy/ccxt.svg)](https://www.npmjs.com/package/ccxt) [![npm](https://img.shields.io/npm/v/ccxt.svg)](https://npmjs.com/package/ccxt) [![PyPI](https://img.shields.io/pypi/v/ccxt.svg)](https://pypi.python.org/pypi/ccxt) [![NuGet version](https://img.shields.io/nuget/v/ccxt)](https://www.nuget.org/packages/ccxt) [![GoDoc](https://pkg.go.dev/badge/github.com/ccxt/ccxt/go/v4?utm_source=godoc)](https://godoc.org/github.com/ccxt/ccxt/go/v4) [![Discord](https://img.shields.io/discord/690203284119617602?logo=discord&logoColor=white)](https://discord.gg/ccxt) [![Supported Exchanges](https://img.shields.io/badge/exchanges-106-blue.svg)](https://github.com/ccxt/ccxt/wiki/Exchange-Markets) [![Follow CCXT at x.com](https://img.shields.io/twitter/follow/ccxt_official.svg?style=social&label=CCXT)](https://x.com/ccxt_official) A `JavaScript` / `Python` / `PHP` / `C#` / `Go` library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs. @@ -47,13 +47,12 @@ Current feature list: | [![kucoin](https://user-images.githubusercontent.com/51840849/87295558-132aaf80-c50e-11ea-9801-a2fb0c57c799.jpg)](https://www.kucoin.com/ucenter/signup?rcode=E5wkqe) | kucoin | [KuCoin](https://www.kucoin.com/ucenter/signup?rcode=E5wkqe) | [![API Version 2](https://img.shields.io/badge/2-lightgray)](https://docs.kucoin.com) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | | [![kucoinfutures](https://user-images.githubusercontent.com/1294454/147508995-9e35030a-d046-43a1-a006-6fabd981b554.jpg)](https://futures.kucoin.com/?rcode=E5wkqe) | kucoinfutures | [KuCoin Futures](https://futures.kucoin.com/?rcode=E5wkqe) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.kucoin.com/futures) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | | [![mexc](https://user-images.githubusercontent.com/1294454/137283979-8b2a818d-8633-461b-bfca-de89e8c446b2.jpg)](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | mexc | [MEXC Global](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | [![API Version 3](https://img.shields.io/badge/3-lightgray)](https://mexcdevelop.github.io/apidocs/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | -| [![modetrade](https://github.com/user-attachments/assets/cec2b7f1-3b2b-4502-971b-447ee1937d6b)](https://trade.mode.network?ref=MODETRADE) | modetrade | [Mode Trade](https://trade.mode.network?ref=MODETRADE) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](undefined) | ![DEX - Distributed EXchange](https://img.shields.io/badge/DEX-blue.svg "DEX - Distributed EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with Mode Trade using CCXT's referral link for a 20% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d20%25&color=orange)](https://trade.mode.network?ref=MODETRADE) | | [![okx](https://user-images.githubusercontent.com/1294454/152485636-38b19e4a-bece-4dec-979a-5982859ffc04.jpg)](https://www.okx.com/join/CCXT2023) | okx | [OKX](https://www.okx.com/join/CCXT2023) | [![API Version 5](https://img.shields.io/badge/5-lightgray)](https://www.okx.com/docs-v5/en/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with OKX using CCXT's referral link for a 20% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d20%25&color=orange)](https://www.okx.com/join/CCXT2023) | | [![woo](https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg)](https://woox.io/register?ref=DIJT0CNL) | woo | [WOO X](https://woox.io/register?ref=DIJT0CNL) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.woox.io/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with WOO X using CCXT's referral link for a 35% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d35%25&color=orange)](https://woox.io/register?ref=DIJT0CNL) | | [![woofipro](https://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1)](https://dex.woo.org/en/trade?ref=CCXT) | woofipro | [WOOFI PRO](https://dex.woo.org/en/trade?ref=CCXT) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://orderly.network/docs/build-on-evm/building-on-evm) | ![DEX - Distributed EXchange](https://img.shields.io/badge/DEX-blue.svg "DEX - Distributed EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | [![Sign up with WOOFI PRO using CCXT's referral link for a 5% discount!](https://img.shields.io/static/v1?label=Fee&message=%2d5%25&color=orange)](https://dex.woo.org/en/trade?ref=CCXT) | ## Supported Cryptocurrency Exchanges -The CCXT library currently supports the following 102 cryptocurrency exchange markets and trading APIs: +The CCXT library currently supports the following 103 cryptocurrency exchange markets and trading APIs: |logo |id |name |ver |type |certified |pro | |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|----------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------| @@ -112,6 +111,7 @@ Current feature list: | [![ellipx](https://github.com/user-attachments/assets/e07c3f40-281c-4cdf-bacf-fa1c58218a2c)](https://www.ellipx.com) | ellipx | [Ellipx](https://www.ellipx.com) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.google.com/document/d/1ZXzTQYffKE_EglTaKptxGQERRnunuLHEMmar7VC9syM) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | | | [![exmo](https://user-images.githubusercontent.com/1294454/27766491-1b0ea956-5eda-11e7-9225-40d67b481b8d.jpg)](https://exmo.me/?ref=131685) | exmo | [EXMO](https://exmo.me/?ref=131685) | [![API Version 1.1](https://img.shields.io/badge/1.1-lightgray)](https://exmo.me/en/api_doc?ref=131685) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | | | [![fmfwio](https://user-images.githubusercontent.com/1294454/159177712-b685b40c-5269-4cea-ac83-f7894c49525d.jpg)](https://fmfw.io/referral/da948b21d6c92d69) | fmfwio | [FMFW.io](https://fmfw.io/referral/da948b21d6c92d69) | [![API Version 3](https://img.shields.io/badge/3-lightgray)](https://api.fmfw.io/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | | +| [![foxbit](https://github.com/user-attachments/assets/ba1435eb-1d59-4393-8de7-0db10a002fb3)](https://app.foxbit.com.br) | foxbit | [Foxbit](https://app.foxbit.com.br) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.foxbit.com.br) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | | | [![gate](https://github.com/user-attachments/assets/64f988c5-07b6-4652-b5c1-679a6bf67c85)](https://www.gate.io/signup/2436035) | gate | [Gate.io](https://www.gate.io/signup/2436035) | [![API Version 4](https://img.shields.io/badge/4-lightgray)](https://www.gate.io/docs/developers/apiv4/en/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![gemini](https://user-images.githubusercontent.com/1294454/27816857-ce7be644-6096-11e7-82d6-3c257263229c.jpg)](https://gemini.com/) | gemini | [Gemini](https://gemini.com/) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://docs.gemini.com/rest-api) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![hashkey](https://github.com/user-attachments/assets/6dd6127b-cc19-4a13-9b29-a98d81f80e98)](https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN) | hashkey | [HashKey Global](https://global.hashkey.com/en-US/register/invite?invite_code=82FQUN) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://hashkeyglobal-apidoc.readme.io/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | @@ -130,7 +130,7 @@ Current feature list: | [![luno](https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg)](https://www.luno.com/invite/44893A) | luno | [luno](https://www.luno.com/invite/44893A) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://www.luno.com/en/api) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![mercado](https://user-images.githubusercontent.com/1294454/27837060-e7c58714-60ea-11e7-9192-f05e86adb83f.jpg)](https://www.mercadobitcoin.com.br) | mercado | [Mercado Bitcoin](https://www.mercadobitcoin.com.br) | [![API Version 3](https://img.shields.io/badge/3-lightgray)](https://www.mercadobitcoin.com.br/api-doc) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | | | [![mexc](https://user-images.githubusercontent.com/1294454/137283979-8b2a818d-8633-461b-bfca-de89e8c446b2.jpg)](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | mexc | [MEXC Global](https://www.mexc.com/register?inviteCode=mexc-1FQ1GNu1) | [![API Version 3](https://img.shields.io/badge/3-lightgray)](https://mexcdevelop.github.io/apidocs/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | -| [![modetrade](https://github.com/user-attachments/assets/cec2b7f1-3b2b-4502-971b-447ee1937d6b)](https://trade.mode.network?ref=MODETRADE) | modetrade | [Mode Trade](https://trade.mode.network?ref=MODETRADE) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](undefined) | ![DEX - Distributed EXchange](https://img.shields.io/badge/DEX-blue.svg "DEX - Distributed EXchange") | [![CCXT Certified](https://img.shields.io/badge/CCXT-Certified-green.svg)](https://github.com/ccxt/ccxt/wiki/Certification) | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | +| [![modetrade](https://github.com/user-attachments/assets/cec2b7f1-3b2b-4502-971b-447ee1937d6b)](https://trade.mode.network?ref=MODETRADE) | modetrade | [Mode Trade](https://trade.mode.network?ref=MODETRADE) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](undefined) | ![DEX - Distributed EXchange](https://img.shields.io/badge/DEX-blue.svg "DEX - Distributed EXchange") | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![myokx](https://user-images.githubusercontent.com/1294454/152485636-38b19e4a-bece-4dec-979a-5982859ffc04.jpg)](https://www.my.okx.com/join/CCXT2023) | myokx | [MyOKX (EEA)](https://www.my.okx.com/join/CCXT2023) | [![API Version 5](https://img.shields.io/badge/5-lightgray)](https://my.okx.com/docs-v5/en/#overview) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![ndax](https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg)](https://one.ndax.io/bfQiSL) | ndax | [NDAX](https://one.ndax.io/bfQiSL) | [![API Version *](https://img.shields.io/badge/*-lightgray)](https://apidoc.ndax.io/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | [![CCXT Pro](https://img.shields.io/badge/CCXT-Pro-black)](https://ccxt.pro) | | [![novadax](https://user-images.githubusercontent.com/1294454/92337550-2b085500-f0b3-11ea-98e7-5794fb07dd3b.jpg)](https://www.novadax.com.br/?s=ccxt) | novadax | [NovaDAX](https://www.novadax.com.br/?s=ccxt) | [![API Version 1](https://img.shields.io/badge/1-lightgray)](https://doc.novadax.com/pt-BR/) | ![CEX – Centralized EXchange](https://img.shields.io/badge/CEX-green.svg "CEX – Centralized EXchange") | | | @@ -220,13 +220,13 @@ console.log(version, Object.keys(exchanges)); All-in-one browser bundle (dependencies included), served from a CDN of your choice: -* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.92/dist/ccxt.browser.min.js -* unpkg: https://unpkg.com/ccxt@4.4.92/dist/ccxt.browser.min.js +* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.4.96/dist/ccxt.browser.min.js +* unpkg: https://unpkg.com/ccxt@4.4.96/dist/ccxt.browser.min.js CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers. ```HTML - + ``` Creates a global `ccxt` object: diff --git a/build/dummy.txt b/build/dummy.txt index d42b8de32404d..3b9c3b0435a35 100644 --- a/build/dummy.txt +++ b/build/dummy.txt @@ -38,3 +38,8 @@ release!!!! ! ! ! +try +! +! +! +! \ No newline at end of file diff --git a/build/generateImplicitAPI.ts b/build/generateImplicitAPI.ts index b2828d2a31ed3..3c283b8945598 100644 --- a/build/generateImplicitAPI.ts +++ b/build/generateImplicitAPI.ts @@ -216,22 +216,29 @@ function createImplicitMethodsGo(){ const exchange = exchanges[index]; const methodNames = storedCamelCaseMethods[exchange]; + // const reusableMethod = [ + // `func (this *${exchange}) callEndpointAsync(endpointName string, args ...interface{}) <-chan interface{} {`, + // ` parameters := GetArg(args, 0, nil)`, + // ` ch := make(chan interface{})`, + // ` go func() {`, + // ` defer close(ch)`, + // ` defer func() {`, + // ` if r := recover(); r != nil {`, + // ` ch <- "panic:" + ToString(r)`, + // ` }`, + // ` }()`, + // ` ch <- (<-this.callEndpoint (endpointName, parameters))`, + // ` PanicOnError(ch)`, + // ` }()`, + // ` return ch`, + // `}`, + // `` + // ].join('\n'); + const methods = methodNames.map(method=> { return [ `func (this *${exchange}) ${capitalize(method)} (args ...interface{}) <-chan interface{} {`, - ` parameters := GetArg(args, 0, nil)`, - ` ch := make(chan interface{})`, - ` go func() {`, - ` defer close(ch)`, - ` defer func() {`, - ` if r := recover(); r != nil {`, - ` ch <- "panic:" + ToString(r)`, - ` }`, - ` }()`, - ` ch <- (<-this.callEndpoint ("${method}", parameters))`, - ` PanicOnError(ch)`, - ` }()`, - ` return ch`, + ` return this.callEndpointAsync("${method}", args...)`, `}`, ``, ].join('\n') @@ -243,7 +250,8 @@ function createImplicitMethodsGo(){ // ``, // ].join('\n') }); - storedGoMethods[exchange] = storedGoMethods[exchange].concat (methods) + // methods.unshift (reusableMethod); + storedGoMethods[exchange] = storedGoMethods[exchange].concat (methods) } } diff --git a/build/goTranspiler.ts b/build/goTranspiler.ts index 2e55c16b6eb3a..6aaff714d3d60 100644 --- a/build/goTranspiler.ts +++ b/build/goTranspiler.ts @@ -48,9 +48,10 @@ if (platform === 'win32') { } } -const GLOBAL_WRAPPER_FILE = './go/v4/base/exchange_wrappers.go'; +const GLOBAL_WRAPPER_FILE = './go/v4/exchange_wrappers.go'; const EXCHANGE_WRAPPER_FOLDER = './go/v4/' const DYNAMIC_INSTANCE_FILE = './go/v4/exchange_dynamic.go'; +const TYPED_INTERFACE_FILE = './go/v4/exchange_typed_interface.go'; // const EXCHANGE_WS_WRAPPER_FOLDER = './go/v4/exchanges/pro/wrappers/' const ERRORS_FILE = './go/v4/exchange_errors.go'; const BASE_METHODS_FILE = './go/v4/exchange_generated.go'; @@ -68,6 +69,8 @@ const goComments: any = {}; const goTypeOptions: any = {}; const goWithMethods = {}; +const WRAPPER_METHODS: {} = {}; + let goTests: string[] = []; const VIRTUAL_BASE_METHODS: any = { @@ -94,6 +97,7 @@ const VIRTUAL_BASE_METHODS: any = { "fetchMyTrades": true, "fetchOHLCV": true, "fetchOpenOrders": true, + "fetchTradingFees": true, "fetchOption": true, "fetchOrder": true, "fetchOrderBook": true, @@ -151,6 +155,136 @@ const VIRTUAL_BASE_METHODS: any = { "sign": false } +const INTERFACE_METHODS = [ + 'cancelAllOrders', + 'cancelAllOrdersAfter', + 'cancelOrder', + 'cancelOrdersForSymbols', + 'createConvertTrade', + 'createDepositAddress', + 'createLimitBuyOrder', + 'createLimitOrder', + 'createLimitSellOrder', + 'createMarketBuyOrder', + 'createMarketBuyOrderWithCost', + 'createMarketOrder', + 'createMarketOrderWithCost', + 'createMarketSellOrder', + 'createMarketSellOrderWithCost', + 'createOrder', + 'createOrders', + 'createOrderWithTakeProfitAndStopLoss', + 'createPostOnlyOrder', + 'createReduceOnlyOrder', + 'createStopLimitOrder', + 'createStopLossOrder', + 'createStopMarketOrder', + 'createStopOrder', + 'createTakeProfitOrder', + 'createTrailingAmountOrder', + 'createTrailingPercentOrder', + 'createTriggerOrder', + 'editLimitBuyOrder', + 'editLimitOrder', + 'editLimitSellOrder', + 'editOrder', + 'editOrders', + 'fetchAccounts', + 'fetchAllGreeks', + 'fetchBalance', + 'fetchBidsAsks', + 'fetchBorrowInterest', + 'fetchBorrowRate', + 'fetchCanceledAndClosedOrders', + 'fetchClosedOrders', + 'fetchConvertCurrencies', + 'fetchConvertQuote', + 'fetchConvertTrade', + 'fetchConvertTradeHistory', + 'fetchCrossBorrowRate', + 'fetchCrossBorrowRates', + 'fetchCurrencies', + 'fetchDepositAddress', + 'fetchDepositAddresses', + 'fetchDepositAddressesByNetwork', + 'fetchDeposits', + 'fetchDepositsWithdrawals', + 'fetchDepositWithdrawFee', + 'fetchDepositWithdrawFees', + 'fetchFreeBalance', + 'fetchFundingHistory', + 'fetchFundingInterval', + 'fetchFundingIntervals', + 'fetchFundingRate', + 'fetchFundingRateHistory', + 'fetchFundingRates', + 'fetchGreeks', + 'fetchIndexOHLCV', + 'fetchIsolatedBorrowRate', + 'fetchIsolatedBorrowRates', + 'fetchLastPrices', + 'fetchLedger', + 'fetchLedgerEntry', + 'fetchLeverage', + 'fetchLeverages', + 'fetchLeverageTiers', + 'fetchLiquidations', + 'fetchLongShortRatio', + 'fetchLongShortRatioHistory', + 'fetchMarginAdjustmentHistory', + 'fetchMarginMode', + 'fetchMarginModes', + 'fetchMarketLeverageTiers', + 'fetchMarkets', + 'fetchMarkOHLCV', + 'fetchMarkPrice', + 'fetchMarkPrices', + 'fetchMyLiquidations', + 'fetchMyTrades', + 'fetchOHLCV', + 'fetchOpenInterest', + 'fetchOpenInterestHistory', + 'fetchOpenInterests', + 'fetchOpenOrders', + 'fetchOption', + 'fetchOptionChain', + 'fetchOrder', + 'fetchOrderBook', + 'fetchOrderBooks', + 'fetchOrders', + 'fetchOrderStatus', + 'fetchOrderTrades', + 'fetchPaymentMethods', + 'fetchPosition', + 'fetchPositionHistory', + 'fetchPositionMode', + 'fetchPositions', + 'fetchPositionsForSymbol', + 'fetchPositionsHistory', + 'fetchPositionsRisk', + 'fetchPremiumIndexOHLCV', + 'fetchStatus', + 'fetchTicker', + 'fetchTickers', + 'fetchTime', + 'fetchTrades', + 'fetchTradingFee', + 'fetchTradingFees', + 'fetchTradingLimits', + 'fetchTransactionFee', + 'fetchTransactionFees', + 'fetchTransactions', + 'fetchTransfer', + 'fetchTransfers', + 'fetchWithdrawals', + // 'setLeverage', // tmp remove we have to unify types + 'setMargin', + 'setMarginMode', + 'setPositionMode', + 'transfer', + 'withdraw', +] + class NewTranspiler { transpiler!: Transpiler; @@ -431,6 +565,10 @@ class NewTranspiler { return ` <- chan int64`; // custom handling for now } + if (name.startsWith('fetchDepositWithdrawFee')) { // tmp fix later with proper types + return `map[string]interface{}` + } + const isPromise = type.startsWith('Promise<') && type.endsWith('>'); let wrappedType = isPromise ? type.substring(8, type.length - 1) : type; let isList = false; @@ -610,7 +748,7 @@ class NewTranspiler { 'createContractOrder', 'createSwapOrder', 'fetchPortfolioDetails', - 'createVault' + 'createVault', ] // improve this later if (isWs) { if (methodName.indexOf('Snapshot') !== -1 || methodName.indexOf('Subscription') !== -1 || methodName.indexOf('Cache') !== -1) { @@ -641,6 +779,10 @@ class NewTranspiler { return `(res).(int64)`; } + if (methodName === 'fetchDepositWithdrawFees' || methodName === 'fetchDepositWithdrawFee') { + return `(res).(map[string]interface{})`; + } + // handle the typescript type Dict if (unwrappedType === 'Dict' || unwrappedType === 'map[string]interface{}') { return `res.(map[string]interface{})`; @@ -760,12 +902,50 @@ class NewTranspiler { goTypeOptions[capName] = res.concat(withMethod).join("\n"); } + + createMissingMethodWrapper(exchangeName: string, name: string, methodInfo: any) { + if (!methodInfo) { + return ''; + } + const itf = methodInfo.interface + // const params = methodInfo.params; + const exCap = this.capitalize(exchangeName); + const nameCap = this.capitalize(name); + const wrapper = methodInfo.wrapper; + + let args: string[] = []; + for (const param of wrapper.parameters) { + if (param.name === 'params' && wrapper.parameters.length === 1) { + args.push('params...') + break; + } + if (param.isOptional || param.name === 'params' || param.initializer !== undefined || param.initializer === 'undefined' || param.initializer === '{}') { + // if (wrapper.parameters.length === 1) { + // args.push(`params...`) + // } else { + // args.push(`options...`) + // } + args.push(`options...`) + break; + } else { + args.push(this.safeGoName(param.name)) + } + } + + return `func (this *${exCap}) ${itf} {return this.exchangeTyped.${nameCap}(${args.join(', ')})}`; + } + createWrapper (exchangeName: string, methodWrapper: any, isWs = false) { const isAsync = methodWrapper.async; + const isExchange = exchangeName === 'Exchange'; const methodName = methodWrapper.name; + if (methodName.startsWith('watch') || methodName.endsWith('Ws')) { + return ''; + } if (!this.shouldCreateWrapper(methodName, isWs) || !isAsync) { return ''; // skip aux methods like encodeUrl, parseOrder, etc } + const methodNameCapitalized = methodName.charAt(0).toUpperCase() + methodName.slice(1); const returnType = this.convertJavascriptTypeToGoType(methodName, methodWrapper.returnType, true); const unwrappedType = this.unwrapTaskIfNeeded(returnType as string); @@ -805,13 +985,14 @@ class NewTranspiler { params = 'params...' } + const accessor = isExchange ? 'this.Exchange.' : 'this.Core.'; const body = [ // `${two}ch:= make(chan ${unwrappedType})`, // `${two}go func() {`, // `${three}defer close(ch)`, // `${three}defer ReturnPanicError(ch)`, `${defaultParams}`, - `${two}res := <- this.Core.${methodNameCapitalized}(${params})`, + `${two}res := <- ${accessor}${methodNameCapitalized}(${params})`, `${two}if IsError(res) {`, `${three}return ${emtpyObject}, CreateReturnError(res)`, `${two}}`, @@ -819,8 +1000,22 @@ class NewTranspiler { // `${two}}()`, // `${two}return ch`, ] + const interfaceMethod = `${methodNameCapitalized}(${stringArgs}) (${unwrappedType}, error)` + if (!WRAPPER_METHODS[exchangeName]) { + WRAPPER_METHODS[exchangeName] = []; + } + if (!WRAPPER_METHODS[exchangeName][methodName]) { + WRAPPER_METHODS[exchangeName][methodName] = {}; + } + WRAPPER_METHODS[exchangeName][methodName] = { + wrapper: methodWrapper, + interface: interfaceMethod, + params: stringArgs, + } + // wrapperMethods[exchangeName].push([interfaceMethod, stringArgs, methodWrapper]); + const funcContext = isExchange ? 'ExchangeTyped' : this.capitalize(exchangeName); const method = [ - `${one}func (this *${this.capitalize(exchangeName)}) ${methodNameCapitalized}(${stringArgs}) (${unwrappedType}, error) {`, + `${one}func (this *${funcContext}) ${methodNameCapitalized}(${stringArgs}) (${unwrappedType}, error) {`, ...body, // this.getDefaultParamsWrappers(methodNameCapitalized, methodWrapper.parameters), // `${two}res := ${isAsync ? '<-' : ''}this.${exchangeName}.${methodNameCapitalized}(${params});`, @@ -844,30 +1039,71 @@ class NewTranspiler { } createGoWrappers(exchange:string, path: string, wrappers: any[], ws = false) { + const methodsList = wrappers.map(wrapper => wrapper.name); + const missingMethods = INTERFACE_METHODS.filter(method => !methodsList.includes(method)); + const wrappersIndented = wrappers.map(wrapper => this.createWrapper(exchange, wrapper, ws)).filter(wrapper => wrapper !== '').join('\n'); + + let missingMethodsWrappers = ''; + if (exchange !== 'Exchange') { + if (!WRAPPER_METHODS['Exchange']) { + throw new Error('Exchange wrapper methods are not defined, please transpile base methods first'); + } + missingMethodsWrappers = missingMethods.map (m => this.createMissingMethodWrapper(exchange, m, WRAPPER_METHODS['Exchange'][m])).filter(wrapper => wrapper !== '').join('\n'); + } + const shouldCreateClassWrappers = exchange === 'Exchange'; const classes = shouldCreateClassWrappers ? this.createExchangesWrappers().filter(e=> !!e).join('\n') : ''; // const exchangeName = ws ? exchange + 'Ws' : exchange; const namespace = 'package ccxt'; const capitizedName = exchange.charAt(0).toUpperCase() + exchange.slice(1); // const capitalizeStatement = ws ? `public class ${capitizedName}: ${exchange} { public ${capitizedName}(object args = null) : base(args) { } }` : ''; - const exchangeStruct = [ - `type ${capitizedName} struct {`, - ` *${exchange}`, - ` Core *${exchange}`, - `}` - ].join('\n'); - const newMethod = [ - 'func New' + capitizedName + '(userConfig map[string]interface{}) ' + capitizedName + ' {', - ` p := &${exchange}{}`, - ' p.Init(userConfig)', - ` return ${capitizedName}{`, - ` ${exchange}: p,`, - ` Core: p,`, - ` }`, - '}' - ].join('\n'); + let exchangeStruct = ''; + if (exchange === 'Exchange') { + + exchangeStruct = [ + `type ExchangeTyped struct {`, + ` *Exchange`, + `}` + ].join('\n'); + + } else { + + exchangeStruct = [ + `type ${capitizedName} struct {`, + ` *${exchange}`, + ` Core *${exchange}`, + ` exchangeTyped *ExchangeTyped`, + `}` + ].join('\n'); + + } + + let newMethod = ''; + if (exchange === 'Exchange') { + newMethod = [ + 'func NewExchangeTyped(exchangePointer *Exchange) *ExchangeTyped {', + ` return &ExchangeTyped{`, + ` Exchange: exchangePointer,`, + ` }`, + '}' + ].join('\n'); + + } else { + newMethod = [ + 'func New' + capitizedName + '(userConfig map[string]interface{}) *' + capitizedName + ' {', + ` p := &${exchange}{}`, + ' p.Init(userConfig)', + ` return &${capitizedName}{`, + ` ${exchange}: p,`, + ` Core: p,`, + ' exchangeTyped: NewExchangeTyped(&p.Exchange),', + ` }`, + '}' + ].join('\n'); + } + const file = [ namespace, @@ -879,6 +1115,9 @@ class NewTranspiler { this.createGeneratedHeader().join('\n'), '', wrappersIndented, + '// missing typed methods from base', + '//nolint', + missingMethodsWrappers, ].join('\n') log.magenta ('→', (path as any).yellow) @@ -994,7 +1233,13 @@ ${constStatements.join('\n')} return `<-this.DerivedExchange.${capitalizedMethod}(${p2})`; }); // create wrappers with specific types - // this.creategoWrappers('Exchange', GLOBAL_WRAPPER_FILE, baseFile.methodsTypes) + this.createGoWrappers('Exchange', GLOBAL_WRAPPER_FILE, baseFile.methodsTypes) + + // const exchangeMethods = wrapperMethods['Exchange']; + // const sortedList = exchangeMethods.sort((a, b) => a.localeCompare(b)); + // sortedList.forEach( i => { + // console.log(i) + // }); // custom transformations needed for go @@ -1050,7 +1295,7 @@ ${constStatements.join('\n')} }) const functionDecl = ` -func DynamicallyCreateInstance(exchangeId string, exchangeArgs map[string]interface{}) (IExchange, bool) { +func DynamicallyCreateInstance(exchangeId string, exchangeArgs map[string]interface{}) (ICoreExchange, bool) { switch exchangeId { ${caseStatements.join('\n')} default: @@ -1069,6 +1314,58 @@ ${caseStatements.join('\n')} fs.writeFileSync (dynamicInstanceFile, file); } + + createTypedInterfaceFile(){ + if (!WRAPPER_METHODS['Exchange']) { + throw new Error('Exchange wrapper methods are not defined, please transpile base methods first'); + } + const exchanges = ['exchange'].concat(exchangeIds); + + const caseStatements = exchanges.map(exchange => { + const struct = exchange === 'exchange' ? 'ExchangeTyped' : this.capitalize(exchange); + const args = exchange === 'exchange' ? 'nil' : 'options'; + return` case "${exchange}": + itf := New${struct}(${args}) + return itf`; + }) + + const functionDecl = ` +func CreateExchange(exchangeId string, options map[string]interface{}) IExchange { + exchangeId = strings.ToLower(exchangeId) + switch exchangeId { +${caseStatements.join('\n')} + default: + return nil + } +} +` + const interfaceMethods = Object.keys(WRAPPER_METHODS['Exchange']).map(method => { + const methodInfo = WRAPPER_METHODS['Exchange'][method]; + if (!INTERFACE_METHODS.includes(method)) { + return ''; + } + return methodInfo.interface; + }).filter(e => !!e) + + const interfaceDecl = ` +type IExchange interface { + IBaseExchange + ${interfaceMethods.join('\n ')} +}`; + + const file = [ + 'package ccxt', + 'import "strings"', + this.createGeneratedHeader().join('\n'), + '', + interfaceDecl, + functionDecl, + ].join('\n'); + + fs.writeFileSync (TYPED_INTERFACE_FILE, file); + } + + camelize(str: string) { var res = str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) { if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces @@ -1162,31 +1459,30 @@ ${caseStatements.join('\n')} } const options = { goFolder, exchanges } + this.transpileBaseMethods (exchangeBase) // now we always need the baseMethods info + if (!transpilingSingleExchange && !child) { + this.createDynamicInstanceFile(); + this.createTypedInterfaceFile(); + } + if (!baseOnly && !examplesOnly) { await this.transpileDerivedExchangeFiles (tsFolder, options, '.ts', force, !!(child || exchanges.length)) } - // this.transpileExamples(); // disabled for now - if (examplesOnly) { - return; - } - - if (transpilingSingleExchange) { - this.createDynamicInstanceFile(); - return; - } if (child) { return; } - this.transpileBaseMethods (exchangeBase) - this.createDynamicInstanceFile(); if (baseOnly) { return; } + if (transpilingSingleExchange) { + return; + } + this.transpileTests() @@ -1630,13 +1926,13 @@ func (this *${className}) Init(userConfig map[string]interface{}) { // ad-hoc fixes contentIndentend = this.regexAll (contentIndentend, [ - [/var exchange interface{} =/g,'var exchange ccxt.IExchange ='], - [/var mockedExchange interface{} =/g,'var mockedExchange ccxt.IExchange ='], - [/exchange interface\{\},/g, 'exchange ccxt.IExchange,'], - [/exchange interface\{\}\)/g, 'exchange ccxt.IExchange)'], + [/var exchange interface{} =/g,'var exchange ccxt.ICoreExchange ='], + [/var mockedExchange interface{} =/g,'var mockedExchange ccxt.ICoreExchange ='], + [/exchange interface\{\},/g, 'exchange ccxt.ICoreExchange,'], + [/exchange interface\{\}\)/g, 'exchange ccxt.ICoreExchange)'], [/exchange.(\w+)\s*=\s*(.+)/g, 'exchange.Set$1($2)'], [/exchange\.(\w+)(,|;|\)|\s)/g, 'exchange.Get$1()$2'], - [/InitOfflineExchange\(exchangeName interface{}\) interface\{\} {/g, 'InitOfflineExchange(exchangeName interface{}) ccxt.IExchange {'], + [/InitOfflineExchange\(exchangeName interface{}\) interface\{\} {/g, 'InitOfflineExchange(exchangeName interface{}) ccxt.ICoreExchange {'], [/assert\(/g, 'Assert('], [/GetRootException\(ex\)/g, 'GetRootException(e)'], [/OnlySpecificTests \[\]interface\{\}/g, 'OnlySpecificTests interface{} '], @@ -1730,8 +2026,8 @@ func (this *${className}) Init(userConfig map[string]interface{}) { let regexes = [ [/exchange \:\= &ccxt\.Exchange\{\}/g, 'exchange := ccxt.NewExchange()'], [/exchange := ccxt\.Exchange\{\}/g, 'exchange := ccxt.NewExchange()'], - [/exchange interface\{\},/g, 'exchange ccxt.IExchange,'], - [/exchange interface\{\}\)/g, 'exchange ccxt.IExchange)'], + [/exchange interface\{\},/g, 'exchange ccxt.ICoreExchange,'], + [/exchange interface\{\}\)/g, 'exchange ccxt.ICoreExchange)'], [/testSharedMethods\./g, ''], [/assert/gm, 'Assert'], [/exchange.(\w+)\s*=\s*(.+)/g, 'exchange.Set$1($2)'], diff --git a/cleanup.sh b/cleanup.sh index ed9bd1975095d..80f7f6724d299 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -20,3 +20,4 @@ git checkout HEAD examples git checkout HEAD go/v4/exchange_metadata.go git checkout HEAD wiki/Exchange-Markets.md git checkout HEAD wiki/Manual.md +git checkout HEAD -- go/v4 ':(exclude)exchange' diff --git a/cli/ts/cli.ts b/cli/ts/cli.ts index d24e2cb9caebc..59aad221010d5 100644 --- a/cli/ts/cli.ts +++ b/cli/ts/cli.ts @@ -24,7 +24,8 @@ try { ccxt = await (Function ('return import("../../ts/ccxt")') ()); local = true; } catch (ee) { - log.error ('Neither a local installation nor a global CCXT installation was detected, make `npm i` first'); + log.error (ee); + log.error ('Neither a local installation nor a global CCXT installation was detected, make `npm i` first, Also make sure your local ccxt version does not contain any syntax errors.'); process.exit (1); } } @@ -127,6 +128,7 @@ program .option ('--poll', 'will repeat the call continously') .option ('--i', 'iteractive mode, keeps the session opened') .option ('--iso8601') + .option ('--refresh-markets', 'forces markets refresh') .option ('--cors'); // dev related options, docs not needed diff --git a/cli/ts/helpers.ts b/cli/ts/helpers.ts index a8f55d359a139..e61f4c8e6307a 100644 --- a/cli/ts/helpers.ts +++ b/cli/ts/helpers.ts @@ -27,7 +27,8 @@ try { // local ccxt project ccxt = await (Function ('return import("../../ts/ccxt")') ()); } catch (ee) { - log.error ('Neither a local nor a global ccxt installation was detected, please do `npm i` first'); + log.error (ee); + log.error ('Neither a local installation nor a global CCXT installation was detected, make `npm i` first, Also make sure your local ccxt version does not contain any syntax errors.'); process.exit (1); } } @@ -456,11 +457,12 @@ async function loadSettingsAndCreateExchange ( if (fs.existsSync (keysGlobal)) { allSettings = JSON.parse (fs.readFileSync (keysGlobal).toString ()); - } else if (fs.existsSync (keysLocal)) { - allSettings = JSON.parse (fs.readFileSync (keysLocal).toString ()); - } else { - // log ((`( Note, CCXT CLI is being loaded without api keys, because ${keysLocal} does not exist. You can see the sample at https://github.com/ccxt/ccxt/blob/master/keys.json )` as any).yellow); } + if (fs.existsSync (keysLocal)) { + const localSettings = JSON.parse (fs.readFileSync (keysLocal).toString ()); + allSettings = { ...allSettings, ...localSettings }; + } + // log ((`( Note, CCXT CLI is being loaded without api keys, because ${keysLocal} does not exist. You can see the sample at https://github.com/ccxt/ccxt/blob/master/keys.json )` as any).yellow); const exchangeSettings = getExchangeSettings (exchangeId); diff --git a/coin-ws.js b/coin-ws.js deleted file mode 100644 index bc9c5655b712b..0000000000000 --- a/coin-ws.js +++ /dev/null @@ -1,10 +0,0 @@ -import WebSocket from 'ws'; -const webSocket = new WebSocket ('https://stream.coindcx.com'); - -webSocket.onmessage = (ev) => { - console.log (ev) -}; - -webSocket.onopen = (ev) => { - console.log (ev) -} diff --git a/cs/ccxt/api/bingx.cs b/cs/ccxt/api/bingx.cs index e95ddbb0f4c5e..75528fd801017 100644 --- a/cs/ccxt/api/bingx.cs +++ b/cs/ccxt/api/bingx.cs @@ -766,6 +766,11 @@ public async Task apiV3PrivateGetAssetTransfer (object parameters = null return await this.callAsync ("apiV3PrivateGetAssetTransfer",parameters); } + public async Task apiV3PrivateGetAssetTransferRecord (object parameters = null) + { + return await this.callAsync ("apiV3PrivateGetAssetTransferRecord",parameters); + } + public async Task apiV3PrivateGetCapitalDepositHisrec (object parameters = null) { return await this.callAsync ("apiV3PrivateGetCapitalDepositHisrec",parameters); @@ -781,4 +786,14 @@ public async Task apiV3PrivatePostPostAssetTransfer (object parameters = return await this.callAsync ("apiV3PrivatePostPostAssetTransfer",parameters); } + public async Task apiAssetV1PrivatePostTransfer (object parameters = null) + { + return await this.callAsync ("apiAssetV1PrivatePostTransfer",parameters); + } + + public async Task apiAssetV1PublicGetTransferSupportCoins (object parameters = null) + { + return await this.callAsync ("apiAssetV1PublicGetTransferSupportCoins",parameters); + } + } \ No newline at end of file diff --git a/cs/ccxt/api/bitcoincom.cs b/cs/ccxt/api/bitcoincom.cs deleted file mode 100644 index 61aecd200c74c..0000000000000 --- a/cs/ccxt/api/bitcoincom.cs +++ /dev/null @@ -1,569 +0,0 @@ -// ------------------------------------------------------------------------------- - -// 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 - -// ------------------------------------------------------------------------------- - -namespace ccxt; - -public partial class bitcoincom : fmfwio -{ - public bitcoincom (object args = null): base(args) {} - - public async Task publicGetPublicCurrency (object parameters = null) - { - return await this.callAsync ("publicGetPublicCurrency",parameters); - } - - public async Task publicGetPublicCurrencyCurrency (object parameters = null) - { - return await this.callAsync ("publicGetPublicCurrencyCurrency",parameters); - } - - public async Task publicGetPublicSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicSymbol",parameters); - } - - public async Task publicGetPublicSymbolSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicSymbolSymbol",parameters); - } - - public async Task publicGetPublicTicker (object parameters = null) - { - return await this.callAsync ("publicGetPublicTicker",parameters); - } - - public async Task publicGetPublicTickerSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicTickerSymbol",parameters); - } - - public async Task publicGetPublicPriceRate (object parameters = null) - { - return await this.callAsync ("publicGetPublicPriceRate",parameters); - } - - public async Task publicGetPublicPriceHistory (object parameters = null) - { - return await this.callAsync ("publicGetPublicPriceHistory",parameters); - } - - public async Task publicGetPublicPriceTicker (object parameters = null) - { - return await this.callAsync ("publicGetPublicPriceTicker",parameters); - } - - public async Task publicGetPublicPriceTickerSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicPriceTickerSymbol",parameters); - } - - public async Task publicGetPublicTrades (object parameters = null) - { - return await this.callAsync ("publicGetPublicTrades",parameters); - } - - public async Task publicGetPublicTradesSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicTradesSymbol",parameters); - } - - public async Task publicGetPublicOrderbook (object parameters = null) - { - return await this.callAsync ("publicGetPublicOrderbook",parameters); - } - - public async Task publicGetPublicOrderbookSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicOrderbookSymbol",parameters); - } - - public async Task publicGetPublicCandles (object parameters = null) - { - return await this.callAsync ("publicGetPublicCandles",parameters); - } - - public async Task publicGetPublicCandlesSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicCandlesSymbol",parameters); - } - - public async Task publicGetPublicConvertedCandles (object parameters = null) - { - return await this.callAsync ("publicGetPublicConvertedCandles",parameters); - } - - public async Task publicGetPublicConvertedCandlesSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicConvertedCandlesSymbol",parameters); - } - - public async Task publicGetPublicFuturesInfo (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesInfo",parameters); - } - - public async Task publicGetPublicFuturesInfoSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesInfoSymbol",parameters); - } - - public async Task publicGetPublicFuturesHistoryFunding (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesHistoryFunding",parameters); - } - - public async Task publicGetPublicFuturesHistoryFundingSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesHistoryFundingSymbol",parameters); - } - - public async Task publicGetPublicFuturesCandlesIndexPrice (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesIndexPrice",parameters); - } - - public async Task publicGetPublicFuturesCandlesIndexPriceSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesIndexPriceSymbol",parameters); - } - - public async Task publicGetPublicFuturesCandlesMarkPrice (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesMarkPrice",parameters); - } - - public async Task publicGetPublicFuturesCandlesMarkPriceSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesMarkPriceSymbol",parameters); - } - - public async Task publicGetPublicFuturesCandlesPremiumIndex (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesPremiumIndex",parameters); - } - - public async Task publicGetPublicFuturesCandlesPremiumIndexSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesPremiumIndexSymbol",parameters); - } - - public async Task publicGetPublicFuturesCandlesOpenInterest (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesOpenInterest",parameters); - } - - public async Task publicGetPublicFuturesCandlesOpenInterestSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPublicFuturesCandlesOpenInterestSymbol",parameters); - } - - public async Task privateGetSpotBalance (object parameters = null) - { - return await this.callAsync ("privateGetSpotBalance",parameters); - } - - public async Task privateGetSpotBalanceCurrency (object parameters = null) - { - return await this.callAsync ("privateGetSpotBalanceCurrency",parameters); - } - - public async Task privateGetSpotOrder (object parameters = null) - { - return await this.callAsync ("privateGetSpotOrder",parameters); - } - - public async Task privateGetSpotOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privateGetSpotOrderClientOrderId",parameters); - } - - public async Task privateGetSpotFee (object parameters = null) - { - return await this.callAsync ("privateGetSpotFee",parameters); - } - - public async Task privateGetSpotFeeSymbol (object parameters = null) - { - return await this.callAsync ("privateGetSpotFeeSymbol",parameters); - } - - public async Task privateGetSpotHistoryOrder (object parameters = null) - { - return await this.callAsync ("privateGetSpotHistoryOrder",parameters); - } - - public async Task privateGetSpotHistoryTrade (object parameters = null) - { - return await this.callAsync ("privateGetSpotHistoryTrade",parameters); - } - - public async Task privateGetMarginAccount (object parameters = null) - { - return await this.callAsync ("privateGetMarginAccount",parameters); - } - - public async Task privateGetMarginAccountIsolatedSymbol (object parameters = null) - { - return await this.callAsync ("privateGetMarginAccountIsolatedSymbol",parameters); - } - - public async Task privateGetMarginAccountCrossCurrency (object parameters = null) - { - return await this.callAsync ("privateGetMarginAccountCrossCurrency",parameters); - } - - public async Task privateGetMarginOrder (object parameters = null) - { - return await this.callAsync ("privateGetMarginOrder",parameters); - } - - public async Task privateGetMarginOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privateGetMarginOrderClientOrderId",parameters); - } - - public async Task privateGetMarginConfig (object parameters = null) - { - return await this.callAsync ("privateGetMarginConfig",parameters); - } - - public async Task privateGetMarginHistoryOrder (object parameters = null) - { - return await this.callAsync ("privateGetMarginHistoryOrder",parameters); - } - - public async Task privateGetMarginHistoryTrade (object parameters = null) - { - return await this.callAsync ("privateGetMarginHistoryTrade",parameters); - } - - public async Task privateGetMarginHistoryPositions (object parameters = null) - { - return await this.callAsync ("privateGetMarginHistoryPositions",parameters); - } - - public async Task privateGetMarginHistoryClearing (object parameters = null) - { - return await this.callAsync ("privateGetMarginHistoryClearing",parameters); - } - - public async Task privateGetFuturesBalance (object parameters = null) - { - return await this.callAsync ("privateGetFuturesBalance",parameters); - } - - public async Task privateGetFuturesBalanceCurrency (object parameters = null) - { - return await this.callAsync ("privateGetFuturesBalanceCurrency",parameters); - } - - public async Task privateGetFuturesAccount (object parameters = null) - { - return await this.callAsync ("privateGetFuturesAccount",parameters); - } - - public async Task privateGetFuturesAccountIsolatedSymbol (object parameters = null) - { - return await this.callAsync ("privateGetFuturesAccountIsolatedSymbol",parameters); - } - - public async Task privateGetFuturesOrder (object parameters = null) - { - return await this.callAsync ("privateGetFuturesOrder",parameters); - } - - public async Task privateGetFuturesOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privateGetFuturesOrderClientOrderId",parameters); - } - - public async Task privateGetFuturesConfig (object parameters = null) - { - return await this.callAsync ("privateGetFuturesConfig",parameters); - } - - public async Task privateGetFuturesFee (object parameters = null) - { - return await this.callAsync ("privateGetFuturesFee",parameters); - } - - public async Task privateGetFuturesFeeSymbol (object parameters = null) - { - return await this.callAsync ("privateGetFuturesFeeSymbol",parameters); - } - - public async Task privateGetFuturesHistoryOrder (object parameters = null) - { - return await this.callAsync ("privateGetFuturesHistoryOrder",parameters); - } - - public async Task privateGetFuturesHistoryTrade (object parameters = null) - { - return await this.callAsync ("privateGetFuturesHistoryTrade",parameters); - } - - public async Task privateGetFuturesHistoryPositions (object parameters = null) - { - return await this.callAsync ("privateGetFuturesHistoryPositions",parameters); - } - - public async Task privateGetFuturesHistoryClearing (object parameters = null) - { - return await this.callAsync ("privateGetFuturesHistoryClearing",parameters); - } - - public async Task privateGetWalletBalance (object parameters = null) - { - return await this.callAsync ("privateGetWalletBalance",parameters); - } - - public async Task privateGetWalletBalanceCurrency (object parameters = null) - { - return await this.callAsync ("privateGetWalletBalanceCurrency",parameters); - } - - public async Task privateGetWalletCryptoAddress (object parameters = null) - { - return await this.callAsync ("privateGetWalletCryptoAddress",parameters); - } - - public async Task privateGetWalletCryptoAddressRecentDeposit (object parameters = null) - { - return await this.callAsync ("privateGetWalletCryptoAddressRecentDeposit",parameters); - } - - public async Task privateGetWalletCryptoAddressRecentWithdraw (object parameters = null) - { - return await this.callAsync ("privateGetWalletCryptoAddressRecentWithdraw",parameters); - } - - public async Task privateGetWalletCryptoAddressCheckMine (object parameters = null) - { - return await this.callAsync ("privateGetWalletCryptoAddressCheckMine",parameters); - } - - public async Task privateGetWalletTransactions (object parameters = null) - { - return await this.callAsync ("privateGetWalletTransactions",parameters); - } - - public async Task privateGetWalletTransactionsTxId (object parameters = null) - { - return await this.callAsync ("privateGetWalletTransactionsTxId",parameters); - } - - public async Task privateGetWalletCryptoFeeEstimate (object parameters = null) - { - return await this.callAsync ("privateGetWalletCryptoFeeEstimate",parameters); - } - - public async Task privateGetWalletAirdrops (object parameters = null) - { - return await this.callAsync ("privateGetWalletAirdrops",parameters); - } - - public async Task privateGetWalletAmountLocks (object parameters = null) - { - return await this.callAsync ("privateGetWalletAmountLocks",parameters); - } - - public async Task privateGetSubAccount (object parameters = null) - { - return await this.callAsync ("privateGetSubAccount",parameters); - } - - public async Task privateGetSubAccountAcl (object parameters = null) - { - return await this.callAsync ("privateGetSubAccountAcl",parameters); - } - - public async Task privateGetSubAccountBalanceSubAccID (object parameters = null) - { - return await this.callAsync ("privateGetSubAccountBalanceSubAccID",parameters); - } - - public async Task privateGetSubAccountCryptoAddressSubAccIDCurrency (object parameters = null) - { - return await this.callAsync ("privateGetSubAccountCryptoAddressSubAccIDCurrency",parameters); - } - - public async Task privatePostSpotOrder (object parameters = null) - { - return await this.callAsync ("privatePostSpotOrder",parameters); - } - - public async Task privatePostSpotOrderList (object parameters = null) - { - return await this.callAsync ("privatePostSpotOrderList",parameters); - } - - public async Task privatePostMarginOrder (object parameters = null) - { - return await this.callAsync ("privatePostMarginOrder",parameters); - } - - public async Task privatePostMarginOrderList (object parameters = null) - { - return await this.callAsync ("privatePostMarginOrderList",parameters); - } - - public async Task privatePostFuturesOrder (object parameters = null) - { - return await this.callAsync ("privatePostFuturesOrder",parameters); - } - - public async Task privatePostFuturesOrderList (object parameters = null) - { - return await this.callAsync ("privatePostFuturesOrderList",parameters); - } - - public async Task privatePostWalletCryptoAddress (object parameters = null) - { - return await this.callAsync ("privatePostWalletCryptoAddress",parameters); - } - - public async Task privatePostWalletCryptoWithdraw (object parameters = null) - { - return await this.callAsync ("privatePostWalletCryptoWithdraw",parameters); - } - - public async Task privatePostWalletConvert (object parameters = null) - { - return await this.callAsync ("privatePostWalletConvert",parameters); - } - - public async Task privatePostWalletTransfer (object parameters = null) - { - return await this.callAsync ("privatePostWalletTransfer",parameters); - } - - public async Task privatePostWalletInternalWithdraw (object parameters = null) - { - return await this.callAsync ("privatePostWalletInternalWithdraw",parameters); - } - - public async Task privatePostWalletCryptoCheckOffchainAvailable (object parameters = null) - { - return await this.callAsync ("privatePostWalletCryptoCheckOffchainAvailable",parameters); - } - - public async Task privatePostWalletCryptoFeesEstimate (object parameters = null) - { - return await this.callAsync ("privatePostWalletCryptoFeesEstimate",parameters); - } - - public async Task privatePostWalletAirdropsIdClaim (object parameters = null) - { - return await this.callAsync ("privatePostWalletAirdropsIdClaim",parameters); - } - - public async Task privatePostSubAccountFreeze (object parameters = null) - { - return await this.callAsync ("privatePostSubAccountFreeze",parameters); - } - - public async Task privatePostSubAccountActivate (object parameters = null) - { - return await this.callAsync ("privatePostSubAccountActivate",parameters); - } - - public async Task privatePostSubAccountTransfer (object parameters = null) - { - return await this.callAsync ("privatePostSubAccountTransfer",parameters); - } - - public async Task privatePostSubAccountAcl (object parameters = null) - { - return await this.callAsync ("privatePostSubAccountAcl",parameters); - } - - public async Task privatePatchSpotOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privatePatchSpotOrderClientOrderId",parameters); - } - - public async Task privatePatchMarginOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privatePatchMarginOrderClientOrderId",parameters); - } - - public async Task privatePatchFuturesOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privatePatchFuturesOrderClientOrderId",parameters); - } - - public async Task privateDeleteSpotOrder (object parameters = null) - { - return await this.callAsync ("privateDeleteSpotOrder",parameters); - } - - public async Task privateDeleteSpotOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privateDeleteSpotOrderClientOrderId",parameters); - } - - public async Task privateDeleteMarginPosition (object parameters = null) - { - return await this.callAsync ("privateDeleteMarginPosition",parameters); - } - - public async Task privateDeleteMarginPositionIsolatedSymbol (object parameters = null) - { - return await this.callAsync ("privateDeleteMarginPositionIsolatedSymbol",parameters); - } - - public async Task privateDeleteMarginOrder (object parameters = null) - { - return await this.callAsync ("privateDeleteMarginOrder",parameters); - } - - public async Task privateDeleteMarginOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privateDeleteMarginOrderClientOrderId",parameters); - } - - public async Task privateDeleteFuturesPosition (object parameters = null) - { - return await this.callAsync ("privateDeleteFuturesPosition",parameters); - } - - public async Task privateDeleteFuturesPositionMarginModeSymbol (object parameters = null) - { - return await this.callAsync ("privateDeleteFuturesPositionMarginModeSymbol",parameters); - } - - public async Task privateDeleteFuturesOrder (object parameters = null) - { - return await this.callAsync ("privateDeleteFuturesOrder",parameters); - } - - public async Task privateDeleteFuturesOrderClientOrderId (object parameters = null) - { - return await this.callAsync ("privateDeleteFuturesOrderClientOrderId",parameters); - } - - public async Task privateDeleteWalletCryptoWithdrawId (object parameters = null) - { - return await this.callAsync ("privateDeleteWalletCryptoWithdrawId",parameters); - } - - public async Task privatePutMarginAccountIsolatedSymbol (object parameters = null) - { - return await this.callAsync ("privatePutMarginAccountIsolatedSymbol",parameters); - } - - public async Task privatePutFuturesAccountIsolatedSymbol (object parameters = null) - { - return await this.callAsync ("privatePutFuturesAccountIsolatedSymbol",parameters); - } - - public async Task privatePutWalletCryptoWithdrawId (object parameters = null) - { - return await this.callAsync ("privatePutWalletCryptoWithdrawId",parameters); - } - -} \ No newline at end of file diff --git a/cs/ccxt/api/bitfinex1.cs b/cs/ccxt/api/bitfinex1.cs deleted file mode 100644 index 070e5dd724c50..0000000000000 --- a/cs/ccxt/api/bitfinex1.cs +++ /dev/null @@ -1,339 +0,0 @@ -// ------------------------------------------------------------------------------- - -// 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 - -// ------------------------------------------------------------------------------- - -namespace ccxt; - -public partial class bitfinex1 : Exchange -{ - public bitfinex1 (object args = null): base(args) {} - - public async Task v2GetPlatformStatus (object parameters = null) - { - return await this.callAsync ("v2GetPlatformStatus",parameters); - } - - public async Task v2GetTickers (object parameters = null) - { - return await this.callAsync ("v2GetTickers",parameters); - } - - public async Task v2GetTickerSymbol (object parameters = null) - { - return await this.callAsync ("v2GetTickerSymbol",parameters); - } - - public async Task v2GetTickersHist (object parameters = null) - { - return await this.callAsync ("v2GetTickersHist",parameters); - } - - public async Task v2GetTradesSymbolHist (object parameters = null) - { - return await this.callAsync ("v2GetTradesSymbolHist",parameters); - } - - public async Task v2GetBookSymbolPrecision (object parameters = null) - { - return await this.callAsync ("v2GetBookSymbolPrecision",parameters); - } - - public async Task v2GetBookSymbolP0 (object parameters = null) - { - return await this.callAsync ("v2GetBookSymbolP0",parameters); - } - - public async Task v2GetBookSymbolP1 (object parameters = null) - { - return await this.callAsync ("v2GetBookSymbolP1",parameters); - } - - public async Task v2GetBookSymbolP2 (object parameters = null) - { - return await this.callAsync ("v2GetBookSymbolP2",parameters); - } - - public async Task v2GetBookSymbolP3 (object parameters = null) - { - return await this.callAsync ("v2GetBookSymbolP3",parameters); - } - - public async Task v2GetBookSymbolR0 (object parameters = null) - { - return await this.callAsync ("v2GetBookSymbolR0",parameters); - } - - public async Task v2GetStats1KeySizeSymbolSideSection (object parameters = null) - { - return await this.callAsync ("v2GetStats1KeySizeSymbolSideSection",parameters); - } - - public async Task v2GetStats1KeySizeSymbolSection (object parameters = null) - { - return await this.callAsync ("v2GetStats1KeySizeSymbolSection",parameters); - } - - public async Task v2GetStats1KeySizeSymbolLongLast (object parameters = null) - { - return await this.callAsync ("v2GetStats1KeySizeSymbolLongLast",parameters); - } - - public async Task v2GetStats1KeySizeSymbolLongHist (object parameters = null) - { - return await this.callAsync ("v2GetStats1KeySizeSymbolLongHist",parameters); - } - - public async Task v2GetStats1KeySizeSymbolShortLast (object parameters = null) - { - return await this.callAsync ("v2GetStats1KeySizeSymbolShortLast",parameters); - } - - public async Task v2GetStats1KeySizeSymbolShortHist (object parameters = null) - { - return await this.callAsync ("v2GetStats1KeySizeSymbolShortHist",parameters); - } - - public async Task v2GetCandlesTradeTimeframeSymbolSection (object parameters = null) - { - return await this.callAsync ("v2GetCandlesTradeTimeframeSymbolSection",parameters); - } - - public async Task v2GetCandlesTradeTimeframeSymbolLast (object parameters = null) - { - return await this.callAsync ("v2GetCandlesTradeTimeframeSymbolLast",parameters); - } - - public async Task v2GetCandlesTradeTimeframeSymbolHist (object parameters = null) - { - return await this.callAsync ("v2GetCandlesTradeTimeframeSymbolHist",parameters); - } - - public async Task publicGetBookSymbol (object parameters = null) - { - return await this.callAsync ("publicGetBookSymbol",parameters); - } - - public async Task publicGetLendbookCurrency (object parameters = null) - { - return await this.callAsync ("publicGetLendbookCurrency",parameters); - } - - public async Task publicGetLendsCurrency (object parameters = null) - { - return await this.callAsync ("publicGetLendsCurrency",parameters); - } - - public async Task publicGetPubtickerSymbol (object parameters = null) - { - return await this.callAsync ("publicGetPubtickerSymbol",parameters); - } - - public async Task publicGetStatsSymbol (object parameters = null) - { - return await this.callAsync ("publicGetStatsSymbol",parameters); - } - - public async Task publicGetSymbols (object parameters = null) - { - return await this.callAsync ("publicGetSymbols",parameters); - } - - public async Task publicGetSymbolsDetails (object parameters = null) - { - return await this.callAsync ("publicGetSymbolsDetails",parameters); - } - - public async Task publicGetTickers (object parameters = null) - { - return await this.callAsync ("publicGetTickers",parameters); - } - - public async Task publicGetTradesSymbol (object parameters = null) - { - return await this.callAsync ("publicGetTradesSymbol",parameters); - } - - public async Task privatePostAccountFees (object parameters = null) - { - return await this.callAsync ("privatePostAccountFees",parameters); - } - - public async Task privatePostAccountInfos (object parameters = null) - { - return await this.callAsync ("privatePostAccountInfos",parameters); - } - - public async Task privatePostBalances (object parameters = null) - { - return await this.callAsync ("privatePostBalances",parameters); - } - - public async Task privatePostBasketManage (object parameters = null) - { - return await this.callAsync ("privatePostBasketManage",parameters); - } - - public async Task privatePostCredits (object parameters = null) - { - return await this.callAsync ("privatePostCredits",parameters); - } - - public async Task privatePostDepositNew (object parameters = null) - { - return await this.callAsync ("privatePostDepositNew",parameters); - } - - public async Task privatePostFundingClose (object parameters = null) - { - return await this.callAsync ("privatePostFundingClose",parameters); - } - - public async Task privatePostHistory (object parameters = null) - { - return await this.callAsync ("privatePostHistory",parameters); - } - - public async Task privatePostHistoryMovements (object parameters = null) - { - return await this.callAsync ("privatePostHistoryMovements",parameters); - } - - public async Task privatePostKeyInfo (object parameters = null) - { - return await this.callAsync ("privatePostKeyInfo",parameters); - } - - public async Task privatePostMarginInfos (object parameters = null) - { - return await this.callAsync ("privatePostMarginInfos",parameters); - } - - public async Task privatePostMytrades (object parameters = null) - { - return await this.callAsync ("privatePostMytrades",parameters); - } - - public async Task privatePostMytradesFunding (object parameters = null) - { - return await this.callAsync ("privatePostMytradesFunding",parameters); - } - - public async Task privatePostOfferCancel (object parameters = null) - { - return await this.callAsync ("privatePostOfferCancel",parameters); - } - - public async Task privatePostOfferNew (object parameters = null) - { - return await this.callAsync ("privatePostOfferNew",parameters); - } - - public async Task privatePostOfferStatus (object parameters = null) - { - return await this.callAsync ("privatePostOfferStatus",parameters); - } - - public async Task privatePostOffers (object parameters = null) - { - return await this.callAsync ("privatePostOffers",parameters); - } - - public async Task privatePostOffersHist (object parameters = null) - { - return await this.callAsync ("privatePostOffersHist",parameters); - } - - public async Task privatePostOrderCancel (object parameters = null) - { - return await this.callAsync ("privatePostOrderCancel",parameters); - } - - public async Task privatePostOrderCancelAll (object parameters = null) - { - return await this.callAsync ("privatePostOrderCancelAll",parameters); - } - - public async Task privatePostOrderCancelMulti (object parameters = null) - { - return await this.callAsync ("privatePostOrderCancelMulti",parameters); - } - - public async Task privatePostOrderCancelReplace (object parameters = null) - { - return await this.callAsync ("privatePostOrderCancelReplace",parameters); - } - - public async Task privatePostOrderNew (object parameters = null) - { - return await this.callAsync ("privatePostOrderNew",parameters); - } - - public async Task privatePostOrderNewMulti (object parameters = null) - { - return await this.callAsync ("privatePostOrderNewMulti",parameters); - } - - public async Task privatePostOrderStatus (object parameters = null) - { - return await this.callAsync ("privatePostOrderStatus",parameters); - } - - public async Task privatePostOrders (object parameters = null) - { - return await this.callAsync ("privatePostOrders",parameters); - } - - public async Task privatePostOrdersHist (object parameters = null) - { - return await this.callAsync ("privatePostOrdersHist",parameters); - } - - public async Task privatePostPositionClaim (object parameters = null) - { - return await this.callAsync ("privatePostPositionClaim",parameters); - } - - public async Task privatePostPositionClose (object parameters = null) - { - return await this.callAsync ("privatePostPositionClose",parameters); - } - - public async Task privatePostPositions (object parameters = null) - { - return await this.callAsync ("privatePostPositions",parameters); - } - - public async Task privatePostSummary (object parameters = null) - { - return await this.callAsync ("privatePostSummary",parameters); - } - - public async Task privatePostTakenFunds (object parameters = null) - { - return await this.callAsync ("privatePostTakenFunds",parameters); - } - - public async Task privatePostTotalTakenFunds (object parameters = null) - { - return await this.callAsync ("privatePostTotalTakenFunds",parameters); - } - - public async Task privatePostTransfer (object parameters = null) - { - return await this.callAsync ("privatePostTransfer",parameters); - } - - public async Task privatePostUnusedTakenFunds (object parameters = null) - { - return await this.callAsync ("privatePostUnusedTakenFunds",parameters); - } - - public async Task privatePostWithdraw (object parameters = null) - { - return await this.callAsync ("privatePostWithdraw",parameters); - } - -} \ No newline at end of file diff --git a/cs/ccxt/api/bitpanda.cs b/cs/ccxt/api/bitpanda.cs deleted file mode 100644 index 712c578b2bc91..0000000000000 --- a/cs/ccxt/api/bitpanda.cs +++ /dev/null @@ -1,109 +0,0 @@ -// ------------------------------------------------------------------------------- - -// 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 - -// ------------------------------------------------------------------------------- - -namespace ccxt; - -public partial class bitpanda : onetrading -{ - public bitpanda (object args = null): base(args) {} - - public async Task publicGetCurrencies (object parameters = null) - { - return await this.callAsync ("publicGetCurrencies",parameters); - } - - public async Task publicGetCandlesticksInstrumentCode (object parameters = null) - { - return await this.callAsync ("publicGetCandlesticksInstrumentCode",parameters); - } - - public async Task publicGetFees (object parameters = null) - { - return await this.callAsync ("publicGetFees",parameters); - } - - public async Task publicGetInstruments (object parameters = null) - { - return await this.callAsync ("publicGetInstruments",parameters); - } - - public async Task publicGetOrderBookInstrumentCode (object parameters = null) - { - return await this.callAsync ("publicGetOrderBookInstrumentCode",parameters); - } - - public async Task publicGetMarketTicker (object parameters = null) - { - return await this.callAsync ("publicGetMarketTicker",parameters); - } - - public async Task publicGetMarketTickerInstrumentCode (object parameters = null) - { - return await this.callAsync ("publicGetMarketTickerInstrumentCode",parameters); - } - - public async Task publicGetTime (object parameters = null) - { - return await this.callAsync ("publicGetTime",parameters); - } - - public async Task privateGetAccountBalances (object parameters = null) - { - return await this.callAsync ("privateGetAccountBalances",parameters); - } - - public async Task privateGetAccountFees (object parameters = null) - { - return await this.callAsync ("privateGetAccountFees",parameters); - } - - public async Task privateGetAccountOrders (object parameters = null) - { - return await this.callAsync ("privateGetAccountOrders",parameters); - } - - public async Task privateGetAccountOrdersOrderId (object parameters = null) - { - return await this.callAsync ("privateGetAccountOrdersOrderId",parameters); - } - - public async Task privateGetAccountOrdersOrderIdTrades (object parameters = null) - { - return await this.callAsync ("privateGetAccountOrdersOrderIdTrades",parameters); - } - - public async Task privateGetAccountTrades (object parameters = null) - { - return await this.callAsync ("privateGetAccountTrades",parameters); - } - - public async Task privateGetAccountTradesTradeId (object parameters = null) - { - return await this.callAsync ("privateGetAccountTradesTradeId",parameters); - } - - public async Task privatePostAccountOrders (object parameters = null) - { - return await this.callAsync ("privatePostAccountOrders",parameters); - } - - public async Task privateDeleteAccountOrders (object parameters = null) - { - return await this.callAsync ("privateDeleteAccountOrders",parameters); - } - - public async Task privateDeleteAccountOrdersOrderId (object parameters = null) - { - return await this.callAsync ("privateDeleteAccountOrdersOrderId",parameters); - } - - public async Task privateDeleteAccountOrdersClientClientId (object parameters = null) - { - return await this.callAsync ("privateDeleteAccountOrdersClientClientId",parameters); - } - -} \ No newline at end of file diff --git a/cs/ccxt/api/foxbit.cs b/cs/ccxt/api/foxbit.cs new file mode 100644 index 0000000000000..37a7cb339d8c6 --- /dev/null +++ b/cs/ccxt/api/foxbit.cs @@ -0,0 +1,124 @@ +// ------------------------------------------------------------------------------- + +// 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 + +// ------------------------------------------------------------------------------- + +namespace ccxt; + +public partial class foxbit : Exchange +{ + public foxbit (object args = null): base(args) {} + + public async Task v3PublicGetCurrencies (object parameters = null) + { + return await this.callAsync ("v3PublicGetCurrencies",parameters); + } + + public async Task v3PublicGetMarkets (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarkets",parameters); + } + + public async Task v3PublicGetMarketsTicker24hr (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketsTicker24hr",parameters); + } + + public async Task v3PublicGetMarketsMarketOrderbook (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketsMarketOrderbook",parameters); + } + + public async Task v3PublicGetMarketsMarketCandlesticks (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketsMarketCandlesticks",parameters); + } + + public async Task v3PublicGetMarketsMarketTradesHistory (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketsMarketTradesHistory",parameters); + } + + public async Task v3PublicGetMarketsMarketTicker24hr (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketsMarketTicker24hr",parameters); + } + + public async Task v3PrivateGetAccounts (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccounts",parameters); + } + + public async Task v3PrivateGetAccountsSymbolTransactions (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountsSymbolTransactions",parameters); + } + + public async Task v3PrivateGetOrders (object parameters = null) + { + return await this.callAsync ("v3PrivateGetOrders",parameters); + } + + public async Task v3PrivateGetOrdersByOrderIdId (object parameters = null) + { + return await this.callAsync ("v3PrivateGetOrdersByOrderIdId",parameters); + } + + public async Task v3PrivateGetTrades (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTrades",parameters); + } + + public async Task v3PrivateGetDepositsAddress (object parameters = null) + { + return await this.callAsync ("v3PrivateGetDepositsAddress",parameters); + } + + public async Task v3PrivateGetDeposits (object parameters = null) + { + return await this.callAsync ("v3PrivateGetDeposits",parameters); + } + + public async Task v3PrivateGetWithdrawals (object parameters = null) + { + return await this.callAsync ("v3PrivateGetWithdrawals",parameters); + } + + public async Task v3PrivateGetMeFeesTrading (object parameters = null) + { + return await this.callAsync ("v3PrivateGetMeFeesTrading",parameters); + } + + public async Task v3PrivatePostOrders (object parameters = null) + { + return await this.callAsync ("v3PrivatePostOrders",parameters); + } + + public async Task v3PrivatePostOrdersBatch (object parameters = null) + { + return await this.callAsync ("v3PrivatePostOrdersBatch",parameters); + } + + public async Task v3PrivatePostOrdersCancelReplace (object parameters = null) + { + return await this.callAsync ("v3PrivatePostOrdersCancelReplace",parameters); + } + + public async Task v3PrivatePostWithdrawals (object parameters = null) + { + return await this.callAsync ("v3PrivatePostWithdrawals",parameters); + } + + public async Task v3PrivatePutOrdersCancel (object parameters = null) + { + return await this.callAsync ("v3PrivatePutOrdersCancel",parameters); + } + + public async Task statusPublicGetStatus (object parameters = null) + { + return await this.callAsync ("statusPublicGetStatus",parameters); + } + +} \ No newline at end of file diff --git a/cs/ccxt/api/poloniexfutures.cs b/cs/ccxt/api/poloniexfutures.cs deleted file mode 100644 index 989f999d2e2dd..0000000000000 --- a/cs/ccxt/api/poloniexfutures.cs +++ /dev/null @@ -1,234 +0,0 @@ -// ------------------------------------------------------------------------------- - -// 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 - -// ------------------------------------------------------------------------------- - -namespace ccxt; - -public partial class poloniexfutures : Exchange -{ - public poloniexfutures (object args = null): base(args) {} - - public async Task publicGetContractsActive (object parameters = null) - { - return await this.callAsync ("publicGetContractsActive",parameters); - } - - public async Task publicGetContractsSymbol (object parameters = null) - { - return await this.callAsync ("publicGetContractsSymbol",parameters); - } - - public async Task publicGetTicker (object parameters = null) - { - return await this.callAsync ("publicGetTicker",parameters); - } - - public async Task publicGetTickers (object parameters = null) - { - return await this.callAsync ("publicGetTickers",parameters); - } - - public async Task publicGetLevel2Snapshot (object parameters = null) - { - return await this.callAsync ("publicGetLevel2Snapshot",parameters); - } - - public async Task publicGetLevel2Depth (object parameters = null) - { - return await this.callAsync ("publicGetLevel2Depth",parameters); - } - - public async Task publicGetLevel2MessageQuery (object parameters = null) - { - return await this.callAsync ("publicGetLevel2MessageQuery",parameters); - } - - public async Task publicGetLevel3Snapshot (object parameters = null) - { - return await this.callAsync ("publicGetLevel3Snapshot",parameters); - } - - public async Task publicGetTradeHistory (object parameters = null) - { - return await this.callAsync ("publicGetTradeHistory",parameters); - } - - public async Task publicGetInterestQuery (object parameters = null) - { - return await this.callAsync ("publicGetInterestQuery",parameters); - } - - public async Task publicGetIndexQuery (object parameters = null) - { - return await this.callAsync ("publicGetIndexQuery",parameters); - } - - public async Task publicGetMarkPriceSymbolCurrent (object parameters = null) - { - return await this.callAsync ("publicGetMarkPriceSymbolCurrent",parameters); - } - - public async Task publicGetPremiumQuery (object parameters = null) - { - return await this.callAsync ("publicGetPremiumQuery",parameters); - } - - public async Task publicGetFundingRateSymbolCurrent (object parameters = null) - { - return await this.callAsync ("publicGetFundingRateSymbolCurrent",parameters); - } - - public async Task publicGetTimestamp (object parameters = null) - { - return await this.callAsync ("publicGetTimestamp",parameters); - } - - public async Task publicGetStatus (object parameters = null) - { - return await this.callAsync ("publicGetStatus",parameters); - } - - public async Task publicGetKlineQuery (object parameters = null) - { - return await this.callAsync ("publicGetKlineQuery",parameters); - } - - public async Task publicPostBulletPublic (object parameters = null) - { - return await this.callAsync ("publicPostBulletPublic",parameters); - } - - public async Task privateGetAccountOverview (object parameters = null) - { - return await this.callAsync ("privateGetAccountOverview",parameters); - } - - public async Task privateGetTransactionHistory (object parameters = null) - { - return await this.callAsync ("privateGetTransactionHistory",parameters); - } - - public async Task privateGetMaxActiveOrders (object parameters = null) - { - return await this.callAsync ("privateGetMaxActiveOrders",parameters); - } - - public async Task privateGetMaxRiskLimit (object parameters = null) - { - return await this.callAsync ("privateGetMaxRiskLimit",parameters); - } - - public async Task privateGetUserFeeRate (object parameters = null) - { - return await this.callAsync ("privateGetUserFeeRate",parameters); - } - - public async Task privateGetMarginTypeQuery (object parameters = null) - { - return await this.callAsync ("privateGetMarginTypeQuery",parameters); - } - - public async Task privateGetOrders (object parameters = null) - { - return await this.callAsync ("privateGetOrders",parameters); - } - - public async Task privateGetStopOrders (object parameters = null) - { - return await this.callAsync ("privateGetStopOrders",parameters); - } - - public async Task privateGetRecentDoneOrders (object parameters = null) - { - return await this.callAsync ("privateGetRecentDoneOrders",parameters); - } - - public async Task privateGetOrdersOrderId (object parameters = null) - { - return await this.callAsync ("privateGetOrdersOrderId",parameters); - } - - public async Task privateGetClientOrderIdClientOid (object parameters = null) - { - return await this.callAsync ("privateGetClientOrderIdClientOid",parameters); - } - - public async Task privateGetFills (object parameters = null) - { - return await this.callAsync ("privateGetFills",parameters); - } - - public async Task privateGetOpenOrderStatistics (object parameters = null) - { - return await this.callAsync ("privateGetOpenOrderStatistics",parameters); - } - - public async Task privateGetPosition (object parameters = null) - { - return await this.callAsync ("privateGetPosition",parameters); - } - - public async Task privateGetPositions (object parameters = null) - { - return await this.callAsync ("privateGetPositions",parameters); - } - - public async Task privateGetFundingHistory (object parameters = null) - { - return await this.callAsync ("privateGetFundingHistory",parameters); - } - - public async Task privatePostOrders (object parameters = null) - { - return await this.callAsync ("privatePostOrders",parameters); - } - - public async Task privatePostBatchOrders (object parameters = null) - { - return await this.callAsync ("privatePostBatchOrders",parameters); - } - - public async Task privatePostPositionMarginAutoDepositStatus (object parameters = null) - { - return await this.callAsync ("privatePostPositionMarginAutoDepositStatus",parameters); - } - - public async Task privatePostPositionMarginDepositMargin (object parameters = null) - { - return await this.callAsync ("privatePostPositionMarginDepositMargin",parameters); - } - - public async Task privatePostPositionMarginWithdrawMargin (object parameters = null) - { - return await this.callAsync ("privatePostPositionMarginWithdrawMargin",parameters); - } - - public async Task privatePostBulletPrivate (object parameters = null) - { - return await this.callAsync ("privatePostBulletPrivate",parameters); - } - - public async Task privatePostMarginTypeChange (object parameters = null) - { - return await this.callAsync ("privatePostMarginTypeChange",parameters); - } - - public async Task privateDeleteOrdersOrderId (object parameters = null) - { - return await this.callAsync ("privateDeleteOrdersOrderId",parameters); - } - - public async Task privateDeleteOrders (object parameters = null) - { - return await this.callAsync ("privateDeleteOrders",parameters); - } - - public async Task privateDeleteStopOrders (object parameters = null) - { - return await this.callAsync ("privateDeleteStopOrders",parameters); - } - -} \ No newline at end of file diff --git a/cs/ccxt/api/wazirx.cs b/cs/ccxt/api/wazirx.cs deleted file mode 100644 index fd009cd55ded7..0000000000000 --- a/cs/ccxt/api/wazirx.cs +++ /dev/null @@ -1,144 +0,0 @@ -// ------------------------------------------------------------------------------- - -// 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 - -// ------------------------------------------------------------------------------- - -namespace ccxt; - -public partial class wazirx : Exchange -{ - public wazirx (object args = null): base(args) {} - - public async Task publicGetExchangeInfo (object parameters = null) - { - return await this.callAsync ("publicGetExchangeInfo",parameters); - } - - public async Task publicGetDepth (object parameters = null) - { - return await this.callAsync ("publicGetDepth",parameters); - } - - public async Task publicGetPing (object parameters = null) - { - return await this.callAsync ("publicGetPing",parameters); - } - - public async Task publicGetSystemStatus (object parameters = null) - { - return await this.callAsync ("publicGetSystemStatus",parameters); - } - - public async Task publicGetTickers24hr (object parameters = null) - { - return await this.callAsync ("publicGetTickers24hr",parameters); - } - - public async Task publicGetTicker24hr (object parameters = null) - { - return await this.callAsync ("publicGetTicker24hr",parameters); - } - - public async Task publicGetTime (object parameters = null) - { - return await this.callAsync ("publicGetTime",parameters); - } - - public async Task publicGetTrades (object parameters = null) - { - return await this.callAsync ("publicGetTrades",parameters); - } - - public async Task publicGetKlines (object parameters = null) - { - return await this.callAsync ("publicGetKlines",parameters); - } - - public async Task privateGetAccount (object parameters = null) - { - return await this.callAsync ("privateGetAccount",parameters); - } - - public async Task privateGetAllOrders (object parameters = null) - { - return await this.callAsync ("privateGetAllOrders",parameters); - } - - public async Task privateGetFunds (object parameters = null) - { - return await this.callAsync ("privateGetFunds",parameters); - } - - public async Task privateGetHistoricalTrades (object parameters = null) - { - return await this.callAsync ("privateGetHistoricalTrades",parameters); - } - - public async Task privateGetOpenOrders (object parameters = null) - { - return await this.callAsync ("privateGetOpenOrders",parameters); - } - - public async Task privateGetOrder (object parameters = null) - { - return await this.callAsync ("privateGetOrder",parameters); - } - - public async Task privateGetMyTrades (object parameters = null) - { - return await this.callAsync ("privateGetMyTrades",parameters); - } - - public async Task privateGetCoins (object parameters = null) - { - return await this.callAsync ("privateGetCoins",parameters); - } - - public async Task privateGetCryptoWithdraws (object parameters = null) - { - return await this.callAsync ("privateGetCryptoWithdraws",parameters); - } - - public async Task privateGetCryptoDepositsAddress (object parameters = null) - { - return await this.callAsync ("privateGetCryptoDepositsAddress",parameters); - } - - public async Task privateGetSubAccountFundTransferHistory (object parameters = null) - { - return await this.callAsync ("privateGetSubAccountFundTransferHistory",parameters); - } - - public async Task privateGetSubAccountAccounts (object parameters = null) - { - return await this.callAsync ("privateGetSubAccountAccounts",parameters); - } - - public async Task privatePostOrder (object parameters = null) - { - return await this.callAsync ("privatePostOrder",parameters); - } - - public async Task privatePostOrderTest (object parameters = null) - { - return await this.callAsync ("privatePostOrderTest",parameters); - } - - public async Task privatePostCreateAuthToken (object parameters = null) - { - return await this.callAsync ("privatePostCreateAuthToken",parameters); - } - - public async Task privateDeleteOrder (object parameters = null) - { - return await this.callAsync ("privateDeleteOrder",parameters); - } - - public async Task privateDeleteOpenOrders (object parameters = null) - { - return await this.callAsync ("privateDeleteOpenOrders",parameters); - } - -} \ No newline at end of file diff --git a/cs/ccxt/api/woo.cs b/cs/ccxt/api/woo.cs index 2476f3b0d01ae..c87e140592bba 100644 --- a/cs/ccxt/api/woo.cs +++ b/cs/ccxt/api/woo.cs @@ -301,11 +301,211 @@ public async Task v2PrivateGetClientHolding (object parameters = null) return await this.callAsync ("v2PrivateGetClientHolding",parameters); } + public async Task v3PublicGetSystemInfo (object parameters = null) + { + return await this.callAsync ("v3PublicGetSystemInfo",parameters); + } + + public async Task v3PublicGetInstruments (object parameters = null) + { + return await this.callAsync ("v3PublicGetInstruments",parameters); + } + + public async Task v3PublicGetToken (object parameters = null) + { + return await this.callAsync ("v3PublicGetToken",parameters); + } + + public async Task v3PublicGetTokenNetwork (object parameters = null) + { + return await this.callAsync ("v3PublicGetTokenNetwork",parameters); + } + + public async Task v3PublicGetTokenInfo (object parameters = null) + { + return await this.callAsync ("v3PublicGetTokenInfo",parameters); + } + + public async Task v3PublicGetMarketTrades (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketTrades",parameters); + } + + public async Task v3PublicGetMarketTradesHistory (object parameters = null) + { + return await this.callAsync ("v3PublicGetMarketTradesHistory",parameters); + } + + public async Task v3PublicGetOrderbook (object parameters = null) + { + return await this.callAsync ("v3PublicGetOrderbook",parameters); + } + + public async Task v3PublicGetKline (object parameters = null) + { + return await this.callAsync ("v3PublicGetKline",parameters); + } + + public async Task v3PublicGetKlineHistory (object parameters = null) + { + return await this.callAsync ("v3PublicGetKlineHistory",parameters); + } + + public async Task v3PublicGetFutures (object parameters = null) + { + return await this.callAsync ("v3PublicGetFutures",parameters); + } + + public async Task v3PublicGetFundingRate (object parameters = null) + { + return await this.callAsync ("v3PublicGetFundingRate",parameters); + } + + public async Task v3PublicGetFundingRateHistory (object parameters = null) + { + return await this.callAsync ("v3PublicGetFundingRateHistory",parameters); + } + public async Task v3PublicGetInsuranceFund (object parameters = null) { return await this.callAsync ("v3PublicGetInsuranceFund",parameters); } + public async Task v3PrivateGetTradeOrder (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeOrder",parameters); + } + + public async Task v3PrivateGetTradeOrders (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeOrders",parameters); + } + + public async Task v3PrivateGetTradeAlgoOrder (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeAlgoOrder",parameters); + } + + public async Task v3PrivateGetTradeAlgoOrders (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeAlgoOrders",parameters); + } + + public async Task v3PrivateGetTradeTransaction (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeTransaction",parameters); + } + + public async Task v3PrivateGetTradeTransactionHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeTransactionHistory",parameters); + } + + public async Task v3PrivateGetTradeTradingFee (object parameters = null) + { + return await this.callAsync ("v3PrivateGetTradeTradingFee",parameters); + } + + public async Task v3PrivateGetAccountInfo (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountInfo",parameters); + } + + public async Task v3PrivateGetAccountTokenConfig (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountTokenConfig",parameters); + } + + public async Task v3PrivateGetAccountSymbolConfig (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountSymbolConfig",parameters); + } + + public async Task v3PrivateGetAccountSubAccountsAll (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountSubAccountsAll",parameters); + } + + public async Task v3PrivateGetAccountReferralSummary (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountReferralSummary",parameters); + } + + public async Task v3PrivateGetAccountReferralRewardHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountReferralRewardHistory",parameters); + } + + public async Task v3PrivateGetAccountCredentials (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAccountCredentials",parameters); + } + + public async Task v3PrivateGetAssetBalances (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAssetBalances",parameters); + } + + public async Task v3PrivateGetAssetTokenHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAssetTokenHistory",parameters); + } + + public async Task v3PrivateGetAssetTransferHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAssetTransferHistory",parameters); + } + + public async Task v3PrivateGetAssetWalletHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAssetWalletHistory",parameters); + } + + public async Task v3PrivateGetAssetWalletDeposit (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAssetWalletDeposit",parameters); + } + + public async Task v3PrivateGetAssetStakingYieldHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetAssetStakingYieldHistory",parameters); + } + + public async Task v3PrivateGetFuturesPositions (object parameters = null) + { + return await this.callAsync ("v3PrivateGetFuturesPositions",parameters); + } + + public async Task v3PrivateGetFuturesLeverage (object parameters = null) + { + return await this.callAsync ("v3PrivateGetFuturesLeverage",parameters); + } + + public async Task v3PrivateGetFuturesDefaultMarginMode (object parameters = null) + { + return await this.callAsync ("v3PrivateGetFuturesDefaultMarginMode",parameters); + } + + public async Task v3PrivateGetFuturesFundingFeeHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetFuturesFundingFeeHistory",parameters); + } + + public async Task v3PrivateGetSpotMarginInterestRate (object parameters = null) + { + return await this.callAsync ("v3PrivateGetSpotMarginInterestRate",parameters); + } + + public async Task v3PrivateGetSpotMarginInterestHistory (object parameters = null) + { + return await this.callAsync ("v3PrivateGetSpotMarginInterestHistory",parameters); + } + + public async Task v3PrivateGetSpotMarginMaxMargin (object parameters = null) + { + return await this.callAsync ("v3PrivateGetSpotMarginMaxMargin",parameters); + } + public async Task v3PrivateGetAlgoOrderOid (object parameters = null) { return await this.callAsync ("v3PrivateGetAlgoOrderOid",parameters); @@ -321,11 +521,6 @@ public async Task v3PrivateGetBalances (object parameters = null) return await this.callAsync ("v3PrivateGetBalances",parameters); } - public async Task v3PrivateGetAccountinfo (object parameters = null) - { - return await this.callAsync ("v3PrivateGetAccountinfo",parameters); - } - public async Task v3PrivateGetPositions (object parameters = null) { return await this.callAsync ("v3PrivateGetPositions",parameters); @@ -336,16 +531,6 @@ public async Task v3PrivateGetBuypower (object parameters = null) return await this.callAsync ("v3PrivateGetBuypower",parameters); } - public async Task v3PrivateGetReferrals (object parameters = null) - { - return await this.callAsync ("v3PrivateGetReferrals",parameters); - } - - public async Task v3PrivateGetReferralRewards (object parameters = null) - { - return await this.callAsync ("v3PrivateGetReferralRewards",parameters); - } - public async Task v3PrivateGetConvertExchangeInfo (object parameters = null) { return await this.callAsync ("v3PrivateGetConvertExchangeInfo",parameters); @@ -371,6 +556,51 @@ public async Task v3PrivateGetConvertTrades (object parameters = null) return await this.callAsync ("v3PrivateGetConvertTrades",parameters); } + public async Task v3PrivatePostTradeOrder (object parameters = null) + { + return await this.callAsync ("v3PrivatePostTradeOrder",parameters); + } + + public async Task v3PrivatePostTradeAlgoOrder (object parameters = null) + { + return await this.callAsync ("v3PrivatePostTradeAlgoOrder",parameters); + } + + public async Task v3PrivatePostTradeCancelAllAfter (object parameters = null) + { + return await this.callAsync ("v3PrivatePostTradeCancelAllAfter",parameters); + } + + public async Task v3PrivatePostAccountTradingMode (object parameters = null) + { + return await this.callAsync ("v3PrivatePostAccountTradingMode",parameters); + } + + public async Task v3PrivatePostAccountListenKey (object parameters = null) + { + return await this.callAsync ("v3PrivatePostAccountListenKey",parameters); + } + + public async Task v3PrivatePostAssetTransfer (object parameters = null) + { + return await this.callAsync ("v3PrivatePostAssetTransfer",parameters); + } + + public async Task v3PrivatePostAssetWalletWithdraw (object parameters = null) + { + return await this.callAsync ("v3PrivatePostAssetWalletWithdraw",parameters); + } + + public async Task v3PrivatePostSpotMarginLeverage (object parameters = null) + { + return await this.callAsync ("v3PrivatePostSpotMarginLeverage",parameters); + } + + public async Task v3PrivatePostSpotMarginInterestRepay (object parameters = null) + { + return await this.callAsync ("v3PrivatePostSpotMarginInterestRepay",parameters); + } + public async Task v3PrivatePostAlgoOrder (object parameters = null) { return await this.callAsync ("v3PrivatePostAlgoOrder",parameters); @@ -381,6 +611,26 @@ public async Task v3PrivatePostConvertRft (object parameters = null) return await this.callAsync ("v3PrivatePostConvertRft",parameters); } + public async Task v3PrivatePutTradeOrder (object parameters = null) + { + return await this.callAsync ("v3PrivatePutTradeOrder",parameters); + } + + public async Task v3PrivatePutTradeAlgoOrder (object parameters = null) + { + return await this.callAsync ("v3PrivatePutTradeAlgoOrder",parameters); + } + + public async Task v3PrivatePutFuturesLeverage (object parameters = null) + { + return await this.callAsync ("v3PrivatePutFuturesLeverage",parameters); + } + + public async Task v3PrivatePutFuturesPositionMode (object parameters = null) + { + return await this.callAsync ("v3PrivatePutFuturesPositionMode",parameters); + } + public async Task v3PrivatePutOrderOid (object parameters = null) { return await this.callAsync ("v3PrivatePutOrderOid",parameters); @@ -401,6 +651,31 @@ public async Task v3PrivatePutAlgoOrderClientClientOrderId (object param return await this.callAsync ("v3PrivatePutAlgoOrderClientClientOrderId",parameters); } + public async Task v3PrivateDeleteTradeOrder (object parameters = null) + { + return await this.callAsync ("v3PrivateDeleteTradeOrder",parameters); + } + + public async Task v3PrivateDeleteTradeOrders (object parameters = null) + { + return await this.callAsync ("v3PrivateDeleteTradeOrders",parameters); + } + + public async Task v3PrivateDeleteTradeAlgoOrder (object parameters = null) + { + return await this.callAsync ("v3PrivateDeleteTradeAlgoOrder",parameters); + } + + public async Task v3PrivateDeleteTradeAlgoOrders (object parameters = null) + { + return await this.callAsync ("v3PrivateDeleteTradeAlgoOrders",parameters); + } + + public async Task v3PrivateDeleteTradeAllOrders (object parameters = null) + { + return await this.callAsync ("v3PrivateDeleteTradeAllOrders",parameters); + } + public async Task v3PrivateDeleteAlgoOrderOrderId (object parameters = null) { return await this.callAsync ("v3PrivateDeleteAlgoOrderOrderId",parameters); diff --git a/cs/ccxt/base/Exchange.BaseMethods.cs b/cs/ccxt/base/Exchange.BaseMethods.cs index 5866d1b3186e9..30231a7ea505a 100644 --- a/cs/ccxt/base/Exchange.BaseMethods.cs +++ b/cs/ccxt/base/Exchange.BaseMethods.cs @@ -1377,7 +1377,7 @@ public virtual object parseToNumeric(object number) // keep this in mind: // in JS: 1 == 1.0 is true; 1 === 1.0 is true // in Python: 1 == 1.0 is true - // in PHP 1 == 1.0 is true, but 1 === 1.0 is false + // in PHP 1 == 1.0 is true, but 1 === 1.0 is false. if (isTrue(isGreaterThanOrEqual(getIndexOf(stringVersion, "."), 0))) { return parseFloat(stringVersion); @@ -2422,20 +2422,8 @@ public virtual object parseOrders(object orders, object market = null, object si return this.filterBySymbolSinceLimit(results, symbol, since, limit); } - public virtual object calculateFee(object symbol, object type, object side, object amount, object price, object takerOrMaker = null, object parameters = null) + public virtual object calculateFeeWithRate(object symbol, object type, object side, object amount, object price, object takerOrMaker = null, object feeRate = null, object parameters = null) { - /** - * @method - * @description calculates the presumptive fee that would be charged for an order - * @param {string} symbol unified market symbol - * @param {string} type 'market' or 'limit' - * @param {string} side 'buy' or 'sell' - * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts - * @param {float} price the price for the order to be filled at, in units of the quote currency - * @param {string} takerOrMaker 'taker' or 'maker' - * @param {object} params - * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order - */ takerOrMaker ??= "taker"; parameters ??= new Dictionary(); if (isTrue(isTrue(isEqual(type, "market")) && isTrue(isEqual(takerOrMaker, "maker")))) @@ -2479,7 +2467,7 @@ public virtual object calculateFee(object symbol, object type, object side, obje { takerOrMaker = "taker"; } - object rate = this.safeString(market, takerOrMaker); + object rate = ((bool) isTrue((!isEqual(feeRate, null)))) ? this.numberToString(feeRate) : this.safeString(market, takerOrMaker); cost = Precise.stringMul(cost, rate); return new Dictionary() { { "type", takerOrMaker }, @@ -2489,6 +2477,25 @@ public virtual object calculateFee(object symbol, object type, object side, obje }; } + public virtual object calculateFee(object symbol, object type, object side, object amount, object price, object takerOrMaker = null, object parameters = null) + { + /** + * @method + * @description calculates the presumptive fee that would be charged for an order + * @param {string} symbol unified market symbol + * @param {string} type 'market' or 'limit' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts + * @param {float} price the price for the order to be filled at, in units of the quote currency + * @param {string} takerOrMaker 'taker' or 'maker' + * @param {object} params + * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order + */ + takerOrMaker ??= "taker"; + parameters ??= new Dictionary(); + return this.calculateFeeWithRate(symbol, type, side, amount, price, takerOrMaker, null, parameters); + } + public virtual object safeLiquidation(object liquidation, object market = null) { object contracts = this.safeString(liquidation, "contracts"); @@ -2687,7 +2694,7 @@ public virtual object reduceFeesByCurrency(object fees) { object fee = getValue(fees, i); object code = this.safeString(fee, "currency"); - object feeCurrencyCode = ((bool) isTrue(!isEqual(code, null))) ? code : ((object)i).ToString(); + object feeCurrencyCode = ((bool) isTrue((!isEqual(code, null)))) ? code : ((object)i).ToString(); if (isTrue(!isEqual(feeCurrencyCode, null))) { object rate = this.safeString(fee, "rate"); @@ -2730,8 +2737,7 @@ public virtual object reduceFeesByCurrency(object fees) public virtual object safeTicker(object ticker, object market = null) { object open = this.omitZero(this.safeString(ticker, "open")); - object close = this.omitZero(this.safeString(ticker, "close")); - object last = this.omitZero(this.safeString(ticker, "last")); + object close = this.omitZero(this.safeString2(ticker, "close", "last")); object change = this.omitZero(this.safeString(ticker, "change")); object percentage = this.omitZero(this.safeString(ticker, "percentage")); object average = this.omitZero(this.safeString(ticker, "average")); @@ -2742,20 +2748,66 @@ public virtual object safeTicker(object ticker, object market = null) { vwap = Precise.stringDiv(this.omitZero(quoteVolume), baseVolume); } - if (isTrue(isTrue((!isEqual(last, null))) && isTrue((isEqual(close, null))))) + // calculate open + if (isTrue(!isEqual(change, null))) { - close = last; - } else if (isTrue(isTrue((isEqual(last, null))) && isTrue((!isEqual(close, null))))) + if (isTrue(isTrue(isEqual(close, null)) && isTrue(!isEqual(average, null)))) + { + close = Precise.stringAdd(average, Precise.stringDiv(change, "2")); + } + if (isTrue(isTrue(isEqual(open, null)) && isTrue(!isEqual(close, null)))) + { + open = Precise.stringSub(close, change); + } + } else if (isTrue(!isEqual(percentage, null))) { - last = close; + if (isTrue(isTrue(isEqual(close, null)) && isTrue(!isEqual(average, null)))) + { + object openAddClose = Precise.stringMul(average, "2"); + // openAddClose = open * (1 + (100 + percentage)/100) + object denominator = Precise.stringAdd("2", Precise.stringDiv(percentage, "100")); + object calcOpen = ((bool) isTrue((!isEqual(open, null)))) ? open : Precise.stringDiv(openAddClose, denominator); + close = Precise.stringMul(calcOpen, Precise.stringAdd("1", Precise.stringDiv(percentage, "100"))); + } + if (isTrue(isTrue(isEqual(open, null)) && isTrue(!isEqual(close, null)))) + { + open = Precise.stringDiv(close, Precise.stringAdd("1", Precise.stringDiv(percentage, "100"))); + } } - if (isTrue(isTrue((!isEqual(last, null))) && isTrue((!isEqual(open, null))))) + // change + if (isTrue(isEqual(change, null))) { - if (isTrue(isEqual(change, null))) + if (isTrue(isTrue(!isEqual(close, null)) && isTrue(!isEqual(open, null)))) { - change = Precise.stringSub(last, open); + change = Precise.stringSub(close, open); + } else if (isTrue(isTrue(!isEqual(close, null)) && isTrue(!isEqual(percentage, null)))) + { + change = Precise.stringMul(Precise.stringDiv(percentage, "100"), Precise.stringDiv(close, "100")); + } else if (isTrue(isTrue(!isEqual(open, null)) && isTrue(!isEqual(percentage, null)))) + { + change = Precise.stringMul(open, Precise.stringDiv(percentage, "100")); } - if (isTrue(isEqual(average, null))) + } + // calculate things according to "open" (similar can be done with "close") + if (isTrue(!isEqual(open, null))) + { + // percentage (using change) + if (isTrue(isTrue(isEqual(percentage, null)) && isTrue(!isEqual(change, null)))) + { + percentage = Precise.stringMul(Precise.stringDiv(change, open), "100"); + } + // close (using change) + if (isTrue(isTrue(isEqual(close, null)) && isTrue(!isEqual(change, null)))) + { + close = Precise.stringAdd(open, change); + } + // close (using average) + if (isTrue(isTrue(isEqual(close, null)) && isTrue(!isEqual(average, null)))) + { + close = Precise.stringMul(average, "2"); + } + // average + if (isTrue(isTrue(isEqual(average, null)) && isTrue(!isEqual(close, null)))) { object precision = 18; if (isTrue(isTrue(!isEqual(market, null)) && isTrue(this.isTickPrecision()))) @@ -2767,23 +2819,12 @@ public virtual object safeTicker(object ticker, object market = null) precision = this.precisionFromString(precisionPrice); } } - average = Precise.stringDiv(Precise.stringAdd(last, open), "2", precision); + average = Precise.stringDiv(Precise.stringAdd(open, close), "2", precision); } } - if (isTrue(isTrue(isTrue(isTrue((isEqual(percentage, null))) && isTrue((!isEqual(change, null)))) && isTrue((!isEqual(open, null)))) && isTrue(Precise.stringGt(open, "0")))) - { - percentage = Precise.stringMul(Precise.stringDiv(change, open), "100"); - } - if (isTrue(isTrue(isTrue((isEqual(change, null))) && isTrue((!isEqual(percentage, null)))) && isTrue((!isEqual(open, null))))) - { - change = Precise.stringDiv(Precise.stringMul(percentage, open), "100"); - } - if (isTrue(isTrue(isTrue((isEqual(open, null))) && isTrue((!isEqual(last, null)))) && isTrue((!isEqual(change, null))))) - { - open = Precise.stringSub(last, change); - } // timestamp and symbol operations don't belong in safeTicker // they should be done in the derived classes + object closeParsed = this.parseNumber(this.omitZero(close)); return this.extend(ticker, new Dictionary() { { "bid", this.parseNumber(this.omitZero(this.safeString(ticker, "bid"))) }, { "bidVolume", this.safeNumber(ticker, "bidVolume") }, @@ -2792,8 +2833,8 @@ public virtual object safeTicker(object ticker, object market = null) { "high", this.parseNumber(this.omitZero(this.safeString(ticker, "high"))) }, { "low", this.parseNumber(this.omitZero(this.safeString(ticker, "low"))) }, { "open", this.parseNumber(this.omitZero(open)) }, - { "close", this.parseNumber(this.omitZero(close)) }, - { "last", this.parseNumber(this.omitZero(last)) }, + { "close", closeParsed }, + { "last", closeParsed }, { "change", this.parseNumber(change) }, { "percentage", this.parseNumber(percentage) }, { "average", this.parseNumber(average) }, @@ -5423,13 +5464,13 @@ public async virtual Task fetchDepositsWithdrawals(object code = null, o throw new NotSupported ((string)add(this.id, " fetchDepositsWithdrawals() is not supported yet")) ; } - public async virtual Task fetchDeposits(object symbol = null, object since = null, object limit = null, object parameters = null) + public async virtual Task fetchDeposits(object code = null, object since = null, object limit = null, object parameters = null) { parameters ??= new Dictionary(); throw new NotSupported ((string)add(this.id, " fetchDeposits() is not supported yet")) ; } - public async virtual Task fetchWithdrawals(object symbol = null, object since = null, object limit = null, object parameters = null) + public async virtual Task fetchWithdrawals(object code = null, object since = null, object limit = null, object parameters = null) { parameters ??= new Dictionary(); throw new NotSupported ((string)add(this.id, " fetchWithdrawals() is not supported yet")) ; diff --git a/cs/ccxt/base/Exchange.MetaData.cs b/cs/ccxt/base/Exchange.MetaData.cs index e3316349c5f64..9219381375901 100644 --- a/cs/ccxt/base/Exchange.MetaData.cs +++ b/cs/ccxt/base/Exchange.MetaData.cs @@ -3,7 +3,7 @@ namespace ccxt; // file updated automatically by vss and export-exchanges public partial class Exchange { - public static string ccxtVersion = "4.4.92"; + public static string ccxtVersion = "4.4.96"; - public static List exchanges = new List { "alpaca", "apex", "ascendex", "bequant", "bigone", "binance", "binancecoinm", "binanceus", "binanceusdm", "bingx", "bit2c", "bitbank", "bitbns", "bitfinex", "bitflyer", "bitget", "bithumb", "bitmart", "bitmex", "bitopro", "bitrue", "bitso", "bitstamp", "bitteam", "bittrade", "bitvavo", "blockchaincom", "blofin", "btcalpha", "btcbox", "btcmarkets", "btcturk", "bybit", "cex", "coinbase", "coinbaseadvanced", "coinbaseexchange", "coinbaseinternational", "coincatch", "coincheck", "coinex", "coinmate", "coinmetro", "coinone", "coinsph", "coinspot", "cryptocom", "cryptomus", "defx", "delta", "deribit", "derive", "digifinex", "ellipx", "exmo", "fmfwio", "gate", "gateio", "gemini", "hashkey", "hitbtc", "hollaex", "htx", "huobi", "hyperliquid", "independentreserve", "indodax", "kraken", "krakenfutures", "kucoin", "kucoinfutures", "latoken", "lbank", "luno", "mercado", "mexc", "modetrade", "myokx", "ndax", "novadax", "oceanex", "okcoin", "okx", "okxus", "onetrading", "oxfun", "p2b", "paradex", "paymium", "phemex", "poloniex", "probit", "timex", "tokocrypto", "tradeogre", "upbit", "vertex", "wavesexchange", "whitebit", "woo", "woofipro", "xt", "yobit", "zaif", "zonda" }; + public static List exchanges = new List { "alpaca", "apex", "ascendex", "bequant", "bigone", "binance", "binancecoinm", "binanceus", "binanceusdm", "bingx", "bit2c", "bitbank", "bitbns", "bitfinex", "bitflyer", "bitget", "bithumb", "bitmart", "bitmex", "bitopro", "bitrue", "bitso", "bitstamp", "bitteam", "bittrade", "bitvavo", "blockchaincom", "blofin", "btcalpha", "btcbox", "btcmarkets", "btcturk", "bybit", "cex", "coinbase", "coinbaseadvanced", "coinbaseexchange", "coinbaseinternational", "coincatch", "coincheck", "coinex", "coinmate", "coinmetro", "coinone", "coinsph", "coinspot", "cryptocom", "cryptomus", "defx", "delta", "deribit", "derive", "digifinex", "ellipx", "exmo", "fmfwio", "foxbit", "gate", "gateio", "gemini", "hashkey", "hitbtc", "hollaex", "htx", "huobi", "hyperliquid", "independentreserve", "indodax", "kraken", "krakenfutures", "kucoin", "kucoinfutures", "latoken", "lbank", "luno", "mercado", "mexc", "modetrade", "myokx", "ndax", "novadax", "oceanex", "okcoin", "okx", "okxus", "onetrading", "oxfun", "p2b", "paradex", "paymium", "phemex", "poloniex", "probit", "timex", "tokocrypto", "tradeogre", "upbit", "vertex", "wavesexchange", "whitebit", "woo", "woofipro", "xt", "yobit", "zaif", "zonda" }; } diff --git a/cs/ccxt/base/Exchange.Options.cs b/cs/ccxt/base/Exchange.Options.cs index 09cb8340fcf49..f2e2bef6c3fea 100644 --- a/cs/ccxt/base/Exchange.Options.cs +++ b/cs/ccxt/base/Exchange.Options.cs @@ -130,6 +130,7 @@ public object last_request_body public object name { get; set; } public object headers { get; set; } = new dict(); + public bool returnResponseHeaders { get; set; } = false; public dict httpExceptions { get; set; } = new dict(); @@ -292,5 +293,7 @@ void initializeProperties(dict userConfig = null) this.newUpdates = SafeValue(extendedProperties, "newUpdates") as bool? ?? true; this.accounts = SafeValue(extendedProperties, "accounts") as List; this.features = SafeValue(extendedProperties, "features", features) as dict; + + this.returnResponseHeaders = (bool)SafeValue(extendedProperties, "returnResponseHeaders", false); } } diff --git a/cs/ccxt/base/Exchange.Wrappers.cs b/cs/ccxt/base/Exchange.Wrappers.cs index a5793ced5dfc5..dbe8fb08aec00 100644 --- a/cs/ccxt/base/Exchange.Wrappers.cs +++ b/cs/ccxt/base/Exchange.Wrappers.cs @@ -237,10 +237,10 @@ public async Task> SetPositionMode(bool hedged, strin var res = await this.setPositionMode(hedged, symbol, parameters); return ((Dictionary)res); } - public async Task> SetMargin(string symbol, double amount, Dictionary parameters = null) + public async Task SetMargin(string symbol, double amount, Dictionary parameters = null) { var res = await this.setMargin(symbol, amount, parameters); - return ((Dictionary)res); + return new MarginModification(res); } public async Task FetchLongShortRatio(string symbol, string timeframe = null, Dictionary parameters = null) { @@ -500,15 +500,15 @@ public async Task> FetchTransactionFees(List var res = await this.fetchTransactionFees(codes, parameters); return ((Dictionary)res); } - public async Task> FetchDepositWithdrawFees(List codes = null, Dictionary parameters = null) + public async Task> FetchDepositWithdrawFees(List codes = null, Dictionary parameters = null) { var res = await this.fetchDepositWithdrawFees(codes, parameters); - return ((Dictionary)res); + return ((Dictionary)res); } - public async Task FetchDepositWithdrawFee(string code, Dictionary parameters = null) + public async Task FetchDepositWithdrawFee(string code, Dictionary parameters = null) { var res = await this.fetchDepositWithdrawFee(code, parameters); - return new DepositWithdrawFeeNetwork(res); + return new DepositWithdrawFee(res); } public async Task FetchCrossBorrowRate(string code, Dictionary parameters = null) { @@ -738,10 +738,10 @@ public async Task CreateOrderWs(string symbol, string type, string side, var res = await this.createOrderWs(symbol, type, side, amount, price, parameters); return new Order(res); } - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } public async Task> CancelOrderWs(string id, string symbol = null, Dictionary parameters = null) { @@ -753,20 +753,20 @@ public async Task> CancelOrdersWs(List ids, s var res = await this.cancelOrdersWs(ids, symbol, parameters); return ((Dictionary)res); } - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } public async Task> CancelAllOrdersAfter(Int64 timeout, Dictionary parameters = null) { var res = await this.cancelAllOrdersAfter(timeout, parameters); return ((Dictionary)res); } - public async Task> CancelOrdersForSymbols(List orders, Dictionary parameters = null) + public async Task> CancelOrdersForSymbols(List orders, Dictionary parameters = null) { var res = await this.cancelOrdersForSymbols(orders, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } public async Task> CancelAllOrdersWs(string symbol = null, Dictionary parameters = null) { @@ -909,18 +909,18 @@ public async Task> FetchDepositsWithdrawals(string code = null var res = await this.fetchDepositsWithdrawals(code, since, limit, parameters); return ((IList)res).Select(item => new Transaction(item)).ToList(); } - public async Task> FetchDeposits(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + public async Task> FetchDeposits(string code = 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.fetchDeposits(symbol, since, limit, parameters); + var res = await this.fetchDeposits(code, since, limit, parameters); return ((IList)res).Select(item => new Transaction(item)).ToList(); } - public async Task> FetchWithdrawals(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + public async Task> FetchWithdrawals(string code = 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.fetchWithdrawals(symbol, since, limit, parameters); + var res = await this.fetchWithdrawals(code, since, limit, parameters); return ((IList)res).Select(item => new Transaction(item)).ToList(); } public async Task> FetchDepositsWs(string code = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) @@ -1269,6 +1269,7 @@ public class Digifinex: digifinex { public Digifinex(object args = null) : base public class Ellipx: ellipx { public Ellipx(object args = null) : base(args) { } } public class Exmo: exmo { public Exmo(object args = null) : base(args) { } } public class Fmfwio: fmfwio { public Fmfwio(object args = null) : base(args) { } } +public class Foxbit: foxbit { public Foxbit(object args = null) : base(args) { } } public class Gate: gate { public Gate(object args = null) : base(args) { } } public class Gateio: gateio { public Gateio(object args = null) : base(args) { } } public class Gemini: gemini { public Gemini(object args = null) : base(args) { } } diff --git a/cs/ccxt/base/Exchange.cs b/cs/ccxt/base/Exchange.cs index 99f265b279cac..abe2a2437de3c 100644 --- a/cs/ccxt/base/Exchange.cs +++ b/cs/ccxt/base/Exchange.cs @@ -312,7 +312,7 @@ public async virtual Task fetch(object url2, object method2 = null, obje this.httpClient.DefaultRequestHeaders.Clear(); - var responseHeaders = response?.Headers.ToDictionary(x => x, y => y.Value.First()); + var responseHeaders = response?.Headers.ToDictionary(x => x.Key, y => y.Value.First()); this.last_response_headers = responseHeaders; this.last_request_headers = headers; var httpStatusCode = (int)response?.StatusCode; @@ -326,6 +326,11 @@ public async virtual Task fetch(object url2, object method2 = null, obje try { responseBody = JsonHelper.Deserialize(result); + if (this.returnResponseHeaders && responseBody is Dictionary dict) + { + dict["headers"] = responseHeaders; + responseBody = dict; + } } catch (Exception e) { diff --git a/cs/ccxt/base/Throttler.cs b/cs/ccxt/base/Throttler.cs index 32b5ab2ed42ee..f93c8fffee7a8 100644 --- a/cs/ccxt/base/Throttler.cs +++ b/cs/ccxt/base/Throttler.cs @@ -11,6 +11,8 @@ public class Throttler private bool running = false; + private static object throttlerLock = new object(); + public Throttler(dict config) { this.config = new Dictionary() @@ -75,23 +77,26 @@ private async Task loop() public async Task throttle(object cost2) { - - var cost = (cost2 != null) ? Convert.ToDouble(cost2) : Convert.ToDouble(this.config["cost"]); - if (this.queue.Count > (int)this.config["maxCapacity"]) + lock (throttlerLock) { - throw new Exception("throttle queue is over maxCapacity (" + this.config["maxCapacity"].ToString() + "), see https://github.com/ccxt/ccxt/issues/11645#issuecomment-1195695526"); - } - var t = new Task(() => { }); - this.queue.Enqueue((t, cost)); - if (!this.running) - { - this.running = true; - // Task.Run(() => { this.loop(); }); - this.loop(); + var cost = (cost2 != null) ? Convert.ToDouble(cost2) : Convert.ToDouble(this.config["cost"]); + if (this.queue.Count > (int)this.config["maxCapacity"]) + { + throw new Exception("throttle queue is over maxCapacity (" + this.config["maxCapacity"].ToString() + "), see https://github.com/ccxt/ccxt/issues/11645#issuecomment-1195695526"); + } + var t = new Task(() => { }); + this.queue.Enqueue((t, cost)); + if (!this.running) + { + this.running = true; + // Task.Run(() => { this.loop(); }); + this.loop(); + } + return t; } - return t; } + // move this elsewhere later private dict extend(object aa, object bb) { diff --git a/cs/ccxt/ccxt.csproj b/cs/ccxt/ccxt.csproj index df1eb3164f8c2..0c8889d4d9cdb 100644 --- a/cs/ccxt/ccxt.csproj +++ b/cs/ccxt/ccxt.csproj @@ -10,9 +10,9 @@ ccxt Carlos, Kroitor, Carlo - 4.4.92 - 4.4.92 - 4.4.92 + 4.4.96 + 4.4.96 + 4.4.96 README.md Cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges false diff --git a/cs/ccxt/exchanges/apex.cs b/cs/ccxt/exchanges/apex.cs index 7d248e7679048..2546ff77c2438 100644 --- a/cs/ccxt/exchanges/apex.cs +++ b/cs/ccxt/exchanges/apex.cs @@ -1637,7 +1637,7 @@ public async override Task cancelAllOrders(object symbol = null, object } object response = await this.privatePostV3DeleteOpenOrders(this.extend(request, parameters)); object data = this.safeDict(response, "data", new Dictionary() {}); - return data; + return new List {this.parseOrder(data, market)}; } /** @@ -1667,7 +1667,7 @@ public async override Task cancelOrder(object id, object symbol = null, response = await this.privatePostV3DeleteOrder(this.extend(request, parameters)); } object data = this.safeDict(response, "data", new Dictionary() {}); - return data; + return this.safeOrder(data); } /** diff --git a/cs/ccxt/exchanges/ascendex.cs b/cs/ccxt/exchanges/ascendex.cs index 25d6f8b23d2a6..c2b9ddb38f8c6 100644 --- a/cs/ccxt/exchanges/ascendex.cs +++ b/cs/ccxt/exchanges/ascendex.cs @@ -2679,9 +2679,9 @@ public async override Task cancelAllOrders(object symbol = null, object // } // } // - return this.safeOrder(new Dictionary() { - { "info", response }, - }); + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } public override object parseDepositAddress(object depositAddress, object currency = null) diff --git a/cs/ccxt/exchanges/binance.cs b/cs/ccxt/exchanges/binance.cs index 22cfd06c9ddcc..c2aa0c9a91c97 100644 --- a/cs/ccxt/exchanges/binance.cs +++ b/cs/ccxt/exchanges/binance.cs @@ -1297,7 +1297,9 @@ public override object describe() { "options", new Dictionary() { { "sandboxMode", false }, { "fetchMargins", true }, - { "fetchMarkets", new List() {"spot", "linear", "inverse"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"spot", "linear", "inverse"} }, + } }, { "loadAllOptions", false }, { "fetchCurrencies", true }, { "defaultTimeInForce", "GTC" }, @@ -3005,7 +3007,17 @@ public async override Task fetchMarkets(object parameters = null) { parameters ??= new Dictionary(); object promisesRaw = new List() {}; - object rawFetchMarkets = this.safeList(this.options, "fetchMarkets", new List() {"spot", "linear", "inverse"}); + object rawFetchMarkets = null; + object defaultTypes = new List() {"spot", "linear", "inverse"}; + object fetchMarketsOptions = this.safeDict(this.options, "fetchMarkets"); + if (isTrue(!isEqual(fetchMarketsOptions, null))) + { + rawFetchMarkets = this.safeList(fetchMarketsOptions, "types", defaultTypes); + } else + { + // for backward-compatibility + rawFetchMarkets = this.safeList(this.options, "fetchMarkets", defaultTypes); + } // handle loadAllOptions option object loadAllOptions = this.safeBool(this.options, "loadAllOptions", false); if (isTrue(loadAllOptions)) diff --git a/cs/ccxt/exchanges/binancecoinm.cs b/cs/ccxt/exchanges/binancecoinm.cs index 06884d45ac136..7ca5fc7e92b07 100644 --- a/cs/ccxt/exchanges/binancecoinm.cs +++ b/cs/ccxt/exchanges/binancecoinm.cs @@ -24,7 +24,9 @@ public override object describe() { "createStopMarketOrder", true }, } }, { "options", new Dictionary() { - { "fetchMarkets", new List() {"inverse"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"inverse"} }, + } }, { "defaultSubType", "inverse" }, { "leverageBrackets", null }, } }, diff --git a/cs/ccxt/exchanges/binanceus.cs b/cs/ccxt/exchanges/binanceus.cs index 1a004b3ed6022..72a520fe2fe3e 100644 --- a/cs/ccxt/exchanges/binanceus.cs +++ b/cs/ccxt/exchanges/binanceus.cs @@ -39,7 +39,9 @@ public override object describe() } }, } }, { "options", new Dictionary() { - { "fetchMarkets", new List() {"spot"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"spot"} }, + } }, { "defaultType", "spot" }, { "fetchMargins", false }, { "quoteOrderQty", false }, diff --git a/cs/ccxt/exchanges/binanceusdm.cs b/cs/ccxt/exchanges/binanceusdm.cs index 8c2384e1cfcef..402ef95ec9488 100644 --- a/cs/ccxt/exchanges/binanceusdm.cs +++ b/cs/ccxt/exchanges/binanceusdm.cs @@ -24,7 +24,9 @@ public override object describe() { "createStopMarketOrder", true }, } }, { "options", new Dictionary() { - { "fetchMarkets", new List() {"linear"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"linear"} }, + } }, { "defaultSubType", "linear" }, { "leverageBrackets", null }, { "marginTypes", new Dictionary() {} }, diff --git a/cs/ccxt/exchanges/bingx.cs b/cs/ccxt/exchanges/bingx.cs index 5465a9a70c3eb..947550a155547 100644 --- a/cs/ccxt/exchanges/bingx.cs +++ b/cs/ccxt/exchanges/bingx.cs @@ -105,6 +105,7 @@ public override object describe() { "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", new Dictionary() { { "swap", "https://open-api-vst.{hostname}/openApi" }, @@ -434,6 +435,7 @@ public override object describe() { "private", new Dictionary() { { "get", new Dictionary() { { "asset/transfer", 1 }, + { "asset/transferRecord", 5 }, { "capital/deposit/hisrec", 1 }, { "capital/withdraw/history", 1 }, } }, @@ -442,6 +444,20 @@ public override object describe() } }, } }, } }, + { "asset", new Dictionary() { + { "v1", new Dictionary() { + { "private", new Dictionary() { + { "post", new Dictionary() { + { "transfer", 5 }, + } }, + } }, + { "public", new Dictionary() { + { "get", new Dictionary() { + { "transfer/supportCoins", 5 }, + } }, + } }, + } }, + } }, } }, } }, { "timeframes", new Dictionary() { @@ -506,16 +522,19 @@ public override object describe() { "options", new Dictionary() { { "defaultType", "spot" }, { "accountsByType", new Dictionary() { - { "funding", "FUND" }, - { "spot", "SPOT" }, - { "swap", "PFUTURES" }, - { "future", "SFUTURES" }, + { "funding", "fund" }, + { "spot", "spot" }, + { "future", "stdFutures" }, + { "swap", "USDTMPerp" }, + { "linear", "USDTMPerp" }, + { "inverse", "coinMPerp" }, } }, { "accountsById", new Dictionary() { - { "FUND", "funding" }, - { "SPOT", "spot" }, - { "PFUTURES", "swap" }, - { "SFUTURES", "future" }, + { "fund", "funding" }, + { "spot", "spot" }, + { "stdFutures", "future" }, + { "USDTMPerp", "linear" }, + { "coinMPerp", "inverse" }, } }, { "recvWindow", multiply(5, 1000) }, { "broker", "CCXT" }, @@ -768,6 +787,10 @@ public async override Task fetchCurrencies(object parameters = null) { "min", this.safeNumber(rawNetwork, "withdrawMin") }, { "max", this.safeNumber(rawNetwork, "withdrawMax") }, } }, + { "deposit", new Dictionary() { + { "min", this.safeNumber(rawNetwork, "depositMin") }, + { "max", null }, + } }, }; object precision = this.parseNumber(this.parsePrecision(this.safeString(rawNetwork, "withdrawPrecision"))); ((IDictionary)networks)[(string)networkCode] = new Dictionary() { @@ -782,20 +805,44 @@ public async override Task fetchCurrencies(object parameters = null) { "limits", limits }, }; } - ((IDictionary)result)[(string)code] = this.safeCurrencyStructure(new Dictionary() { - { "info", entry }, - { "code", code }, - { "id", currencyId }, - { "precision", null }, - { "name", name }, - { "active", null }, - { "deposit", null }, - { "withdraw", null }, - { "networks", networks }, - { "fee", null }, - { "limits", null }, - { "type", "crypto" }, - }); + if (!isTrue((inOp(result, code)))) + { + ((IDictionary)result)[(string)code] = new Dictionary() { + { "info", entry }, + { "code", code }, + { "id", currencyId }, + { "precision", null }, + { "name", name }, + { "active", null }, + { "deposit", null }, + { "withdraw", null }, + { "networks", networks }, + { "fee", null }, + { "limits", null }, + { "type", "crypto" }, + }; + } else + { + object existing = getValue(result, code); + object existingNetworks = this.safeDict(existing, "networks", new Dictionary() {}); + object newNetworkCodes = new List(((IDictionary)networks).Keys); + for (object j = 0; isLessThan(j, getArrayLength(newNetworkCodes)); postFixIncrement(ref j)) + { + object newNetworkCode = getValue(newNetworkCodes, j); + if (!isTrue((inOp(existingNetworks, newNetworkCode)))) + { + ((IDictionary)existingNetworks)[(string)newNetworkCode] = getValue(networks, newNetworkCode); + } + } + ((IDictionary)getValue(result, code))["networks"] = existingNetworks; + } + } + object codes = new List(((IDictionary)result).Keys); + for (object i = 0; isLessThan(i, getArrayLength(codes)); postFixIncrement(ref i)) + { + object code = getValue(codes, i); + object currency = getValue(result, code); + ((IDictionary)result)[(string)code] = this.safeCurrencyStructure(currency); } return result; } @@ -4525,11 +4572,11 @@ public async override Task fetchCanceledAndClosedOrders(object symbol = * @method * @name bingx#transfer * @description transfer currency internally between wallets on the same account - * @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20Transfer + * @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20Transfer%20New * @param {string} code unified currency code * @param {float} amount amount to transfer * @param {string} fromAccount account to transfer from (spot, swap, futures, or funding) - * @param {string} toAccount account to transfer to (spot, swap, futures, or funding) + * @param {string} toAccount account to transfer to (spot, swap (linear or inverse), future, or funding) * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure} */ @@ -4539,14 +4586,39 @@ public async override Task transfer(object code, object amount, object f await this.loadMarkets(); object currency = this.currency(code); object accountsByType = this.safeDict(this.options, "accountsByType", new Dictionary() {}); + object subType = null; + var subTypeparametersVariable = this.handleSubTypeAndParams("transfer", null, parameters); + subType = ((IList)subTypeparametersVariable)[0]; + parameters = ((IList)subTypeparametersVariable)[1]; object fromId = this.safeString(accountsByType, fromAccount, fromAccount); object toId = this.safeString(accountsByType, toAccount, toAccount); + if (isTrue(isEqual(fromId, "swap"))) + { + if (isTrue(isEqual(subType, "inverse"))) + { + fromId = "coinMPerp"; + } else + { + fromId = "USDTMPerp"; + } + } + if (isTrue(isEqual(toId, "swap"))) + { + if (isTrue(isEqual(subType, "inverse"))) + { + toId = "coinMPerp"; + } else + { + toId = "USDTMPerp"; + } + } object request = new Dictionary() { + { "fromAccount", fromId }, + { "toAccount", toId }, { "asset", getValue(currency, "id") }, { "amount", this.currencyToPrecision(code, amount) }, - { "type", add(add(fromId, "_"), toId) }, }; - object response = await this.spotV3PrivateGetGetAssetTransfer(this.extend(request, parameters)); + object response = await this.apiAssetV1PrivatePostTransfer(this.extend(request, parameters)); // // { // "tranId": 1933130865269936128, @@ -4555,7 +4627,7 @@ public async override Task transfer(object code, object amount, object f // return new Dictionary() { { "info", response }, - { "id", this.safeString(response, "tranId") }, + { "id", this.safeString(response, "transferId") }, { "timestamp", null }, { "datetime", null }, { "currency", code }, @@ -4570,13 +4642,13 @@ public async override Task transfer(object code, object amount, object f * @method * @name bingx#fetchTransfers * @description fetch a history of internal transfers made on an account - * @see https://bingx-api.github.io/docs/#/spot/account-api.html#Query%20User%20Universal%20Transfer%20History%20(USER_DATA) + * @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20transfer%20records%20new * @param {string} [code] unified currency code of the currency transferred * @param {int} [since] the earliest time in ms to fetch transfers for * @param {int} [limit] the maximum number of transfers structures to retrieve (default 10, max 100) * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {string} params.fromAccount (mandatory) transfer from (spot, swap, futures, or funding) - * @param {string} params.toAccount (mandatory) transfer to (spot, swap, futures, or funding) + * @param {string} params.fromAccount (mandatory) transfer from (spot, swap (linear or inverse), future, or funding) + * @param {string} params.toAccount (mandatory) transfer to (spot, swap(linear or inverse), future, or funding) * @param {boolean} [params.paginate] whether to paginate the results (default false) * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure} */ @@ -4584,6 +4656,7 @@ public async override Task fetchTransfers(object code = null, object sin { parameters ??= new Dictionary(); await this.loadMarkets(); + object request = new Dictionary() {}; object currency = null; if (isTrue(!isEqual(code, null))) { @@ -4596,7 +4669,15 @@ public async override Task fetchTransfers(object code = null, object sin object toId = this.safeString(accountsByType, toAccount, toAccount); if (isTrue(isTrue(isEqual(fromId, null)) || isTrue(isEqual(toId, null)))) { - throw new ExchangeError ((string)add(this.id, " fromAccount & toAccount parameter are required")) ; + throw new ExchangeError ((string)add(this.id, " fromAccount & toAccount parameters are required")) ; + } + if (isTrue(!isEqual(fromAccount, null))) + { + ((IDictionary)request)["fromAccount"] = fromId; + } + if (isTrue(!isEqual(toAccount, null))) + { + ((IDictionary)request)["toAccount"] = toId; } parameters = this.omit(parameters, new List() {"fromAccount", "toAccount"}); object maxLimit = 100; @@ -4608,33 +4689,31 @@ public async override Task fetchTransfers(object code = null, object sin { return await this.fetchPaginatedCallDynamic("fetchTransfers", null, since, limit, parameters, maxLimit); } - object request = new Dictionary() { - { "type", add(add(fromId, "_"), toId) }, - }; if (isTrue(!isEqual(since, null))) { ((IDictionary)request)["startTime"] = since; } if (isTrue(!isEqual(limit, null))) { - ((IDictionary)request)["size"] = limit; + ((IDictionary)request)["pageSize"] = limit; } var requestparametersVariable = this.handleUntilOption("endTime", request, parameters); request = ((IList)requestparametersVariable)[0]; parameters = ((IList)requestparametersVariable)[1]; - object response = await this.spotV3PrivateGetAssetTransfer(this.extend(request, parameters)); + object response = await this.apiV3PrivateGetAssetTransferRecord(this.extend(request, parameters)); // // { - // "total": 3, + // "total": 2, // "rows": [ // { - // "asset": "USDT", - // "amount": "100.00000000000000000000", - // "type": "FUND_SFUTURES", + // "asset": "LTC", + // "amount": "0.05000000000000000000", // "status": "CONFIRMED", - // "tranId": 1067594500957016069, - // "timestamp": 1658388859000 - // }, + // "transferId": "1051461075661819338791", + // "timestamp": 1752202092000, + // "fromAccount": "spot", + // "toAccount": "USDTMPerp" + // } // ] // } // @@ -4644,15 +4723,14 @@ public async override Task fetchTransfers(object code = null, object sin public override object parseTransfer(object transfer, object currency = null) { - object tranId = this.safeString(transfer, "tranId"); + object tranId = this.safeString(transfer, "transferId"); object timestamp = this.safeInteger(transfer, "timestamp"); - object currencyCode = this.safeCurrencyCode(null, currency); + object currencyId = this.safeString(transfer, "asset"); + object currencyCode = this.safeCurrencyCode(currencyId, currency); object status = this.safeString(transfer, "status"); object accountsById = this.safeDict(this.options, "accountsById", new Dictionary() {}); - object typeId = this.safeString(transfer, "type"); - object typeIdSplit = ((string)typeId).Split(new [] {((string)"_")}, StringSplitOptions.None).ToList(); - object fromId = this.safeString(typeIdSplit, 0); - object toId = this.safeString(typeIdSplit, 1); + object fromId = this.safeString(transfer, "fromAccount"); + object toId = this.safeString(transfer, "toAccount"); object fromAccount = this.safeString(accountsById, fromId, fromId); object toAccount = this.safeString(accountsById, toId, toId); return new Dictionary() { @@ -5341,37 +5419,13 @@ public async override Task fetchMyTrades(object symbol = null, object si public override object parseDepositWithdrawFee(object fee, object currency = null) { // - // { - // "coin": "BTC", - // "name": "BTC", - // "networkList": [ - // { - // "name": "BTC", - // "network": "BTC", - // "isDefault": true, - // "minConfirm": "2", - // "withdrawEnable": true, - // "withdrawFee": "0.00035", - // "withdrawMax": "1.62842", - // "withdrawMin": "0.0005" - // }, - // { - // "name": "BTC", - // "network": "BEP20", - // "isDefault": false, - // "minConfirm": "15", - // "withdrawEnable": true, - // "withdrawFee": "0.00001", - // "withdrawMax": "1.62734", - // "withdrawMin": "0.0001" - // } - // ] - // } + // currencie structure // - object networkList = this.safeList(fee, "networkList", new List() {}); - object networkListLength = getArrayLength(networkList); + object networks = this.safeDict(fee, "networks", new Dictionary() {}); + object networkCodes = new List(((IDictionary)networks).Keys); + object networksLength = getArrayLength(networkCodes); object result = new Dictionary() { - { "info", fee }, + { "info", networks }, { "withdraw", new Dictionary() { { "fee", null }, { "percentage", null }, @@ -5382,26 +5436,23 @@ public override object parseDepositWithdrawFee(object fee, object currency = nul } }, { "networks", new Dictionary() {} }, }; - if (isTrue(!isEqual(networkListLength, 0))) + if (isTrue(!isEqual(networksLength, 0))) { - for (object i = 0; isLessThan(i, networkListLength); postFixIncrement(ref i)) + for (object i = 0; isLessThan(i, networksLength); postFixIncrement(ref i)) { - object network = getValue(networkList, i); - object networkId = this.safeString(network, "network"); - object isDefault = this.safeBool(network, "isDefault"); - object currencyCode = this.safeString(currency, "code"); - object networkCode = this.networkIdToCode(networkId, currencyCode); + object networkCode = getValue(networkCodes, i); + object network = getValue(networks, networkCode); ((IDictionary)getValue(result, "networks"))[(string)networkCode] = new Dictionary() { { "deposit", new Dictionary() { { "fee", null }, { "percentage", null }, } }, { "withdraw", new Dictionary() { - { "fee", this.safeNumber(network, "withdrawFee") }, + { "fee", this.safeNumber(network, "fee") }, { "percentage", false }, } }, }; - if (isTrue(isDefault)) + if (isTrue(isEqual(networksLength, 1))) { ((IDictionary)getValue(result, "withdraw"))["fee"] = this.safeNumber(network, "withdrawFee"); ((IDictionary)getValue(result, "withdraw"))["percentage"] = false; @@ -5424,9 +5475,19 @@ public async override Task fetchDepositWithdrawFees(object codes = null, { parameters ??= new Dictionary(); await this.loadMarkets(); - object response = await this.walletsV1PrivateGetCapitalConfigGetall(parameters); - object coins = this.safeList(response, "data"); - return this.parseDepositWithdrawFees(coins, codes, "coin"); + object response = await this.fetchCurrencies(parameters); + object depositWithdrawFees = new Dictionary() {}; + object responseCodes = new List(((IDictionary)response).Keys); + for (object i = 0; isLessThan(i, getArrayLength(responseCodes)); postFixIncrement(ref i)) + { + object code = getValue(responseCodes, i); + if (isTrue(isTrue((isEqual(codes, null))) || isTrue((this.inArray(code, codes))))) + { + object entry = getValue(response, code); + ((IDictionary)depositWithdrawFees)[(string)code] = this.parseDepositWithdrawFee(entry); + } + } + return depositWithdrawFees; } /** @@ -6077,9 +6138,17 @@ public override object sign(object path, object section = null, object method = } object url = this.implodeHostname(getValue(getValue(this.urls, "api"), type)); path = this.implodeParams(path, parameters); - if (isTrue(isEqual(version, "transfer"))) + object versionIsTransfer = (isEqual(version, "transfer")); + object versionIsAsset = (isEqual(version, "asset")); + if (isTrue(isTrue(versionIsTransfer) || isTrue(versionIsAsset))) { - type = "account/transfer"; + if (isTrue(versionIsTransfer)) + { + type = "account/transfer"; + } else + { + type = "api/asset"; + } version = getValue(section, 2); access = getValue(section, 3); } diff --git a/cs/ccxt/exchanges/bitcoincom.cs b/cs/ccxt/exchanges/bitcoincom.cs deleted file mode 100644 index 40350bbb8b962..0000000000000 --- a/cs/ccxt/exchanges/bitcoincom.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace ccxt; - -// 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 bitcoincom : fmfwio -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "id", "bitcoincom" }, - { "name", "Bitcoin.com" }, - { "alias", true }, - }); - } -} diff --git a/cs/ccxt/exchanges/bitfinex1.cs b/cs/ccxt/exchanges/bitfinex1.cs deleted file mode 100644 index 1b361dc2a2ccd..0000000000000 --- a/cs/ccxt/exchanges/bitfinex1.cs +++ /dev/null @@ -1,1878 +0,0 @@ -namespace ccxt; - -// 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 bitfinex1 : Exchange -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "id", "bitfinex1" }, - { "name", "Bitfinex" }, - { "countries", new List() {"VG"} }, - { "version", "v1" }, - { "rateLimit", 666.666 }, - { "pro", true }, - { "has", new Dictionary() { - { "CORS", null }, - { "spot", true }, - { "margin", null }, - { "swap", null }, - { "future", null }, - { "option", null }, - { "cancelAllOrders", true }, - { "cancelOrder", true }, - { "createDepositAddress", true }, - { "createOrder", true }, - { "editOrder", true }, - { "fetchBalance", true }, - { "fetchClosedOrders", true }, - { "fetchDepositAddress", true }, - { "fetchDepositAddresses", false }, - { "fetchDepositAddressesByNetwork", false }, - { "fetchDeposits", false }, - { "fetchDepositsWithdrawals", true }, - { "fetchDepositWithdrawFee", "emulated" }, - { "fetchDepositWithdrawFees", true }, - { "fetchFundingHistory", false }, - { "fetchFundingRate", false }, - { "fetchFundingRateHistory", false }, - { "fetchFundingRates", false }, - { "fetchIndexOHLCV", false }, - { "fetchLeverageTiers", false }, - { "fetchMarginMode", false }, - { "fetchMarkets", true }, - { "fetchMarkOHLCV", false }, - { "fetchMyTrades", true }, - { "fetchOHLCV", true }, - { "fetchOpenOrders", true }, - { "fetchOrder", true }, - { "fetchOrderBook", true }, - { "fetchPositionMode", false }, - { "fetchPositions", true }, - { "fetchPremiumIndexOHLCV", false }, - { "fetchTicker", true }, - { "fetchTickers", true }, - { "fetchTime", false }, - { "fetchTrades", true }, - { "fetchTradingFee", false }, - { "fetchTradingFees", true }, - { "fetchTransactionFees", true }, - { "fetchTransactions", "emulated" }, - { "transfer", true }, - { "withdraw", true }, - } }, - { "timeframes", new Dictionary() { - { "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" }, - } }, - { "urls", new Dictionary() { - { "logo", "https://github.com/user-attachments/assets/9147c6c5-7197-481e-827b-7483672bb0e9" }, - { "api", new Dictionary() { - { "v2", "https://api-pub.bitfinex.com" }, - { "public", "https://api.bitfinex.com" }, - { "private", "https://api.bitfinex.com" }, - } }, - { "www", "https://www.bitfinex.com" }, - { "referral", "https://www.bitfinex.com/?refcode=P61eYxFL" }, - { "doc", new List() {"https://docs.bitfinex.com/v1/docs", "https://github.com/bitfinexcom/bitfinex-api-node"} }, - } }, - { "api", new Dictionary() { - { "v2", new Dictionary() { - { "get", new Dictionary() { - { "platform/status", 3 }, - { "tickers", 1 }, - { "ticker/{symbol}", 1 }, - { "tickers/hist", 1 }, - { "trades/{symbol}/hist", 1 }, - { "book/{symbol}/{precision}", 0.375 }, - { "book/{symbol}/P0", 0.375 }, - { "book/{symbol}/P1", 0.375 }, - { "book/{symbol}/P2", 0.375 }, - { "book/{symbol}/P3", 0.375 }, - { "book/{symbol}/R0", 0.375 }, - { "stats1/{key}:{size}:{symbol}:{side}/{section}", 1 }, - { "stats1/{key}:{size}:{symbol}/{section}", 1 }, - { "stats1/{key}:{size}:{symbol}:long/last", 1 }, - { "stats1/{key}:{size}:{symbol}:long/hist", 1 }, - { "stats1/{key}:{size}:{symbol}:short/last", 1 }, - { "stats1/{key}:{size}:{symbol}:short/hist", 1 }, - { "candles/trade:{timeframe}:{symbol}/{section}", 1 }, - { "candles/trade:{timeframe}:{symbol}/last", 1 }, - { "candles/trade:{timeframe}:{symbol}/hist", 1 }, - } }, - } }, - { "public", new Dictionary() { - { "get", new Dictionary() { - { "book/{symbol}", 1 }, - { "lendbook/{currency}", 6 }, - { "lends/{currency}", 3 }, - { "pubticker/{symbol}", 3 }, - { "stats/{symbol}", 6 }, - { "symbols", 18 }, - { "symbols_details", 18 }, - { "tickers", 1 }, - { "trades/{symbol}", 3 }, - } }, - } }, - { "private", new Dictionary() { - { "post", new Dictionary() { - { "account_fees", 18 }, - { "account_infos", 6 }, - { "balances", 9.036 }, - { "basket_manage", 6 }, - { "credits", 6 }, - { "deposit/new", 18 }, - { "funding/close", 6 }, - { "history", 6 }, - { "history/movements", 6 }, - { "key_info", 6 }, - { "margin_infos", 3 }, - { "mytrades", 3 }, - { "mytrades_funding", 6 }, - { "offer/cancel", 6 }, - { "offer/new", 6 }, - { "offer/status", 6 }, - { "offers", 6 }, - { "offers/hist", 90.03 }, - { "order/cancel", 0.2 }, - { "order/cancel/all", 0.2 }, - { "order/cancel/multi", 0.2 }, - { "order/cancel/replace", 0.2 }, - { "order/new", 0.2 }, - { "order/new/multi", 0.2 }, - { "order/status", 0.2 }, - { "orders", 0.2 }, - { "orders/hist", 90.03 }, - { "position/claim", 18 }, - { "position/close", 18 }, - { "positions", 18 }, - { "summary", 18 }, - { "taken_funds", 6 }, - { "total_taken_funds", 6 }, - { "transfer", 18 }, - { "unused_taken_funds", 6 }, - { "withdraw", 18 }, - } }, - } }, - } }, - { "fees", new Dictionary() { - { "trading", new Dictionary() { - { "feeSide", "get" }, - { "tierBased", true }, - { "percentage", true }, - { "maker", this.parseNumber("0.001") }, - { "taker", this.parseNumber("0.002") }, - { "tiers", new Dictionary() { - { "taker", new List() {new List {this.parseNumber("0"), this.parseNumber("0.002")}, new List {this.parseNumber("500000"), this.parseNumber("0.002")}, new List {this.parseNumber("1000000"), this.parseNumber("0.002")}, new List {this.parseNumber("2500000"), this.parseNumber("0.002")}, new List {this.parseNumber("5000000"), this.parseNumber("0.002")}, new List {this.parseNumber("7500000"), this.parseNumber("0.002")}, new List {this.parseNumber("10000000"), this.parseNumber("0.0018")}, new List {this.parseNumber("15000000"), this.parseNumber("0.0016")}, new List {this.parseNumber("20000000"), this.parseNumber("0.0014")}, new List {this.parseNumber("25000000"), this.parseNumber("0.0012")}, new List {this.parseNumber("30000000"), this.parseNumber("0.001")}} }, - { "maker", new List() {new List {this.parseNumber("0"), this.parseNumber("0.001")}, new List {this.parseNumber("500000"), this.parseNumber("0.0008")}, new List {this.parseNumber("1000000"), this.parseNumber("0.0006")}, new List {this.parseNumber("2500000"), this.parseNumber("0.0004")}, new List {this.parseNumber("5000000"), this.parseNumber("0.0002")}, new List {this.parseNumber("7500000"), this.parseNumber("0")}, new List {this.parseNumber("10000000"), this.parseNumber("0")}, new List {this.parseNumber("15000000"), this.parseNumber("0")}, new List {this.parseNumber("20000000"), this.parseNumber("0")}, new List {this.parseNumber("25000000"), this.parseNumber("0")}, new List {this.parseNumber("30000000"), this.parseNumber("0")}} }, - } }, - } }, - { "funding", new Dictionary() { - { "tierBased", false }, - { "percentage", false }, - { "deposit", new Dictionary() {} }, - { "withdraw", new Dictionary() {} }, - } }, - } }, - { "commonCurrencies", new Dictionary() { - { "ALG", "ALGO" }, - { "AMP", "AMPL" }, - { "ATO", "ATOM" }, - { "BCHABC", "XEC" }, - { "BCHN", "BCH" }, - { "DAT", "DATA" }, - { "DOG", "MDOGE" }, - { "DSH", "DASH" }, - { "EDO", "PNT" }, - { "EUS", "EURS" }, - { "EUT", "EURT" }, - { "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" }, - { "UST", "USDT" }, - { "VSY", "VSYS" }, - { "WAX", "WAXP" }, - { "XCH", "XCHF" }, - { "ZBT", "ZB" }, - } }, - { "exceptions", new Dictionary() { - { "exact", new Dictionary() { - { "temporarily_unavailable", typeof(ExchangeNotAvailable) }, - { "Order could not be cancelled.", typeof(OrderNotFound) }, - { "No such order found.", typeof(OrderNotFound) }, - { "Order price must be positive.", typeof(InvalidOrder) }, - { "Could not find a key matching the given X-BFX-APIKEY.", typeof(AuthenticationError) }, - { "Key price should be a decimal number, e.g. \"123.456\"", typeof(InvalidOrder) }, - { "Key amount should be a decimal number, e.g. \"123.456\"", typeof(InvalidOrder) }, - { "ERR_RATE_LIMIT", typeof(RateLimitExceeded) }, - { "Ratelimit", typeof(RateLimitExceeded) }, - { "Nonce is too small.", typeof(InvalidNonce) }, - { "No summary found.", typeof(ExchangeError) }, - { "Cannot evaluate your available balance, please try again", typeof(ExchangeNotAvailable) }, - { "Unknown symbol", typeof(BadSymbol) }, - { "Cannot complete transfer. Exchange balance insufficient.", typeof(InsufficientFunds) }, - { "Momentary balance check. Please wait few seconds and try the transfer again.", typeof(ExchangeError) }, - } }, - { "broad", new Dictionary() { - { "Invalid X-BFX-SIGNATURE", typeof(AuthenticationError) }, - { "This API key does not have permission", typeof(PermissionDenied) }, - { "not enough exchange balance for ", typeof(InsufficientFunds) }, - { "minimum size for ", typeof(InvalidOrder) }, - { "Invalid order", typeof(InvalidOrder) }, - { "The available balance is only", typeof(InsufficientFunds) }, - } }, - } }, - { "precisionMode", SIGNIFICANT_DIGITS }, - { "options", new Dictionary() { - { "currencyNames", new Dictionary() { - { "AGI", "agi" }, - { "AID", "aid" }, - { "AIO", "aio" }, - { "ANT", "ant" }, - { "AVT", "aventus" }, - { "BAT", "bat" }, - { "BCH", "bab" }, - { "BCI", "bci" }, - { "BFT", "bft" }, - { "BSV", "bsv" }, - { "BTC", "bitcoin" }, - { "BTG", "bgold" }, - { "CFI", "cfi" }, - { "COMP", "comp" }, - { "DAI", "dai" }, - { "DADI", "dad" }, - { "DASH", "dash" }, - { "DATA", "datacoin" }, - { "DTH", "dth" }, - { "EDO", "eidoo" }, - { "ELF", "elf" }, - { "EOS", "eos" }, - { "ETC", "ethereumc" }, - { "ETH", "ethereum" }, - { "ETP", "metaverse" }, - { "FUN", "fun" }, - { "GNT", "golem" }, - { "IOST", "ios" }, - { "IOTA", "iota" }, - { "LEO", "let" }, - { "LINK", "link" }, - { "LRC", "lrc" }, - { "LTC", "litecoin" }, - { "LYM", "lym" }, - { "MANA", "mna" }, - { "MIT", "mit" }, - { "MKR", "mkr" }, - { "MTN", "mtn" }, - { "NEO", "neo" }, - { "ODE", "ode" }, - { "OMG", "omisego" }, - { "OMNI", "mastercoin" }, - { "QASH", "qash" }, - { "QTUM", "qtum" }, - { "RCN", "rcn" }, - { "RDN", "rdn" }, - { "REP", "rep" }, - { "REQ", "req" }, - { "RLC", "rlc" }, - { "SAN", "santiment" }, - { "SNGLS", "sng" }, - { "SNT", "status" }, - { "SPANK", "spk" }, - { "STORJ", "stj" }, - { "TNB", "tnb" }, - { "TRX", "trx" }, - { "TUSD", "tsd" }, - { "USD", "wire" }, - { "USDC", "udc" }, - { "UTK", "utk" }, - { "USDT", "tetheruso" }, - { "VEE", "vee" }, - { "WAX", "wax" }, - { "XLM", "xlm" }, - { "XMR", "monero" }, - { "XRP", "ripple" }, - { "XVG", "xvg" }, - { "YOYOW", "yoyow" }, - { "ZEC", "zcash" }, - { "ZRX", "zrx" }, - { "XTZ", "xtz" }, - } }, - { "orderTypes", new Dictionary() { - { "limit", "exchange limit" }, - { "market", "exchange market" }, - } }, - { "fiat", new Dictionary() { - { "USD", "USD" }, - { "EUR", "EUR" }, - { "JPY", "JPY" }, - { "GBP", "GBP" }, - { "CNH", "CNH" }, - } }, - { "accountsByType", new Dictionary() { - { "spot", "exchange" }, - { "margin", "trading" }, - { "funding", "deposit" }, - { "swap", "trading" }, - } }, - } }, - }); - } - - /** - * @method - * @name bitfinex1#fetchTransactionFees - * @deprecated - * @description please use fetchDepositWithdrawFees instead - * @see https://docs.bitfinex.com/v1/reference/rest-auth-fees - * @param {string[]|undefined} codes list of unified currency codes - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure} - */ - public async override Task fetchTransactionFees(object codes = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object result = new Dictionary() {}; - object response = await this.privatePostAccountFees(parameters); - // - // { - // "withdraw": { - // "BTC": "0.0004", - // } - // } - // - object fees = this.safeDict(response, "withdraw", new Dictionary() {}); - object ids = new List(((IDictionary)fees).Keys); - for (object i = 0; isLessThan(i, getArrayLength(ids)); postFixIncrement(ref i)) - { - object id = getValue(ids, i); - object code = this.safeCurrencyCode(id); - if (isTrue(isTrue((!isEqual(codes, null))) && !isTrue(this.inArray(code, codes)))) - { - continue; - } - ((IDictionary)result)[(string)code] = new Dictionary() { - { "withdraw", this.safeNumber(fees, id) }, - { "deposit", new Dictionary() {} }, - { "info", this.safeNumber(fees, id) }, - }; - } - return result; - } - - /** - * @method - * @name bitfinex1#fetchDepositWithdrawFees - * @description fetch deposit and withdraw fees - * @see https://docs.bitfinex.com/v1/reference/rest-auth-fees - * @param {string[]|undefined} codes list of unified currency codes - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure} - */ - public async override Task fetchDepositWithdrawFees(object codes = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object response = await this.privatePostAccountFees(parameters); - // - // { - // "withdraw": { - // "BTC": "0.0004", - // ... - // } - // } - // - object withdraw = this.safeList(response, "withdraw"); - return this.parseDepositWithdrawFees(withdraw, codes); - } - - public override object parseDepositWithdrawFee(object fee, object currency = null) - { - // - // '0.0004' - // - return new Dictionary() { - { "withdraw", new Dictionary() { - { "fee", this.parseNumber(fee) }, - { "percentage", null }, - } }, - { "deposit", new Dictionary() { - { "fee", null }, - { "percentage", null }, - } }, - { "networks", new Dictionary() {} }, - { "info", fee }, - }; - } - - /** - * @method - * @name bitfinex1#fetchTradingFees - * @description fetch the trading fees for multiple markets - * @see https://docs.bitfinex.com/v1/reference/rest-auth-summary - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols - */ - public async override Task fetchTradingFees(object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object response = await this.privatePostSummary(parameters); - // - // { - // "time": "2022-02-23T16:05:47.659000Z", - // "status": { resid_hint: null, login_last: "2022-02-23T16:05:48Z" }, - // "is_locked": false, - // "leo_lev": "0", - // "leo_amount_avg": "0.0", - // "trade_vol_30d": [ - // { - // "curr": "Total (USD)", - // "vol": "0.0", - // "vol_safe": "0.0", - // "vol_maker": "0.0", - // "vol_BFX": "0.0", - // "vol_BFX_safe": "0.0", - // "vol_BFX_maker": "0.0" - // } - // ], - // "fees_funding_30d": {}, - // "fees_funding_total_30d": "0", - // "fees_trading_30d": {}, - // "fees_trading_total_30d": "0", - // "rebates_trading_30d": {}, - // "rebates_trading_total_30d": "0", - // "maker_fee": "0.001", - // "taker_fee": "0.002", - // "maker_fee_2crypto": "0.001", - // "maker_fee_2stablecoin": "0.001", - // "maker_fee_2fiat": "0.001", - // "maker_fee_2deriv": "0.0002", - // "taker_fee_2crypto": "0.002", - // "taker_fee_2stablecoin": "0.002", - // "taker_fee_2fiat": "0.002", - // "taker_fee_2deriv": "0.00065", - // "deriv_maker_rebate": "0.0002", - // "deriv_taker_fee": "0.00065", - // "trade_last": null - // } - // - object result = new Dictionary() {}; - object fiat = this.safeDict(this.options, "fiat", new Dictionary() {}); - object makerFee = this.safeNumber(response, "maker_fee"); - object takerFee = this.safeNumber(response, "taker_fee"); - object makerFee2Fiat = this.safeNumber(response, "maker_fee_2fiat"); - object takerFee2Fiat = this.safeNumber(response, "taker_fee_2fiat"); - object makerFee2Deriv = this.safeNumber(response, "maker_fee_2deriv"); - object takerFee2Deriv = this.safeNumber(response, "taker_fee_2deriv"); - for (object i = 0; isLessThan(i, getArrayLength(this.symbols)); postFixIncrement(ref i)) - { - object symbol = getValue(this.symbols, i); - object market = this.market(symbol); - object fee = new Dictionary() { - { "info", response }, - { "symbol", symbol }, - { "percentage", true }, - { "tierBased", true }, - }; - if (isTrue(inOp(fiat, getValue(market, "quote")))) - { - ((IDictionary)fee)["maker"] = makerFee2Fiat; - ((IDictionary)fee)["taker"] = takerFee2Fiat; - } else if (isTrue(getValue(market, "contract"))) - { - ((IDictionary)fee)["maker"] = makerFee2Deriv; - ((IDictionary)fee)["taker"] = takerFee2Deriv; - } else - { - ((IDictionary)fee)["maker"] = makerFee; - ((IDictionary)fee)["taker"] = takerFee; - } - ((IDictionary)result)[(string)symbol] = fee; - } - return result; - } - - /** - * @method - * @name bitfinex1#fetchMarkets - * @description retrieves data on all markets for bitfinex - * @see https://docs.bitfinex.com/v1/reference/rest-public-symbols - * @see https://docs.bitfinex.com/v1/reference/rest-public-symbol-details - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} an array of objects representing market data - */ - public async override Task fetchMarkets(object parameters = null) - { - parameters ??= new Dictionary(); - object idsPromise = this.publicGetSymbols(); - // - // [ "btcusd", "ltcusd", "ltcbtc" ] - // - object detailsPromise = this.publicGetSymbolsDetails(); - // - // [ - // { - // "pair":"btcusd", - // "price_precision":5, - // "initial_margin":"10.0", - // "minimum_margin":"5.0", - // "maximum_order_size":"2000.0", - // "minimum_order_size":"0.0002", - // "expiration":"NA", - // "margin":true - // }, - // ] - // - var idsdetailsVariable = await promiseAll(new List() {idsPromise, detailsPromise}); - var ids = ((IList) idsdetailsVariable)[0]; - var details = ((IList) idsdetailsVariable)[1]; - object result = new List() {}; - for (object i = 0; isLessThan(i, getArrayLength(details)); postFixIncrement(ref i)) - { - object market = getValue(details, i); - object id = this.safeString(market, "pair"); - if (!isTrue(this.inArray(id, ids))) - { - continue; - } - id = ((string)id).ToUpper(); - object baseId = null; - object quoteId = null; - if (isTrue(isGreaterThanOrEqual(getIndexOf(id, ":"), 0))) - { - object parts = ((string)id).Split(new [] {((string)":")}, StringSplitOptions.None).ToList(); - baseId = getValue(parts, 0); - quoteId = getValue(parts, 1); - } else - { - baseId = slice(id, 0, 3); - quoteId = slice(id, 3, 6); - } - object bs = this.safeCurrencyCode(baseId); - object quote = this.safeCurrencyCode(quoteId); - object symbol = add(add(bs, "/"), quote); - object type = "spot"; - if (isTrue(isGreaterThan(getIndexOf(id, "F0"), -1))) - { - type = "swap"; - } - ((IList)result).Add(new Dictionary() { - { "id", id }, - { "symbol", symbol }, - { "base", bs }, - { "quote", quote }, - { "settle", null }, - { "baseId", baseId }, - { "quoteId", quoteId }, - { "settleId", null }, - { "type", type }, - { "spot", (isEqual(type, "spot")) }, - { "margin", this.safeBool(market, "margin") }, - { "swap", (isEqual(type, "swap")) }, - { "future", false }, - { "option", false }, - { "active", true }, - { "contract", (isEqual(type, "swap")) }, - { "linear", null }, - { "inverse", null }, - { "contractSize", null }, - { "expiry", null }, - { "expiryDatetime", null }, - { "strike", null }, - { "optionType", null }, - { "precision", new Dictionary() { - { "amount", parseInt("8") }, - { "price", this.safeInteger(market, "price_precision") }, - } }, - { "limits", new Dictionary() { - { "leverage", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - { "amount", new Dictionary() { - { "min", this.safeNumber(market, "minimum_order_size") }, - { "max", this.safeNumber(market, "maximum_order_size") }, - } }, - { "price", new Dictionary() { - { "min", this.parseNumber("1e-8") }, - { "max", null }, - } }, - { "cost", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - } }, - { "created", null }, - { "info", market }, - }); - } - return result; - } - - public override object amountToPrecision(object symbol, object amount) - { - // https://docs.bitfinex.com/docs/introduction#amount-precision - // The amount field allows up to 8 decimals. - // Anything exceeding this will be rounded to the 8th decimal. - symbol = this.safeSymbol(symbol); - return this.decimalToPrecision(amount, TRUNCATE, getValue(getValue(getValue(this.markets, symbol), "precision"), "amount"), DECIMAL_PLACES); - } - - public override object priceToPrecision(object symbol, object price) - { - symbol = this.safeSymbol(symbol); - price = this.decimalToPrecision(price, ROUND, getValue(getValue(getValue(this.markets, symbol), "precision"), "price"), this.precisionMode); - // https://docs.bitfinex.com/docs/introduction#price-precision - // The precision level of all trading prices is based on significant figures. - // All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345). - // Prices submit with a precision larger than 5 will be cut by the API. - return this.decimalToPrecision(price, TRUNCATE, 8, DECIMAL_PLACES); - } - - /** - * @method - * @name bitfinex1#fetchBalance - * @description query for balance and get the amount of funds available for trading or funds locked in orders - * @see https://docs.bitfinex.com/v1/reference/rest-auth-wallet-balances - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} - */ - public async override Task fetchBalance(object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object accountsByType = this.safeDict(this.options, "accountsByType", new Dictionary() {}); - object requestedType = this.safeString(parameters, "type", "exchange"); - object accountType = this.safeString(accountsByType, requestedType, requestedType); - if (isTrue(isEqual(accountType, null))) - { - object keys = new List(((IDictionary)accountsByType).Keys); - throw new ExchangeError ((string)add(add(this.id, " fetchBalance() type parameter must be one of "), String.Join(", ", ((IList)keys).ToArray()))) ; - } - object query = this.omit(parameters, "type"); - object response = await this.privatePostBalances(query); - // [ { type: "deposit", - // "currency": "btc", - // "amount": "0.00116721", - // "available": "0.00116721" }, - // { type: "exchange", - // "currency": "ust", - // "amount": "0.0000002", - // "available": "0.0000002" }, - // { type: "trading", - // "currency": "btc", - // "amount": "0.0005", - // "available": "0.0005" } ], - object result = new Dictionary() { - { "info", response }, - }; - object isDerivative = isEqual(requestedType, "derivatives"); - for (object i = 0; isLessThan(i, getArrayLength(response)); postFixIncrement(ref i)) - { - object balance = getValue(response, i); - object type = this.safeString(balance, "type"); - object currencyId = this.safeStringLower(balance, "currency", ""); - object start = subtract(((string)currencyId).Length, 2); - object isDerivativeCode = isEqual(slice(currencyId, start, null), "f0"); - // this will only filter the derivative codes if the requestedType is 'derivatives' - object derivativeCondition = (!isTrue(isDerivative) || isTrue(isDerivativeCode)); - if (isTrue(isTrue((isEqual(accountType, type))) && isTrue(derivativeCondition))) - { - object code = this.safeCurrencyCode(currencyId); - // bitfinex had BCH previously, now it's BAB, but the old - // BCH symbol is kept for backward-compatibility - // we need a workaround here so that the old BCH balance - // would not override the new BAB balance (BAB is unified to BCH) - // https://github.com/ccxt/ccxt/issues/4989 - if (!isTrue((inOp(result, code)))) - { - object account = this.account(); - ((IDictionary)account)["free"] = this.safeString(balance, "available"); - ((IDictionary)account)["total"] = this.safeString(balance, "amount"); - ((IDictionary)result)[(string)code] = account; - } - } - } - return this.safeBalance(result); - } - - /** - * @method - * @name bitfinex1#transfer - * @description transfer currency internally between wallets on the same account - * @see https://docs.bitfinex.com/v1/reference/rest-auth-transfer-between-wallets - * @param {string} code unified currency code - * @param {float} amount amount to transfer - * @param {string} fromAccount account to transfer from - * @param {string} toAccount account to transfer to - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure} - */ - public async override Task transfer(object code, object amount, object fromAccount, object toAccount, object parameters = null) - { - // transferring between derivatives wallet and regular wallet is not documented in their API - // however we support it in CCXT (from just looking at web inspector) - parameters ??= new Dictionary(); - await this.loadMarkets(); - object accountsByType = this.safeDict(this.options, "accountsByType", new Dictionary() {}); - object fromId = this.safeString(accountsByType, fromAccount, fromAccount); - object toId = this.safeString(accountsByType, toAccount, toAccount); - object currency = this.currency(code); - object fromCurrencyId = this.convertDerivativesId(getValue(currency, "id"), fromAccount); - object toCurrencyId = this.convertDerivativesId(getValue(currency, "id"), toAccount); - object requestedAmount = this.currencyToPrecision(code, amount); - object request = new Dictionary() { - { "amount", requestedAmount }, - { "currency", fromCurrencyId }, - { "currency_to", toCurrencyId }, - { "walletfrom", fromId }, - { "walletto", toId }, - }; - object response = await this.privatePostTransfer(this.extend(request, parameters)); - // - // [ - // { - // "status": "success", - // "message": "0.0001 Bitcoin transfered from Margin to Exchange" - // } - // ] - // - object result = this.safeValue(response, 0); - object message = this.safeString(result, "message"); - if (isTrue(isEqual(message, null))) - { - throw new ExchangeError ((string)add(this.id, " transfer failed")) ; - } - return this.extend(this.parseTransfer(result, currency), new Dictionary() { - { "fromAccount", fromAccount }, - { "toAccount", toAccount }, - { "amount", this.parseNumber(requestedAmount) }, - }); - } - - public override object parseTransfer(object transfer, object currency = null) - { - // - // { - // "status": "success", - // "message": "0.0001 Bitcoin transfered from Margin to Exchange" - // } - // - return new Dictionary() { - { "info", transfer }, - { "id", null }, - { "timestamp", null }, - { "datetime", null }, - { "currency", this.safeCurrencyCode(null, currency) }, - { "amount", null }, - { "fromAccount", null }, - { "toAccount", null }, - { "status", this.parseTransferStatus(this.safeString(transfer, "status")) }, - }; - } - - public virtual object parseTransferStatus(object status) - { - object statuses = new Dictionary() { - { "SUCCESS", "ok" }, - }; - return this.safeString(statuses, status, status); - } - - public virtual object convertDerivativesId(object currencyId, object type) - { - object start = subtract(getArrayLength(currencyId), 2); - object isDerivativeCode = isEqual(slice(currencyId, start, null), "F0"); - if (isTrue(isTrue((isTrue(isTrue(!isEqual(type, "derivatives")) && isTrue(!isEqual(type, "trading"))) && isTrue(!isEqual(type, "margin")))) && isTrue(isDerivativeCode))) - { - currencyId = slice(currencyId, 0, start); - } else if (isTrue(isTrue(isEqual(type, "derivatives")) && !isTrue(isDerivativeCode))) - { - currencyId = add(currencyId, "F0"); - } - return currencyId; - } - - /** - * @method - * @name bitfinex1#fetchOrderBook - * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://docs.bitfinex.com/v1/reference/rest-public-orderbook - * @param {string} symbol unified symbol of the market to fetch the order book for - * @param {int} [limit] the maximum amount of order book entries to return - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols - */ - public async override Task fetchOrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit_bids"] = limit; - ((IDictionary)request)["limit_asks"] = limit; - } - object response = await this.publicGetBookSymbol(this.extend(request, parameters)); - return this.parseOrderBook(response, getValue(market, "symbol"), null, "bids", "asks", "price", "amount"); - } - - /** - * @method - * @name bitfinex1#fetchTickers - * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market - * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task fetchTickers(object symbols = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - symbols = this.marketSymbols(symbols); - object response = await this.publicGetTickers(parameters); - object result = new Dictionary() {}; - for (object i = 0; isLessThan(i, getArrayLength(response)); postFixIncrement(ref i)) - { - object ticker = this.parseTicker(getValue(response, i)); - object symbol = getValue(ticker, "symbol"); - ((IDictionary)result)[(string)symbol] = ticker; - } - return this.filterByArrayTickers(result, "symbol", symbols); - } - - /** - * @method - * @name bitfinex1#fetchTicker - * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - * @see https://docs.bitfinex.com/v1/reference/rest-public-ticker - * @param {string} symbol unified symbol of the market to fetch the ticker for - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task fetchTicker(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object ticker = await this.publicGetPubtickerSymbol(this.extend(request, parameters)); - // - // { - // mid: '63560.5', - // bid: '63560.0', - // ask: '63561.0', - // last_price: '63547.0', - // low: '62812.0', - // high: '64480.0', - // volume: '517.25634977', - // timestamp: '1715102384.9849467' - // } - // - return this.parseTicker(ticker, market); - } - - public override object parseTicker(object ticker, object market = null) - { - // - // { - // mid: '63560.5', - // bid: '63560.0', - // ask: '63561.0', - // last_price: '63547.0', - // low: '62812.0', - // high: '64480.0', - // volume: '517.25634977', - // timestamp: '1715102384.9849467' - // } - // - object timestamp = this.safeTimestamp(ticker, "timestamp"); - object marketId = this.safeString(ticker, "pair"); - market = this.safeMarket(marketId, market); - object symbol = getValue(market, "symbol"); - object last = this.safeString(ticker, "last_price"); - return this.safeTicker(new Dictionary() { - { "symbol", symbol }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "high", this.safeString(ticker, "high") }, - { "low", this.safeString(ticker, "low") }, - { "bid", this.safeString(ticker, "bid") }, - { "bidVolume", null }, - { "ask", this.safeString(ticker, "ask") }, - { "askVolume", null }, - { "vwap", null }, - { "open", null }, - { "close", last }, - { "last", last }, - { "previousClose", null }, - { "change", null }, - { "percentage", null }, - { "average", this.safeString(ticker, "mid") }, - { "baseVolume", this.safeString(ticker, "volume") }, - { "quoteVolume", null }, - { "info", ticker }, - }, market); - } - - public override object parseTrade(object trade, object market = null) - { - // - // fetchTrades (public) v1 - // - // { - // "timestamp":1637258380, - // "tid":894452833, - // "price":"0.99941", - // "amount":"261.38", - // "exchange":"bitfinex", - // "type":"sell" - // } - // - // fetchMyTrades (private) v1 - // - // { - // "price":"0.99941", - // "amount":"261.38", - // "timestamp":"1637258380.0", - // "type":"Sell", - // "fee_currency":"UST", - // "fee_amount":"-0.52245157", - // "tid":894452833, - // "order_id":78819731373 - // } - // - // { - // "price":"0.99958", - // "amount":"261.90514", - // "timestamp":"1637258238.0", - // "type":"Buy", - // "fee_currency":"UDC", - // "fee_amount":"-0.52381028", - // "tid":894452800, - // "order_id":78819504838 - // } - // - object id = this.safeString(trade, "tid"); - object timestamp = this.safeTimestamp(trade, "timestamp"); - object type = null; - object side = this.safeStringLower(trade, "type"); - object orderId = this.safeString(trade, "order_id"); - object priceString = this.safeString(trade, "price"); - object amountString = this.safeString(trade, "amount"); - object fee = null; - if (isTrue(inOp(trade, "fee_amount"))) - { - object feeCostString = Precise.stringNeg(this.safeString(trade, "fee_amount")); - object feeCurrencyId = this.safeString(trade, "fee_currency"); - object feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId); - fee = new Dictionary() { - { "cost", feeCostString }, - { "currency", feeCurrencyCode }, - }; - } - return this.safeTrade(new Dictionary() { - { "id", id }, - { "info", trade }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "symbol", getValue(market, "symbol") }, - { "type", type }, - { "order", orderId }, - { "side", side }, - { "takerOrMaker", null }, - { "price", priceString }, - { "amount", amountString }, - { "cost", null }, - { "fee", fee }, - }, market); - } - - /** - * @method - * @name bitfinex1#fetchTrades - * @description get the list of most recent trades for a particular symbol - * @see https://docs.bitfinex.com/v1/reference/rest-public-trades - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task fetchTrades(object symbol, object since = null, object limit = null, object parameters = null) - { - limit ??= 50; - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - { "limit_trades", limit }, - }; - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["timestamp"] = this.parseToInt(divide(since, 1000)); - } - object response = await this.publicGetTradesSymbol(this.extend(request, parameters)); - // - // [ - // { - // "timestamp": "1694284565", - // "tid": "1415415034", - // "price": "25862.0", - // "amount": "0.00020685", - // "exchange": "bitfinex", - // "type": "buy" - // }, - // ] - // - return this.parseTrades(response, market, since, limit); - } - - /** - * @method - * @name bitfinex1#fetchMyTrades - * @description fetch all trades made by the user - * @see https://docs.bitfinex.com/v1/reference/rest-auth-past-trades - * @param {string} symbol unified market symbol - * @param {int} [since] the earliest time in ms to fetch trades for - * @param {int} [limit] the maximum number of trades structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} - */ - public async override Task fetchMyTrades(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - if (isTrue(isEqual(symbol, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " fetchMyTrades() requires a symbol argument")) ; - } - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit_trades"] = limit; - } - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["timestamp"] = this.parseToInt(divide(since, 1000)); - } - object response = await this.privatePostMytrades(this.extend(request, parameters)); - return this.parseTrades(response, market, since, limit); - } - - /** - * @method - * @name bitfinex1#createOrder - * @description create a trade order - * @see https://docs.bitfinex.com/v1/reference/rest-auth-new-order - * @param {string} symbol unified symbol of the market to create an order in - * @param {string} type 'market' or 'limit' - * @param {string} side 'buy' or 'sell' - * @param {float} amount how much of currency you want to trade in units of base currency - * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task createOrder(object symbol, object type, object side, object amount, object price = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object postOnly = this.safeBool(parameters, "postOnly", false); - type = ((string)type).ToLower(); - parameters = this.omit(parameters, new List() {"postOnly"}); - if (isTrue(getValue(market, "spot"))) - { - // although they claim that type needs to be 'exchange limit' or 'exchange market' - // in fact that's not the case for swap markets - type = this.safeStringLower(getValue(this.options, "orderTypes"), type, type); - } - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - { "side", side }, - { "amount", this.amountToPrecision(symbol, amount) }, - { "type", type }, - { "ocoorder", false }, - { "buy_price_oco", 0 }, - { "sell_price_oco", 0 }, - }; - if (isTrue(isGreaterThan(getIndexOf(type, "market"), -1))) - { - ((IDictionary)request)["price"] = ((object)this.nonce()).ToString(); - } else - { - ((IDictionary)request)["price"] = this.priceToPrecision(symbol, price); - } - if (isTrue(postOnly)) - { - ((IDictionary)request)["is_postonly"] = true; - } - object response = await this.privatePostOrderNew(this.extend(request, parameters)); - return this.parseOrder(response, market); - } - - public async override Task editOrder(object id, object symbol, object type, object side, object amount = null, object price = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object order = new Dictionary() { - { "order_id", parseInt(id) }, - }; - if (isTrue(!isEqual(price, null))) - { - ((IDictionary)order)["price"] = this.priceToPrecision(symbol, price); - } - if (isTrue(!isEqual(amount, null))) - { - ((IDictionary)order)["amount"] = this.numberToString(amount); - } - if (isTrue(!isEqual(symbol, null))) - { - ((IDictionary)order)["symbol"] = this.marketId(symbol); - } - if (isTrue(!isEqual(side, null))) - { - ((IDictionary)order)["side"] = side; - } - if (isTrue(!isEqual(type, null))) - { - ((IDictionary)order)["type"] = this.safeString(getValue(this.options, "orderTypes"), type, type); - } - object response = await this.privatePostOrderCancelReplace(this.extend(order, parameters)); - return this.parseOrder(response); - } - - /** - * @method - * @name bitfinex1#cancelOrder - * @description cancels an open order - * @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-order - * @param {string} id order id - * @param {string} symbol not used by bitfinex cancelOrder () - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task cancelOrder(object id, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() { - { "order_id", parseInt(id) }, - }; - object response = await this.privatePostOrderCancel(this.extend(request, parameters)); - // - // { - // id: '161236928925', - // cid: '1720172026812', - // cid_date: '2024-07-05', - // gid: null, - // symbol: 'adaust', - // exchange: 'bitfinex', - // price: '0.33', - // avg_execution_price: '0.0', - // side: 'buy', - // type: 'exchange limit', - // timestamp: '1720172026.813', - // is_live: true, - // is_cancelled: false, - // is_hidden: false, - // oco_order: null, - // was_forced: false, - // original_amount: '10.0', - // remaining_amount: '10.0', - // executed_amount: '0.0', - // src: 'api', - // meta: {} - // } - // - return this.parseOrder(response); - } - - /** - * @method - * @name bitfinex1#cancelAllOrders - * @description cancel all open orders - * @see https://docs.bitfinex.com/v1/reference/rest-auth-cancel-all-orders - * @param {string} symbol not used by bitfinex cancelAllOrders - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} response from exchange - */ - public async override Task cancelAllOrders(object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - object response = await this.privatePostOrderCancelAll(parameters); - // - // { result: 'Submitting 1 order cancellations.' } - // - return new List {this.safeOrder(new Dictionary() { - { "info", response }, -})}; - } - - public override object parseOrder(object order, object market = null) - { - // - // { - // "id": 57334010955, - // "cid": 1611584840966, - // "cid_date": null, - // "gid": null, - // "symbol": "ltcbtc", - // "exchange": null, - // "price": "0.0042125", - // "avg_execution_price": "0.0042097", - // "side": "sell", - // "type": "exchange market", - // "timestamp": "1611584841.0", - // "is_live": false, - // "is_cancelled": false, - // "is_hidden": 0, - // "oco_order": 0, - // "was_forced": false, - // "original_amount": "0.205176", - // "remaining_amount": "0.0", - // "executed_amount": "0.205176", - // "src": "web" - // } - // - object side = this.safeString(order, "side"); - object open = this.safeBool(order, "is_live"); - object canceled = this.safeBool(order, "is_cancelled"); - object status = null; - if (isTrue(open)) - { - status = "open"; - } else if (isTrue(canceled)) - { - status = "canceled"; - } else - { - status = "closed"; - } - object marketId = this.safeStringUpper(order, "symbol"); - object symbol = this.safeSymbol(marketId, market); - object orderType = this.safeString(order, "type", ""); - object exchange = isGreaterThanOrEqual(getIndexOf(orderType, "exchange "), 0); - if (isTrue(exchange)) - { - object parts = ((string)getValue(order, "type")).Split(new [] {((string)" ")}, StringSplitOptions.None).ToList(); - orderType = getValue(parts, 1); - } - object timestamp = this.safeTimestamp(order, "timestamp"); - object id = this.safeString(order, "id"); - return this.safeOrder(new Dictionary() { - { "info", order }, - { "id", id }, - { "clientOrderId", null }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "lastTradeTimestamp", null }, - { "symbol", symbol }, - { "type", orderType }, - { "timeInForce", null }, - { "postOnly", null }, - { "side", side }, - { "price", this.safeString(order, "price") }, - { "triggerPrice", null }, - { "average", this.safeString(order, "avg_execution_price") }, - { "amount", this.safeString(order, "original_amount") }, - { "remaining", this.safeString(order, "remaining_amount") }, - { "filled", this.safeString(order, "executed_amount") }, - { "status", status }, - { "fee", null }, - { "cost", null }, - { "trades", null }, - }, market); - } - - /** - * @method - * @name bitfinex1#fetchOpenOrders - * @description fetch all unfilled currently open orders - * @see https://docs.bitfinex.com/v1/reference/rest-auth-active-orders - * @param {string} symbol unified market symbol - * @param {int} [since] the earliest time in ms to fetch open orders for - * @param {int} [limit] the maximum number of open orders structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task fetchOpenOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - if (isTrue(!isEqual(symbol, null))) - { - if (!isTrue((inOp(this.markets, symbol)))) - { - throw new ExchangeError ((string)add(add(this.id, " has no symbol "), symbol)) ; - } - } - object response = await this.privatePostOrders(parameters); - object orders = this.parseOrders(response, null, since, limit); - if (isTrue(!isEqual(symbol, null))) - { - orders = this.filterBy(orders, "symbol", symbol); - } - return orders; - } - - /** - * @method - * @name bitfinex1#fetchClosedOrders - * @description fetches information on multiple closed orders made by the user - * @see https://docs.bitfinex.com/v1/reference/rest-auth-orders-history - * @param {string} symbol unified market symbol of the market orders were made in - * @param {int} [since] the earliest time in ms to fetch orders for - * @param {int} [limit] the maximum number of order structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Order[]} a list 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) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - symbol = this.symbol(symbol); - object request = new Dictionary() {}; - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit"] = limit; - } - object response = await this.privatePostOrdersHist(this.extend(request, parameters)); - object orders = this.parseOrders(response, null, since, limit); - if (isTrue(!isEqual(symbol, null))) - { - orders = this.filterBy(orders, "symbol", symbol); - } - orders = this.filterByArray(orders, "status", new List() {"closed", "canceled"}, false); - return orders; - } - - /** - * @method - * @name bitfinex1#fetchOrder - * @description fetches information on an order made by the user - * @see https://docs.bitfinex.com/v1/reference/rest-auth-order-status - * @param {string} id the order id - * @param {string} symbol not used by bitfinex fetchOrder - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task fetchOrder(object id, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() { - { "order_id", parseInt(id) }, - }; - object response = await this.privatePostOrderStatus(this.extend(request, parameters)); - return this.parseOrder(response); - } - - public override object parseOHLCV(object ohlcv, object market = null) - { - // - // [ - // 1457539800000, - // 0.02594, - // 0.02594, - // 0.02594, - // 0.02594, - // 0.1 - // ] - // - return new List {this.safeInteger(ohlcv, 0), this.safeNumber(ohlcv, 1), this.safeNumber(ohlcv, 3), this.safeNumber(ohlcv, 4), this.safeNumber(ohlcv, 2), this.safeNumber(ohlcv, 5)}; - } - - /** - * @method - * @name bitfinex1#fetchOHLCV - * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market - * @see https://docs.bitfinex.com/reference/rest-public-candles#aggregate-funding-currency-candles - * @param {string} symbol unified symbol of the market to fetch OHLCV data for - * @param {string} timeframe the length of time each candle represents - * @param {int} [since] timestamp in ms of the earliest candle to fetch - * @param {int} [limit] the maximum amount of candles to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {int} [params.until] timestamp in ms of the latest candle to fetch - * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume - */ - public async override Task fetchOHLCV(object symbol, object timeframe = null, object since = null, object limit = null, object parameters = null) - { - timeframe ??= "1m"; - parameters ??= new Dictionary(); - await this.loadMarkets(); - if (isTrue(isEqual(limit, null))) - { - limit = 100; - } else - { - limit = mathMin(limit, 10000); - } - object market = this.market(symbol); - object v2id = add("t", getValue(market, "id")); - object request = new Dictionary() { - { "symbol", v2id }, - { "timeframe", this.safeString(this.timeframes, timeframe, timeframe) }, - { "sort", 1 }, - { "limit", limit }, - }; - object until = this.safeInteger(parameters, "until"); - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["start"] = since; - } else if (isTrue(!isEqual(until, null))) - { - object duration = this.parseTimeframe(timeframe); - ((IDictionary)request)["start"] = subtract(until, (multiply(multiply((subtract(limit, 1)), duration), 1000))); - } - if (isTrue(!isEqual(until, null))) - { - ((IDictionary)request)["end"] = until; - } - parameters = this.omit(parameters, "until"); - object response = await this.v2GetCandlesTradeTimeframeSymbolHist(this.extend(request, parameters)); - // - // [ - // [1457539800000,0.02594,0.02594,0.02594,0.02594,0.1], - // [1457547300000,0.02577,0.02577,0.02577,0.02577,0.01], - // [1457550240000,0.0255,0.0253,0.0255,0.0252,3.2640000000000002], - // ] - // - return this.parseOHLCVs(response, market, timeframe, since, limit); - } - - public virtual object getCurrencyName(object code) - { - // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method - if (isTrue(inOp(getValue(this.options, "currencyNames"), code))) - { - return getValue(getValue(this.options, "currencyNames"), code); - } - throw new NotSupported ((string)add(add(add(this.id, " "), code), " not supported for withdrawal")) ; - } - - /** - * @method - * @name bitfinex1#createDepositAddress - * @description create a currency deposit address - * @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit - * @param {string} code unified currency code of the currency for the deposit address - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} - */ - public async override Task createDepositAddress(object code, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() { - { "renew", 1 }, - }; - return await this.fetchDepositAddress(code, this.extend(request, parameters)); - } - - /** - * @method - * @name bitfinex1#fetchDepositAddress - * @description fetch the deposit address for a currency associated with this account - * @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit - * @param {string} code unified currency code - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} - */ - public async override Task fetchDepositAddress(object code, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method - object name = this.getCurrencyName(code); - object request = new Dictionary() { - { "method", name }, - { "wallet_name", "exchange" }, - { "renew", 0 }, - }; - object response = await this.privatePostDepositNew(this.extend(request, parameters)); - object address = this.safeValue(response, "address"); - object tag = null; - if (isTrue(inOp(response, "address_pool"))) - { - tag = address; - address = getValue(response, "address_pool"); - } - this.checkAddress(address); - return new Dictionary() { - { "currency", code }, - { "address", address }, - { "tag", tag }, - { "network", null }, - { "info", response }, - }; - } - - /** - * @method - * @name bitfinex1#fetchDepositsWithdrawals - * @description fetch history of deposits and withdrawals - * @see https://docs.bitfinex.com/v1/reference/rest-auth-deposit-withdrawal-history - * @param {string} code unified currency code for the currency of the deposit/withdrawals - * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined - * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure} - */ - public async override Task fetchDepositsWithdrawals(object code = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object currencyId = this.safeString(parameters, "currency"); - object query = this.omit(parameters, "currency"); - object currency = null; - if (isTrue(isEqual(currencyId, null))) - { - if (isTrue(isEqual(code, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " fetchDepositsWithdrawals() requires a currency `code` argument or a `currency` parameter")) ; - } else - { - currency = this.currency(code); - currencyId = getValue(currency, "id"); - } - } - ((IDictionary)query)["currency"] = currencyId; - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)query)["since"] = this.parseToInt(divide(since, 1000)); - } - object response = await this.privatePostHistoryMovements(this.extend(query, parameters)); - // - // [ - // { - // "id": 581183, - // "txid": 123456, - // "currency": "BTC", - // "method": "BITCOIN", - // "type": "WITHDRAWAL", - // "amount": ".01", - // "description": "3QXYWgRGX2BPYBpUDBssGbeWEa5zq6snBZ, offchain transfer ", - // "address": "3QXYWgRGX2BPYBpUDBssGbeWEa5zq6snBZ", - // "status": "COMPLETED", - // "timestamp": "1443833327.0", - // "timestamp_created": "1443833327.1", - // "fee": 0.1, - // } - // ] - // - return this.parseTransactions(response, currency, since, limit); - } - - public override object parseTransaction(object transaction, object currency = null) - { - // - // crypto - // - // { - // "id": 12042490, - // "fee": "-0.02", - // "txid": "EA5B5A66000B66855865EFF2494D7C8D1921FCBE996482157EBD749F2C85E13D", - // "type": "DEPOSIT", - // "amount": "2099.849999", - // "method": "RIPPLE", - // "status": "COMPLETED", - // "address": "2505189261", - // "currency": "XRP", - // "timestamp": "1551730524.0", - // "description": "EA5B5A66000B66855865EFF2494D7C8D1921FCBE996482157EBD749F2C85E13D", - // "timestamp_created": "1551730523.0" - // } - // - // fiat - // - // { - // "id": 12725095, - // "fee": "-60.0", - // "txid": null, - // "type": "WITHDRAWAL", - // "amount": "9943.0", - // "method": "WIRE", - // "status": "SENDING", - // "address": null, - // "currency": "EUR", - // "timestamp": "1561802484.0", - // "description": "Name: bob, AccountAddress: some address, Account: someaccountno, Bank: bank address, SWIFT: foo, Country: UK, Details of Payment: withdrawal name, Intermediary Bank Name: , Intermediary Bank Address: , Intermediary Bank City: , Intermediary Bank Country: , Intermediary Bank Account: , Intermediary Bank SWIFT: , Fee: -60.0", - // "timestamp_created": "1561716066.0" - // } - // - // withdraw - // - // { - // "status": "success", - // "message": "Your withdrawal request has been successfully submitted.", - // "withdrawal_id": 586829 - // } - // - object timestamp = this.safeTimestamp(transaction, "timestamp_created"); - object currencyId = this.safeString(transaction, "currency"); - object code = this.safeCurrencyCode(currencyId, currency); - object feeCost = this.safeString(transaction, "fee"); - if (isTrue(!isEqual(feeCost, null))) - { - feeCost = Precise.stringAbs(feeCost); - } - return new Dictionary() { - { "info", transaction }, - { "id", this.safeString2(transaction, "id", "withdrawal_id") }, - { "txid", this.safeString(transaction, "txid") }, - { "type", this.safeStringLower(transaction, "type") }, - { "currency", code }, - { "network", null }, - { "amount", this.safeNumber(transaction, "amount") }, - { "status", this.parseTransactionStatus(this.safeString(transaction, "status")) }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "address", this.safeString(transaction, "address") }, - { "addressFrom", null }, - { "addressTo", null }, - { "tag", this.safeString(transaction, "description") }, - { "tagFrom", null }, - { "tagTo", null }, - { "updated", this.safeTimestamp(transaction, "timestamp") }, - { "comment", null }, - { "internal", null }, - { "fee", new Dictionary() { - { "currency", code }, - { "cost", this.parseNumber(feeCost) }, - { "rate", null }, - } }, - }; - } - - public virtual object parseTransactionStatus(object status) - { - object statuses = new Dictionary() { - { "SENDING", "pending" }, - { "CANCELED", "canceled" }, - { "ZEROCONFIRMED", "failed" }, - { "COMPLETED", "ok" }, - }; - return this.safeString(statuses, status, status); - } - - /** - * @method - * @name bitfinex1#withdraw - * @description make a withdrawal - * @see https://docs.bitfinex.com/v1/reference/rest-auth-withdrawal - * @param {string} code unified currency code - * @param {float} amount the amount to withdraw - * @param {string} address the address to withdraw to - * @param {string} tag - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @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) - { - parameters ??= new Dictionary(); - var tagparametersVariable = this.handleWithdrawTagAndParams(tag, parameters); - tag = ((IList)tagparametersVariable)[0]; - parameters = ((IList)tagparametersVariable)[1]; - this.checkAddress(address); - await this.loadMarkets(); - // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method - object name = this.getCurrencyName(code); - object currency = this.currency(code); - object request = new Dictionary() { - { "withdraw_type", name }, - { "walletselected", "exchange" }, - { "amount", this.numberToString(amount) }, - { "address", address }, - }; - if (isTrue(!isEqual(tag, null))) - { - ((IDictionary)request)["payment_id"] = tag; - } - object responses = await this.privatePostWithdraw(this.extend(request, parameters)); - // - // [ - // { - // "status":"success", - // "message":"Your withdrawal request has been successfully submitted.", - // "withdrawal_id":586829 - // } - // ] - // - object response = this.safeDict(responses, 0, new Dictionary() {}); - object id = this.safeInteger(response, "withdrawal_id"); - object message = this.safeString(response, "message"); - object errorMessage = this.findBroadlyMatchedKey(getValue(this.exceptions, "broad"), message); - if (isTrue(isEqual(id, 0))) - { - if (isTrue(!isEqual(errorMessage, null))) - { - object ExceptionClass = getValue(getValue(this.exceptions, "broad"), errorMessage); - throwDynamicException(ExceptionClass, add(add(this.id, " "), message));return null; - } - throw new ExchangeError ((string)add(add(this.id, " withdraw returned an id of zero: "), this.json(response))) ; - } - return this.parseTransaction(response, currency); - } - - /** - * @method - * @name bitfinex1#fetchPositions - * @description fetch all open positions - * @see https://docs.bitfinex.com/v1/reference/rest-auth-active-positions - * @param {string[]|undefined} symbols list of unified market symbols - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} - */ - public async override Task fetchPositions(object symbols = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object response = await this.privatePostPositions(parameters); - // - // [ - // { - // "id":943715, - // "symbol":"btcusd", - // "status":"ACTIVE", - // "base":"246.94", - // "amount":"1.0", - // "timestamp":"1444141857.0", - // "swap":"0.0", - // "pl":"-2.22042" - // } - // ] - // - // todo unify parsePosition/parsePositions - return response; - } - - public override object nonce() - { - return this.microseconds(); - } - - public override object sign(object path, object api = null, object method = null, object parameters = null, object headers = null, object body = null) - { - api ??= "public"; - method ??= "GET"; - parameters ??= new Dictionary(); - object request = add("/", this.implodeParams(path, parameters)); - if (isTrue(isEqual(api, "v2"))) - { - request = add(add("/", api), request); - } else - { - request = add(add("/", this.version), request); - } - object query = this.omit(parameters, this.extractParams(path)); - object url = add(getValue(getValue(this.urls, "api"), api), request); - if (isTrue(isTrue((isEqual(api, "public"))) || isTrue((isGreaterThanOrEqual(getIndexOf(path, "/hist"), 0))))) - { - if (isTrue(getArrayLength(new List(((IDictionary)query).Keys)))) - { - object suffix = add("?", this.urlencode(query)); - url = add(url, suffix); - request = add(request, suffix); - } - } - if (isTrue(isEqual(api, "private"))) - { - this.checkRequiredCredentials(); - object nonce = this.nonce(); - query = this.extend(new Dictionary() { - { "nonce", ((object)nonce).ToString() }, - { "request", request }, - }, query); - body = this.json(query); - object payload = this.stringToBase64(body); - object secret = this.encode(this.secret); - object signature = this.hmac(this.encode(payload), secret, sha384); - headers = new Dictionary() { - { "X-BFX-APIKEY", this.apiKey }, - { "X-BFX-PAYLOAD", payload }, - { "X-BFX-SIGNATURE", signature }, - { "Content-Type", "application/json" }, - }; - } - return new Dictionary() { - { "url", url }, - { "method", method }, - { "body", body }, - { "headers", headers }, - }; - } - - public override object handleErrors(object code, object reason, object url, object method, object headers, object body, object response, object requestHeaders, object requestBody) - { - if (isTrue(isEqual(response, null))) - { - return null; - } - object throwError = false; - if (isTrue(isGreaterThanOrEqual(code, 400))) - { - if (isTrue(isEqual(getValue(body, 0), "{"))) - { - throwError = true; - } - } else - { - // json response with error, i.e: - // [{"status":"error","message":"Momentary balance check. Please wait few seconds and try the transfer again."}] - object responseObject = this.safeDict(response, 0, new Dictionary() {}); - object status = this.safeString(responseObject, "status", ""); - if (isTrue(isEqual(status, "error"))) - { - throwError = true; - } - } - if (isTrue(throwError)) - { - object feedback = add(add(this.id, " "), body); - object message = this.safeString2(response, "message", "error"); - this.throwExactlyMatchedException(getValue(this.exceptions, "exact"), message, feedback); - this.throwBroadlyMatchedException(getValue(this.exceptions, "broad"), message, feedback); - throw new ExchangeError ((string)feedback) ; - } - return null; - } -} diff --git a/cs/ccxt/exchanges/bitget.cs b/cs/ccxt/exchanges/bitget.cs index 1101e05398a0d..73c17168c3998 100644 --- a/cs/ccxt/exchanges/bitget.cs +++ b/cs/ccxt/exchanges/bitget.cs @@ -1966,7 +1966,7 @@ public async virtual Task fetchDefaultMarkets(object parameters) { "cross", hasCrossMargin }, { "isolated", hasIsolatedMargin }, }; - isMarginTradingAllowed = isTrue(hasCrossMargin) || isTrue(hasCrossMargin); + isMarginTradingAllowed = isTrue(hasCrossMargin) || isTrue(hasIsolatedMargin); } else { if (isTrue(isEqual(symbolType, "perpetual"))) @@ -4387,82 +4387,35 @@ public override object parseOrder(object order, object market = null) // "result": "success" // } // - // spot: fetchOrder - // - // { - // "userId": "7264631750", - // "symbol": "BTCUSDT", - // "orderId": "1111461743123927040", - // "clientOid": "63f95110-93b5-4309-8f77-46339f1bcf3c", - // "price": "25000.0000000000000000", - // "size": "0.0002000000000000", - // "orderType": "limit", - // "side": "buy", - // "status": "live", - // "priceAvg": "0", - // "baseVolume": "0.0000000000000000", - // "quoteVolume": "0.0000000000000000", - // "enterPointSource": "API", - // "feeDetail": "", - // "orderSource": "normal", - // "cTime": "1700719050198", - // "uTime": "1700719050198" - // } - // - // swap and future: fetchOrder - // - // { - // "symbol": "BTCUSDT", - // "size": "0.001", - // "orderId": "1111465253393825792", - // "clientOid": "1111465253431574529", - // "baseVolume": "0", - // "fee": "0", - // "price": "27000", - // "priceAvg": "", - // "state": "live", - // "side": "buy", - // "force": "gtc", - // "totalProfits": "0", - // "posSide": "long", - // "marginCoin": "USDT", - // "presetStopSurplusPrice": "", - // "presetStopLossPrice": "", - // "quoteVolume": "0", - // "orderType": "limit", - // "leverage": "20", - // "marginMode": "crossed", - // "reduceOnly": "NO", - // "enterPointSource": "API", - // "tradeSide": "open", - // "posMode": "hedge_mode", - // "orderSource": "normal", - // "cTime": "1700719887120", - // "uTime": "1700719887120" - // } - // - // spot: fetchOpenOrders + // spot: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders // // { // "userId": "7264631750", // "symbol": "BTCUSDT", // "orderId": "1111499608327360513", // "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6", - // "priceAvg": "25000.0000000000000000", - // "size": "0.0002000000000000", + // "size": "0.0002000000000000", // COST for 'buy market' order! AMOUNT in all other cases + // "price": "0", // in fetchOrder: 0 for market order, otherwise limit price (field not present in fetchOpenOrders // "orderType": "limit", // "side": "buy", // "status": "live", // "basePrice": "0", - // "baseVolume": "0.0000000000000000", - // "quoteVolume": "0.0000000000000000", + // "priceAvg": "25000.0000000000000000", // 0 if nothing filled + // "baseVolume": "0.0000000000000000", // 0 if nothing filled + // "quoteVolume": "0.0000000000000000", // 0 if nothing filled // "enterPointSource": "WEB", // "orderSource": "normal", // "cTime": "1700728077966", // "uTime": "1700728077966" + // "feeDetail": "{\\"newFees\\":{\\"c\\":0,\\"d\\":0,\\"deduction\\":false,\\"r\\":-0.0064699886,\\"t\\":-0.0064699886,\\"totalDeductionFee\\":0},\\"USDT\\":{\\"deduction\\":false,\\"feeCoinCode\\":\\"USDT\\",\\"totalDeductionFee\\":0,\\"totalFee\\":-0.0064699886000000}}", // might not be present in fetchOpenOrders + // "triggerPrice": null, + // "tpslType": "normal", + // "quoteCoin": "USDT", // not present in fetchOpenOrders + // "baseCoin": "DOT", // not present in fetchOpenOrders + // "cancelReason": "", // not present in fetchOpenOrders // } // - // spot stop: fetchOpenOrders, fetchCanceledAndClosedOrders + // spot trigger: fetchOpenOrders, fetchCanceledAndClosedOrders // // { // "orderId": "1111503385931620352", @@ -4503,18 +4456,19 @@ public override object parseOrder(object order, object market = null) // "uTime": "1700729691866" // } // - // swap: fetchOpenOrders, fetchCanceledAndClosedOrders + // swap and future: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders // // { // "symbol": "BTCUSDT", - // "size": "0.002", - // "orderId": "1111488897767604224", - // "clientOid": "1111488897805352960", + // "size": "0.001", + // "orderId": "1111465253393825792", + // "clientOid": "1111465253431574529", // "baseVolume": "0", // "fee": "0", - // "price": "25000", + // "price": "27000", // "priceAvg": "", - // "status": "live", + // "state": "live", + // // "status": "live", // key for fetchOpenOrders, fetchClosedOrders // "side": "buy", // "force": "gtc", // "totalProfits": "0", @@ -4523,7 +4477,7 @@ public override object parseOrder(object order, object market = null) // "quoteVolume": "0", // "leverage": "20", // "marginMode": "crossed", - // "enterPointSource": "web", + // "enterPointSource": "API", // "tradeSide": "open", // "posMode": "hedge_mode", // "orderType": "limit", @@ -4531,94 +4485,22 @@ public override object parseOrder(object order, object market = null) // "presetStopSurplusPrice": "", // "presetStopLossPrice": "", // "reduceOnly": "NO", - // "cTime": "1700725524378", - // "uTime": "1700725524378" - // } + // "cTime": "1700719887120", + // "uTime": "1700719887120" // - // swap stop: fetchOpenOrders + // for swap trigger order, the additional below fields are present: // - // { // "planType": "normal_plan", - // "symbol": "BTCUSDT", - // "size": "0.001", - // "orderId": "1111491399869075457", - // "clientOid": "1111491399869075456", - // "price": "27000", // "callbackRatio": "", // "triggerPrice": "24000", // "triggerType": "mark_price", // "planStatus": "live", - // "side": "buy", - // "posSide": "long", - // "marginCoin": "USDT", - // "marginMode": "crossed", - // "enterPointSource": "API", - // "tradeSide": "open", - // "posMode": "hedge_mode", - // "orderType": "limit", - // "stopSurplusTriggerPrice": "", - // "stopSurplusExecutePrice": "", - // "stopSurplusTriggerType": "fill_price", - // "stopLossTriggerPrice": "", - // "stopLossExecutePrice": "", - // "stopLossTriggerType": "fill_price", - // "cTime": "1700726120917", - // "uTime": "1700726120917" - // } - // - // spot: fetchCanceledAndClosedOrders - // - // { - // "userId": "7264631750", - // "symbol": "BTCUSDT", - // "orderId": "1111499608327360513", - // "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6", - // "price": "25000.0000000000000000", - // "size": "0.0002000000000000", - // "orderType": "limit", - // "side": "buy", - // "status": "cancelled", - // "priceAvg": "0", - // "baseVolume": "0.0000000000000000", - // "quoteVolume": "0.0000000000000000", - // "enterPointSource": "WEB", - // "feeDetail": "", - // "orderSource": "normal", - // "cTime": "1700728077966", - // "uTime": "1700728911471" - // } - // - // swap stop: fetchCanceledAndClosedOrders - // - // { - // "planType": "normal_plan", - // "symbol": "BTCUSDT", - // "size": "0.001", - // "orderId": "1111491399869075457", - // "clientOid": "1111491399869075456", - // "planStatus": "cancelled", - // "price": "27000", - // "feeDetail": null, - // "baseVolume": "0", - // "callbackRatio": "", - // "triggerPrice": "24000", - // "triggerType": "mark_price", - // "side": "buy", - // "posSide": "long", - // "marginCoin": "USDT", - // "marginMode": "crossed", - // "enterPointSource": "API", - // "tradeSide": "open", - // "posMode": "hedge_mode", - // "orderType": "limit", // "stopSurplusTriggerPrice": "", // "stopSurplusExecutePrice": "", // "stopSurplusTriggerType": "fill_price", // "stopLossTriggerPrice": "", // "stopLossExecutePrice": "", // "stopLossTriggerType": "fill_price", - // "cTime": "1700726120917", - // "uTime": "1700727879652" // } // object errorMessage = this.safeString(order, "errorMsg"); @@ -4718,6 +4600,13 @@ public override object parseOrder(object order, object market = null) { side = ((bool) isTrue((isEqual(side, "buy")))) ? "sell" : "buy"; } + object orderType = this.safeString(order, "orderType"); + object isBuyMarket = isTrue((isEqual(side, "buy"))) && isTrue((isEqual(orderType, "market"))); + if (isTrue(isTrue(getValue(market, "spot")) && isTrue(isBuyMarket))) + { + // as noted in top comment, for 'buy market' the 'size' field is COST, not AMOUNT + size = this.safeString(order, "baseVolume"); + } return this.safeOrder(new Dictionary() { { "info", order }, { "id", this.safeString2(order, "orderId", "data") }, @@ -4727,7 +4616,7 @@ public override object parseOrder(object order, object market = null) { "lastTradeTimestamp", updateTimestamp }, { "lastUpdateTimestamp", updateTimestamp }, { "symbol", getValue(market, "symbol") }, - { "type", this.safeString(order, "orderType") }, + { "type", orderType }, { "side", side }, { "price", price }, { "amount", size }, diff --git a/cs/ccxt/exchanges/bitmart.cs b/cs/ccxt/exchanges/bitmart.cs index 748c1210c7f12..6b761984c0c06 100644 --- a/cs/ccxt/exchanges/bitmart.cs +++ b/cs/ccxt/exchanges/bitmart.cs @@ -3218,7 +3218,9 @@ public async override Task cancelOrder(object id, object symbol = null, // if (isTrue(getValue(market, "swap"))) { - return response; + return this.safeOrder(new Dictionary() { + { "info", response }, + }); } object data = this.safeValue(response, "data"); if (isTrue(isEqual(data, true))) @@ -3383,7 +3385,9 @@ public async override Task cancelAllOrders(object symbol = null, object // "trace": "7f9c94e10f9d4513bc08a7bfc2a5559a.70.16954131323145323" // } // - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } public async virtual Task fetchOrdersByStatus(object status, object symbol = null, object since = null, object limit = null, object parameters = null) diff --git a/cs/ccxt/exchanges/bitmex.cs b/cs/ccxt/exchanges/bitmex.cs index 1ae7f2c1ee654..a05597b5761f8 100644 --- a/cs/ccxt/exchanges/bitmex.cs +++ b/cs/ccxt/exchanges/bitmex.cs @@ -2103,7 +2103,7 @@ public async override Task fetchTrades(object symbol, object since = nul * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {object} [params.triggerPrice] the price at which a trigger order is triggered at - * @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'above' or 'below' + * @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'ascending' or 'descending' * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure} */ @@ -2138,7 +2138,7 @@ public async override Task createOrder(object symbol, object type, objec if (isTrue(isTrue(isTriggerOrder) || isTrue(isTrailingAmountOrder))) { object triggerDirection = this.safeString(parameters, "triggerDirection"); - object triggerAbove = (isEqual(triggerDirection, "above")); + object triggerAbove = (isTrue((isEqual(triggerDirection, "ascending"))) || isTrue((isEqual(triggerDirection, "above")))); if (isTrue(isTrue((isEqual(type, "limit"))) || isTrue((isEqual(type, "market"))))) { this.checkRequiredArgument("createOrder", triggerDirection, "triggerDirection", new List() {"above", "below"}); @@ -2207,7 +2207,7 @@ public async override Task editOrder(object id, object symbol, object ty if (isTrue(isTrailingAmountOrder)) { object triggerDirection = this.safeString(parameters, "triggerDirection"); - object triggerAbove = (isEqual(triggerDirection, "above")); + object triggerAbove = (isTrue((isEqual(triggerDirection, "ascending"))) || isTrue((isEqual(triggerDirection, "above")))); if (isTrue(isTrue((isEqual(type, "limit"))) || isTrue((isEqual(type, "market"))))) { this.checkRequiredArgument("createOrder", triggerDirection, "triggerDirection", new List() {"above", "below"}); diff --git a/cs/ccxt/exchanges/bitpanda.cs b/cs/ccxt/exchanges/bitpanda.cs deleted file mode 100644 index 188e7b14931b0..0000000000000 --- a/cs/ccxt/exchanges/bitpanda.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace ccxt; - -// 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 bitpanda : onetrading -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "id", "bitpanda" }, - { "alias", true }, - }); - } -} diff --git a/cs/ccxt/exchanges/bitrue.cs b/cs/ccxt/exchanges/bitrue.cs index 4f1767da047d9..21094b1feb8dc 100644 --- a/cs/ccxt/exchanges/bitrue.cs +++ b/cs/ccxt/exchanges/bitrue.cs @@ -318,7 +318,9 @@ public override object describe() } }, { "options", new Dictionary() { { "createMarketBuyOrderRequiresPrice", true }, - { "fetchMarkets", new List() {"spot", "linear", "inverse"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"spot", "linear", "inverse"} }, + } }, { "fetchMyTradesMethod", "v2PrivateGetMyTrades" }, { "hasAlreadyAuthenticatedSuccessfully", false }, { "currencyToPrecisionRoundingMode", TRUNCATE }, @@ -783,10 +785,20 @@ public async override Task fetchMarkets(object parameters = null) { parameters ??= new Dictionary(); object promisesRaw = new List() {}; - object fetchMarkets = this.safeValue(this.options, "fetchMarkets", new List() {"spot", "linear", "inverse"}); - for (object i = 0; isLessThan(i, getArrayLength(fetchMarkets)); postFixIncrement(ref i)) + object types = null; + object defaultTypes = new List() {"spot", "linear", "inverse"}; + object fetchMarketsOptions = this.safeDict(this.options, "fetchMarkets"); + if (isTrue(!isEqual(fetchMarketsOptions, null))) + { + types = this.safeList(fetchMarketsOptions, "types", defaultTypes); + } else + { + // for backward-compatibility + types = this.safeList(this.options, "fetchMarkets", defaultTypes); + } + for (object i = 0; isLessThan(i, getArrayLength(types)); postFixIncrement(ref i)) { - object marketType = getValue(fetchMarkets, i); + object marketType = getValue(types, i); if (isTrue(isEqual(marketType, "spot"))) { ((IList)promisesRaw).Add(this.spotV1PublicGetExchangeInfo(parameters)); diff --git a/cs/ccxt/exchanges/bitstamp.cs b/cs/ccxt/exchanges/bitstamp.cs index bdd51cac62553..49b3aa578da6f 100644 --- a/cs/ccxt/exchanges/bitstamp.cs +++ b/cs/ccxt/exchanges/bitstamp.cs @@ -484,6 +484,7 @@ public override object describe() { "Bitstamp.net is under scheduled maintenance. We'll be back soon.", typeof(OnMaintenance) }, { "Order could not be placed.", typeof(ExchangeNotAvailable) }, { "Invalid offset.", typeof(BadRequest) }, + { "Trading is currently unavailable for your account.", typeof(AccountSuspended) }, } }, { "broad", new Dictionary() { { "Minimum order size is", typeof(InvalidOrder) }, diff --git a/cs/ccxt/exchanges/blofin.cs b/cs/ccxt/exchanges/blofin.cs index 118871793798a..f6757fa00c303 100644 --- a/cs/ccxt/exchanges/blofin.cs +++ b/cs/ccxt/exchanges/blofin.cs @@ -932,6 +932,7 @@ public async override Task fetchOHLCV(object symbol, object timeframe = * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) + * @param {int} [params.until] timestamp in ms of the latest funding rate to fetch * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} */ public async override Task fetchFundingRateHistory(object symbol = null, object since = null, object limit = null, object parameters = null) @@ -948,7 +949,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); + return await this.fetchPaginatedCallDeterministic("fetchFundingRateHistory", symbol, since, limit, "8h", parameters, 100); } object market = this.market(symbol); object request = new Dictionary() { @@ -962,6 +963,12 @@ public async override Task fetchFundingRateHistory(object symbol = null, { ((IDictionary)request)["limit"] = limit; } + object until = this.safeInteger(parameters, "until"); + if (isTrue(!isEqual(until, null))) + { + ((IDictionary)request)["after"] = until; + parameters = this.omit(parameters, "until"); + } object response = await this.publicGetMarketFundingRateHistory(this.extend(request, parameters)); object rates = new List() {}; object data = this.safeList(response, "data", new List() {}); @@ -2700,7 +2707,7 @@ public async override Task setMarginMode(object marginMode, object symbo // } // object data = this.safeDict(response, "data", new Dictionary() {}); - return this.parseMarginMode(data, market); + return ((object)this.parseMarginMode(data, market)); } /** diff --git a/cs/ccxt/exchanges/bybit.cs b/cs/ccxt/exchanges/bybit.cs index f05a729100f2a..94ccfa5ff5069 100644 --- a/cs/ccxt/exchanges/bybit.cs +++ b/cs/ccxt/exchanges/bybit.cs @@ -956,7 +956,9 @@ public override object describe() { "options", new Dictionary() { { "usePrivateInstrumentsInfo", false }, { "enableDemoTrading", false }, - { "fetchMarkets", new List() {"spot", "linear", "inverse", "option"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"spot", "linear", "inverse", "option"} }, + } }, { "enableUnifiedMargin", null }, { "enableUnifiedAccount", null }, { "unifiedMarginStatus", null }, @@ -1082,6 +1084,7 @@ public override object describe() { "4h", "4h" }, { "1d", "1d" }, } }, + { "useMarkPriceForPositionCollateral", false }, } }, { "features", new Dictionary() { { "default", new Dictionary() { @@ -1692,10 +1695,20 @@ public async override Task fetchMarkets(object parameters = null) await this.loadTimeDifference(); } object promisesUnresolved = new List() {}; - object fetchMarkets = this.safeList(this.options, "fetchMarkets", new List() {"spot", "linear", "inverse"}); - for (object i = 0; isLessThan(i, getArrayLength(fetchMarkets)); postFixIncrement(ref i)) + object types = null; + object defaultTypes = new List() {"spot", "linear", "inverse", "option"}; + object fetchMarketsOptions = this.safeDict(this.options, "fetchMarkets"); + if (isTrue(!isEqual(fetchMarketsOptions, null))) + { + types = this.safeList(fetchMarketsOptions, "types", defaultTypes); + } else + { + // for backward-compatibility + types = this.safeList(this.options, "fetchMarkets", defaultTypes); + } + for (object i = 0; isLessThan(i, getArrayLength(types)); postFixIncrement(ref i)) { - object marketType = getValue(fetchMarkets, i); + object marketType = getValue(types, i); if (isTrue(isEqual(marketType, "spot"))) { ((IList)promisesUnresolved).Add(this.fetchSpotMarkets(parameters)); @@ -4045,7 +4058,7 @@ public async override Task createMarketSellOrderWithCost(object symbol, * @param {int} [params.isLeverage] *unified spot only* false then spot trading true then margin trading * @param {string} [params.tpslMode] *contract only* 'full' or 'partial' * @param {string} [params.mmp] *option only* market maker protection - * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'above' or 'below' + * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'ascending' or 'descending' * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at * @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at * @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at @@ -4072,7 +4085,7 @@ public async override Task createOrder(object symbol, object type, objec object isTakeProfit = !isEqual(takeProfitPrice, null); object orderRequest = this.createOrderRequest(symbol, type, side, amount, price, parameters, enableUnifiedAccount); object defaultMethod = null; - if (isTrue(isTrue(isTrue(isTrailingAmountOrder) || isTrue(isStopLoss)) || isTrue(isTakeProfit))) + if (isTrue(isTrue((isTrue(isTrue(isTrailingAmountOrder) || isTrue(isStopLoss)) || isTrue(isTakeProfit))) && !isTrue(getValue(market, "spot")))) { defaultMethod = "privatePostV5PositionTradingStop"; } else @@ -4140,7 +4153,7 @@ public virtual object createOrderRequest(object symbol, object type, object side object isLimit = isEqual(lowerCaseType, "limit"); object isBuy = isEqual(side, "buy"); object defaultMethod = null; - if (isTrue(isTrue(isTrue(isTrailingAmountOrder) || isTrue(isStopLossTriggerOrder)) || isTrue(isTakeProfitTriggerOrder))) + if (isTrue(isTrue((isTrue(isTrue(isTrailingAmountOrder) || isTrue(isStopLossTriggerOrder)) || isTrue(isTakeProfitTriggerOrder))) && !isTrue(getValue(market, "spot")))) { defaultMethod = "privatePostV5PositionTradingStop"; } else @@ -4321,9 +4334,9 @@ public virtual object createOrderRequest(object symbol, object type, object side { if (isTrue(isEqual(triggerDirection, null))) { - throw new ArgumentsRequired ((string)add(this.id, " stop/trigger orders require a triggerDirection parameter, either \"above\" or \"below\" to determine the direction of the trigger.")) ; + throw new ArgumentsRequired ((string)add(this.id, " stop/trigger orders require a triggerDirection parameter, either \"ascending\" or \"descending\" to determine the direction of the trigger.")) ; } - object isAsending = (isTrue((isEqual(triggerDirection, "above"))) || isTrue((isEqual(triggerDirection, "1")))); + object isAsending = (isTrue(isTrue((isEqual(triggerDirection, "ascending"))) || isTrue((isEqual(triggerDirection, "above")))) || isTrue((isEqual(triggerDirection, "1")))); ((IDictionary)request)["triggerDirection"] = ((bool) isTrue(isAsending)) ? 1 : 2; } ((IDictionary)request)["triggerPrice"] = this.getPrice(symbol, triggerPrice); @@ -5087,7 +5100,9 @@ public async override Task cancelAllOrders(object symbol = null, object object orders = this.safeList(result, "list"); if (!isTrue(((orders is IList) || (orders.GetType().IsGenericType && orders.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))))) { - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } return this.parseOrders(orders, market); } @@ -6987,6 +7002,7 @@ public override object parsePosition(object position, object market = null) } object collateralString = this.safeString(position, "positionBalance"); object entryPrice = this.omitZero(this.safeStringN(position, new List() {"entryPrice", "avgPrice", "avgEntryPrice"})); + object markPrice = this.safeString(position, "markPrice"); object liquidationPrice = this.omitZero(this.safeString(position, "liqPrice")); object leverage = this.safeString(position, "leverage"); if (isTrue(!isEqual(liquidationPrice, null))) @@ -6994,7 +7010,8 @@ public override object parsePosition(object position, object market = null) if (isTrue(isEqual(getValue(market, "settle"), "USDC"))) { // (Entry price - Liq price) * Contracts + Maintenance Margin + (unrealised pnl) = Collateral - object difference = Precise.stringAbs(Precise.stringSub(entryPrice, liquidationPrice)); + object price = ((bool) isTrue(this.safeBool(this.options, "useMarkPriceForPositionCollateral", false))) ? markPrice : entryPrice; + object difference = Precise.stringAbs(Precise.stringSub(price, liquidationPrice)); collateralString = Precise.stringAdd(Precise.stringAdd(Precise.stringMul(difference, size), maintenanceMarginString), unrealisedPnl); } else { @@ -7053,7 +7070,7 @@ public override object parsePosition(object position, object market = null) { "contractSize", this.safeNumber(market, "contractSize") }, { "marginRatio", this.parseNumber(marginRatio) }, { "liquidationPrice", this.parseNumber(liquidationPrice) }, - { "markPrice", this.safeNumber(position, "markPrice") }, + { "markPrice", this.parseNumber(markPrice) }, { "lastPrice", this.safeNumber(position, "avgExitPrice") }, { "collateral", this.parseNumber(collateralString) }, { "marginMode", marginMode }, @@ -9178,7 +9195,7 @@ public override object parseIncome(object income, object market = null) { "timestamp", timestamp }, { "datetime", this.iso8601(timestamp) }, { "id", this.safeString(income, "execId") }, - { "amount", this.safeNumber(income, "execQty") }, + { "amount", this.safeNumber(income, "execFee") }, { "rate", this.safeNumber(income, "feeRate") }, }; } diff --git a/cs/ccxt/exchanges/coinbase.cs b/cs/ccxt/exchanges/coinbase.cs index 8cc645eea566d..be302752a7b8a 100644 --- a/cs/ccxt/exchanges/coinbase.cs +++ b/cs/ccxt/exchanges/coinbase.cs @@ -27,6 +27,9 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelOrder", true }, { "cancelOrders", true }, { "closeAllPositions", false }, @@ -41,6 +44,8 @@ public override object describe() { "createMarketSellOrder", true }, { "createMarketSellOrderWithCost", false }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, { "createPostOnlyOrder", true }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", true }, @@ -51,8 +56,12 @@ public override object describe() { "fetchAccounts", true }, { "fetchBalance", true }, { "fetchBidsAsks", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, { "fetchBorrowRateHistories", false }, { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCanceledOrders", true }, { "fetchClosedOrders", true }, { "fetchConvertQuote", true }, @@ -70,42 +79,69 @@ public override object describe() { "fetchDeposits", true }, { "fetchDepositsWithdrawals", true }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchL2OrderBook", false }, { "fetchLedger", true }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, { "fetchMyBuys", true }, + { "fetchMyLiquidations", false }, { "fetchMySells", true }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, { "fetchOHLCV", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrders", true }, { "fetchPosition", true }, + { "fetchPositionHistory", false }, { "fetchPositionMode", false }, { "fetchPositions", true }, + { "fetchPositionsForSymbol", false }, + { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchTicker", true }, { "fetchTickers", true }, { "fetchTime", true }, { "fetchTrades", true }, { "fetchTradingFee", "emulated" }, { "fetchTradingFees", true }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawals", true }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "setLeverage", false }, + { "setMargin", false }, { "setMarginMode", false }, { "setPositionMode", false }, { "withdraw", true }, @@ -282,12 +318,14 @@ public override object describe() { "rate_limit_exceeded", typeof(RateLimitExceeded) }, { "internal_server_error", typeof(ExchangeError) }, { "UNSUPPORTED_ORDER_CONFIGURATION", typeof(BadRequest) }, - { "INSUFFICIENT_FUND", typeof(BadRequest) }, + { "INSUFFICIENT_FUND", typeof(InsufficientFunds) }, { "PERMISSION_DENIED", typeof(PermissionDenied) }, { "INVALID_ARGUMENT", typeof(BadRequest) }, { "PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE", typeof(InvalidOrder) }, + { "PREVIEW_INSUFFICIENT_FUND", typeof(InsufficientFunds) }, } }, { "broad", new Dictionary() { + { "Insufficient balance in source account", typeof(InsufficientFunds) }, { "request timestamp expired", typeof(InvalidNonce) }, { "order with this orderID was not found", typeof(OrderNotFound) }, } }, diff --git a/cs/ccxt/exchanges/coinbaseexchange.cs b/cs/ccxt/exchanges/coinbaseexchange.cs index f417922302fd2..a0b35094d369a 100644 --- a/cs/ccxt/exchanges/coinbaseexchange.cs +++ b/cs/ccxt/exchanges/coinbaseexchange.cs @@ -21,31 +21,73 @@ public override object describe() { "swap", false }, { "future", false }, { "option", false }, + { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelAllOrders", true }, { "cancelOrder", true }, + { "closeAllPositions", false }, + { "closePosition", false }, { "createDepositAddress", true }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", true }, { "createStopMarketOrder", true }, { "createStopOrder", true }, { "fetchAccounts", true }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, + { "fetchBorrowRateHistories", false }, + { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchClosedOrders", true }, + { "fetchCrossBorrowRate", false }, + { "fetchCrossBorrowRates", false }, { "fetchCurrencies", true }, { "fetchDepositAddress", false }, { "fetchDeposits", true }, { "fetchDepositsWithdrawals", true }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, + { "fetchIndexOHLCV", false }, + { "fetchIsolatedBorrowRate", false }, + { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLedger", true }, + { "fetchLeverage", false }, + { "fetchLeverages", false }, + { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, + { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, { "fetchOHLCV", true }, + { "fetchOpenInterest", false }, + { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrders", true }, @@ -57,6 +99,8 @@ public override object describe() { "fetchPositionsForSymbol", false }, { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, + { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchTicker", true }, { "fetchTickers", true }, { "fetchTime", true }, @@ -64,7 +108,16 @@ public override object describe() { "fetchTradingFee", false }, { "fetchTradingFees", true }, { "fetchTransactions", "emulated" }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawals", true }, + { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, + { "setLeverage", false }, + { "setMargin", false }, + { "setMarginMode", false }, + { "setPositionMode", false }, { "withdraw", true }, } }, { "timeframes", new Dictionary() { @@ -1517,7 +1570,10 @@ public async override Task cancelOrder(object id, object symbol = null, market = this.market(symbol); ((IDictionary)request)["product_id"] = getValue(market, "symbol"); // the request will be more performant if you include it } - return await ((Task)callDynamically(this, method, new object[] { this.extend(request, parameters) })); + object response = await ((Task)callDynamically(this, method, new object[] { this.extend(request, parameters) })); + return this.safeOrder(new Dictionary() { + { "info", response }, + }); } /** @@ -1540,7 +1596,10 @@ public async override Task cancelAllOrders(object symbol = null, object market = this.market(symbol); ((IDictionary)request)["product_id"] = getValue(market, "symbol"); // the request will be more performant if you include it } - return await this.privateDeleteOrders(this.extend(request, parameters)); + object response = await this.privateDeleteOrders(this.extend(request, parameters)); + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } public async override Task fetchPaymentMethods(object parameters = null) diff --git a/cs/ccxt/exchanges/coincheck.cs b/cs/ccxt/exchanges/coincheck.cs index e8ce683a81c1a..289162607b86b 100644 --- a/cs/ccxt/exchanges/coincheck.cs +++ b/cs/ccxt/exchanges/coincheck.cs @@ -20,30 +20,59 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelOrder", true }, { "closeAllPositions", false }, { "closePosition", false }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, { "fetchBorrowRateHistories", false }, { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCrossBorrowRate", false }, { "fetchCrossBorrowRates", false }, { "fetchDeposits", true }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, + { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrderBook", true }, { "fetchPosition", false }, { "fetchPositionHistory", false }, @@ -53,13 +82,19 @@ public override object describe() { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchTicker", true }, { "fetchTrades", true }, { "fetchTradingFee", false }, { "fetchTradingFees", true }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawals", true }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "setLeverage", false }, + { "setMargin", false }, { "setMarginMode", false }, { "setPositionMode", false }, { "ws", true }, diff --git a/cs/ccxt/exchanges/coinmate.cs b/cs/ccxt/exchanges/coinmate.cs index edce630992045..9c0ad6ce2541f 100644 --- a/cs/ccxt/exchanges/coinmate.cs +++ b/cs/ccxt/exchanges/coinmate.cs @@ -20,32 +20,60 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelOrder", true }, { "closeAllPositions", false }, { "closePosition", false }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, { "fetchBorrowRateHistories", false }, { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCrossBorrowRate", false }, { "fetchCrossBorrowRates", false }, { "fetchDepositsWithdrawals", true }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrders", true }, @@ -57,14 +85,20 @@ public override object describe() { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchTicker", true }, { "fetchTickers", true }, { "fetchTrades", true }, { "fetchTradingFee", true }, { "fetchTradingFees", false }, { "fetchTransactions", "emulated" }, + { "fetchVolatilityHistory", false }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "setLeverage", false }, + { "setMargin", false }, { "setMarginMode", false }, { "setPositionMode", false }, { "transfer", false }, diff --git a/cs/ccxt/exchanges/coinmetro.cs b/cs/ccxt/exchanges/coinmetro.cs index 67af11bcc6cf1..1dec47b5a10b1 100644 --- a/cs/ccxt/exchanges/coinmetro.cs +++ b/cs/ccxt/exchanges/coinmetro.cs @@ -201,6 +201,7 @@ public override object describe() { "options", new Dictionary() { { "currenciesByIdForParseMarket", null }, { "currencyIdsListForParseMarket", new List() {"QRDO"} }, + { "skippedMarkets", new List() {"VXVUSDT"} }, } }, { "features", new Dictionary() { { "spot", new Dictionary() { @@ -436,11 +437,14 @@ public async override Task fetchCurrencies(object parameters = null) public async override Task fetchMarkets(object parameters = null) { parameters ??= new Dictionary(); - object response = await this.publicGetMarkets(parameters); + object promises = new List() {}; + ((IList)promises).Add(this.publicGetMarkets(parameters)); if (isTrue(isEqual(this.safeValue(this.options, "currenciesByIdForParseMarket"), null))) { - await this.fetchCurrencies(); + ((IList)promises).Add(this.fetchCurrencies()); } + object responses = await promiseAll(promises); + object response = getValue(responses, 0); // // [ // { @@ -456,7 +460,18 @@ public async override Task fetchMarkets(object parameters = null) // ... // ] // - return this.parseMarkets(response); + object skippedMarkets = this.safeList(this.options, "skippedMarkets", new List() {}); + object result = new List() {}; + for (object i = 0; isLessThan(i, getArrayLength(response)); postFixIncrement(ref i)) + { + object market = this.parseMarket(getValue(response, i)); + if (isTrue(this.inArray(getValue(market, "id"), skippedMarkets))) + { + continue; + } + ((IList)result).Add(market); + } + return result; } public override object parseMarket(object market) diff --git a/cs/ccxt/exchanges/coinone.cs b/cs/ccxt/exchanges/coinone.cs index 941d6b0210972..b364f8d3340bd 100644 --- a/cs/ccxt/exchanges/coinone.cs +++ b/cs/ccxt/exchanges/coinone.cs @@ -22,18 +22,28 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelOrder", true }, { "closeAllPositions", false }, { "closePosition", false }, { "createMarketOrder", false }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", false }, { "createStopMarketOrder", false }, { "createStopOrder", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, { "fetchBorrowRateHistories", false }, { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchClosedOrders", false }, { "fetchCrossBorrowRate", false }, { "fetchCrossBorrowRates", false }, @@ -42,20 +52,38 @@ public override object describe() { "fetchDepositAddresses", true }, { "fetchDepositAddressesByNetwork", false }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchPosition", false }, @@ -66,11 +94,17 @@ public override object describe() { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchTicker", true }, { "fetchTickers", true }, { "fetchTrades", true }, + { "fetchVolatilityHistory", false }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "setLeverage", false }, + { "setMargin", false }, { "setMarginMode", false }, { "setPositionMode", false }, { "ws", true }, diff --git a/cs/ccxt/exchanges/coinsph.cs b/cs/ccxt/exchanges/coinsph.cs index 626b3361c0b86..788505d69b19e 100644 --- a/cs/ccxt/exchanges/coinsph.cs +++ b/cs/ccxt/exchanges/coinsph.cs @@ -23,6 +23,9 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelAllOrders", true }, { "cancelOrder", true }, { "cancelOrders", false }, @@ -33,6 +36,8 @@ public override object describe() { "createMarketOrderWithCost", false }, { "createMarketSellOrderWithCost", false }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", true }, @@ -44,8 +49,11 @@ public override object describe() { "fetchBalance", true }, { "fetchBidsAsks", false }, { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, { "fetchBorrowRateHistories", false }, { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCanceledOrders", false }, { "fetchClosedOrder", false }, { "fetchClosedOrders", true }, @@ -60,24 +68,42 @@ public override object describe() { "fetchDepositWithdrawFee", false }, { "fetchDepositWithdrawFees", false }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchL3OrderBook", false }, { "fetchLedger", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, + { "fetchMarginMode", false }, + { "fetchMarginModes", false }, { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, { "fetchOHLCV", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrder", null }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrderBooks", false }, @@ -91,6 +117,7 @@ public override object describe() { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchStatus", true }, { "fetchTicker", true }, { "fetchTickers", true }, @@ -103,12 +130,14 @@ public override object describe() { "fetchTransactionFees", false }, { "fetchTransactions", false }, { "fetchTransfers", false }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawal", null }, { "fetchWithdrawals", true }, { "fetchWithdrawalWhitelist", false }, { "reduceMargin", false }, { "repayCrossMargin", false }, { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "setLeverage", false }, { "setMargin", false }, { "setMarginMode", false }, diff --git a/cs/ccxt/exchanges/coinspot.cs b/cs/ccxt/exchanges/coinspot.cs index 3e4c933a74d32..1712e61a61563 100644 --- a/cs/ccxt/exchanges/coinspot.cs +++ b/cs/ccxt/exchanges/coinspot.cs @@ -21,33 +21,61 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelOrder", true }, { "closeAllPositions", false }, { "closePosition", false }, { "createMarketOrder", false }, { "createOrder", true }, + { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", false }, { "createStopMarketOrder", false }, { "createStopOrder", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, { "fetchBorrowRateHistories", false }, { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCrossBorrowRate", false }, { "fetchCrossBorrowRates", false }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, + { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrderBook", true }, { "fetchPosition", false }, { "fetchPositionHistory", false }, @@ -57,13 +85,19 @@ public override object describe() { "fetchPositionsHistory", false }, { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchTicker", true }, { "fetchTickers", true }, { "fetchTrades", true }, { "fetchTradingFee", false }, { "fetchTradingFees", false }, + { "fetchVolatilityHistory", false }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "setLeverage", false }, + { "setMargin", false }, { "setMarginMode", false }, { "setPositionMode", false }, { "ws", false }, @@ -696,7 +730,8 @@ public async override Task createOrder(object symbol, object type, objec { "amount", amount }, { "rate", price }, }; - return await ((Task)callDynamically(this, method, new object[] { this.extend(request, parameters) })); + object response = await ((Task)callDynamically(this, method, new object[] { this.extend(request, parameters) })); + return this.parseOrder(response); } /** diff --git a/cs/ccxt/exchanges/cryptocom.cs b/cs/ccxt/exchanges/cryptocom.cs index 024b3302b5ad9..f6890730f94cd 100644 --- a/cs/ccxt/exchanges/cryptocom.cs +++ b/cs/ccxt/exchanges/cryptocom.cs @@ -1827,7 +1827,10 @@ public async override Task cancelAllOrders(object symbol = null, object market = this.market(symbol); ((IDictionary)request)["instrument_name"] = getValue(market, "id"); } - return await this.v1PrivatePostPrivateCancelAllOrders(this.extend(request, parameters)); + object response = await this.v1PrivatePostPrivateCancelAllOrders(this.extend(request, parameters)); + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/cryptomus.cs b/cs/ccxt/exchanges/cryptomus.cs index 7025da52bfecd..1f16fa6349422 100644 --- a/cs/ccxt/exchanges/cryptomus.cs +++ b/cs/ccxt/exchanges/cryptomus.cs @@ -23,11 +23,15 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelAllOrders", false }, { "cancelAllOrdersAfter", false }, { "cancelOrder", true }, { "cancelOrders", false }, { "cancelWithdraw", false }, + { "closeAllPositions", false }, { "closePosition", false }, { "createConvertTrade", false }, { "createDepositAddress", false }, @@ -37,6 +41,8 @@ public override object describe() { "createMarketSellOrderWithCost", false }, { "createOrder", true }, { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", false }, { "createStopLossOrder", false }, @@ -48,6 +54,12 @@ public override object describe() { "createTriggerOrder", false }, { "fetchAccounts", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, + { "fetchBorrowRateHistories", false }, + { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCanceledAndClosedOrders", true }, { "fetchCanceledOrders", false }, { "fetchClosedOrder", false }, @@ -56,27 +68,48 @@ public override object describe() { "fetchConvertQuote", false }, { "fetchConvertTrade", false }, { "fetchConvertTradeHistory", false }, + { "fetchCrossBorrowRate", false }, + { "fetchCrossBorrowRates", false }, { "fetchCurrencies", true }, { "fetchDepositAddress", false }, { "fetchDeposits", false }, { "fetchDepositsWithdrawals", false }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, + { "fetchIsolatedBorrowRate", false }, + { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLedger", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", false }, { "fetchOHLCV", false }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrder", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrders", false }, @@ -87,7 +120,9 @@ public override object describe() { "fetchPositions", false }, { "fetchPositionsForSymbol", false }, { "fetchPositionsHistory", false }, + { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchStatus", false }, { "fetchTicker", false }, { "fetchTickers", true }, @@ -97,11 +132,16 @@ public override object describe() { "fetchTradingFees", true }, { "fetchTransactions", false }, { "fetchTransfers", false }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawals", false }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "sandbox", false }, { "setLeverage", false }, { "setMargin", false }, + { "setMarginMode", false }, { "setPositionMode", false }, { "transfer", false }, { "withdraw", false }, @@ -759,7 +799,9 @@ public async override Task cancelOrder(object id, object symbol = null, // "success": true // } // - return response; + return this.safeOrder(new Dictionary() { + { "info", response }, + }); } /** diff --git a/cs/ccxt/exchanges/defx.cs b/cs/ccxt/exchanges/defx.cs index 2cda6129352a3..7753fb2ad7578 100644 --- a/cs/ccxt/exchanges/defx.cs +++ b/cs/ccxt/exchanges/defx.cs @@ -1564,7 +1564,9 @@ public async override Task cancelAllOrders(object symbol = null, object // } // } // - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/deribit.cs b/cs/ccxt/exchanges/deribit.cs index f13ecb57065ed..6048f02b2e961 100644 --- a/cs/ccxt/exchanges/deribit.cs +++ b/cs/ccxt/exchanges/deribit.cs @@ -2835,21 +2835,21 @@ public override object parsePosition(object position, object market = null) object unrealizedPnl = this.safeString(position, "floating_profit_loss"); object initialMarginString = this.safeString(position, "initial_margin"); object notionalString = this.safeString(position, "size_currency"); + object notionalStringAbs = Precise.stringAbs(notionalString); object maintenanceMarginString = this.safeString(position, "maintenance_margin"); - object currentTime = this.milliseconds(); return this.safePosition(new Dictionary() { { "info", position }, { "id", null }, { "symbol", this.safeString(market, "symbol") }, - { "timestamp", currentTime }, - { "datetime", this.iso8601(currentTime) }, + { "timestamp", null }, + { "datetime", null }, { "lastUpdateTimestamp", null }, { "initialMargin", this.parseNumber(initialMarginString) }, - { "initialMarginPercentage", this.parseNumber(Precise.stringMul(Precise.stringDiv(initialMarginString, notionalString), "100")) }, + { "initialMarginPercentage", this.parseNumber(Precise.stringMul(Precise.stringDiv(initialMarginString, notionalStringAbs), "100")) }, { "maintenanceMargin", this.parseNumber(maintenanceMarginString) }, - { "maintenanceMarginPercentage", this.parseNumber(Precise.stringMul(Precise.stringDiv(maintenanceMarginString, notionalString), "100")) }, + { "maintenanceMarginPercentage", this.parseNumber(Precise.stringMul(Precise.stringDiv(maintenanceMarginString, notionalStringAbs), "100")) }, { "entryPrice", this.safeNumber(position, "average_price") }, - { "notional", this.parseNumber(notionalString) }, + { "notional", this.parseNumber(notionalStringAbs) }, { "leverage", this.safeInteger(position, "leverage") }, { "unrealizedPnl", this.parseNumber(unrealizedPnl) }, { "contracts", null }, diff --git a/cs/ccxt/exchanges/derive.cs b/cs/ccxt/exchanges/derive.cs index 6439aefe09968..a83b3d19ae232 100644 --- a/cs/ccxt/exchanges/derive.cs +++ b/cs/ccxt/exchanges/derive.cs @@ -1609,7 +1609,9 @@ public async override Task cancelAllOrders(object symbol = null, object // "result": "ok" // } // - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/ellipx.cs b/cs/ccxt/exchanges/ellipx.cs index f5413602255d9..7723a6c8edccf 100644 --- a/cs/ccxt/exchanges/ellipx.cs +++ b/cs/ccxt/exchanges/ellipx.cs @@ -23,11 +23,15 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelAllOrders", false }, { "cancelAllOrdersAfter", false }, { "cancelOrder", true }, { "cancelOrders", false }, { "cancelWithdraw", false }, + { "closeAllPositions", false }, { "closePosition", false }, { "createConvertTrade", false }, { "createDepositAddress", false }, @@ -37,6 +41,8 @@ public override object describe() { "createMarketSellOrderWithCost", false }, { "createOrder", true }, { "createOrderWithTakeProfitAndStopLoss", false }, + { "createOrderWithTakeProfitAndStopLossWs", false }, + { "createPostOnlyOrder", false }, { "createReduceOnlyOrder", false }, { "createStopLimitOrder", false }, { "createStopLossOrder", false }, @@ -48,6 +54,12 @@ public override object describe() { "createTriggerOrder", false }, { "fetchAccounts", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, + { "fetchBorrowRateHistories", false }, + { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCanceledAndClosedOrders", false }, { "fetchCanceledOrders", false }, { "fetchClosedOrder", false }, @@ -56,27 +68,48 @@ public override object describe() { "fetchConvertQuote", false }, { "fetchConvertTrade", false }, { "fetchConvertTradeHistory", false }, + { "fetchCrossBorrowRate", false }, + { "fetchCrossBorrowRates", false }, { "fetchCurrencies", true }, { "fetchDepositAddress", true }, { "fetchDeposits", false }, { "fetchDepositsWithdrawals", false }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", false }, { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, + { "fetchIsolatedBorrowRate", false }, + { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLedger", false }, { "fetchLeverage", false }, + { "fetchLeverages", false }, { "fetchLeverageTiers", false }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, + { "fetchMarketLeverageTiers", false }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", false }, { "fetchOHLCV", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrder", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrders", true }, @@ -87,7 +120,9 @@ public override object describe() { "fetchPositions", false }, { "fetchPositionsForSymbol", false }, { "fetchPositionsHistory", false }, + { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchStatus", false }, { "fetchTicker", true }, { "fetchTickers", false }, @@ -97,11 +132,16 @@ public override object describe() { "fetchTradingFees", false }, { "fetchTransactions", false }, { "fetchTransfers", false }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawals", false }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, + { "repayMargin", false }, { "sandbox", false }, { "setLeverage", false }, { "setMargin", false }, + { "setMarginMode", false }, { "setPositionMode", false }, { "transfer", false }, { "withdraw", true }, diff --git a/cs/ccxt/exchanges/foxbit.cs b/cs/ccxt/exchanges/foxbit.cs new file mode 100644 index 0000000000000..e10162201a362 --- /dev/null +++ b/cs/ccxt/exchanges/foxbit.cs @@ -0,0 +1,2203 @@ +namespace ccxt; + +// 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 foxbit : Exchange +{ + public override object describe() + { + return this.deepExtend(base.describe(), new Dictionary() { + { "id", "foxbit" }, + { "name", "Foxbit" }, + { "countries", new List() {"pt-BR"} }, + { "rateLimit", 33.334 }, + { "version", "1" }, + { "comment", "Foxbit Exchange" }, + { "certified", false }, + { "pro", false }, + { "has", new Dictionary() { + { "CORS", true }, + { "spot", true }, + { "margin", null }, + { "swap", null }, + { "future", null }, + { "option", null }, + { "cancelAllOrders", true }, + { "cancelOrder", true }, + { "createLimitBuyOrder", true }, + { "createLimitSellOrder", true }, + { "createMarketBuyOrder", true }, + { "createMarketSellOrder", true }, + { "createOrder", true }, + { "fecthOrderBook", true }, + { "fetchBalance", true }, + { "fetchCanceledOrders", true }, + { "fetchClosedOrders", true }, + { "fetchCurrencies", true }, + { "fetchDepositAddress", true }, + { "fetchDeposits", true }, + { "fetchL2OrderBook", true }, + { "fetchLedger", true }, + { "fetchMarkets", true }, + { "fetchMyTrades", true }, + { "fetchOHLCV", true }, + { "fetchOpenOrders", true }, + { "fetchOrder", true }, + { "fetchOrders", true }, + { "fetchTicker", true }, + { "fetchTickers", true }, + { "fetchTrades", true }, + { "fetchTradingFee", true }, + { "fetchTradingFees", true }, + { "fetchTransactions", true }, + { "fetchWithdrawals", true }, + { "loadMarkets", true }, + { "sandbox", false }, + { "withdraw", true }, + { "ws", false }, + } }, + { "timeframes", new Dictionary() { + { "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", new Dictionary() { + { "logo", "https://github.com/user-attachments/assets/ba1435eb-1d59-4393-8de7-0db10a002fb3" }, + { "api", new Dictionary() { + { "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", new List() {"https://docs.foxbit.com.br"} }, + } }, + { "precisionMode", DECIMAL_PLACES }, + { "exceptions", new Dictionary() { + { "exact", new Dictionary() { + { "400", typeof(BadRequest) }, + { "429", typeof(RateLimitExceeded) }, + { "404", typeof(BadRequest) }, + { "500", typeof(ExchangeError) }, + { "2001", typeof(AuthenticationError) }, + { "2002", typeof(AuthenticationError) }, + { "2003", typeof(AuthenticationError) }, + { "2004", typeof(BadRequest) }, + { "2005", typeof(PermissionDenied) }, + { "3001", typeof(PermissionDenied) }, + { "3002", typeof(PermissionDenied) }, + { "3003", typeof(AccountSuspended) }, + { "4001", typeof(BadRequest) }, + { "4002", typeof(InsufficientFunds) }, + { "4003", typeof(InvalidOrder) }, + { "4004", typeof(BadSymbol) }, + { "4005", typeof(BadRequest) }, + { "4007", typeof(ExchangeError) }, + { "4008", typeof(InvalidOrder) }, + { "4009", typeof(PermissionDenied) }, + { "4011", typeof(RateLimitExceeded) }, + { "4012", typeof(ExchangeError) }, + { "5001", typeof(ExchangeNotAvailable) }, + { "5002", typeof(OnMaintenance) }, + { "5003", typeof(OnMaintenance) }, + { "5004", typeof(InvalidOrder) }, + { "5005", typeof(InvalidOrder) }, + { "5006", typeof(InvalidOrder) }, + } }, + { "broad", new Dictionary() {} }, + } }, + { "requiredCredentials", new Dictionary() { + { "apiKey", true }, + { "secret", true }, + } }, + { "api", new Dictionary() { + { "v3", new Dictionary() { + { "public", new Dictionary() { + { "get", new Dictionary() { + { "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", new Dictionary() { + { "get", new Dictionary() { + { "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", new Dictionary() { + { "orders", 2 }, + { "orders/batch", 7.5 }, + { "orders/cancel-replace", 3 }, + { "withdrawals", 10 }, + } }, + { "put", new Dictionary() { + { "orders/cancel", 2 }, + } }, + } }, + } }, + { "status", new Dictionary() { + { "public", new Dictionary() { + { "get", new Dictionary() { + { "status", 30 }, + } }, + } }, + } }, + } }, + { "fees", new Dictionary() { + { "trading", new Dictionary() { + { "feeSide", "get" }, + { "tierBased", false }, + { "percentage", true }, + { "taker", this.parseNumber("0.005") }, + { "maker", this.parseNumber("0.0025") }, + } }, + } }, + { "options", new Dictionary() { + { "sandboxMode", false }, + { "networksById", new Dictionary() { + { "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", new Dictionary() { + { "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", new Dictionary() { + { "spot", new Dictionary() { + { "sandbox", false }, + { "createOrder", new Dictionary() { + { "marginMode", false }, + { "triggerPrice", true }, + { "triggerPriceType", new Dictionary() { + { "last", true }, + { "mark", false }, + { "index", false }, + } }, + { "triggerDirection", false }, + { "stopLossPrice", false }, + { "takeProfitPrice", false }, + { "attachedStopLossTakeProfit", null }, + { "timeInForce", new Dictionary() { + { "GTC", true }, + { "FOK", true }, + { "IOC", true }, + { "PO", true }, + { "GTD", false }, + } }, + { "hedged", false }, + { "leverage", false }, + { "marketBuyByCost", false }, + { "marketBuyRequiresPrice", false }, + { "selfTradePrevention", new Dictionary() { + { "expire_maker", true }, + { "expire_taker", true }, + { "expire_both", true }, + { "none", true }, + } }, + { "trailing", false }, + { "icebergAmount", false }, + } }, + { "createOrders", new Dictionary() { + { "max", 5 }, + } }, + { "fetchMyTrades", new Dictionary() { + { "marginMode", false }, + { "limit", 100 }, + { "daysBack", 90 }, + { "untilDays", 10000 }, + { "symbolRequired", true }, + } }, + { "fetchOrder", new Dictionary() { + { "marginMode", false }, + { "limit", 1 }, + { "daysBack", 90 }, + { "trigger", false }, + { "trailing", false }, + { "symbolRequired", false }, + } }, + { "fetchOpenOrders", new Dictionary() { + { "marginMode", false }, + { "limit", 100 }, + { "daysBack", 90 }, + { "trigger", false }, + { "trailing", false }, + { "symbolRequired", false }, + } }, + { "fetchOrders", new Dictionary() { + { "marginMode", true }, + { "limit", 100 }, + { "daysBack", 90 }, + { "untilDays", 10000 }, + { "trigger", false }, + { "trailing", false }, + { "symbolRequired", false }, + } }, + { "fetchClosedOrders", new Dictionary() { + { "marginMode", true }, + { "limit", 100 }, + { "daysBack", 90 }, + { "daysBackCanceled", 90 }, + { "untilDays", 10000 }, + { "trigger", false }, + { "trailing", false }, + { "symbolRequired", false }, + } }, + { "fetchOHLCV", new Dictionary() { + { "limit", 500 }, + } }, + } }, + } }, + }); + } + + public async override Task fetchCurrencies(object parameters = null) + { + parameters ??= new Dictionary(); + object response = await this.v3PublicGetCurrencies(parameters); + // { + // "data": [ + // { + // "symbol": "btc", + // "name": "Bitcoin", + // "type": "CRYPTO", + // "precision": 8, + // "deposit_info": { + // "min_to_confirm": "1", + // "min_amount": "0.0001" + // }, + // "withdraw_info": { + // "enabled": true, + // "min_amount": "0.0001", + // "fee": "0.0001" + // }, + // "category": { + // "code": "cripto", + // "name": "Cripto" + // }, + // "networks": [ + // { + // "name": "Bitcoin", + // "code": "btc", + // "deposit_info": { + // status: "ENABLED", + // }, + // "withdraw_info": { + // "status": "ENABLED", + // "fee": "0.0001", + // }, + // "has_destination_tag": false + // } + // ] + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + object result = new Dictionary() {}; + for (object i = 0; isLessThan(i, getArrayLength(data)); postFixIncrement(ref i)) + { + object currency = getValue(data, i); + object precision = this.safeInteger(currency, "precision"); + object currencyId = this.safeString(currency, "symbol"); + object name = this.safeString(currency, "name"); + object code = this.safeCurrencyCode(currencyId); + object depositInfo = this.safeDict(currency, "deposit_info"); + object withdrawInfo = this.safeDict(currency, "withdraw_info"); + object networks = this.safeList(currency, "networks", new List() {}); + object type = this.safeStringLower(currency, "type"); + object parsedNetworks = new Dictionary() {}; + for (object j = 0; isLessThan(j, getArrayLength(networks)); postFixIncrement(ref j)) + { + object network = getValue(networks, j); + object networkId = this.safeString(network, "code"); + object networkCode = this.networkIdToCode(networkId, code); + object networkWithdrawInfo = this.safeDict(network, "withdraw_info"); + object networkDepositInfo = this.safeDict(network, "deposit_info"); + object isWithdrawEnabled = isEqual(this.safeString(networkWithdrawInfo, "status"), "ENABLED"); + object isDepositEnabled = isEqual(this.safeString(networkDepositInfo, "status"), "ENABLED"); + ((IDictionary)parsedNetworks)[(string)networkCode] = new Dictionary() { + { "info", currency }, + { "id", networkId }, + { "network", networkCode }, + { "name", this.safeString(network, "name") }, + { "deposit", isDepositEnabled }, + { "withdraw", isWithdrawEnabled }, + { "active", true }, + { "precision", precision }, + { "fee", this.safeNumber(networkWithdrawInfo, "fee") }, + { "limits", new Dictionary() { + { "amount", new Dictionary() { + { "min", null }, + { "max", null }, + } }, + { "deposit", new Dictionary() { + { "min", this.safeNumber(depositInfo, "min_amount") }, + { "max", null }, + } }, + { "withdraw", new Dictionary() { + { "min", this.safeNumber(withdrawInfo, "min_amount") }, + { "max", null }, + } }, + } }, + }; + } + if (isTrue(isEqual(this.safeDict(result, code), null))) + { + ((IDictionary)result)[(string)code] = this.safeCurrencyStructure(new Dictionary() { + { "id", currencyId }, + { "code", code }, + { "info", currency }, + { "name", name }, + { "active", true }, + { "type", type }, + { "deposit", this.safeBool(depositInfo, "enabled", false) }, + { "withdraw", this.safeBool(withdrawInfo, "enabled", false) }, + { "fee", this.safeNumber(withdrawInfo, "fee") }, + { "precision", precision }, + { "limits", new Dictionary() { + { "amount", new Dictionary() { + { "min", null }, + { "max", null }, + } }, + { "deposit", new Dictionary() { + { "min", this.safeNumber(depositInfo, "min_amount") }, + { "max", null }, + } }, + { "withdraw", new Dictionary() { + { "min", this.safeNumber(withdrawInfo, "min_amount") }, + { "max", null }, + } }, + } }, + { "networks", parsedNetworks }, + }); + } + } + return result; + } + + /** + * @method + * @name foxbit#fetchMarkets + * @description Retrieves data on all markets for foxbit. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_index + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} an array of objects representing market data + */ + public async override Task fetchMarkets(object parameters = null) + { + parameters ??= new Dictionary(); + object response = await this.v3PublicGetMarkets(parameters); + // { + // "data": [ + // { + // "symbol": "btcbrl", + // "quantity_min": "0.00000236", + // "quantity_increment": "0.00000001", + // "quantity_precision": 8, + // "price_min": "0.0001", + // "price_increment": "0.0001", + // "price_precision": 4, + // "default_fees": { + // "maker": "0.001", + // "taker": "0.001" + // }, + // "base": { + // "symbol": "btc", + // "name": "Bitcoin", + // "type": "CRYPTO", + // "precision": 8, + // "category": { + // "code": "cripto", + // "name": "Cripto" + // }, + // "deposit_info": { + // "min_to_confirm": "1", + // "min_amount": "0.0001", + // "enabled": true + // }, + // "withdraw_info": { + // "enabled": true, + // "min_amount": "0.0001", + // "fee": "0.0001" + // }, + // "networks": [ + // { + // "name": "Bitcoin", + // "code": "bitcoin", + // "deposit_info": { + // "status": "ENABLED" + // }, + // "withdraw_info": { + // "status": "ENABLED", + // "fee": "0.0001" + // }, + // "has_destination_tag": false + // } + // ], + // "default_network_code": "bitcoin" + // }, + // "quote": { + // "symbol": "btc", + // "name": "Bitcoin", + // "type": "CRYPTO", + // "precision": 8, + // "category": { + // "code": "cripto", + // "name": "Cripto" + // }, + // "deposit_info": { + // "min_to_confirm": "1", + // "min_amount": "0.0001", + // "enabled": true + // }, + // "withdraw_info": { + // "enabled": true, + // "min_amount": "0.0001", + // "fee": "0.0001" + // }, + // "networks": [ + // { + // "name": "Bitcoin", + // "code": "bitcoin", + // "deposit_info": { + // "status": "ENABLED" + // }, + // "withdraw_info": { + // "status": "ENABLED", + // "fee": "0.0001" + // }, + // "has_destination_tag": false + // } + // ], + // "default_network_code": "bitcoin" + // }, + // "order_type": [ + // "LIMIT", + // "MARKET", + // "INSTANT", + // "STOP_LIMIT", + // "STOP_MARKET" + // ] + // } + // ] + // } + object markets = this.safeList(response, "data", new List() {}); + return this.parseMarkets(markets); + } + + /** + * @method + * @name foxbit#fetchTicker + * @description Get last 24 hours ticker information, in real-time, for given market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_ticker + * @param {string} symbol unified symbol of the market to fetch the ticker for + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} + */ + public async override Task fetchTicker(object symbol, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = this.market(symbol); + object request = new Dictionary() { + { "market", getValue(market, "id") }, + }; + object response = await this.v3PublicGetMarketsMarketTicker24hr(this.extend(request, parameters)); + // { + // "data": [ + // { + // "market_symbol": "btcbrl", + // "last_trade": { + // "price": "358504.69340000", + // "volume": "0.00027893", + // "date": "2024-01-01T00:00:00.000Z" + // }, + // "rolling_24h": { + // "price_change": "3211.87290000", + // "price_change_percent": "0.90400726", + // "volume": "20.03206866", + // "trades_count": "4376", + // "open": "355292.82050000", + // "high": "362999.99990000", + // "low": "355002.88880000" + // }, + // "best": { + // "ask": { + // "price": "358504.69340000", + // "volume": "0.00027893" + // }, + // "bid": { + // "price": "358504.69340000", + // "volume": "0.00027893" + // } + // } + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + object result = this.safeDict(data, 0, new Dictionary() {}); + return this.parseTicker(result, market); + } + + /** + * @method + * @name foxbit#fetchTickers + * @description Retrieve the ticker data of all markets. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_tickers + * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure} + */ + public async override Task fetchTickers(object symbols = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + symbols = this.marketSymbols(symbols); + object response = await this.v3PublicGetMarketsTicker24hr(parameters); + // { + // "data": [ + // { + // "market_symbol": "btcbrl", + // "last_trade": { + // "price": "358504.69340000", + // "volume": "0.00027893", + // "date": "2024-01-01T00:00:00.000Z" + // }, + // "rolling_24h": { + // "price_change": "3211.87290000", + // "price_change_percent": "0.90400726", + // "volume": "20.03206866", + // "trades_count": "4376", + // "open": "355292.82050000", + // "high": "362999.99990000", + // "low": "355002.88880000" + // }, + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + return this.parseTickers(data, symbols); + } + + /** + * @method + * @name foxbit#fetchTradingFees + * @description fetch the trading fees for multiple markets + * @see https://docs.foxbit.com.br/rest/v3/#tag/Member-Info/operation/MembersController_listTradingFees + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols + */ + public async override Task fetchTradingFees(object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object response = await this.v3PrivateGetMeFeesTrading(parameters); + // [ + // { + // "market_symbol": "btcbrl", + // "maker": "0.0025", + // "taker": "0.005" + // } + // ] + object data = this.safeList(response, "data", new List() {}); + object result = new Dictionary() {}; + for (object i = 0; isLessThan(i, getArrayLength(data)); postFixIncrement(ref i)) + { + object entry = getValue(data, i); + object marketId = this.safeString(entry, "market_symbol"); + object market = this.safeMarket(marketId); + object symbol = getValue(market, "symbol"); + ((IDictionary)result)[(string)symbol] = this.parseTradingFee(entry, market); + } + return result; + } + + /** + * @method + * @name foxbit#fetchOrderBook + * @description Exports a copy of the order book of a specific market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_findOrderbook + * @param {string} symbol unified symbol of the market to fetch the order book for + * @param {int} [limit] the maximum amount of order book entries to return, the maximum is 100 + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols + */ + public async override Task fetchOrderBook(object symbol, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = this.market(symbol); + object defaultLimit = 20; + object request = new Dictionary() { + { "market", getValue(market, "id") }, + { "depth", ((bool) isTrue((isEqual(limit, null)))) ? defaultLimit : limit }, + }; + object response = await this.v3PublicGetMarketsMarketOrderbook(this.extend(request, parameters)); + // { + // "sequence_id": 1234567890, + // "timestamp": 1713187921336, + // "bids": [ + // [ + // "3.00000000", + // "300.00000000" + // ], + // [ + // "1.70000000", + // "310.00000000" + // ] + // ], + // "asks": [ + // [ + // "3.00000000", + // "300.00000000" + // ], + // [ + // "2.00000000", + // "321.00000000" + // ] + // ] + // } + object timestamp = this.safeInteger(response, "timestamp"); + return this.parseOrderBook(response, symbol, timestamp); + } + + /** + * @method + * @name foxbit#fetchTrades + * @description Retrieve the trades of a specific market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_publicTrades + * @param {string} symbol unified symbol of the market to fetch trades for + * @param {int} [since] timestamp in ms of the earliest trade to fetch + * @param {int} [limit] the maximum amount of trades to fetch + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} + */ + public async override Task fetchTrades(object symbol, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = this.market(symbol); + object request = new Dictionary() { + { "market", getValue(market, "id") }, + }; + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 200))) + { + ((IDictionary)request)["page_size"] = 200; + } + } + // [ + // { + // "id": 1, + // "price": "329248.74700000", + // "volume": "0.00100000", + // "taker_side": "BUY", + // "created_at": "2024-01-01T00:00:00Z" + // } + // ] + object response = await this.v3PublicGetMarketsMarketTradesHistory(this.extend(request, parameters)); + object data = this.safeList(response, "data", new List() {}); + return this.parseTrades(data, market, since, limit); + } + + /** + * @method + * @name foxbit#fetchOHLCV + * @description Fetch historical candlestick data containing the open, high, low, and close price, and the volume of a market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_findCandlesticks + * @param {string} symbol unified symbol of the market to fetch OHLCV data for + * @param {string} timeframe the length of time each candle represents + * @param {int} [since] timestamp in ms of the earliest candle to fetch + * @param {int} [limit] the maximum amount of candles to fetch + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume + */ + public async override Task fetchOHLCV(object symbol, object timeframe = null, object since = null, object limit = null, object parameters = null) + { + timeframe ??= "1m"; + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = this.market(symbol); + object interval = this.safeString(this.timeframes, timeframe, timeframe); + object request = new Dictionary() { + { "market", getValue(market, "id") }, + { "interval", interval }, + }; + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["limit"] = limit; + if (isTrue(isGreaterThan(limit, 500))) + { + ((IDictionary)request)["limit"] = 500; + } + } + object response = await this.v3PublicGetMarketsMarketCandlesticks(this.extend(request, parameters)); + // [ + // [ + // "1692918000000", // timestamp + // "127772.05150000", // open + // "128467.99980000", // high + // "127750.01000000", // low + // "128353.99990000", // close + // "1692918060000", // close timestamp + // "0.17080431", // base volume + // "21866.35948786", // quote volume + // 66, // number of trades + // "0.12073605", // taker buy base volume + // "15466.34096391" // taker buy quote volume + // ] + // ] + return this.parseOHLCVs(response, market, interval, since, limit); + } + + /** + * @method + * @name foxbit#fetchBalance + * @description Query for balance and get the amount of funds available for trading or funds locked in orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Account/operation/AccountsController_all + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} + */ + public async override Task fetchBalance(object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object response = await this.v3PrivateGetAccounts(parameters); + // { + // "data": [ + // { + // "currency_symbol": "btc", + // "balance": "10000.0", + // "balance_available": "9000.0", + // "balance_locked": "1000.0" + // } + // ] + // } + object accounts = this.safeList(response, "data", new List() {}); + object result = new Dictionary() { + { "info", response }, + }; + for (object i = 0; isLessThan(i, getArrayLength(accounts)); postFixIncrement(ref i)) + { + object account = getValue(accounts, i); + object currencyId = this.safeString(account, "currency_symbol"); + object currencyCode = this.safeCurrencyCode(currencyId); + object total = this.safeString(account, "balance"); + object used = this.safeString(account, "balance_locked"); + object free = this.safeString(account, "balance_available"); + object balanceObj = new Dictionary() { + { "free", free }, + { "used", used }, + { "total", total }, + }; + ((IDictionary)result)[(string)currencyCode] = balanceObj; + } + return this.safeBalance(result); + } + + /** + * @method + * @name foxbit#fetchOpenOrders + * @description Fetch all unfilled currently open orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders + * @param {string} symbol unified market symbol + * @param {int} [since] the earliest time in ms to fetch open orders for + * @param {int} [limit] the maximum number of open order structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task fetchOpenOrders(object symbol = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + return await this.fetchOrdersByStatus("ACTIVE", symbol, since, limit, parameters); + } + + /** + * @method + * @name foxbit#fetchClosedOrders + * @description Fetch all currently closed orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders + * @param {string} symbol unified market symbol of the market orders were made in + * @param {int} [since] the earliest time in ms to fetch orders for + * @param {int} [limit] the maximum number of order structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Order[]} a list 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) + { + parameters ??= new Dictionary(); + return await this.fetchOrdersByStatus("FILLED", symbol, since, limit, parameters); + } + + public async virtual Task fetchCanceledOrders(object symbol = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + return await this.fetchOrdersByStatus("CANCELED", symbol, since, limit, parameters); + } + + public async virtual Task fetchOrdersByStatus(object status, object symbol = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = null; + object request = new Dictionary() { + { "state", status }, + }; + if (isTrue(!isEqual(symbol, null))) + { + market = this.market(symbol); + ((IDictionary)request)["market_symbol"] = getValue(market, "id"); + } + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 100))) + { + ((IDictionary)request)["page_size"] = 100; + } + } + object response = await this.v3PrivateGetOrders(this.extend(request, parameters)); + object data = this.safeList(response, "data", new List() {}); + return this.parseOrders(data); + } + + /** + * @method + * @name foxbit#createOrder + * @description Create an order with the specified characteristics + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_create + * @param {string} symbol unified symbol of the market to create an order in + * @param {string} type 'market', 'limit', 'stop_market', 'stop_limit', 'instant' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much you want to trade in units of the base currency + * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.timeInForce] "GTC", "FOK", "IOC", "PO" + * @param {float} [params.triggerPrice] The time in force for the order. One of GTC, FOK, IOC, PO. See .features or foxbit's doc to see more details. + * @param {bool} [params.postOnly] true or false whether the order is post-only + * @param {string} [params.clientOrderId] a unique identifier for the order + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task createOrder(object symbol, object type, object side, object amount, object price = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = this.market(symbol); + type = ((string)type).ToUpper(); + if (isTrue(isTrue(isTrue(isTrue(isTrue(!isEqual(type, "LIMIT")) && isTrue(!isEqual(type, "MARKET"))) && isTrue(!isEqual(type, "STOP_MARKET"))) && isTrue(!isEqual(type, "STOP_LIMIT"))) && isTrue(!isEqual(type, "INSTANT")))) + { + throw new InvalidOrder ((string)add(add("Invalid order type: ", type), ". Must be one of: limit, market, stop_market, stop_limit, instant.")) ; + } + object timeInForce = this.safeStringUpper(parameters, "timeInForce"); + object postOnly = this.safeBool(parameters, "postOnly", false); + object triggerPrice = this.safeNumber(parameters, "triggerPrice"); + object request = new Dictionary() { + { "market_symbol", getValue(market, "id") }, + { "side", ((string)side).ToUpper() }, + { "type", type }, + }; + if (isTrue(isTrue(isEqual(type, "STOP_MARKET")) || isTrue(isEqual(type, "STOP_LIMIT")))) + { + if (isTrue(isEqual(triggerPrice, null))) + { + throw new InvalidOrder ((string)add(add("Invalid order type: ", type), ". Must have triggerPrice.")) ; + } + } + if (isTrue(!isEqual(timeInForce, null))) + { + if (isTrue(isEqual(timeInForce, "PO"))) + { + ((IDictionary)request)["post_only"] = true; + } else + { + ((IDictionary)request)["time_in_force"] = timeInForce; + } + } + if (isTrue(postOnly)) + { + ((IDictionary)request)["post_only"] = true; + } + if (isTrue(!isEqual(triggerPrice, null))) + { + ((IDictionary)request)["stop_price"] = this.priceToPrecision(symbol, triggerPrice); + } + if (isTrue(isEqual(type, "INSTANT"))) + { + ((IDictionary)request)["amount"] = this.priceToPrecision(symbol, amount); + } else + { + ((IDictionary)request)["quantity"] = this.amountToPrecision(symbol, amount); + } + if (isTrue(isTrue(isEqual(type, "LIMIT")) || isTrue(isEqual(type, "STOP_LIMIT")))) + { + ((IDictionary)request)["price"] = this.priceToPrecision(symbol, price); + } + object clientOrderId = this.safeString(parameters, "clientOrderId"); + if (isTrue(!isEqual(clientOrderId, null))) + { + ((IDictionary)request)["client_order_id"] = clientOrderId; + } + parameters = this.omit(parameters, new List() {"timeInForce", "postOnly", "triggerPrice", "clientOrderId"}); + object response = await this.v3PrivatePostOrders(this.extend(request, parameters)); + // { + // "id": 1234567890, + // "sn": "OKMAKSDHRVVREK", + // "client_order_id": "451637946501" + // } + return this.parseOrder(response, market); + } + + /** + * @method + * @name foxbit#createOrders + * @description create a list of trade orders + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/createBatch + * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task createOrders(object orders, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object ordersRequests = new List() {}; + for (object i = 0; isLessThan(i, getArrayLength(orders)); postFixIncrement(ref i)) + { + object order = this.safeDict(orders, i); + object symbol = this.safeString(order, "symbol"); + object market = this.market(symbol); + object type = this.safeStringUpper(order, "type"); + object orderParams = this.safeDict(order, "params", new Dictionary() {}); + if (isTrue(isTrue(isTrue(isTrue(isTrue(!isEqual(type, "LIMIT")) && isTrue(!isEqual(type, "MARKET"))) && isTrue(!isEqual(type, "STOP_MARKET"))) && isTrue(!isEqual(type, "STOP_LIMIT"))) && isTrue(!isEqual(type, "INSTANT")))) + { + throw new InvalidOrder ((string)add(add("Invalid order type: ", type), ". Must be one of: limit, market, stop_market, stop_limit, instant.")) ; + } + object timeInForce = this.safeStringUpper(orderParams, "timeInForce"); + object postOnly = this.safeBool(orderParams, "postOnly", false); + object triggerPrice = this.safeNumber(orderParams, "triggerPrice"); + object request = new Dictionary() { + { "market_symbol", getValue(market, "id") }, + { "side", this.safeStringUpper(order, "side") }, + { "type", type }, + }; + if (isTrue(isTrue(isEqual(type, "STOP_MARKET")) || isTrue(isEqual(type, "STOP_LIMIT")))) + { + if (isTrue(isEqual(triggerPrice, null))) + { + throw new InvalidOrder ((string)add(add("Invalid order type: ", type), ". Must have triggerPrice.")) ; + } + } + if (isTrue(!isEqual(timeInForce, null))) + { + if (isTrue(isEqual(timeInForce, "PO"))) + { + ((IDictionary)request)["post_only"] = true; + } else + { + ((IDictionary)request)["time_in_force"] = timeInForce; + } + ((IDictionary)orderParams).Remove((string)"timeInForce"); + } + if (isTrue(postOnly)) + { + ((IDictionary)request)["post_only"] = true; + ((IDictionary)orderParams).Remove((string)"postOnly"); + } + if (isTrue(!isEqual(triggerPrice, null))) + { + ((IDictionary)request)["stop_price"] = this.priceToPrecision(symbol, triggerPrice); + ((IDictionary)orderParams).Remove((string)"triggerPrice"); + } + if (isTrue(isEqual(type, "INSTANT"))) + { + ((IDictionary)request)["amount"] = this.priceToPrecision(symbol, this.safeString(order, "amount")); + } else + { + ((IDictionary)request)["quantity"] = this.amountToPrecision(symbol, this.safeString(order, "amount")); + } + if (isTrue(isTrue(isEqual(type, "LIMIT")) || isTrue(isEqual(type, "STOP_LIMIT")))) + { + ((IDictionary)request)["price"] = this.priceToPrecision(symbol, this.safeString(order, "price")); + } + ((IList)ordersRequests).Add(this.extend(request, orderParams)); + } + object createOrdersRequest = new Dictionary() { + { "data", ordersRequests }, + }; + object response = await this.v3PrivatePostOrdersBatch(this.extend(createOrdersRequest, parameters)); + // { + // "data": [ + // { + // "side": "BUY", + // "type": "LIMIT", + // "market_symbol": "btcbrl", + // "client_order_id": "451637946501", + // "remark": "A remarkable note for the order.", + // "quantity": "0.42", + // "price": "250000.0", + // "post_only": true, + // "time_in_force": "GTC" + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + return this.parseOrders(data); + } + + /** + * @method + * @name foxbit#cancelOrder + * @description Cancel open orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancel + * @param {string} id order id + * @param {string} symbol unified symbol of the market the order was made in + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task cancelOrder(object id, object symbol = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object request = new Dictionary() { + { "id", this.parseNumber(id) }, + { "type", "ID" }, + }; + object response = await this.v3PrivatePutOrdersCancel(this.extend(request, parameters)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "id": 123456789 + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + object result = this.safeDict(data, 0, new Dictionary() {}); + return this.parseOrder(result); + } + + /** + * @method + * @name foxbit#cancelAllOrders + * @description Cancel all open orders or all open orders for a specific market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancel + * @param {string} symbol unified market symbol of the market to cancel orders in + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task cancelAllOrders(object symbol = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object request = new Dictionary() { + { "type", "ALL" }, + }; + if (isTrue(!isEqual(symbol, null))) + { + object market = this.market(symbol); + ((IDictionary)request)["type"] = "MARKET"; + ((IDictionary)request)["market_symbol"] = getValue(market, "id"); + } + object response = await this.v3PrivatePutOrdersCancel(this.extend(request, parameters)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "id": 123456789 + // } + // ] + // } + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; + } + + /** + * @method + * @name foxbit#fetchOrder + * @description Get an order by ID. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_findByOrderId + * @param id + * @param {string} symbol it is not used in the foxbit API + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task fetchOrder(object id, object symbol = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object request = new Dictionary() { + { "id", id }, + }; + object response = await this.v3PrivateGetOrdersByOrderIdId(this.extend(request, parameters)); + // { + // "id": "1234567890", + // "sn": "OKMAKSDHRVVREK", + // "client_order_id": "451637946501", + // "market_symbol": "btcbrl", + // "side": "BUY", + // "type": "LIMIT", + // "state": "ACTIVE", + // "price": "290000.0", + // "price_avg": "295333.3333", + // "quantity": "0.42", + // "quantity_executed": "0.41", + // "instant_amount": "290.0", + // "instant_amount_executed": "290.0", + // "created_at": "2021-02-15T22:06:32.999Z", + // "trades_count": "2", + // "remark": "A remarkable note for the order.", + // "funds_received": "290.0" + // } + return this.parseOrder(response, null); + } + + /** + * @method + * @name foxbit#fetchOrders + * @description fetches information on multiple orders made by the user + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders + * @param {string} symbol unified market symbol of the market orders were made in + * @param {int} [since] the earliest time in ms to fetch orders for + * @param {int} [limit] the maximum number of order structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.state] Enum: ACTIVE, CANCELED, FILLED, PARTIALLY_CANCELED, PARTIALLY_FILLED + * @param {string} [params.side] Enum: BUY, SELL + * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task fetchOrders(object symbol = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = null; + object request = new Dictionary() {}; + if (isTrue(!isEqual(symbol, null))) + { + market = this.market(symbol); + ((IDictionary)request)["market_symbol"] = getValue(market, "id"); + } + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 100))) + { + ((IDictionary)request)["page_size"] = 100; + } + } + object response = await this.v3PrivateGetOrders(this.extend(request, parameters)); + // { + // "data": [ + // { + // "id": "1234567890", + // "sn": "OKMAKSDHRVVREK", + // "client_order_id": "451637946501", + // "market_symbol": "btcbrl", + // "side": "BUY", + // "type": "LIMIT", + // "state": "ACTIVE", + // "price": "290000.0", + // "price_avg": "295333.3333", + // "quantity": "0.42", + // "quantity_executed": "0.41", + // "instant_amount": "290.0", + // "instant_amount_executed": "290.0", + // "created_at": "2021-02-15T22:06:32.999Z", + // "trades_count": "2", + // "remark": "A remarkable note for the order.", + // "funds_received": "290.0" + // } + // ] + // } + object list = this.safeList(response, "data", new List() {}); + return this.parseOrders(list, market, since, limit); + } + + /** + * @method + * @name foxbit#fetchMyTrades + * @description Trade history queries will only have data available for the last 3 months, in descending order (most recents trades first). + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/TradesController_all + * @param {string} symbol unified market symbol + * @param {int} [since] the earliest time in ms to fetch trades for + * @param {int} [limit] the maximum number of trade structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} + */ + public async override Task fetchMyTrades(object symbol = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + if (isTrue(isEqual(symbol, null))) + { + throw new ArgumentsRequired ((string)add(this.id, " fetchMyTrades() requires a symbol argument")) ; + } + await this.loadMarkets(); + object market = this.market(symbol); + object request = new Dictionary() { + { "market_symbol", getValue(market, "id") }, + }; + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 100))) + { + ((IDictionary)request)["page_size"] = 100; + } + } + object response = await this.v3PrivateGetTrades(this.extend(request, parameters)); + // { + // "data": [ + // "id": 1234567890, + // "sn": "TC5JZVW2LLJ3IW", + // "order_id": 1234567890, + // "market_symbol": "btcbrl", + // "side": "BUY", + // "price": "290000.0", + // "quantity": "1.0", + // "fee": "0.01", + // "fee_currency_symbol": "btc", + // "created_at": "2021-02-15T22:06:32.999Z" + // ] + // } + object data = this.safeList(response, "data", new List() {}); + return this.parseTrades(data, market, since, limit); + } + + /** + * @method + * @name foxbit#fetchDepositAddress + * @description Fetch the deposit address for a currency associated with this account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_depositAddress + * @param {string} code unified currency code + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.networkCode] the blockchain network to create a deposit address on + * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} + */ + public async override Task fetchDepositAddress(object code, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object currency = this.currency(code); + object request = new Dictionary() { + { "currency_symbol", getValue(currency, "id") }, + }; + var networkCodeparamsOmitedVariable = this.handleNetworkCodeAndParams(parameters); + var networkCode = ((IList) networkCodeparamsOmitedVariable)[0]; + var paramsOmited = ((IList) networkCodeparamsOmitedVariable)[1]; + if (isTrue(!isEqual(networkCode, null))) + { + ((IDictionary)request)["network_code"] = this.networkCodeToId(networkCode, code); + } + object response = await this.v3PrivateGetDepositsAddress(this.extend(request, paramsOmited)); + // { + // "currency_symbol": "btc", + // "address": "2N9sS8LgrY19rvcCWDmE1ou1tTVmqk4KQAB", + // "message": "Address was retrieved successfully", + // "destination_tag": "string", + // "network": { + // "name": "Bitcoin Network", + // "code": "btc" + // } + // } + return this.parseDepositAddress(response, currency); + } + + /** + * @method + * @name foxbit#fetchDeposits + * @description Fetch all deposits made to an account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_listOrders + * @param {string} [code] unified currency code + * @param {int} [since] the earliest time in ms to fetch deposits for + * @param {int} [limit] the maximum number of deposit structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + public async override Task fetchDeposits(object code = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object request = new Dictionary() {}; + object currency = null; + if (isTrue(!isEqual(code, null))) + { + currency = this.currency(code); + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 100))) + { + ((IDictionary)request)["page_size"] = 100; + } + } + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + object response = await this.v3PrivateGetDeposits(this.extend(request, parameters)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "state": "ACCEPTED", + // "currency_symbol": "btc", + // "amount": "1.0", + // "fee": "0.1", + // "created_at": "2022-02-18T22:06:32.999Z", + // "details_crypto": { + // "transaction_id": "e20f035387020c5d5ea18ad53244f09f3", + // "receiving_address": "2N2rTrnKEFcyJjEJqvVjgWZ3bKvKT7Aij61" + // } + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + return this.parseTransactions(data, currency, since, limit); + } + + /** + * @method + * @name foxbit#fetchWithdrawals + * @description Fetch all withdrawals made from an account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_listWithdrawals + * @param {string} [code] unified currency code + * @param {int} [since] the earliest time in ms to fetch withdrawals for + * @param {int} [limit] the maximum number of withdrawal structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + public async override Task fetchWithdrawals(object code = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object request = new Dictionary() {}; + object currency = null; + if (isTrue(!isEqual(code, null))) + { + currency = this.currency(code); + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 100))) + { + ((IDictionary)request)["page_size"] = 100; + } + } + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + object response = await this.v3PrivateGetWithdrawals(this.extend(request, parameters)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "state": "ACCEPTED", + // "rejection_reason": "monthly_limit_exceeded", + // "currency_symbol": "btc", + // "amount": "1.0", + // "fee": "0.1", + // "created_at": "2022-02-18T22:06:32.999Z", + // "details_crypto": { + // "transaction_id": "e20f035387020c5d5ea18ad53244f09f3", + // "destination_address": "2N2rTrnKEFcyJjEJqvVjgWZ3bKvKT7Aij61" + // }, + // "details_fiat": { + // "bank": { + // "code": "1", + // "branch": { + // "number": "1234567890", + // "digit": "1" + // }, + // "account": { + // "number": "1234567890", + // "digit": "1", + // "type": "CHECK" + // } + // } + // } + // } + // ] + // } + object data = this.safeList(response, "data", new List() {}); + return this.parseTransactions(data, currency, since, limit); + } + + /** + * @method + * @name foxbit#fetchTransactions + * @description Fetch all transactions (deposits and withdrawals) made from an account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_listWithdrawals + * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_listOrders + * @param {string} [code] unified currency code + * @param {int} [since] the earliest time in ms to fetch withdrawals for + * @param {int} [limit] the maximum number of withdrawal structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + public async override Task fetchTransactions(object code = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + object withdrawals = await this.fetchWithdrawals(code, since, limit, parameters); + object deposits = await this.fetchDeposits(code, since, limit, parameters); + object allTransactions = this.arrayConcat(withdrawals, deposits); + object result = this.sortBy(allTransactions, "timestamp"); + return result; + } + + /** + * @method + * @name foxbit#fetchStatus + * @description The latest known information on the availability of the exchange API. + * @see https://status.foxbit.com/ + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure} + */ + public async override Task fetchStatus(object parameters = null) + { + parameters ??= new Dictionary(); + object response = await this.statusPublicGetStatus(parameters); + // { + // "data": { + // "id": 1, + // "attributes": { + // "status": "NORMAL", + // "createdAt": "2023-05-17T18:37:05.934Z", + // "updatedAt": "2024-04-17T02:33:50.945Z", + // "publishedAt": "2023-05-17T18:37:07.653Z", + // "locale": "pt-BR" + // } + // }, + // "meta": { + // } + // } + object data = this.safeDict(response, "data", new Dictionary() {}); + object attributes = this.safeDict(data, "attributes", new Dictionary() {}); + object statusRaw = this.safeString(attributes, "status"); + object statusMap = new Dictionary() { + { "NORMAL", "ok" }, + { "UNDER_MAINTENANCE", "maintenance" }, + }; + return new Dictionary() { + { "status", this.safeString(statusMap, statusRaw, statusRaw) }, + { "updated", this.safeString(attributes, "updatedAt") }, + { "eta", null }, + { "url", null }, + { "info", response }, + }; + } + + /** + * @method + * @name foxbit#editOrder + * @description Simultaneously cancel an existing order and create a new one. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancelReplace + * @param {string} id order id + * @param {string} symbol unified symbol of the market to create an order in + * @param {string} type 'market' or 'limit' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much of the currency you want to trade in units of the base currency + * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, used as stop_price on stop market orders + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + public async override Task editOrder(object id, object symbol, object type, object side, object amount = null, object price = null, object parameters = null) + { + parameters ??= new Dictionary(); + if (isTrue(isEqual(symbol, null))) + { + throw new ArgumentsRequired ((string)add(this.id, " editOrder() requires a symbol argument")) ; + } + type = ((string)type).ToUpper(); + if (isTrue(isTrue(isTrue(isTrue(!isEqual(type, "LIMIT")) && isTrue(!isEqual(type, "MARKET"))) && isTrue(!isEqual(type, "STOP_MARKET"))) && isTrue(!isEqual(type, "INSTANT")))) + { + throw new InvalidOrder ((string)add(add("Invalid order type: ", type), ". Must be one of: LIMIT, MARKET, STOP_MARKET, INSTANT.")) ; + } + await this.loadMarkets(); + object market = this.market(symbol); + object request = new Dictionary() { + { "mode", "ALLOW_FAILURE" }, + { "cancel", new Dictionary() { + { "type", "ID" }, + { "id", this.parseNumber(id) }, + } }, + { "create", new Dictionary() { + { "type", type }, + { "side", ((string)side).ToUpper() }, + { "market_symbol", getValue(market, "id") }, + } }, + }; + if (isTrue(isTrue(isEqual(type, "LIMIT")) || isTrue(isEqual(type, "MARKET")))) + { + ((IDictionary)getValue(request, "create"))["quantity"] = this.amountToPrecision(symbol, amount); + if (isTrue(isEqual(type, "LIMIT"))) + { + ((IDictionary)getValue(request, "create"))["price"] = this.priceToPrecision(symbol, price); + } + } + if (isTrue(isEqual(type, "STOP_MARKET"))) + { + ((IDictionary)getValue(request, "create"))["stop_price"] = this.priceToPrecision(symbol, price); + ((IDictionary)getValue(request, "create"))["quantity"] = this.amountToPrecision(symbol, amount); + } + if (isTrue(isEqual(type, "INSTANT"))) + { + ((IDictionary)getValue(request, "create"))["amount"] = this.priceToPrecision(symbol, amount); + } + object response = await this.v3PrivatePostOrdersCancelReplace(this.extend(request, parameters)); + // { + // "cancel": { + // "id": 123456789 + // }, + // "create": { + // "id": 1234567890, + // "client_order_id": "451637946501" + // } + // } + return this.parseOrder(getValue(response, "create"), market); + } + + /** + * @method + * @name foxbit#withdraw + * @description Make a withdrawal. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_createWithdrawal + * @param {string} code unified currency code + * @param {float} amount the amount to withdraw + * @param {string} address the address to withdraw to + * @param {string} tag + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @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) + { + parameters ??= new Dictionary(); + var tagparametersVariable = this.handleWithdrawTagAndParams(tag, parameters); + tag = ((IList)tagparametersVariable)[0]; + parameters = ((IList)tagparametersVariable)[1]; + await this.loadMarkets(); + object currency = this.currency(code); + object request = new Dictionary() { + { "currency_symbol", getValue(currency, "id") }, + { "amount", this.numberToString(amount) }, + { "destination_address", address }, + }; + if (isTrue(!isEqual(tag, null))) + { + ((IDictionary)request)["destination_tag"] = tag; + } + object networkCode = null; + var networkCodeparametersVariable = this.handleNetworkCodeAndParams(parameters); + networkCode = ((IList)networkCodeparametersVariable)[0]; + parameters = ((IList)networkCodeparametersVariable)[1]; + if (isTrue(!isEqual(networkCode, null))) + { + ((IDictionary)request)["network_code"] = this.networkCodeToId(networkCode); + } + object response = await this.v3PrivatePostWithdrawals(this.extend(request, parameters)); + // { + // "amount": "1", + // "currency_symbol": "xrp", + // "network_code": "ripple", + // "destination_address": "0x1234567890123456789012345678", + // "destination_tag": "123456" + // } + return this.parseTransaction(response); + } + + /** + * @method + * @name foxbit#fetchLedger + * @description fetch the history of changes, actions done by the user or operations that altered balance of the user + * @see https://docs.foxbit.com.br/rest/v3/#tag/Account/operation/AccountsController_getTransactions + * @param {string} code unified currency code, default is undefined + * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined + * @param {int} [limit] max number of ledger entrys to return, default is undefined + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure} + */ + public async override Task fetchLedger(object code = null, object since = null, object limit = null, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object request = new Dictionary() {}; + if (isTrue(isEqual(code, null))) + { + throw new ArgumentsRequired ((string)add(this.id, " fetchLedger() requires a code argument")) ; + } + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + if (isTrue(isGreaterThan(limit, 100))) + { + ((IDictionary)request)["page_size"] = 100; + } + } + if (isTrue(!isEqual(since, null))) + { + ((IDictionary)request)["start_time"] = this.iso8601(since); + } + object currency = this.currency(code); + ((IDictionary)request)["symbol"] = getValue(currency, "id"); + object response = await this.v3PrivateGetAccountsSymbolTransactions(this.extend(request, parameters)); + object data = this.safeList(response, "data", new List() {}); + return this.parseLedger(data, currency, since, limit); + } + + public override object parseMarket(object market) + { + object id = this.safeString(market, "symbol"); + object baseAssets = this.safeDict(market, "base"); + object baseId = this.safeString(baseAssets, "symbol"); + object quoteAssets = this.safeDict(market, "quote"); + object quoteId = this.safeString(quoteAssets, "symbol"); + object bs = this.safeCurrencyCode(baseId); + object quote = this.safeCurrencyCode(quoteId); + object symbol = add(add(bs, "/"), quote); + object fees = this.safeDict(market, "default_fees"); + return this.safeMarketStructure(new Dictionary() { + { "id", id }, + { "symbol", symbol }, + { "base", bs }, + { "quote", quote }, + { "baseId", baseId }, + { "quoteId", quoteId }, + { "active", true }, + { "type", "spot" }, + { "spot", true }, + { "margin", false }, + { "future", false }, + { "swap", false }, + { "option", false }, + { "contract", false }, + { "settle", null }, + { "settleId", null }, + { "contractSize", null }, + { "linear", null }, + { "inverse", null }, + { "expiry", null }, + { "expiryDatetime", null }, + { "strike", null }, + { "optionType", null }, + { "taker", this.safeNumber(fees, "taker") }, + { "maker", this.safeNumber(fees, "maker") }, + { "percentage", true }, + { "tierBased", false }, + { "feeSide", "get" }, + { "precision", new Dictionary() { + { "price", this.safeInteger(quoteAssets, "precision") }, + { "amount", this.safeInteger(baseAssets, "precision") }, + { "cost", this.safeInteger(quoteAssets, "precision") }, + } }, + { "limits", new Dictionary() { + { "amount", new Dictionary() { + { "min", this.safeNumber(market, "quantity_min") }, + { "max", null }, + } }, + { "price", new Dictionary() { + { "min", this.safeNumber(market, "price_min") }, + { "max", null }, + } }, + { "cost", new Dictionary() { + { "min", null }, + { "max", null }, + } }, + { "leverage", new Dictionary() { + { "min", null }, + { "max", null }, + } }, + } }, + { "info", market }, + }); + } + + public virtual object parseTradingFee(object entry, object market = null) + { + return new Dictionary() { + { "info", entry }, + { "symbol", getValue(market, "symbol") }, + { "maker", this.safeNumber(entry, "maker") }, + { "taker", this.safeNumber(entry, "taker") }, + { "percentage", true }, + { "tierBased", true }, + }; + } + + public override object parseTicker(object ticker, object market = null) + { + object marketId = this.safeString(ticker, "market_symbol"); + object symbol = this.safeSymbol(marketId, market, null, "spot"); + object rolling_24h = getValue(ticker, "rolling_24h"); + object best = this.safeDict(ticker, "best"); + object bestAsk = this.safeDict(best, "ask"); + object bestBid = this.safeDict(best, "bid"); + object lastTrade = getValue(ticker, "last_trade"); + object lastPrice = this.safeString(lastTrade, "price"); + return this.safeTicker(new Dictionary() { + { "symbol", symbol }, + { "timestamp", this.parseDate(this.safeString(lastTrade, "date")) }, + { "datetime", this.iso8601(this.parseDate(this.safeString(lastTrade, "date"))) }, + { "high", this.safeNumber(rolling_24h, "high") }, + { "low", this.safeNumber(rolling_24h, "low") }, + { "bid", this.safeNumber(bestBid, "price") }, + { "bidVolume", this.safeNumber(bestBid, "volume") }, + { "ask", this.safeNumber(bestAsk, "price") }, + { "askVolume", this.safeNumber(bestAsk, "volume") }, + { "vwap", null }, + { "open", this.safeNumber(rolling_24h, "open") }, + { "close", lastPrice }, + { "last", lastPrice }, + { "previousClose", null }, + { "change", this.safeString(rolling_24h, "price_change") }, + { "percentage", this.safeString(rolling_24h, "price_change_percent") }, + { "average", null }, + { "baseVolume", this.safeString(rolling_24h, "volume") }, + { "quoteVolume", null }, + { "info", ticker }, + }, market); + } + + public override object parseOHLCV(object ohlcv, object market = null) + { + return new List {this.safeInteger(ohlcv, 0), this.safeNumber(ohlcv, 1), this.safeNumber(ohlcv, 2), this.safeNumber(ohlcv, 3), this.safeNumber(ohlcv, 4), this.safeNumber(ohlcv, 6)}; + } + + public override object parseTrade(object trade, object market = null) + { + object timestamp = this.parseDate(this.safeString(trade, "created_at")); + object price = this.safeString(trade, "price"); + object amount = this.safeString(trade, "volume", this.safeString(trade, "quantity")); + object privateSideField = this.safeStringLower(trade, "side"); + object side = this.safeStringLower(trade, "taker_side", privateSideField); + object cost = Precise.stringMul(price, amount); + object fee = new Dictionary() { + { "currency", this.safeSymbol(this.safeString(trade, "fee_currency_symbol")) }, + { "cost", this.safeNumber(trade, "fee") }, + { "rate", null }, + }; + return this.safeTrade(new Dictionary() { + { "id", this.safeString(trade, "id") }, + { "info", trade }, + { "timestamp", timestamp }, + { "datetime", this.iso8601(timestamp) }, + { "symbol", getValue(market, "symbol") }, + { "order", null }, + { "type", null }, + { "side", side }, + { "takerOrMaker", null }, + { "price", price }, + { "amount", amount }, + { "cost", cost }, + { "fee", fee }, + }, market); + } + + public virtual object parseOrderStatus(object status) + { + object statuses = new Dictionary() { + { "PARTIALLY_CANCELED", "open" }, + { "ACTIVE", "open" }, + { "PARTIALLY_FILLED", "open" }, + { "FILLED", "closed" }, + { "PENDING_CANCEL", "canceled" }, + { "CANCELED", "canceled" }, + }; + return this.safeString(statuses, status, status); + } + + public override object parseOrder(object order, object market = null) + { + object symbol = this.safeString(order, "market_symbol"); + if (isTrue(isTrue(isEqual(market, null)) && isTrue(!isEqual(symbol, null)))) + { + market = this.market(symbol); + } + if (isTrue(!isEqual(market, null))) + { + symbol = getValue(market, "symbol"); + } + object timestamp = this.parseDate(this.safeString(order, "created_at")); + object price = this.safeString(order, "price"); + object filled = this.safeString(order, "quantity_executed"); + object remaining = this.safeString(order, "quantity"); + // TODO: validate logic of amount here, should this be calculated? + object amount = null; + if (isTrue(isTrue(!isEqual(remaining, null)) && isTrue(!isEqual(filled, null)))) + { + amount = Precise.stringAdd(remaining, filled); + } + object cost = this.safeString(order, "funds_received"); + if (!isTrue(cost)) + { + object priceAverage = this.safeString(order, "price_avg"); + object priceToCalculate = this.safeString(order, "price", priceAverage); + cost = Precise.stringMul(priceToCalculate, amount); + } + object side = this.safeStringLower(order, "side"); + object feeCurrency = this.safeStringUpper(market, "quoteId"); + if (isTrue(isEqual(side, "buy"))) + { + feeCurrency = this.safeStringUpper(market, "baseId"); + } + return this.safeOrder(new Dictionary() { + { "id", this.safeString(order, "id") }, + { "info", order }, + { "clientOrderId", this.safeString(order, "client_order_id") }, + { "timestamp", timestamp }, + { "datetime", this.iso8601(timestamp) }, + { "lastTradeTimestamp", null }, + { "status", this.parseOrderStatus(this.safeString(order, "state")) }, + { "symbol", this.safeString(market, "symbol") }, + { "type", this.safeString(order, "type") }, + { "timeInForce", this.safeString(order, "time_in_force") }, + { "postOnly", this.safeBool(order, "post_only") }, + { "reduceOnly", null }, + { "side", side }, + { "price", this.parseNumber(price) }, + { "triggerPrice", this.safeNumber(order, "stop_price") }, + { "takeProfitPrice", null }, + { "stopLossPrice", null }, + { "cost", this.parseNumber(cost) }, + { "average", this.safeNumber(order, "price_avg") }, + { "amount", this.parseNumber(amount) }, + { "filled", this.parseNumber(filled) }, + { "remaining", this.parseNumber(remaining) }, + { "trades", null }, + { "fee", new Dictionary() { + { "currency", feeCurrency }, + { "cost", this.safeNumber(order, "fee_paid") }, + } }, + }); + } + + public override object parseDepositAddress(object depositAddress, object currency = null) + { + object network = this.safeDict(depositAddress, "network"); + object networkId = this.safeString(network, "code"); + object currencyCode = this.safeCurrencyCode(null, currency); + object unifiedNetwork = this.networkIdToCode(networkId, currencyCode); + return new Dictionary() { + { "address", this.safeString(depositAddress, "address") }, + { "tag", this.safeString(depositAddress, "tag") }, + { "currency", currencyCode }, + { "network", unifiedNetwork }, + { "info", depositAddress }, + }; + } + + public virtual object parseTransactionStatus(object status) + { + object statuses = new Dictionary() { + { "SUBMITTING", "pending" }, + { "SUBMITTED", "pending" }, + { "REJECTED", "failed" }, + { "CANCELLED", "canceled" }, + { "ACCEPTED", "ok" }, + { "WARNING", "pending" }, + { "UNBLOCKED", "pending" }, + { "BLOCKED", "pending" }, + { "PROCESSING", "pending" }, + { "CANCELED", "canceled" }, + { "FAILED", "failed" }, + { "DONE", "ok" }, + }; + return this.safeString(statuses, status, status); + } + + public override object parseTransaction(object transaction, object currency = null) + { + object cryptoDetails = this.safeDict(transaction, "details_crypto"); + object address = this.safeString2(cryptoDetails, "receiving_address", "destination_address"); + object sn = this.safeString(transaction, "sn"); + object type = "withdrawal"; + if (isTrue(isTrue(!isEqual(sn, null)) && isTrue(isEqual(getValue(sn, 0), "D")))) + { + type = "deposit"; + } + object fee = this.safeString(transaction, "fee", "0"); + object amount = this.safeString(transaction, "amount"); + object currencySymbol = this.safeString(transaction, "currency_symbol"); + object actualAmount = amount; + object currencyCode = this.safeCurrencyCode(currencySymbol); + object status = this.parseTransactionStatus(this.safeString(transaction, "state")); + object created_at = this.safeString(transaction, "created_at"); + object timestamp = this.parseDate(created_at); + object datetime = this.iso8601(timestamp); + if (isTrue(isTrue(!isEqual(fee, null)) && isTrue(!isEqual(amount, null)))) + { + // actualAmount = amount - fee; + actualAmount = Precise.stringSub(amount, fee); + } + object feeRate = Precise.stringDiv(fee, actualAmount); + object feeObj = new Dictionary() { + { "cost", this.parseNumber(fee) }, + { "currency", currencyCode }, + { "rate", this.parseNumber(feeRate) }, + }; + return new Dictionary() { + { "info", transaction }, + { "id", this.safeString(transaction, "sn") }, + { "txid", this.safeString(cryptoDetails, "transaction_id") }, + { "timestamp", timestamp }, + { "datetime", datetime }, + { "network", this.safeString(transaction, "network_code") }, + { "address", address }, + { "addressTo", address }, + { "addressFrom", null }, + { "tag", this.safeString(transaction, "destination_tag") }, + { "tagTo", this.safeString(transaction, "destination_tag") }, + { "tagFrom", null }, + { "type", type }, + { "amount", this.parseNumber(amount) }, + { "currency", currencyCode }, + { "status", status }, + { "updated", null }, + { "fee", feeObj }, + { "comment", null }, + { "internal", null }, + }; + } + + public virtual object parseLedgerEntryType(object type) + { + object types = new Dictionary() { + { "DEPOSITING", "transaction" }, + { "WITHDRAWING", "transaction" }, + { "TRADING", "trade" }, + { "INTERNAL_TRANSFERING", "transfer" }, + { "OTHERS", "transaction" }, + }; + return this.safeString(types, type, type); + } + + public override object parseLedgerEntry(object item, object currency = null) + { + // { + // "uuid": "f8e9f2d6-3c1e-4f2d-8f8e-9f2d6c1e4f2d", + // "amount": "0.0001", + // "balance": "0.0002", + // "created_at": "2021-07-01T12:00:00Z", + // "currency_symbol": "btc", + // "fee": "0.0001", + // "locked": "0.0001", + // "locked_amount": "0.0001", + // "reason_type": "DEPOSITING" + // } + object id = this.safeString(item, "uuid"); + object createdAt = this.safeString(item, "created_at"); + object timestamp = this.parse8601(createdAt); + object reasonType = this.safeString(item, "reason_type"); + object type = this.parseLedgerEntryType(reasonType); + object exchangeSymbol = this.safeString(item, "currency_symbol"); + object currencySymbol = this.safeCurrencyCode(exchangeSymbol); + object direction = "in"; + object amount = this.safeNumber(item, "amount"); + object realAmount = amount; + object balance = this.safeNumber(item, "balance"); + object fee = new Dictionary() { + { "cost", this.safeNumber(item, "fee") }, + { "currency", currencySymbol }, + }; + if (isTrue(isLessThan(amount, 0))) + { + direction = "out"; + realAmount = multiply(amount, -1); + } + return new Dictionary() { + { "id", id }, + { "info", item }, + { "timestamp", timestamp }, + { "datetime", this.iso8601(timestamp) }, + { "direction", direction }, + { "account", null }, + { "referenceId", null }, + { "referenceAccount", null }, + { "type", type }, + { "currency", currencySymbol }, + { "amount", realAmount }, + { "before", subtract(balance, amount) }, + { "after", balance }, + { "status", "ok" }, + { "fee", fee }, + }; + } + + public override object sign(object path, object api = null, object method = null, object parameters = null, object headers = null, object body = null) + { + api ??= new List(); + method ??= "GET"; + parameters ??= new Dictionary(); + object version = getValue(api, 0); + object urlPath = getValue(api, 1); + object fullPath = add(add(add("/rest/", version), "/"), this.implodeParams(path, parameters)); + if (isTrue(isEqual(version, "status"))) + { + fullPath = "/status"; + urlPath = "status"; + } + object url = add(getValue(getValue(this.urls, "api"), urlPath), fullPath); + parameters = this.omit(parameters, this.extractParams(path)); + object timestamp = this.milliseconds(); + object query = ""; + object signatureQuery = ""; + if (isTrue(isEqual(method, "GET"))) + { + object paramKeys = new List(((IDictionary)parameters).Keys); + object paramKeysLength = getArrayLength(paramKeys); + if (isTrue(isGreaterThan(paramKeysLength, 0))) + { + query = this.urlencode(parameters); + url = add(url, add("?", query)); + } + for (object i = 0; isLessThan(i, getArrayLength(paramKeys)); postFixIncrement(ref i)) + { + object key = getValue(paramKeys, i); + object value = this.safeString(parameters, key); + if (isTrue(!isEqual(value, null))) + { + signatureQuery = add(signatureQuery, add(add(key, "="), value)); + } + if (isTrue(isLessThan(i, subtract(paramKeysLength, 1)))) + { + signatureQuery = add(signatureQuery, "&"); + } + } + } + if (isTrue(isTrue(isEqual(method, "POST")) || isTrue(isEqual(method, "PUT")))) + { + body = this.json(parameters); + } + object bodyToSignature = ""; + if (isTrue(!isEqual(body, null))) + { + bodyToSignature = body; + } + headers = new Dictionary() { + { "Content-Type", "application/json" }, + }; + if (isTrue(isEqual(urlPath, "private"))) + { + this.checkRequiredCredentials(); + object preHash = add(add(add(add(this.numberToString(timestamp), method), fullPath), signatureQuery), bodyToSignature); + object signature = this.hmac(this.encode(preHash), this.encode(this.secret), sha256, "hex"); + ((IDictionary)headers)["X-FB-ACCESS-KEY"] = this.apiKey; + ((IDictionary)headers)["X-FB-ACCESS-TIMESTAMP"] = this.numberToString(timestamp); + ((IDictionary)headers)["X-FB-ACCESS-SIGNATURE"] = signature; + } + return new Dictionary() { + { "url", url }, + { "method", method }, + { "body", body }, + { "headers", headers }, + }; + } + + public override object handleErrors(object httpCode, object reason, object url, object method, object headers, object body, object response, object requestHeaders, object requestBody) + { + if (isTrue(isEqual(response, null))) + { + return null; + } + object error = this.safeDict(response, "error"); + object code = this.safeString(error, "code"); + object details = this.safeList(error, "details"); + object message = this.safeString(error, "message"); + object detailsString = ""; + if (isTrue(details)) + { + for (object i = 0; isLessThan(i, getArrayLength(details)); postFixIncrement(ref i)) + { + detailsString = add(add(detailsString, getValue(details, i)), " "); + } + } + if (isTrue(!isEqual(error, null))) + { + object feedback = add(add(add(add(this.id, " "), message), " details: "), detailsString); + this.throwBroadlyMatchedException(getValue(this.exceptions, "broad"), message, feedback); + this.throwBroadlyMatchedException(getValue(this.exceptions, "broad"), detailsString, feedback); + this.throwExactlyMatchedException(getValue(this.exceptions, "exact"), code, feedback); + throw new ExchangeError ((string)feedback) ; + } + return null; + } +} diff --git a/cs/ccxt/exchanges/gate.cs b/cs/ccxt/exchanges/gate.cs index 8844148a3cd65..73a871a01fa37 100644 --- a/cs/ccxt/exchanges/gate.cs +++ b/cs/ccxt/exchanges/gate.cs @@ -4108,7 +4108,7 @@ public async override Task fetchDeposits(object code = null, object sinc ((IDictionary)request)["from"] = start; ((IDictionary)request)["to"] = this.sum(start, multiply(multiply(multiply(30, 24), 60), 60)); } - var requestparametersVariable = this.handleUntilOption("to", request, parameters); + var requestparametersVariable = this.handleUntilOption("to", request, parameters, 0.001); request = ((IList)requestparametersVariable)[0]; parameters = ((IList)requestparametersVariable)[1]; object response = await this.privateWalletGetDeposits(this.extend(request, parameters)); diff --git a/cs/ccxt/exchanges/hashkey.cs b/cs/ccxt/exchanges/hashkey.cs index 323bd91bb6d2e..7877a60a2ca73 100644 --- a/cs/ccxt/exchanges/hashkey.cs +++ b/cs/ccxt/exchanges/hashkey.cs @@ -23,11 +23,15 @@ public override object describe() { "future", false }, { "option", false }, { "addMargin", false }, + { "borrowCrossMargin", false }, + { "borrowIsolatedMargin", false }, + { "borrowMargin", false }, { "cancelAllOrders", true }, { "cancelAllOrdersAfter", false }, { "cancelOrder", true }, { "cancelOrders", true }, { "cancelWithdraw", false }, + { "closeAllPositions", false }, { "closePosition", false }, { "createConvertTrade", false }, { "createDepositAddress", false }, @@ -47,7 +51,14 @@ public override object describe() { "createTrailingPercentOrder", false }, { "createTriggerOrder", true }, { "fetchAccounts", true }, + { "fetchAllGreeks", false }, { "fetchBalance", true }, + { "fetchBorrowInterest", false }, + { "fetchBorrowRate", false }, + { "fetchBorrowRateHistories", false }, + { "fetchBorrowRateHistory", false }, + { "fetchBorrowRates", false }, + { "fetchBorrowRatesPerSymbol", false }, { "fetchCanceledAndClosedOrders", true }, { "fetchCanceledOrders", true }, { "fetchClosedOrder", true }, @@ -56,6 +67,8 @@ public override object describe() { "fetchConvertQuote", false }, { "fetchConvertTrade", false }, { "fetchConvertTradeHistory", false }, + { "fetchCrossBorrowRate", false }, + { "fetchCrossBorrowRates", false }, { "fetchCurrencies", true }, { "fetchDepositAddress", true }, { "fetchDepositAddresses", false }, @@ -63,23 +76,42 @@ public override object describe() { "fetchDeposits", true }, { "fetchDepositsWithdrawals", false }, { "fetchFundingHistory", false }, + { "fetchFundingInterval", false }, + { "fetchFundingIntervals", false }, { "fetchFundingRate", true }, { "fetchFundingRateHistory", true }, { "fetchFundingRates", true }, + { "fetchGreeks", false }, { "fetchIndexOHLCV", false }, + { "fetchIsolatedBorrowRate", false }, + { "fetchIsolatedBorrowRates", false }, + { "fetchIsolatedPositions", false }, { "fetchLedger", true }, { "fetchLeverage", true }, + { "fetchLeverages", false }, { "fetchLeverageTiers", true }, + { "fetchLiquidations", false }, + { "fetchLongShortRatio", false }, + { "fetchLongShortRatioHistory", false }, { "fetchMarginAdjustmentHistory", false }, { "fetchMarginMode", false }, + { "fetchMarginModes", false }, { "fetchMarketLeverageTiers", "emulated" }, { "fetchMarkets", true }, { "fetchMarkOHLCV", false }, + { "fetchMarkPrice", false }, + { "fetchMarkPrices", false }, + { "fetchMyLiquidations", false }, + { "fetchMySettlementHistory", false }, { "fetchMyTrades", true }, { "fetchOHLCV", true }, + { "fetchOpenInterest", false }, { "fetchOpenInterestHistory", false }, + { "fetchOpenInterests", false }, { "fetchOpenOrder", false }, { "fetchOpenOrders", true }, + { "fetchOption", false }, + { "fetchOptionChain", false }, { "fetchOrder", true }, { "fetchOrderBook", true }, { "fetchOrders", false }, @@ -90,7 +122,9 @@ public override object describe() { "fetchPositions", true }, { "fetchPositionsForSymbol", true }, { "fetchPositionsHistory", false }, + { "fetchPositionsRisk", false }, { "fetchPremiumIndexOHLCV", false }, + { "fetchSettlementHistory", false }, { "fetchStatus", true }, { "fetchTicker", true }, { "fetchTickers", true }, @@ -100,11 +134,16 @@ public override object describe() { "fetchTradingFees", true }, { "fetchTransactions", false }, { "fetchTransfers", false }, + { "fetchUnderlyingAssets", false }, + { "fetchVolatilityHistory", false }, { "fetchWithdrawals", true }, { "reduceMargin", false }, + { "repayCrossMargin", false }, + { "repayIsolatedMargin", false }, { "sandbox", false }, { "setLeverage", true }, { "setMargin", false }, + { "setMarginMode", false }, { "setPositionMode", false }, { "transfer", true }, { "withdraw", true }, diff --git a/cs/ccxt/exchanges/htx.cs b/cs/ccxt/exchanges/htx.cs index 9bae65cb85f7f..71e737995536a 100644 --- a/cs/ccxt/exchanges/htx.cs +++ b/cs/ccxt/exchanges/htx.cs @@ -7398,13 +7398,20 @@ public async override Task fetchFundingRateHistory(object symbol = null, parameters = ((IList)paginateparametersVariable)[1]; if (isTrue(paginate)) { - return await this.fetchPaginatedCallCursor("fetchFundingRateHistory", symbol, since, limit, parameters, "page_index", "current_page", 1, 50); + return await this.fetchPaginatedCallCursor("fetchFundingRateHistory", symbol, since, limit, parameters, "current_page", "page_index", 1, 50); } await this.loadMarkets(); object market = this.market(symbol); object request = new Dictionary() { { "contract_code", getValue(market, "id") }, }; + if (isTrue(!isEqual(limit, null))) + { + ((IDictionary)request)["page_size"] = limit; + } else + { + ((IDictionary)request)["page_size"] = 50; // max + } object response = null; if (isTrue(getValue(market, "inverse"))) { diff --git a/cs/ccxt/exchanges/hyperliquid.cs b/cs/ccxt/exchanges/hyperliquid.cs index 1effea3fd2304..a59736a942699 100644 --- a/cs/ccxt/exchanges/hyperliquid.cs +++ b/cs/ccxt/exchanges/hyperliquid.cs @@ -155,6 +155,7 @@ public override object describe() { "orderStatus", 2 }, { "spotClearinghouseState", 2 }, { "exchangeStatus", 2 }, + { "candleSnapshot", 4 }, } }, } }, } }, @@ -338,6 +339,10 @@ public override void setSandboxMode(object enabled) public async override Task fetchCurrencies(object parameters = null) { parameters ??= new Dictionary(); + if (isTrue(this.checkRequiredCredentials(false))) + { + await this.handleBuilderFeeApproval(); + } object request = new Dictionary() { { "type", "meta" }, }; @@ -633,6 +638,7 @@ public async virtual Task fetchSpotMarkets(object parameters = null) { "quote", quote }, { "settle", null }, { "baseId", baseId }, + { "baseName", baseName }, { "quoteId", quoteId }, { "settleId", null }, { "type", "spot" }, @@ -746,6 +752,7 @@ public override object parseMarket(object market) { "quote", quote }, { "settle", settle }, { "baseId", baseId }, + { "baseName", baseName }, { "quoteId", quoteId }, { "settleId", settleId }, { "type", "swap" }, @@ -802,6 +809,7 @@ public override object parseMarket(object market) * @param {string} [params.user] user address, will default to this.walletAddress if not provided * @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} */ public async override Task fetchBalance(object parameters = null) @@ -820,9 +828,8 @@ public async override Task fetchBalance(object parameters = null) marginMode = ((IList)marginModeparametersVariable)[0]; parameters = ((IList)marginModeparametersVariable)[1]; object isSpot = (isEqual(type, "spot")); - object reqType = ((bool) isTrue((isSpot))) ? "spotClearinghouseState" : "clearinghouseState"; object request = new Dictionary() { - { "type", reqType }, + { "type", ((bool) isTrue((isSpot))) ? "spotClearinghouseState" : "clearinghouseState" }, { "user", userAddress }, }; object response = await this.publicPostInfo(this.extend(request, parameters)); @@ -918,7 +925,7 @@ public async override Task fetchOrderBook(object symbol, object limit = object market = this.market(symbol); object request = new Dictionary() { { "type", "l2Book" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, }; object response = await this.publicPostInfo(this.extend(request, parameters)); // @@ -1175,7 +1182,7 @@ public async override Task fetchOHLCV(object symbol, object timeframe = object request = new Dictionary() { { "type", "candleSnapshot" }, { "req", new Dictionary() { - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, { "interval", this.safeString(this.timeframes, timeframe, timeframe) }, { "startTime", since }, { "endTime", until }, @@ -1233,6 +1240,7 @@ public override object parseOHLCV(object ohlcv, object market = null) * @param {int} [params.until] timestamp in ms of the latest trade * @param {string} [params.address] wallet address that made trades * @param {string} [params.user] wallet address that made trades + * @param {string} [params.subAccountAddress] sub account user address * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} */ public async override Task fetchTrades(object symbol, object since = null, object limit = null, object parameters = null) @@ -1474,6 +1482,87 @@ public virtual object buildWithdrawSig(object message) return this.signUserSignedAction(messageTypes, message); } + public virtual object buildApproveBuilderFeeSig(object message) + { + object messageTypes = new Dictionary() { + { "HyperliquidTransaction:ApproveBuilderFee", new List() {new Dictionary() { + { "name", "hyperliquidChain" }, + { "type", "string" }, +}, new Dictionary() { + { "name", "maxFeeRate" }, + { "type", "string" }, +}, new Dictionary() { + { "name", "builder" }, + { "type", "address" }, +}, new Dictionary() { + { "name", "nonce" }, + { "type", "uint64" }, +}} }, + }; + return this.signUserSignedAction(messageTypes, message); + } + + public async virtual Task approveBuilderFee(object builder, object maxFeeRate) + { + object nonce = this.milliseconds(); + object isSandboxMode = this.safeBool(this.options, "sandboxMode", false); + object payload = new Dictionary() { + { "hyperliquidChain", ((bool) isTrue(isSandboxMode)) ? "Testnet" : "Mainnet" }, + { "maxFeeRate", maxFeeRate }, + { "builder", builder }, + { "nonce", nonce }, + }; + object sig = this.buildApproveBuilderFeeSig(payload); + object action = new Dictionary() { + { "hyperliquidChain", getValue(payload, "hyperliquidChain") }, + { "signatureChainId", "0x66eee" }, + { "maxFeeRate", getValue(payload, "maxFeeRate") }, + { "builder", getValue(payload, "builder") }, + { "nonce", nonce }, + { "type", "approveBuilderFee" }, + }; + object request = new Dictionary() { + { "action", action }, + { "nonce", nonce }, + { "signature", sig }, + { "vaultAddress", null }, + }; + // + // { + // "status": "ok", + // "response": { + // "type": "default" + // } + // } + // + return await this.privatePostExchange(request); + } + + public async virtual Task handleBuilderFeeApproval() + { + object buildFee = this.safeBool(this.options, "builderFee", true); + if (!isTrue(buildFee)) + { + return false; // skip if builder fee is not enabled + } + object approvedBuilderFee = this.safeBool(this.options, "approvedBuilderFee", false); + if (isTrue(approvedBuilderFee)) + { + return true; // skip if builder fee is already approved + } + try + { + object builder = this.safeString(this.options, "builder", "0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6"); + object maxFeeRate = this.safeString(this.options, "feeRate", "0.01%"); + await this.approveBuilderFee(builder, maxFeeRate); + ((IDictionary)this.options)["approvedBuilderFee"] = true; + } catch(Exception e) + { + ((IDictionary)this.options)["builderFee"] = false; // disable builder fee if an error occurs + } + return true; + } + /** * @method * @name hyperliquid#createOrder @@ -1492,6 +1581,7 @@ public virtual object buildWithdrawSig(object message) * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.slippage] the slippage for market order * @param {string} [params.vaultAddress] the vault address for order + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task createOrder(object symbol, object type, object side, object amount, object price = null, object parameters = null) @@ -1518,6 +1608,7 @@ public async override Task createOrders(object orders, object parameters { parameters ??= new Dictionary(); await this.loadMarkets(); + await this.handleBuilderFeeApproval(); object request = this.createOrdersRequest(orders, parameters); object response = await this.privatePostExchange(request); // @@ -1727,9 +1818,13 @@ public virtual object createOrdersRequest(object orders, object parameters = nul { "orders", orderReq }, { "grouping", grouping }, }; - if (isTrue(isEqual(vaultAddress, null))) + if (isTrue(this.safeBool(this.options, "approvedBuilderFee", false))) { - ((IDictionary)orderAction)["brokerCode"] = 1; + object wallet = this.safeStringLower(this.options, "builder", "0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6"); + ((IDictionary)orderAction)["builder"] = new Dictionary() { + { "b", wallet }, + { "f", this.safeInteger(this.options, "feeInt", 10) }, + }; } object signature = this.signL1Action(orderAction, nonce, vaultAddress); object request = new Dictionary() { @@ -1756,6 +1851,7 @@ public virtual object createOrdersRequest(object orders, object parameters = nul * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.vaultAddress] the vault address for order + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task cancelOrder(object id, object symbol = null, object parameters = null) @@ -1776,6 +1872,7 @@ public async override Task cancelOrder(object id, object symbol = null, * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async virtual Task cancelOrders(object ids, object symbol = null, object parameters = null) @@ -1827,7 +1924,7 @@ public async virtual Task cancelOrders(object ids, object symbol = null, } ((IDictionary)cancelAction)["cancels"] = cancelReq; object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "cancelOrders", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "cancelOrders", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; vaultAddress = this.formatVaultAddress(vaultAddress); @@ -1877,6 +1974,7 @@ public async virtual Task cancelOrders(object ids, object symbol = null, * @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}] * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task cancelOrdersForSymbols(object orders, object parameters = null) @@ -1923,7 +2021,7 @@ public async override Task cancelOrdersForSymbols(object orders, object ((IDictionary)cancelAction)["type"] = ((bool) isTrue(cancelByCloid)) ? "cancelByCloid" : "cancel"; ((IDictionary)cancelAction)["cancels"] = cancelReq; object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "cancelOrdersForSymbols", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "cancelOrdersForSymbols", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; vaultAddress = this.formatVaultAddress(vaultAddress); @@ -1949,7 +2047,9 @@ public async override Task cancelOrdersForSymbols(object orders, object // } // } // - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** @@ -1959,6 +2059,7 @@ public async override Task cancelOrdersForSymbols(object orders, object * @param {number} timeout time in milliseconds, 0 represents cancel the timer * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} the api result */ public async override Task cancelAllOrdersAfter(object timeout, object parameters = null) @@ -1976,7 +2077,7 @@ public async override Task cancelAllOrdersAfter(object timeout, object p { "time", add(nonce, timeout) }, }; object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "cancelAllOrdersAfter", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "cancelAllOrdersAfter", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; vaultAddress = this.formatVaultAddress(vaultAddress); @@ -2155,6 +2256,7 @@ public virtual object editOrdersRequest(object orders, object parameters = null) * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.vaultAddress] the vault address for order + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task editOrder(object id, object symbol, object type, object side, object amount = null, object price = null, object parameters = null) @@ -2294,7 +2396,7 @@ public async override Task fetchFundingRateHistory(object symbol = null, object market = this.market(symbol); object request = new Dictionary() { { "type", "fundingHistory" }, - { "coin", getValue(market, "base") }, + { "coin", getValue(market, "baseName") }, }; if (isTrue(!isEqual(since, null))) { @@ -2349,6 +2451,7 @@ public async override Task fetchFundingRateHistory(object symbol = null, * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided * @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders' + * @param {string} [params.subAccountAddress] sub account user address * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task fetchOpenOrders(object symbol = null, object since = null, object limit = null, object parameters = null) @@ -2465,6 +2568,7 @@ public async override Task fetchCanceledAndClosedOrders(object symbol = * @param {int} [limit] the maximum number of open orders structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task fetchOrders(object symbol = null, object since = null, object limit = null, object parameters = null) @@ -2506,6 +2610,7 @@ public async override Task fetchOrders(object symbol = null, object sinc * @param {string} symbol unified symbol of the market the order was made in * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ public async override Task fetchOrder(object id, object symbol = null, object parameters = null) @@ -2755,6 +2860,7 @@ public virtual object parseOrderType(object status) * @param {int} [limit] the maximum number of trades structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] timestamp in ms of the latest trade + * @param {string} [params.subAccountAddress] sub account user address * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} */ public async override Task fetchMyTrades(object symbol = null, object since = null, object limit = null, object parameters = null) @@ -2894,6 +3000,7 @@ public async override Task fetchPosition(object symbol, object parameter * @param {string[]} [symbols] list of unified market symbols * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} */ public async override Task fetchPositions(object symbols = null, object parameters = null) @@ -3047,6 +3154,8 @@ public override object parsePosition(object position, object market = null) * @param {string} symbol unified market symbol of the market the position is held in, default is undefined * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.leverage] the rate of leverage, is required if setting trade mode (symbol) + * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} response from the exchange */ public async override Task setMarginMode(object marginMode, object symbol = null, object parameters = null) @@ -3074,7 +3183,7 @@ public async override Task setMarginMode(object marginMode, object symbo { "leverage", leverage }, }; object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "setMarginMode", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "setMarginMode", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; if (isTrue(!isEqual(vaultAddress, null))) @@ -3137,7 +3246,7 @@ public async override Task setLeverage(object leverage, object symbol = { "leverage", leverage }, }; object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "setLeverage", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "setLeverage", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; vaultAddress = this.formatVaultAddress(vaultAddress); @@ -3172,6 +3281,8 @@ public async override Task setLeverage(object leverage, object symbol = * @param {string} symbol unified market symbol * @param {float} amount amount of margin to add * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure} */ public async override Task addMargin(object symbol, object amount, object parameters = null) @@ -3188,6 +3299,8 @@ public async override Task addMargin(object symbol, object amount, objec * @param {string} symbol unified market symbol * @param {float} amount the amount of margin to remove * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure} */ public async override Task reduceMargin(object symbol, object amount, object parameters = null) @@ -3215,7 +3328,7 @@ public async virtual Task modifyMarginHelper(object symbol, object amoun { "ntli", sz }, }; object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "modifyMargin", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "modifyMargin", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; vaultAddress = this.formatVaultAddress(vaultAddress); @@ -3328,8 +3441,7 @@ public async override Task transfer(object code, object amount, object f object transferResponse = await this.privatePostExchange(transferRequest); return transferResponse; } - // handle sub-account/different account transfer - this.checkAddress(toAccount); + // transfer between main account and subaccount if (isTrue(!isEqual(code, null))) { code = ((string)code).ToUpper(); @@ -3338,22 +3450,30 @@ public async override Task transfer(object code, object amount, object f throw new NotSupported ((string)add(this.id, " transfer() only support USDC")) ; } } - object payload = new Dictionary() { - { "hyperliquidChain", ((bool) isTrue(isSandboxMode)) ? "Testnet" : "Mainnet" }, - { "destination", toAccount }, - { "amount", this.numberToString(amount) }, - { "time", nonce }, + object isDeposit = false; + object subAccountAddress = null; + if (isTrue(isEqual(fromAccount, "main"))) + { + subAccountAddress = toAccount; + isDeposit = true; + } else if (isTrue(isEqual(toAccount, "main"))) + { + subAccountAddress = fromAccount; + } else + { + throw new NotSupported ((string)add(this.id, " transfer() only support main <> subaccount transfer")) ; + } + this.checkAddress(subAccountAddress); + object usd = this.parseToInt(Precise.stringMul(this.numberToString(amount), "1000000")); + object action = new Dictionary() { + { "type", "subAccountTransfer" }, + { "subAccountUser", subAccountAddress }, + { "isDeposit", isDeposit }, + { "usd", usd }, }; - object sig = this.buildUsdSendSig(payload); + object sig = this.signL1Action(action, nonce); object request = new Dictionary() { - { "action", new Dictionary() { - { "hyperliquidChain", getValue(payload, "hyperliquidChain") }, - { "signatureChainId", "0x66eee" }, - { "destination", toAccount }, - { "amount", ((object)amount).ToString() }, - { "time", nonce }, - { "type", "usdSend" }, - } }, + { "action", action }, { "nonce", nonce }, { "signature", sig }, }; @@ -3520,6 +3640,7 @@ public override object parseTransaction(object transaction, object currency = nu * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure} */ public async override Task fetchTradingFee(object symbol, object parameters = null) @@ -3635,6 +3756,7 @@ public virtual object parseTradingFee(object fee, object market = null) * @param {int} [limit] max number of ledger entries to return * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] timestamp in ms of the latest ledger entry + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger} */ public async override Task fetchLedger(object code = null, object since = null, object limit = null, object parameters = null) @@ -3739,6 +3861,7 @@ public virtual object parseLedgerEntryType(object type) * @param {int} [limit] the maximum number of deposits structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] the latest time in ms to fetch withdrawals for + * @param {string} [params.subAccountAddress] sub account user address * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ public async override Task fetchDeposits(object code = null, object since = null, object limit = null, object parameters = null) @@ -3791,6 +3914,7 @@ public async override Task fetchDeposits(object code = null, object sinc * @param {int} [limit] the maximum number of withdrawals structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] the latest time in ms to fetch withdrawals for + * @param {string} [params.subAccountAddress] sub account user address * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ public async override Task fetchWithdrawals(object code = null, object since = null, object limit = null, object parameters = null) @@ -3913,6 +4037,7 @@ public override object parseOpenInterest(object interest, object market = null) * @param {int} [since] the earliest time in ms to fetch funding history for * @param {int} [limit] the maximum number of funding history structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [funding history structure]{@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) @@ -4029,7 +4154,7 @@ public virtual object formatVaultAddress(object address = null) public virtual object handlePublicAddress(object methodName, object parameters) { object userAux = null; - var userAuxparametersVariable = this.handleOptionAndParams(parameters, methodName, "user"); + var userAuxparametersVariable = this.handleOptionAndParams2(parameters, methodName, "user", "subAccountAddress"); userAux = ((IList)userAuxparametersVariable)[0]; parameters = ((IList)userAuxparametersVariable)[1]; object user = userAux; @@ -4053,7 +4178,7 @@ public virtual object coinToMarketId(object coin) { return coin; // spot } - return add(coin, "/USDC:USDC"); + return add(this.safeCurrencyCode(coin), "/USDC:USDC"); } public override object handleErrors(object code, object reason, object url, object method, object headers, object body, object response, object requestHeaders, object requestBody) @@ -4142,7 +4267,7 @@ public virtual object parseCreateEditOrderArgs(object id, object symbol, object parameters ??= new Dictionary(); object market = this.market(symbol); object vaultAddress = null; - var vaultAddressparametersVariable = this.handleOptionAndParams(parameters, "createOrder", "vaultAddress"); + var vaultAddressparametersVariable = this.handleOptionAndParams2(parameters, "createOrder", "vaultAddress", "subAccountAddress"); vaultAddress = ((IList)vaultAddressparametersVariable)[0]; parameters = ((IList)vaultAddressparametersVariable)[1]; vaultAddress = this.formatVaultAddress(vaultAddress); diff --git a/cs/ccxt/exchanges/kucoin.cs b/cs/ccxt/exchanges/kucoin.cs index 4348eede74910..68148c5bbbb9a 100644 --- a/cs/ccxt/exchanges/kucoin.cs +++ b/cs/ccxt/exchanges/kucoin.cs @@ -2633,7 +2633,7 @@ public async override Task cancelAllOrders(object symbol = null, object parameters ??= new Dictionary(); await this.loadMarkets(); object request = new Dictionary() {}; - object trigger = this.safeBool(parameters, "stop", false); + object trigger = this.safeBool2(parameters, "trigger", "stop", false); object hf = null; var hfparametersVariable = this.handleHfAndParams(parameters); hf = ((IList)hfparametersVariable)[0]; @@ -2671,7 +2671,9 @@ public async override Task cancelAllOrders(object symbol = null, object { response = await this.privateDeleteOrders(this.extend(request, query)); } - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/kucoinfutures.cs b/cs/ccxt/exchanges/kucoinfutures.cs index bf9ac75febe89..186e9815e7f4d 100644 --- a/cs/ccxt/exchanges/kucoinfutures.cs +++ b/cs/ccxt/exchanges/kucoinfutures.cs @@ -1833,7 +1833,9 @@ public async override Task cancelOrder(object id, object symbol = null, // }, // } // - return this.safeValue(response, "data"); + return this.safeOrder(new Dictionary() { + { "info", response }, + }); } /** @@ -1944,7 +1946,10 @@ public async override Task cancelAllOrders(object symbol = null, object // }, // } // - return this.safeValue(response, "data"); + object data = this.safeDict(response, "data"); + return new List {this.safeOrder(new Dictionary() { + { "info", data }, +})}; } /** @@ -3467,7 +3472,7 @@ public async override Task setMarginMode(object marginMode, object symbo // } // object data = this.safeDict(response, "data", new Dictionary() {}); - return this.parseMarginMode(data, market); + return ((object)this.parseMarginMode(data, market)); } /** diff --git a/cs/ccxt/exchanges/mexc.cs b/cs/ccxt/exchanges/mexc.cs index e23c3d744440a..22da0b18467dc 100644 --- a/cs/ccxt/exchanges/mexc.cs +++ b/cs/ccxt/exchanges/mexc.cs @@ -4827,11 +4827,14 @@ public async override Task fetchDeposits(object code = null, object sinc // "network": "TRX", // "status": "5", // "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh", - // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0", // "insertTime": "1664805021000", // "unlockConfirm": "200", // "confirmTimes": "203", - // "memo": "xxyy1122" + // "memo": "xxyy1122", + // "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "updateTime": "1664805621000", + // "netWork: "TRX" // } // ] // @@ -4877,7 +4880,7 @@ public async override Task fetchWithdrawals(object code = null, object s // [ // { // "id": "adcd1c8322154de691b815eedcd10c42", - // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0", // "coin": "USDC-MATIC", // "network": "MATIC", // "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62", @@ -4888,7 +4891,11 @@ public async override Task fetchWithdrawals(object code = null, object s // "confirmNo": null, // "applyTime": "1664882739000", // "remark": '', - // "memo": null + // "memo": null, + // "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "updateTime": "1664882799000", + // "netWork: "MATIC" // } // ] // @@ -4906,18 +4913,21 @@ public override object parseTransaction(object transaction, object currency = nu // "network": "TRX", // "status": "5", // "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh", - // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0", // "insertTime": "1664805021000", // "unlockConfirm": "200", // "confirmTimes": "203", - // "memo": "xxyy1122" + // "memo": "xxyy1122", + // "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "updateTime": "1664805621000", + // "netWork: "TRX" // } // // fetchWithdrawals // // { // "id": "adcd1c8322154de691b815eedcd10c42", - // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0", // "coin": "USDC-MATIC", // "network": "MATIC", // "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62", @@ -4927,8 +4937,12 @@ public override object parseTransaction(object transaction, object currency = nu // "transactionFee": "1", // "confirmNo": null, // "applyTime": "1664882739000", - // "remark": '', - // "memo": null + // "remark": "", + // "memo": null, + // "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "updateTime": "1664882799000", + // "netWork: "MATIC" // } // // withdraw @@ -4940,6 +4954,7 @@ public override object parseTransaction(object transaction, object currency = nu object id = this.safeString(transaction, "id"); object type = ((bool) isTrue((isEqual(id, null)))) ? "deposit" : "withdrawal"; object timestamp = this.safeInteger2(transaction, "insertTime", "applyTime"); + object updated = this.safeInteger(transaction, "updateTime"); object currencyId = null; object currencyWithNetwork = this.safeString(transaction, "coin"); if (isTrue(!isEqual(currencyWithNetwork, null))) @@ -4956,7 +4971,7 @@ public override object parseTransaction(object transaction, object currency = nu object status = this.parseTransactionStatusByType(this.safeString(transaction, "status"), type); object amountString = this.safeString(transaction, "amount"); object address = this.safeString(transaction, "address"); - object txid = this.safeString(transaction, "txId"); + object txid = this.safeString2(transaction, "transHash", "txId"); object fee = null; object feeCostString = this.safeString(transaction, "transactionFee"); if (isTrue(!isEqual(feeCostString, null))) @@ -4988,8 +5003,8 @@ public override object parseTransaction(object transaction, object currency = nu { "amount", this.parseNumber(amountString) }, { "currency", code }, { "status", status }, - { "updated", null }, - { "comment", null }, + { "updated", updated }, + { "comment", this.safeString(transaction, "remark") }, { "internal", null }, { "fee", fee }, }; @@ -6002,7 +6017,7 @@ public async override Task setMarginMode(object marginMode, object symbo // // { success: true, code: '0' } // - return this.parseLeverage(response, market); + return ((object)this.parseLeverage(response, market)); // tmp revert type } public override object nonce() diff --git a/cs/ccxt/exchanges/modetrade.cs b/cs/ccxt/exchanges/modetrade.cs index 3efa977accd39..3a945238ed842 100644 --- a/cs/ccxt/exchanges/modetrade.cs +++ b/cs/ccxt/exchanges/modetrade.cs @@ -13,7 +13,7 @@ public override object describe() { "countries", new List() {"KY"} }, { "rateLimit", 100 }, { "version", "v1" }, - { "certified", true }, + { "certified", false }, { "pro", true }, { "dex", true }, { "hostname", "trade.mode.network" }, @@ -1895,9 +1895,9 @@ public async override Task cancelAllOrders(object symbol = null, object // } // } // - return new List() {new Dictionary() { + return new List {this.safeOrder(new Dictionary() { { "info", response }, -}}; +})}; } /** diff --git a/cs/ccxt/exchanges/okcoin.cs b/cs/ccxt/exchanges/okcoin.cs index 927c8be69db2b..9ddd4891cefe4 100644 --- a/cs/ccxt/exchanges/okcoin.cs +++ b/cs/ccxt/exchanges/okcoin.cs @@ -1785,7 +1785,7 @@ public async override Task cancelOrder(object id, object symbol = null, if (isTrue(isTrue(trigger) || isTrue(advanced))) { object orderInner = await this.cancelOrders(new List() {id}, symbol, parameters); - return this.safeValue(orderInner, 0); + return this.safeDict(orderInner, 0); } object market = this.market(symbol); object request = new Dictionary() { diff --git a/cs/ccxt/exchanges/okx.cs b/cs/ccxt/exchanges/okx.cs index f8d3a5c5ba61d..654ec265a79dd 100644 --- a/cs/ccxt/exchanges/okx.cs +++ b/cs/ccxt/exchanges/okx.cs @@ -1050,7 +1050,9 @@ public override object describe() } }, { "createOrder", "privatePostTradeBatchOrders" }, { "createMarketBuyOrderRequiresPrice", false }, - { "fetchMarkets", new List() {"spot", "future", "swap", "option"} }, + { "fetchMarkets", new Dictionary() { + { "types", new List() {"spot", "future", "swap", "option"} }, + } }, { "timeDifference", 0 }, { "adjustForTimeDifference", false }, { "defaultType", "spot" }, @@ -1470,7 +1472,15 @@ public async override Task fetchMarkets(object parameters = null) { await this.loadTimeDifference(); } - object types = this.safeList(this.options, "fetchMarkets", new List() {}); + object types = new List() {"spot", "future", "swap", "option"}; + object fetchMarketsOption = this.safeDict(this.options, "fetchMarkets"); + if (isTrue(!isEqual(fetchMarketsOption, null))) + { + types = this.safeList(fetchMarketsOption, "types", types); + } else + { + types = this.safeList(this.options, "fetchMarkets", types); // backward-support + } object promises = new List() {}; object result = new List() {}; for (object i = 0; isLessThan(i, getArrayLength(types)); postFixIncrement(ref i)) @@ -2625,13 +2635,13 @@ public virtual object parseTradingBalance(object response) // it may be incorrect to use total, free and used for swap accounts object eq = this.safeString(balance, "eq"); object availEq = this.safeString(balance, "availEq"); - if (isTrue(isTrue((isEqual(eq, null))) || isTrue((isEqual(availEq, null))))) + ((IDictionary)account)["total"] = eq; + if (isTrue(isEqual(availEq, null))) { ((IDictionary)account)["free"] = this.safeString(balance, "availBal"); ((IDictionary)account)["used"] = this.safeString(balance, "frozenBal"); } else { - ((IDictionary)account)["total"] = eq; ((IDictionary)account)["free"] = availEq; } ((IDictionary)result)[(string)code] = account; @@ -3099,7 +3109,8 @@ public virtual object createOrderRequest(object symbol, object type, object side { throw new InvalidOrder ((string)add(this.id, " createOrder() requires a trigger price in params[\"stopLoss\"][\"triggerPrice\"], or params[\"stopLoss\"][\"stopPrice\"], or params[\"stopLoss\"][\"slTriggerPx\"] for a stop loss order")) ; } - ((IDictionary)request)["slTriggerPx"] = this.priceToPrecision(symbol, stopLossTriggerPrice); + object slTriggerPx = this.priceToPrecision(symbol, stopLossTriggerPrice); + ((IDictionary)request)["slTriggerPx"] = slTriggerPx; object stopLossLimitPrice = this.safeValueN(stopLoss, new List() {"price", "stopLossPrice", "slOrdPx"}); object stopLossOrderType = this.safeString(stopLoss, "type"); if (isTrue(!isEqual(stopLossOrderType, null))) @@ -3204,6 +3215,16 @@ public virtual object createOrderRequest(object symbol, object type, object side { ((IDictionary)request)["ordType"] = "oco"; } + if (isTrue(isEqual(side, "sell"))) + { + request = this.omit(request, "tgtCcy"); + } + if (isTrue(isEqual(this.safeString(request, "tdMode"), "cash"))) + { + // for some reason tdMode = cash throws + // {"code":"1","data":[{"algoClOrdId":"","algoId":"","clOrdId":"","sCode":"51000","sMsg":"Parameter tdMode error ","tag":""}],"msg":""} + ((IDictionary)request)["tdMode"] = marginMode; + } if (isTrue(!isEqual(takeProfitPrice, null))) { ((IDictionary)request)["tpTriggerPx"] = this.priceToPrecision(symbol, takeProfitPrice); @@ -3584,7 +3605,7 @@ public async override Task cancelOrder(object id, object symbol = null, if (isTrue(isTrue(trigger) || isTrue(trailing))) { object orderInner = await this.cancelOrders(new List() {id}, symbol, parameters); - return this.safeValue(orderInner, 0); + return this.safeDict(orderInner, 0); } await this.loadMarkets(); object market = this.market(symbol); diff --git a/cs/ccxt/exchanges/onetrading.cs b/cs/ccxt/exchanges/onetrading.cs index a9e675af395c2..cb9cd6a2b103c 100644 --- a/cs/ccxt/exchanges/onetrading.cs +++ b/cs/ccxt/exchanges/onetrading.cs @@ -1355,7 +1355,9 @@ public async override Task cancelAllOrders(object symbol = null, object // "a10e9bd1-8f72-4cfe-9f1b-7f1c8a9bd8ee" // ] // - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/oxfun.cs b/cs/ccxt/exchanges/oxfun.cs index 4163f3de1b7d6..f7893d3b103c7 100644 --- a/cs/ccxt/exchanges/oxfun.cs +++ b/cs/ccxt/exchanges/oxfun.cs @@ -2816,7 +2816,10 @@ public async override Task cancelAllOrders(object symbol = null, object // "data": { "notice": "No working orders found" } // } // - return await this.privateDeleteV3OrdersCancelAll(this.extend(request, parameters)); + object response = await this.privateDeleteV3OrdersCancelAll(this.extend(request, parameters)); + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/paradex.cs b/cs/ccxt/exchanges/paradex.cs index 95f10ac91c420..f6d0cf79c702a 100644 --- a/cs/ccxt/exchanges/paradex.cs +++ b/cs/ccxt/exchanges/paradex.cs @@ -43,6 +43,7 @@ public override object describe() { "createTriggerOrder", true }, { "editOrder", false }, { "fetchAccounts", false }, + { "fetchAllGreeks", true }, { "fetchBalance", true }, { "fetchBorrowInterest", false }, { "fetchBorrowRateHistories", false }, @@ -62,7 +63,6 @@ public override object describe() { "fetchFundingRateHistory", false }, { "fetchFundingRates", false }, { "fetchGreeks", true }, - { "fetchAllGreeks", true }, { "fetchIndexOHLCV", false }, { "fetchIsolatedBorrowRate", false }, { "fetchIsolatedBorrowRates", false }, @@ -1336,7 +1336,7 @@ public override object parseOrder(object order, object market = null) object status = this.safeString(order, "status"); if (isTrue(!isEqual(cancelReason, null))) { - if (isTrue(isEqual(cancelReason, "NOT_ENOUGH_MARGIN"))) + if (isTrue(isTrue(isEqual(cancelReason, "NOT_ENOUGH_MARGIN")) || isTrue(isEqual(cancelReason, "ORDER_EXCEEDS_POSITION_LIMIT")))) { status = "rejected"; } else @@ -1682,7 +1682,9 @@ public async override Task cancelAllOrders(object symbol = null, object // // if success, no response... // - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** diff --git a/cs/ccxt/exchanges/phemex.cs b/cs/ccxt/exchanges/phemex.cs index c816d31444bf1..60e3be5cf0fed 100644 --- a/cs/ccxt/exchanges/phemex.cs +++ b/cs/ccxt/exchanges/phemex.cs @@ -2873,10 +2873,10 @@ public async override Task createOrder(object symbol, object type, objec parameters = ((IList)triggerDirectionparametersVariable)[1]; if (isTrue(isEqual(triggerDirection, null))) { - throw new ArgumentsRequired ((string)add(this.id, " createOrder() also requires a 'triggerDirection' parameter with either 'up' or 'down' value")) ; + throw new ArgumentsRequired ((string)add(this.id, " createOrder() also requires a 'triggerDirection' parameter with either 'ascending' or 'descending' value")) ; } // the flow defined per https://phemex-docs.github.io/#more-order-type-examples - if (isTrue(isEqual(triggerDirection, "up"))) + if (isTrue(isTrue(isEqual(triggerDirection, "ascending")) || isTrue(isEqual(triggerDirection, "up")))) { if (isTrue(isEqual(side, "sell"))) { @@ -2885,7 +2885,7 @@ public async override Task createOrder(object symbol, object type, objec { ((IDictionary)request)["ordType"] = ((bool) isTrue((isEqual(type, "Market")))) ? "Stop" : "StopLimit"; } - } else if (isTrue(isEqual(triggerDirection, "down"))) + } else if (isTrue(isTrue(isEqual(triggerDirection, "descending")) || isTrue(isEqual(triggerDirection, "down")))) { if (isTrue(isEqual(side, "sell"))) { diff --git a/cs/ccxt/exchanges/poloniexfutures.cs b/cs/ccxt/exchanges/poloniexfutures.cs deleted file mode 100644 index c7f4fdc46a3e8..0000000000000 --- a/cs/ccxt/exchanges/poloniexfutures.cs +++ /dev/null @@ -1,2081 +0,0 @@ -namespace ccxt; - -// 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 poloniexfutures : Exchange -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "id", "poloniexfutures" }, - { "name", "Poloniex Futures" }, - { "countries", new List() {"US"} }, - { "rateLimit", 33.3 }, - { "certified", false }, - { "pro", true }, - { "version", "v1" }, - { "has", new Dictionary() { - { "CORS", null }, - { "spot", false }, - { "margin", true }, - { "swap", true }, - { "future", false }, - { "option", null }, - { "createOrder", true }, - { "createStopOrder", true }, - { "createTriggerOrder", true }, - { "fetchBalance", true }, - { "fetchClosedOrders", true }, - { "fetchCurrencies", false }, - { "fetchDepositAddress", false }, - { "fetchDepositAddresses", false }, - { "fetchDepositAddressesByNetwork", false }, - { "fetchFundingInterval", true }, - { "fetchFundingIntervals", false }, - { "fetchFundingRate", true }, - { "fetchFundingRateHistory", false }, - { "fetchL3OrderBook", true }, - { "fetchMarkets", true }, - { "fetchMyTrades", true }, - { "fetchOHLCV", true }, - { "fetchOpenOrders", true }, - { "fetchOrder", true }, - { "fetchOrderBook", true }, - { "fetchOrdersByStatus", true }, - { "fetchPositions", true }, - { "fetchTicker", true }, - { "fetchTickers", true }, - { "fetchTime", true }, - { "fetchTrades", true }, - { "setMarginMode", true }, - } }, - { "timeframes", new Dictionary() { - { "1m", 1 }, - { "5m", 5 }, - { "15m", 15 }, - { "30m", 30 }, - { "1h", 60 }, - { "2h", 120 }, - { "4h", 480 }, - { "12h", 720 }, - { "1d", 1440 }, - { "1w", 10080 }, - } }, - { "urls", new Dictionary() { - { "logo", "https://user-images.githubusercontent.com/1294454/27766817-e9456312-5ee6-11e7-9b3c-b628ca5626a5.jpg" }, - { "api", new Dictionary() { - { "public", "https://futures-api.poloniex.com" }, - { "private", "https://futures-api.poloniex.com" }, - } }, - { "www", "https://www.poloniex.com" }, - { "doc", "https://api-docs.poloniex.com/futures/" }, - { "fees", "https://poloniex.com/fee-schedule" }, - { "referral", "https://poloniex.com/signup?c=UBFZJRPJ" }, - } }, - { "api", new Dictionary() { - { "public", new Dictionary() { - { "get", new Dictionary() { - { "contracts/active", 10 }, - { "contracts/{symbol}", 10 }, - { "ticker", 10 }, - { "tickers", 10 }, - { "level2/snapshot", 180.002 }, - { "level2/depth", 180.002 }, - { "level2/message/query", 180.002 }, - { "level3/snapshot", 180.002 }, - { "trade/history", 10 }, - { "interest/query", 10 }, - { "index/query", 10 }, - { "mark-price/{symbol}/current", 10 }, - { "premium/query", 10 }, - { "funding-rate/{symbol}/current", 10 }, - { "timestamp", 10 }, - { "status", 10 }, - { "kline/query", 10 }, - } }, - { "post", new Dictionary() { - { "bullet-public", 10 }, - } }, - } }, - { "private", new Dictionary() { - { "get", new Dictionary() { - { "account-overview", 1 }, - { "transaction-history", 1 }, - { "maxActiveOrders", 1 }, - { "maxRiskLimit", 1 }, - { "userFeeRate", 1 }, - { "marginType/query", 1 }, - { "orders", 1 }, - { "stopOrders", 1 }, - { "recentDoneOrders", 1 }, - { "orders/{order-id}", 1 }, - { "clientOrderId/{clientOid}", 1 }, - { "fills", 1 }, - { "openOrderStatistics", 1 }, - { "position", 1.5 }, - { "positions", 1.5 }, - { "funding-history", 1 }, - } }, - { "post", new Dictionary() { - { "orders", 1.5 }, - { "batchOrders", 1.5 }, - { "position/margin/auto-deposit-status", 1.5 }, - { "position/margin/deposit-margin", 1.5 }, - { "position/margin/withdraw-margin", 1.5 }, - { "bullet-private", 1 }, - { "marginType/change", 1 }, - } }, - { "delete", new Dictionary() { - { "orders/{order-id}", 1.5 }, - { "orders", 150.016 }, - { "stopOrders", 150.016 }, - } }, - } }, - } }, - { "precisionMode", TICK_SIZE }, - { "fees", new Dictionary() { - { "trading", new Dictionary() { - { "tierBased", false }, - { "percentage", true }, - { "taker", this.parseNumber("0.00075") }, - { "maker", this.parseNumber("0.0001") }, - } }, - { "funding", new Dictionary() { - { "tierBased", false }, - { "percentage", false }, - { "withdraw", new Dictionary() {} }, - { "deposit", new Dictionary() {} }, - } }, - } }, - { "commonCurrencies", new Dictionary() {} }, - { "requiredCredentials", new Dictionary() { - { "apiKey", true }, - { "secret", true }, - { "password", true }, - } }, - { "options", new Dictionary() { - { "networks", new Dictionary() { - { "OMNI", "omni" }, - { "ERC20", "eth" }, - { "TRC20", "trx" }, - } }, - { "versions", new Dictionary() { - { "public", new Dictionary() { - { "GET", new Dictionary() { - { "ticker", "v2" }, - { "tickers", "v2" }, - { "level3/snapshot", "v2" }, - } }, - } }, - } }, - } }, - { "features", new Dictionary() { - { "default", new Dictionary() { - { "sandbox", false }, - { "createOrder", new Dictionary() { - { "marginMode", false }, - { "triggerPrice", true }, - { "triggerPriceType", new Dictionary() { - { "last", true }, - { "mark", true }, - { "index", true }, - } }, - { "triggerDirection", true }, - { "stopLossPrice", false }, - { "takeProfitPrice", false }, - { "attachedStopLossTakeProfit", null }, - { "timeInForce", new Dictionary() { - { "IOC", true }, - { "FOK", false }, - { "PO", true }, - { "GTD", false }, - } }, - { "hedged", false }, - { "leverage", true }, - { "marketBuyByCost", true }, - { "marketBuyRequiresPrice", false }, - { "selfTradePrevention", false }, - { "trailing", false }, - { "iceberg", true }, - } }, - { "createOrders", null }, - { "fetchMyTrades", new Dictionary() { - { "marginMode", false }, - { "limit", null }, - { "daysBack", 100000 }, - { "untilDays", 7 }, - { "symbolRequired", false }, - } }, - { "fetchOrder", new Dictionary() { - { "marginMode", false }, - { "trigger", false }, - { "trailing", false }, - { "symbolRequired", false }, - } }, - { "fetchOpenOrders", new Dictionary() { - { "marginMode", true }, - { "limit", null }, - { "trigger", false }, - { "trailing", false }, - { "symbolRequired", false }, - } }, - { "fetchOrders", null }, - { "fetchClosedOrders", new Dictionary() { - { "marginMode", false }, - { "limit", 100 }, - { "daysBack", 100000 }, - { "daysBackCanceled", 1 }, - { "untilDays", 100000 }, - { "trigger", false }, - { "trailing", false }, - { "symbolRequired", false }, - } }, - { "fetchOHLCV", new Dictionary() { - { "limit", 200 }, - } }, - } }, - { "spot", null }, - { "swap", new Dictionary() { - { "linear", new Dictionary() { - { "extends", "default" }, - } }, - { "inverse", null }, - } }, - { "future", new Dictionary() { - { "linear", null }, - { "inverse", null }, - } }, - } }, - { "exceptions", new Dictionary() { - { "exact", new Dictionary() { - { "400", typeof(BadRequest) }, - { "401", typeof(AuthenticationError) }, - { "403", typeof(NotSupported) }, - { "404", typeof(NotSupported) }, - { "405", typeof(NotSupported) }, - { "415", typeof(BadRequest) }, - { "429", typeof(RateLimitExceeded) }, - { "500", typeof(ExchangeNotAvailable) }, - { "503", typeof(ExchangeNotAvailable) }, - { "400001", typeof(AuthenticationError) }, - { "400002", typeof(InvalidNonce) }, - { "400003", typeof(AuthenticationError) }, - { "400004", typeof(AuthenticationError) }, - { "400005", typeof(AuthenticationError) }, - { "400006", typeof(AuthenticationError) }, - { "400007", typeof(AuthenticationError) }, - { "404000", typeof(NotSupported) }, - { "400100", typeof(BadRequest) }, - { "411100", typeof(AccountSuspended) }, - { "500000", typeof(ExchangeNotAvailable) }, - } }, - { "broad", new Dictionary() { - { "Position does not exist", typeof(OrderNotFound) }, - } }, - } }, - }); - } - - /** - * @method - * @name poloniexfutures#fetchMarkets - * @description retrieves data on all markets for poloniexfutures - * @see https://api-docs.poloniex.com/futures/api/symbol - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} an array of objects representing market data - */ - public async override Task fetchMarkets(object parameters = null) - { - parameters ??= new Dictionary(); - object response = await this.publicGetContractsActive(parameters); - // - // { - // "code": "200000", - // "data": [ - // { - // "symbol": "APTUSDTPERP", - // "takerFixFee": "0E-10", - // "nextFundingRateTime": "20145603", - // "makerFixFee": "0E-10", - // "type": "FFWCSX", - // "predictedFundingFeeRate": "0.000000", - // "turnoverOf24h": "386037.46704292", - // "initialMargin": "0.05", - // "isDeleverage": true, - // "createdAt": "1666681959000", - // "fundingBaseSymbol": ".APTINT8H", - // "lowPriceOf24h": "4.34499979019165", - // "lastTradePrice": "4.4090000000", - // "indexPriceTickSize": "0.001", - // "fairMethod": "FundingRate", - // "takerFeeRate": "0.00040", - // "order": "102", - // "updatedAt": "1671076377000", - // "displaySettleCurrency": "USDT", - // "indexPrice": "4.418", - // "multiplier": "1.0", - // "maxLeverage": "20", - // "fundingQuoteSymbol": ".USDTINT8H", - // "quoteCurrency": "USDT", - // "maxOrderQty": "1000000", - // "maxPrice": "1000000.0000000000", - // "maintainMargin": "0.025", - // "status": "Open", - // "displayNameMap": [Object], - // "openInterest": "2367", - // "highPriceOf24h": "4.763999938964844", - // "fundingFeeRate": "0.000000", - // "volumeOf24h": "83540.00000000", - // "riskStep": "500000", - // "isQuanto": true, - // "maxRiskLimit": "20000", - // "rootSymbol": "USDT", - // "baseCurrency": "APT", - // "firstOpenDate": "1666701000000", - // "tickSize": "0.001", - // "markMethod": "FairPrice", - // "indexSymbol": ".PAPTUSDT", - // "markPrice": "4.418", - // "minRiskLimit": "1000000", - // "settlementFixFee": "0E-10", - // "settlementSymbol": '', - // "priceChgPctOf24h": "-0.0704", - // "fundingRateSymbol": ".APTUSDTPERPFPI8H", - // "makerFeeRate": "0.00010", - // "isInverse": false, - // "lotSize": "1", - // "settleCurrency": "USDT", - // "settlementFeeRate": "0.0" - // }, - // ] - // } - // - object data = this.safeValue(response, "data", new List() {}); - return this.parseMarkets(data); - } - - public override object parseMarket(object market) - { - object id = this.safeString(market, "symbol"); - object baseId = this.safeString(market, "baseCurrency"); - object quoteId = this.safeString(market, "quoteCurrency"); - object settleId = this.safeString(market, "rootSymbol"); - object bs = this.safeCurrencyCode(baseId); - object quote = this.safeCurrencyCode(quoteId); - object settle = this.safeCurrencyCode(settleId); - object symbol = add(add(add(add(bs, "/"), quote), ":"), settle); - object inverse = this.safeValue(market, "isInverse"); - object status = this.safeString(market, "status"); - object multiplier = this.safeString(market, "multiplier"); - object tickSize = this.safeNumber(market, "indexPriceTickSize"); - object lotSize = this.safeNumber(market, "lotSize"); - object limitAmountMax = this.safeNumber(market, "maxOrderQty"); - object limitPriceMax = this.safeNumber(market, "maxPrice"); - return new Dictionary() { - { "id", id }, - { "symbol", symbol }, - { "base", bs }, - { "quote", quote }, - { "settle", settle }, - { "baseId", baseId }, - { "quoteId", quoteId }, - { "settleId", settleId }, - { "type", "swap" }, - { "spot", false }, - { "margin", false }, - { "swap", true }, - { "future", false }, - { "option", false }, - { "active", (isEqual(status, "Open")) }, - { "contract", true }, - { "linear", !isTrue(inverse) }, - { "inverse", inverse }, - { "taker", this.safeNumber(market, "takerFeeRate") }, - { "maker", this.safeNumber(market, "makerFeeRate") }, - { "contractSize", this.parseNumber(Precise.stringAbs(multiplier)) }, - { "expiry", null }, - { "expiryDatetime", null }, - { "strike", null }, - { "optionType", null }, - { "precision", new Dictionary() { - { "amount", lotSize }, - { "price", tickSize }, - } }, - { "limits", new Dictionary() { - { "leverage", new Dictionary() { - { "min", this.parseNumber("1") }, - { "max", this.safeNumber(market, "maxLeverage") }, - } }, - { "amount", new Dictionary() { - { "min", lotSize }, - { "max", limitAmountMax }, - } }, - { "price", new Dictionary() { - { "min", tickSize }, - { "max", limitPriceMax }, - } }, - { "cost", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - } }, - { "created", this.safeInteger(market, "firstOpenDate") }, - { "info", market }, - }; - } - - public override object parseTicker(object ticker, object market = null) - { - // - // { - // "symbol": "BTCUSDTPERP", // Market of the symbol - // "sequence": 45, // Sequence number which is used to judge the continuity of the pushed messages - // "side": "sell", // Transaction side of the last traded taker order - // "price": 3600.00, // Filled price - // "size": 16, // Filled quantity - // "tradeId": "5c9dcf4170744d6f5a3d32fb", // Order ID - // "bestBidSize": 795, // Best bid size - // "bestBidPrice": 3200.00, // Best bid - // "bestAskPrice": 3600.00, // Best ask size - // "bestAskSize": 284, // Best ask - // "ts": 1553846081210004941 // Filled time - nanosecond - // } - // - // { - // "volume": 30449670, //24h Volume - // "turnover": 845169919063, //24h Turnover - // "lastPrice": 3551, //Last price - // "priceChgPct": 0.0043, //24h Change - // "ts": 1547697294838004923 //Snapshot time (nanosecond) - // } - // - object marketId = this.safeString(ticker, "symbol"); - object symbol = this.safeSymbol(marketId, market); - object timestampString = this.safeString(ticker, "ts"); - object multiplier = null; - if (isTrue(isEqual(((string)timestampString).Length, 16))) - { - // 16 digits: https://app.travis-ci.com/github/ccxt/ccxt/builds/270587157#L5454 - multiplier = 0.001; - } else if (isTrue(isEqual(((string)timestampString).Length, 17))) - { - // 17 digits: https://app.travis-ci.com/github/ccxt/ccxt/builds/269959181#L4011 - multiplier = 0.0001; - } else if (isTrue(isEqual(((string)timestampString).Length, 18))) - { - multiplier = 0.00001; - } else - { - // 19 length default - multiplier = 0.000001; - } - object timestamp = this.safeIntegerProduct(ticker, "ts", multiplier); - object last = this.safeString2(ticker, "price", "lastPrice"); - object percentage = Precise.stringMul(this.safeString(ticker, "priceChgPct"), "100"); - return this.safeTicker(new Dictionary() { - { "symbol", symbol }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "high", null }, - { "low", null }, - { "bid", this.safeString(ticker, "bestBidPrice") }, - { "bidVolume", this.safeString(ticker, "bestBidSize") }, - { "ask", this.safeString(ticker, "bestAskPrice") }, - { "askVolume", this.safeString(ticker, "bestAskSize") }, - { "vwap", null }, - { "open", null }, - { "close", last }, - { "last", last }, - { "previousClose", null }, - { "change", null }, - { "percentage", percentage }, - { "average", null }, - { "baseVolume", this.safeString2(ticker, "size", "volume") }, - { "quoteVolume", this.safeString(ticker, "turnover") }, - { "info", ticker }, - }, market); - } - - /** - * @method - * @name poloniexfutures#fetchTicker - * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - * @see https://api-docs.poloniex.com/futures/api/ticker#get-real-time-ticker-20 - * @param {string} symbol unified symbol of the market to fetch the ticker for - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task fetchTicker(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object response = await this.publicGetTicker(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": { - // "sequence": "11574719", - // "symbol": "BTCUSDTPERP", - // "side": "sell", - // "size": "1", - // "price": "16990.1", - // "bestBidSize": "3", - // "bestBidPrice": "16990.1", - // "bestAskPrice": "16991.0", - // "tradeId": "639c8a529fd7cf0001af4157", - // "bestAskSize": "505", - // "ts": "1671203410721232337" - // } - // } - // - return this.parseTicker(this.safeValue(response, "data", new Dictionary() {}), market); - } - - /** - * @method - * @name poloniexfutures#fetchTickers - * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market - * @see https://api-docs.poloniex.com/futures/api/ticker#get-real-time-ticker-of-all-symbols - * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task fetchTickers(object symbols = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object response = await this.publicGetTickers(parameters); - object data = this.safeList(response, "data", new List() {}); - return this.parseTickers(data, symbols); - } - - /** - * @method - * @name poloniexfuturesfutures#fetchOrderBook - * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://api-docs.poloniex.com/futures/api/orderbook#get-full-order-book---level-2 - * @see https://api-docs.poloniex.com/futures/api/orderbook#get-full-order-book--level-3 - * @param {string} symbol unified symbol of the market to fetch the order book for - * @param {int} [limit] the maximum amount of order book entries to return - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols - */ - public async override Task fetchOrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object level = this.safeNumber(parameters, "level"); - parameters = this.omit(parameters, "level"); - if (isTrue(isTrue(isTrue(!isEqual(level, null)) && isTrue(!isEqual(level, 2))) && isTrue(!isEqual(level, 3)))) - { - throw new BadRequest ((string)add(this.id, " fetchOrderBook() can only return level 2 & 3")) ; - } - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object response = null; - if (isTrue(isEqual(level, 3))) - { - response = await this.publicGetLevel3Snapshot(this.extend(request, parameters)); - } else - { - response = await this.publicGetLevel2Snapshot(this.extend(request, parameters)); - } - // L2 - // - // { - // "code": "200000", - // "data": { - // "symbol": "BTCUSDTPERP", - // "sequence": 1669149851334, - // "asks": [ - // [ - // 16952, - // 12 - // ], - // ], - // "bids": [ - // [ - // 16951.9, - // 13 - // ], - // ], - // } - // - // L3 - // - // { - // "code": "200000", - // "data": { - // "symbol": "BTCUSDTPERP", - // "sequence": 1669149851334, - // "asks": [ - // [ - // "639c95388cba5100084eabce", - // "16952.0", - // "1", - // 1671206200542484700 - // ], - // ], - // "bids": [ - // [ - // "626659d83385c200072e690b", - // "17.0", - // "1000", - // 1650874840161291000 - // ], - // ], - // } - // - object data = this.safeValue(response, "data", new Dictionary() {}); - object timestamp = this.safeIntegerProduct(data, "ts", 0.000001); - object orderbook = null; - if (isTrue(isEqual(level, 3))) - { - orderbook = this.parseOrderBook(data, getValue(market, "symbol"), timestamp, "bids", "asks", 1, 2); - } else - { - orderbook = this.parseOrderBook(data, getValue(market, "symbol"), timestamp, "bids", "asks", 0, 1); - } - ((IDictionary)orderbook)["nonce"] = this.safeInteger(data, "sequence"); - return orderbook; - } - - /** - * @method - * @name poloniexfutures#fetchL3OrderBook - * @description fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://api-docs.poloniex.com/futures/api/orderbook#get-full-order-book--level-3 - * @param {string} symbol unified market symbol - * @param {int} [limit] max number of orders to return, default is undefined - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} an [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure} - */ - public async override Task fetchL3OrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - return this.fetchOrderBook(getValue(market, "id"), null, new Dictionary() { - { "level", 3 }, - }); - } - - public override object parseTrade(object trade, object market = null) - { - // - // fetchTrades (public) - // - // { - // "sequence": 11827985, - // "side": "buy", - // "size": 101, - // "price": "16864.0000000000", - // "takerOrderId": "639c986f0ac2470007be75ee", - // "makerOrderId": "639c986fa69d280007b76111", - // "tradeId": "639c986f9fd7cf0001afd7ee", - // "ts": 1671207023485924400 - // } - // - // fetchMyTrades - // - // { - // "symbol": "BTCUSDTPERP", //Ticker symbol of the contract - // "tradeId": "5ce24c1f0c19fc3c58edc47c", //Trade ID - // "orderId": "5ce24c16b210233c36ee321d", // Order ID - // "side": "sell", //Transaction side - // "liquidity": "taker", //Liquidity- taker or maker - // "price": "8302", //Filled price - // "size": 10, //Filled amount - // "value": "0.001204529", //Order value - // "feeRate": "0.0005", //Floating fees - // "fixFee": "0.00000006", //Fixed fees - // "feeCurrency": "XBT", //Charging currency - // "stop": "", //A mark to the stop order type - // "fee": "0.0000012022", //Transaction fee - // "orderType": "limit", //Order type - // "tradeType": "trade", //Trade type (trade, liquidation, ADL or settlement) - // "createdAt": 1558334496000, //Time the order created - // "settleCurrency": "XBT", //settlement currency - // "tradeTime": 1558334496000000000 //trade time in nanosecond - // } - // - object marketId = this.safeString(trade, "symbol"); - market = this.safeMarket(marketId, market, "-"); - object id = this.safeString(trade, "tradeId"); - object orderId = this.safeString(trade, "orderId"); - object takerOrMaker = this.safeString(trade, "liquidity"); - object timestamp = this.safeInteger(trade, "ts"); - if (isTrue(!isEqual(timestamp, null))) - { - timestamp = this.parseToInt(divide(timestamp, 1000000)); - } else - { - timestamp = this.safeInteger(trade, "createdAt"); - // if it's a historical v1 trade, the exchange returns timestamp in seconds - if (isTrue(isTrue((inOp(trade, "dealValue"))) && isTrue((!isEqual(timestamp, null))))) - { - timestamp = multiply(timestamp, 1000); - } - } - object priceString = this.safeString(trade, "price"); - object amountString = this.safeString(trade, "size"); - object side = this.safeString(trade, "side"); - object fee = null; - object feeCostString = this.safeString(trade, "fee"); - if (isTrue(!isEqual(feeCostString, null))) - { - object feeCurrencyId = this.safeString(trade, "feeCurrency"); - object feeCurrency = this.safeCurrencyCode(feeCurrencyId); - if (isTrue(isEqual(feeCurrency, null))) - { - feeCurrency = ((bool) isTrue((isEqual(side, "sell")))) ? getValue(market, "quote") : getValue(market, "base"); - } - fee = new Dictionary() { - { "cost", feeCostString }, - { "currency", feeCurrency }, - { "rate", this.safeString(trade, "feeRate") }, - }; - } - object type = this.safeString(trade, "orderType"); - if (isTrue(isEqual(type, "match"))) - { - type = null; - } - object costString = this.safeString(trade, "value"); - return this.safeTrade(new Dictionary() { - { "info", trade }, - { "id", id }, - { "order", orderId }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "symbol", getValue(market, "symbol") }, - { "type", type }, - { "takerOrMaker", takerOrMaker }, - { "side", side }, - { "price", priceString }, - { "amount", amountString }, - { "cost", costString }, - { "fee", fee }, - }, market); - } - - /** - * @method - * @name poloniexfutures#fetchTrades - * @description get the list of most recent trades for a particular symbol - * @see https://api-docs.poloniex.com/futures/api/historical#transaction-history - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task fetchTrades(object symbol, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object response = await this.publicGetTradeHistory(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": [ - // { - // "sequence": 11827985, - // "side": "buy", - // "size": 101, - // "price": "16864.0000000000", - // "takerOrderId": "639c986f0ac2470007be75ee", - // "makerOrderId": "639c986fa69d280007b76111", - // "tradeId": "639c986f9fd7cf0001afd7ee", - // "ts": 1671207023485924400 - // }, - // } - // - object trades = this.safeList(response, "data", new List() {}); - return this.parseTrades(trades, market, since, limit); - } - - /** - * @method - * @name poloniexfutures#fetchTime - * @description fetches the current integer timestamp in milliseconds from the poloniexfutures server - * @see https://api-docs.poloniex.com/futures/api/time#server-time - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {int} the current integer timestamp in milliseconds from the poloniexfutures server - */ - public async override Task fetchTime(object parameters = null) - { - parameters ??= new Dictionary(); - object response = await this.publicGetTimestamp(parameters); - // - // { - // "code":"200000", - // "msg":"success", - // "data":1546837113087 - // } - // - return this.safeInteger(response, "data"); - } - - /** - * @method - * @name poloniexfutures#fetchOHLCV - * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market - * @see https://api-docs.poloniex.com/futures/api/kline#get-k-line-data-of-contract - * @param {string} symbol unified symbol of the market to fetch OHLCV data for - * @param {string} timeframe the length of time each candle represents - * @param {int} [since] timestamp in ms of the earliest candle to fetch - * @param {int} [limit] the maximum amount of candles to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume - */ - public async override Task fetchOHLCV(object symbol, object timeframe = null, object since = null, object limit = null, object parameters = null) - { - timeframe ??= "1m"; - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object marketId = getValue(market, "id"); - object parsedTimeframe = this.safeInteger(this.timeframes, timeframe); - object request = new Dictionary() { - { "symbol", marketId }, - }; - if (isTrue(!isEqual(parsedTimeframe, null))) - { - ((IDictionary)request)["granularity"] = parsedTimeframe; - } else - { - ((IDictionary)request)["granularity"] = timeframe; - } - object duration = multiply(this.parseTimeframe(timeframe), 1000); - object endAt = this.milliseconds(); - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["from"] = since; - if (isTrue(isEqual(limit, null))) - { - limit = this.safeInteger(this.options, "fetchOHLCVLimit", 200); - } - endAt = this.sum(since, multiply(limit, duration)); - ((IDictionary)request)["to"] = endAt; - } else if (isTrue(!isEqual(limit, null))) - { - since = subtract(endAt, multiply(limit, duration)); - ((IDictionary)request)["from"] = since; - } - object response = await this.publicGetKlineQuery(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": [ - // [1636459200000, 4779.3, 4792.1, 4768.7, 4770.3, 78051], - // [1636460100000, 4770.25, 4778.55, 4757.55, 4777.25, 80164], - // [1636461000000, 4777.25, 4791.45, 4774.5, 4791.3, 51555] - // ] - // } - // - object data = this.safeList(response, "data", new List() {}); - return this.parseOHLCVs(data, market, timeframe, since, limit); - } - - public override object parseBalance(object response) - { - object result = new Dictionary() { - { "info", response }, - { "timestamp", null }, - { "datetime", null }, - }; - object data = this.safeValue(response, "data"); - object currencyId = this.safeString(data, "currency"); - object code = this.safeCurrencyCode(currencyId); - object account = this.account(); - ((IDictionary)account)["free"] = this.safeString(data, "availableBalance"); - ((IDictionary)account)["total"] = this.safeString(data, "accountEquity"); - ((IDictionary)result)[(string)code] = account; - return this.safeBalance(result); - } - - /** - * @method - * @name poloniexfutures#fetchBalance - * @description query for balance and get the amount of funds available for trading or funds locked in orders - * @see https://api-docs.poloniex.com/futures/api/account#get-account-overview - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} - */ - public async override Task fetchBalance(object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object currencyId = this.safeString(parameters, "currency"); - object request = new Dictionary() {}; - if (isTrue(!isEqual(currencyId, null))) - { - object currency = this.currency(currencyId); - request = new Dictionary() { - { "currency", getValue(currency, "id") }, - }; - } - object response = await this.privateGetAccountOverview(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": { - // "accountEquity": 0.00005, - // "unrealisedPNL": 0, - // "marginBalance": 0.00005, - // "positionMargin": 0, - // "orderMargin": 0, - // "frozenFunds": 0, - // "availableBalance": 0.00005, - // "currency": "XBT" - // } - // } - // - return this.parseBalance(response); - } - - /** - * @method - * @name poloniexfutures#createOrder - * @description Create an order on the exchange - * @see https://api-docs.poloniex.com/futures/api/orders#place-an-order - * @param {string} symbol Unified CCXT market symbol - * @param {string} type 'limit' or 'market' - * @param {string} side 'buy' or 'sell' - * @param {float} amount the amount of currency to trade - * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {float} [params.leverage] Leverage size of the order - * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at - * @param {bool} [params.reduceOnly] A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true. - * @param {string} [params.timeInForce] GTC, GTT, IOC, or FOK, default is GTC, limit orders only - * @param {string} [params.postOnly] Post only flag, invalid when timeInForce is IOC or FOK - * @param {string} [params.clientOid] client order id, defaults to uuid if not passed - * @param {string} [params.remark] remark for the order, length cannot exceed 100 utf8 characters - * @param {string} [params.stop] 'up' or 'down', defaults to 'up' if side is sell and 'down' if side is buy, requires stopPrice - * @param {string} [params.stopPriceType] TP, IP or MP, defaults to TP - * @param {bool} [params.closeOrder] set to true to close position - * @param {bool} [params.forceHold] A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. - * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task createOrder(object symbol, object type, object side, object amount, object price = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - // required param, cannot be used twice - object clientOrderId = this.safeString2(parameters, "clientOid", "clientOrderId", this.uuid()); - parameters = this.omit(parameters, new List() {"clientOid", "clientOrderId"}); - if (isTrue(isLessThan(amount, 1))) - { - throw new InvalidOrder ((string)add(this.id, " createOrder() minimum contract order amount is 1")) ; - } - object preciseAmount = parseInt(this.amountToPrecision(symbol, amount)); - object request = new Dictionary() { - { "clientOid", clientOrderId }, - { "side", side }, - { "symbol", getValue(market, "id") }, - { "type", type }, - { "size", preciseAmount }, - { "leverage", 1 }, - }; - object triggerPrice = this.safeValue2(parameters, "triggerPrice", "stopPrice"); - if (isTrue(triggerPrice)) - { - ((IDictionary)request)["stop"] = ((bool) isTrue((isEqual(side, "buy")))) ? "up" : "down"; - object stopPriceType = this.safeString(parameters, "stopPriceType", "TP"); - ((IDictionary)request)["stopPriceType"] = stopPriceType; - ((IDictionary)request)["stopPrice"] = this.priceToPrecision(symbol, triggerPrice); - } - object timeInForce = this.safeStringUpper(parameters, "timeInForce"); - if (isTrue(isEqual(type, "limit"))) - { - if (isTrue(isEqual(price, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " createOrder() requires a price argument for limit orders")) ; - } else - { - ((IDictionary)request)["price"] = this.priceToPrecision(symbol, price); - } - if (isTrue(!isEqual(timeInForce, null))) - { - ((IDictionary)request)["timeInForce"] = timeInForce; - } - } - object postOnly = this.safeBool(parameters, "postOnly", false); - object hidden = this.safeValue(parameters, "hidden"); - if (isTrue(isTrue(postOnly) && isTrue((!isEqual(hidden, null))))) - { - throw new BadRequest ((string)add(this.id, " createOrder() does not support the postOnly parameter together with a hidden parameter")) ; - } - object iceberg = this.safeValue(parameters, "iceberg"); - if (isTrue(iceberg)) - { - object visibleSize = this.safeValue(parameters, "visibleSize"); - if (isTrue(isEqual(visibleSize, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " createOrder() requires a visibleSize parameter for iceberg orders")) ; - } - } - parameters = this.omit(parameters, new List() {"timeInForce", "stopPrice", "triggerPrice"}); // Time in force only valid for limit orders, exchange error when gtc for market orders - object response = await this.privatePostOrders(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": { - // "orderId": "619717484f1d010001510cde", - // }, - // } - // - object data = this.safeValue(response, "data", new Dictionary() {}); - return this.safeOrder(new Dictionary() { - { "id", this.safeString(data, "orderId") }, - { "clientOrderId", null }, - { "timestamp", null }, - { "datetime", null }, - { "lastTradeTimestamp", null }, - { "symbol", null }, - { "type", null }, - { "side", null }, - { "price", null }, - { "amount", null }, - { "cost", null }, - { "average", null }, - { "filled", null }, - { "remaining", null }, - { "status", null }, - { "fee", null }, - { "trades", null }, - { "timeInForce", null }, - { "postOnly", null }, - { "triggerPrice", null }, - { "info", response }, - }, market); - } - - /** - * @method - * @name poloniexfutures#cancelOrder - * @description cancels an open order - * @see https://api-docs.poloniex.com/futures/api/orders#cancel-an-order - * @param {string} id order id - * @param {string} symbol unified symbol of the market the order was made in - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task cancelOrder(object id, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() { - { "order-id", id }, - }; - object response = await this.privateDeleteOrdersOrderId(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": { - // "cancelledOrderIds": [ - // "619714b8b6353000014c505a", - // ], - // "cancelFailedOrders": [ - // { - // "orderId": "63a9c5c2b9e7d70007eb0cd5", - // "orderState": "2" - // } - // ], - // }, - // } - // - object data = this.safeValue(response, "data"); - object cancelledOrderIds = this.safeValue(data, "cancelledOrderIds"); - object cancelledOrderIdsLength = getArrayLength(cancelledOrderIds); - if (isTrue(isEqual(cancelledOrderIdsLength, 0))) - { - throw new InvalidOrder ((string)add(this.id, " cancelOrder() order already cancelled")) ; - } - return this.parseOrder(data); - } - - /** - * @method - * @name poloniexfutures#fetchPositions - * @description fetch all open positions - * @see https://api-docs.poloniex.com/futures/api/positions#get-position-list - * @param {string[]|undefined} symbols list of unified market symbols - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} - */ - public async override Task fetchPositions(object symbols = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object response = await this.privateGetPositions(parameters); - // - // { - // "code": "200000", - // "data": [ - // { - // "id": "615ba79f83a3410001cde321", - // "symbol": "ETHUSDTM", - // "autoDeposit": false, - // "maintMarginReq": 0.005, - // "riskLimit": 1000000, - // "realLeverage": 18.61, - // "crossMode": false, - // "delevPercentage": 0.86, - // "openingTimestamp": 1638563515618, - // "currentTimestamp": 1638576872774, - // "currentQty": 2, - // "currentCost": 83.64200000, - // "currentComm": 0.05018520, - // "unrealisedCost": 83.64200000, - // "realisedGrossCost": 0.00000000, - // "realisedCost": 0.05018520, - // "isOpen": true, - // "markPrice": 4225.01, - // "markValue": 84.50020000, - // "posCost": 83.64200000, - // "posCross": 0.0000000000, - // "posInit": 3.63660870, - // "posComm": 0.05236717, - // "posLoss": 0.00000000, - // "posMargin": 3.68897586, - // "posMaint": 0.50637594, - // "maintMargin": 4.54717586, - // "realisedGrossPnl": 0.00000000, - // "realisedPnl": -0.05018520, - // "unrealisedPnl": 0.85820000, - // "unrealisedPnlPcnt": 0.0103, - // "unrealisedRoePcnt": 0.2360, - // "avgEntryPrice": 4182.10, - // "liquidationPrice": 4023.00, - // "bankruptPrice": 4000.25, - // "settleCurrency": "USDT", - // "isInverse": false - // } - // ] - // } - // - object data = this.safeList(response, "data"); - return this.parsePositions(data, symbols); - } - - public override object parsePosition(object position, object market = null) - { - // - // { - // "code": "200000", - // "data": [ - // { - // "id": "615ba79f83a3410001cde321", // Position ID - // "symbol": "ETHUSDTM", // Symbol - // "autoDeposit": false, // Auto deposit margin or not - // "maintMarginReq": 0.005, // Maintenance margin requirement - // "riskLimit": 1000000, // Risk limit - // "realLeverage": 25.92, // Leverage of the order - // "crossMode": false, // Cross mode or not - // "delevPercentage": 0.76, // ADL ranking percentile - // "openingTimestamp": 1638578546031, // Open time - // "currentTimestamp": 1638578563580, // Current timestamp - // "currentQty": 2, // Current postion quantity - // "currentCost": 83.787, // Current postion value - // "currentComm": 0.0167574, // Current commission - // "unrealisedCost": 83.787, // Unrealised value - // "realisedGrossCost": 0.0, // Accumulated realised gross profit value - // "realisedCost": 0.0167574, // Current realised position value - // "isOpen": true, // Opened position or not - // "markPrice": 4183.38, // Mark price - // "markValue": 83.6676, // Mark value - // "posCost": 83.787, // Position value - // "posCross": 0.0, // added margin - // "posInit": 3.35148, // Leverage margin - // "posComm": 0.05228309, // Bankruptcy cost - // "posLoss": 0.0, // Funding fees paid out - // "posMargin": 3.40376309, // Position margin - // "posMaint": 0.50707892, // Maintenance margin - // "maintMargin": 3.28436309, // Position margin - // "realisedGrossPnl": 0.0, // Accumulated realised gross profit value - // "realisedPnl": -0.0167574, // Realised profit and loss - // "unrealisedPnl": -0.1194, // Unrealised profit and loss - // "unrealisedPnlPcnt": -0.0014, // Profit-loss ratio of the position - // "unrealisedRoePcnt": -0.0356, // Rate of return on investment - // "avgEntryPrice": 4189.35, // Average entry price - // "liquidationPrice": 4044.55, // Liquidation price - // "bankruptPrice": 4021.75, // Bankruptcy price - // "settleCurrency": "USDT", // Currency used to clear and settle the trades - // "isInverse": false - // } - // ] - // } - // - object symbol = this.safeString(position, "symbol"); - market = this.safeMarket(symbol, market); - object timestamp = this.safeInteger(position, "currentTimestamp"); - object size = this.safeString(position, "currentQty"); - object side = null; - if (isTrue(Precise.stringGt(size, "0"))) - { - side = "long"; - } else if (isTrue(Precise.stringLt(size, "0"))) - { - side = "short"; - } - object notional = Precise.stringAbs(this.safeString(position, "posCost")); - object initialMargin = this.safeString(position, "posInit"); - object initialMarginPercentage = Precise.stringDiv(initialMargin, notional); - // const marginRatio = Precise.stringDiv (maintenanceRate, collateral); - object unrealisedPnl = this.safeString(position, "unrealisedPnl"); - object crossMode = this.safeValue(position, "crossMode"); - // currently crossMode is always set to false and only isolated positions are supported - object marginMode = ((bool) isTrue(crossMode)) ? "cross" : "isolated"; - return new Dictionary() { - { "info", position }, - { "id", null }, - { "symbol", this.safeString(market, "symbol") }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "initialMargin", this.parseNumber(initialMargin) }, - { "initialMarginPercentage", this.parseNumber(initialMarginPercentage) }, - { "maintenanceMargin", this.safeNumber(position, "posMaint") }, - { "maintenanceMarginPercentage", this.safeNumber(position, "maintMarginReq") }, - { "entryPrice", this.safeNumber(position, "avgEntryPrice") }, - { "notional", this.parseNumber(notional) }, - { "leverage", this.safeNumber(position, "realLeverage") }, - { "unrealizedPnl", this.parseNumber(unrealisedPnl) }, - { "contracts", this.parseNumber(Precise.stringAbs(size)) }, - { "contractSize", this.safeValue(market, "contractSize") }, - { "marginRatio", null }, - { "liquidationPrice", this.safeNumber(position, "liquidationPrice") }, - { "markPrice", this.safeNumber(position, "markPrice") }, - { "collateral", this.safeNumber(position, "maintMargin") }, - { "marginMode", marginMode }, - { "side", side }, - { "percentage", this.parseNumber(Precise.stringDiv(unrealisedPnl, initialMargin)) }, - { "stopLossPrice", null }, - { "takeProfitPrice", null }, - }; - } - - /** - * @method - * @name poloniexfutures#fetchFundingHistory - * @description fetch the history of funding payments paid and received on this account - * @see https://api-docs.poloniex.com/futures/api/funding-fees#get-funding-history - * @param {string} symbol unified market symbol - * @param {int} [since] the earliest time in ms to fetch funding history for - * @param {int} [limit] the maximum number of funding history structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [funding history structure]{@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(); - if (isTrue(isEqual(symbol, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " fetchFundingHistory() requires a symbol argument")) ; - } - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["startAt"] = since; - } - if (isTrue(!isEqual(limit, null))) - { - // * Since is ignored if limit is defined - ((IDictionary)request)["maxCount"] = limit; - } - object response = await this.privateGetFundingHistory(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": { - // "dataList": [ - // { - // "id": 239471298749817, - // "symbol": "ETHUSDTM", - // "timePoint": 1638532800000, - // "fundingRate": 0.000100, - // "markPrice": 4612.8300000000, - // "positionQty": 12, - // "positionCost": 553.5396000000, - // "funding": -0.0553539600, - // "settleCurrency": "USDT" - // }, - // ... - // ], - // "hasMore": true - // } - // } - // - object data = this.safeValue(response, "data"); - object dataList = this.safeValue(data, "dataList", new List() {}); - object dataListLength = getArrayLength(dataList); - object fees = new List() {}; - for (object i = 0; isLessThan(i, dataListLength); postFixIncrement(ref i)) - { - object listItem = getValue(dataList, i); - object timestamp = this.safeInteger(listItem, "timePoint"); - ((IList)fees).Add(new Dictionary() { - { "info", listItem }, - { "symbol", symbol }, - { "code", this.safeCurrencyCode(this.safeString(listItem, "settleCurrency")) }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "id", this.safeNumber(listItem, "id") }, - { "amount", this.safeNumber(listItem, "funding") }, - { "fundingRate", this.safeNumber(listItem, "fundingRate") }, - { "markPrice", this.safeNumber(listItem, "markPrice") }, - { "positionQty", this.safeNumber(listItem, "positionQty") }, - { "positionCost", this.safeNumber(listItem, "positionCost") }, - }); - } - return fees; - } - - /** - * @method - * @name poloniexfutures#cancelAllOrders - * @description cancel all open orders - * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {object} [params.trigger] When true, all the trigger orders will be cancelled - * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task cancelAllOrders(object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() {}; - if (isTrue(!isEqual(symbol, null))) - { - ((IDictionary)request)["symbol"] = this.marketId(symbol); - } - object trigger = this.safeValue2(parameters, "stop", "trigger"); - parameters = this.omit(parameters, new List() {"stop", "trigger"}); - object response = null; - if (isTrue(trigger)) - { - response = await this.privateDeleteStopOrders(this.extend(request, parameters)); - } else - { - response = await this.privateDeleteOrders(this.extend(request, parameters)); - } - // - // { - // "code": "200000", - // "data": { - // "cancelledOrderIds": [ - // "619714b8b6353000014c505a", - // ], - // }, - // } - // - object data = this.safeValue(response, "data"); - object result = new List() {}; - object cancelledOrderIds = this.safeValue(data, "cancelledOrderIds"); - object cancelledOrderIdsLength = getArrayLength(cancelledOrderIds); - for (object i = 0; isLessThan(i, cancelledOrderIdsLength); postFixIncrement(ref i)) - { - object cancelledOrderId = this.safeString(cancelledOrderIds, i); - ((IList)result).Add(this.safeOrder(new Dictionary() { - { "id", cancelledOrderId }, - { "clientOrderId", null }, - { "timestamp", null }, - { "datetime", null }, - { "lastTradeTimestamp", null }, - { "symbol", null }, - { "type", null }, - { "side", null }, - { "price", null }, - { "amount", null }, - { "cost", null }, - { "average", null }, - { "filled", null }, - { "remaining", null }, - { "status", null }, - { "fee", null }, - { "trades", null }, - { "timeInForce", null }, - { "postOnly", null }, - { "triggerPrice", null }, - { "info", response }, - })); - } - return result; - } - - /** - * @method - * @name poloniexfutures#fetchOrdersByStatus - * @description fetches a list of orders placed on the exchange - * @see https://api-docs.poloniex.com/futures/api/orders#get-order-listdeprecated - * @see https://api-docs.poloniex.com/futures/api/orders#get-untriggered-stop-order-list - * @param {string} status 'active' or 'closed', only 'active' is valid for stop orders - * @param {string} symbol unified symbol for the market to retrieve orders from - * @param {int} [since] timestamp in ms of the earliest order to retrieve - * @param {int} [limit] The maximum number of orders to retrieve - * @param {object} [params] exchange specific parameters - * @param {bool} [params.stop] set to true to retrieve untriggered stop orders - * @param {int} [params.until] End time in ms - * @param {string} [params.side] buy or sell - * @param {string} [params.type] limit or market - * @returns An [array of order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async virtual Task fetchOrdersByStatus(object status, object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object trigger = this.safeValue2(parameters, "stop", "trigger"); - object until = this.safeInteger(parameters, "until"); - parameters = this.omit(parameters, new List() {"trigger", "stop", "until"}); - if (isTrue(isEqual(status, "closed"))) - { - status = "done"; - } - object request = new Dictionary() {}; - if (!isTrue(trigger)) - { - ((IDictionary)request)["status"] = ((bool) isTrue((isEqual(status, "open")))) ? "active" : "done"; - } else if (isTrue(!isEqual(status, "open"))) - { - throw new BadRequest ((string)add(this.id, " fetchOrdersByStatus() can only fetch untriggered stop orders")) ; - } - 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)["startAt"] = since; - } - if (isTrue(!isEqual(until, null))) - { - ((IDictionary)request)["endAt"] = until; - } - object response = null; - if (isTrue(trigger)) - { - response = await this.privateGetStopOrders(this.extend(request, parameters)); - } else - { - response = await this.privateGetOrders(this.extend(request, parameters)); - } - // - // { - // "code": "200000", - // "data": { - // "totalNum": 1, - // "totalPage": 1, - // "pageSize": 50, - // "currentPage": 1, - // "items": [ - // { - // "symbol": "ADAUSDTPERP", - // "leverage": "1", - // "hidden": false, - // "forceHold": false, - // "closeOrder": false, - // "type": "limit", - // "isActive": true, - // "createdAt": 1678936920000, - // "orderTime": 1678936920480905922, - // "price": "0.3", - // "iceberg": false, - // "stopTriggered": false, - // "id": "64128b582cc0710007a3c840", - // "value": "3", - // "timeInForce": "GTC", - // "updatedAt": 1678936920000, - // "side": "buy", - // "stopPriceType": "", - // "dealValue": "0", - // "dealSize": 0, - // "settleCurrency": "USDT", - // "stp": "", - // "filledValue": "0", - // "postOnly": false, - // "size": 1, - // "stop": "", - // "filledSize": 0, - // "reduceOnly": false, - // "marginType": 1, - // "cancelExist": false, - // "clientOid": "ba669f39-dfcc-4664-9801-a42d06e59c2e", - // "status": "open" - // } - // ] - // } - // } - // - object responseData = this.safeValue(response, "data", new Dictionary() {}); - object orders = this.safeValue(responseData, "items", new List() {}); - object ordersLength = getArrayLength(orders); - object result = new List() {}; - for (object i = 0; isLessThan(i, ordersLength); postFixIncrement(ref i)) - { - object order = getValue(orders, i); - object orderStatus = this.safeString(order, "status"); - if (isTrue(isEqual(status, orderStatus))) - { - ((IList)result).Add(getValue(orders, i)); - } - } - return this.parseOrders(result, market, since, limit); - } - - /** - * @method - * @name poloniexfutures#fetchOpenOrders - * @description fetch all unfilled currently open orders - * @see https://api-docs.poloniex.com/futures/api/orders#get-order-listdeprecated - * @see https://api-docs.poloniex.com/futures/api/orders#get-untriggered-stop-order-list - * @param {string} symbol unified market symbol - * @param {int} [since] the earliest time in ms to fetch open orders for - * @param {int} [limit] the maximum number of open orders structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {int} [params.until] end time in ms - * @param {string} [params.side] buy or sell - * @param {string} [params.type] limit, or market - * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task fetchOpenOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - return await this.fetchOrdersByStatus("open", symbol, since, limit, parameters); - } - - /** - * @method - * @name poloniexfutures#fetchClosedOrders - * @description fetches information on multiple closed orders made by the user - * @see https://api-docs.poloniex.com/futures/api/orders#get-order-listdeprecated - * @see https://api-docs.poloniex.com/futures/api/orders#get-untriggered-stop-order-list - * @param {string} symbol unified market symbol of the market orders were made in - * @param {int} [since] the earliest time in ms to fetch orders for - * @param {int} [limit] the maximum number of order structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {int} [params.until] end time in ms - * @param {string} [params.side] buy or sell - * @param {string} [params.type] limit, or market - * @returns {Order[]} a list 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) - { - parameters ??= new Dictionary(); - return await this.fetchOrdersByStatus("closed", symbol, since, limit, parameters); - } - - /** - * @method - * @name poloniexfutures#fetchOrder - * @description fetches information on an order made by the user - * @see https://api-docs.poloniex.com/futures/api/orders#get-details-of-a-single-order - * @see https://api-docs.poloniex.com/futures/api/orders#get-single-order-by-clientoid - * @param {string} id the order id - * @param {string} symbol unified symbol of the market the order was made in - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task fetchOrder(object id, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() {}; - object response = null; - if (isTrue(isEqual(id, null))) - { - object clientOrderId = this.safeString2(parameters, "clientOid", "clientOrderId"); - if (isTrue(isEqual(clientOrderId, null))) - { - throw new InvalidOrder ((string)add(this.id, " fetchOrder() requires parameter id or params.clientOid")) ; - } - ((IDictionary)request)["clientOid"] = clientOrderId; - parameters = this.omit(parameters, new List() {"clientOid", "clientOrderId"}); - response = await this.privateGetClientOrderIdClientOid(this.extend(request, parameters)); - } else - { - ((IDictionary)request)["order-id"] = id; - response = await this.privateGetOrdersOrderId(this.extend(request, parameters)); - } - // - // { - // "code": "200000", - // "data": { - // "symbol": "ADAUSDTPERP", - // "leverage": "1", - // "hidden": false, - // "forceHold": false, - // "closeOrder": false, - // "type": "market", - // "isActive": false, - // "createdAt": 1678929587000, - // "orderTime": 1678929587248115582, - // "iceberg": false, - // "stopTriggered": false, - // "id": "64126eb38c6919000737dcdc", - // "value": "3.1783", - // "timeInForce": "GTC", - // "updatedAt": 1678929587000, - // "side": "buy", - // "stopPriceType": "", - // "dealValue": "3.1783", - // "dealSize": 1, - // "settleCurrency": "USDT", - // "trades": [ - // { - // "feePay": "0.00158915", - // "tradeId": "64126eb36803eb0001ff99bc" - // } - // ], - // "endAt": 1678929587000, - // "stp": "", - // "filledValue": "3.1783", - // "postOnly": false, - // "size": 1, - // "stop": "", - // "filledSize": 1, - // "reduceOnly": false, - // "marginType": 1, - // "cancelExist": false, - // "clientOid": "d19e8fcb-2df4-44bc-afd4-67dd42048246", - // "status": "done" - // } - // } - // - object market = ((bool) isTrue((!isEqual(symbol, null)))) ? this.market(symbol) : null; - object responseData = this.safeDict(response, "data"); - return this.parseOrder(responseData, market); - } - - public override object parseOrder(object order, object market = null) - { - // - // createOrder - // - // { - // "code": "200000", - // "data": { - // "orderId": "619717484f1d010001510cde", - // }, - // } - // - // fetchOrder - // - // { - // "symbol": "ADAUSDTPERP", - // "leverage": "1", - // "hidden": false, - // "forceHold": false, - // "closeOrder": false, - // "type": "market", - // "isActive": false, - // "createdAt": 1678929587000, - // "orderTime": 1678929587248115582, - // "iceberg": false, - // "stopTriggered": false, - // "id": "64126eb38c6919000737dcdc", - // "value": "3.1783", - // "timeInForce": "GTC", - // "updatedAt": 1678929587000, - // "side": "buy", - // "stopPriceType": "", - // "dealValue": "3.1783", - // "dealSize": 1, - // "settleCurrency": "USDT", - // "trades": [ - // { - // "feePay": "0.00158915", - // "tradeId": "64126eb36803eb0001ff99bc" - // } - // ], - // "endAt": 1678929587000, - // "stp": "", - // "filledValue": "3.1783", - // "postOnly": false, - // "size": 1, - // "stop": "", - // "filledSize": 1, - // "reduceOnly": false, - // "marginType": 1, - // "cancelExist": false, - // "clientOid": "d19e8fcb-2df4-44bc-afd4-67dd42048246", - // "status": "done" - // } - // - // cancelOrder - // - // { - // "cancelledOrderIds": [ - // "619714b8b6353000014c505a", - // ], - // "cancelFailedOrders": [ - // { - // "orderId": "63a9c5c2b9e7d70007eb0cd5", - // "orderState": "2" - // } - // ], - // }, - // - object marketId = this.safeString(order, "symbol"); - market = this.safeMarket(marketId, market); - object timestamp = this.safeInteger(order, "createdAt"); - // price is zero for market order - // omitZero is called in safeOrder2 - object feeCurrencyId = this.safeString(order, "feeCurrency"); - object filled = this.safeString(order, "dealSize"); - object rawCost = this.safeString2(order, "dealFunds", "filledValue"); - object average = null; - if (isTrue(Precise.stringGt(filled, "0"))) - { - object contractSize = this.safeString(market, "contractSize"); - if (isTrue(getValue(market, "linear"))) - { - average = Precise.stringDiv(rawCost, Precise.stringMul(contractSize, filled)); - } else - { - average = Precise.stringDiv(Precise.stringMul(contractSize, filled), rawCost); - } - } - // precision reported by their api is 8 d.p. - // const average = Precise.stringDiv (rawCost, Precise.stringMul (filled, market['contractSize'])); - // bool - object isActive = this.safeBool(order, "isActive", false); - object cancelExist = this.safeBool(order, "cancelExist", false); - object status = ((bool) isTrue(isActive)) ? "open" : "closed"; - object id = this.safeString(order, "id"); - if (isTrue(inOp(order, "cancelledOrderIds"))) - { - object cancelledOrderIds = this.safeValue(order, "cancelledOrderIds"); - id = this.safeString(cancelledOrderIds, 0); - } - return this.safeOrder(new Dictionary() { - { "info", order }, - { "id", id }, - { "clientOrderId", this.safeString(order, "clientOid") }, - { "symbol", this.safeString(market, "symbol") }, - { "type", this.safeString(order, "type") }, - { "timeInForce", this.safeString(order, "timeInForce") }, - { "postOnly", this.safeValue(order, "postOnly") }, - { "side", this.safeString(order, "side") }, - { "amount", this.safeString(order, "size") }, - { "price", this.safeString(order, "price") }, - { "triggerPrice", this.safeString(order, "stopPrice") }, - { "cost", this.safeString(order, "dealValue") }, - { "filled", filled }, - { "remaining", null }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "fee", new Dictionary() { - { "currency", this.safeCurrencyCode(feeCurrencyId) }, - { "cost", this.safeString(order, "fee") }, - } }, - { "status", ((bool) isTrue(cancelExist)) ? "canceled" : status }, - { "lastTradeTimestamp", null }, - { "average", average }, - { "trades", null }, - }, market); - } - - /** - * @method - * @name poloniexfutures#fetchFundingRate - * @description fetch the current funding rate - * @see https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index - * @param {string} symbol unified market symbol - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure} - */ - public async override Task fetchFundingRate(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object response = await this.publicGetFundingRateSymbolCurrent(this.extend(request, parameters)); - // - // { - // "symbol": ".BTCUSDTPERPFPI8H", - // "granularity": 28800000, - // "timePoint": 1558000800000, - // "value": 0.00375, - // "predictedValue": 0.00375 - // } - // - object data = this.safeDict(response, "data", new Dictionary() {}); - return this.parseFundingRate(data, market); - } - - /** - * @method - * @name poloniexfutures#fetchFundingInterval - * @description fetch the current funding rate interval - * @see https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index - * @param {string} symbol unified market symbol - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure} - */ - public async override Task fetchFundingInterval(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - return await this.fetchFundingRate(symbol, parameters); - } - - public override object parseFundingRate(object data, object market = null) - { - // - // { - // "symbol": ".ETHUSDTMFPI8H", - // "granularity": 28800000, - // "timePoint": 1637380800000, - // "value": 0.0001, - // "predictedValue": 0.0001, - // } - // - object fundingTimestamp = this.safeInteger(data, "timePoint"); - object marketId = this.safeString(data, "symbol"); - return new Dictionary() { - { "info", data }, - { "symbol", this.safeSymbol(marketId, market, null, "contract") }, - { "markPrice", null }, - { "indexPrice", null }, - { "interestRate", null }, - { "estimatedSettlePrice", null }, - { "timestamp", null }, - { "datetime", null }, - { "fundingRate", this.safeNumber(data, "value") }, - { "fundingTimestamp", fundingTimestamp }, - { "fundingDatetime", this.iso8601(fundingTimestamp) }, - { "nextFundingRate", this.safeNumber(data, "predictedValue") }, - { "nextFundingTimestamp", null }, - { "nextFundingDatetime", null }, - { "previousFundingRate", null }, - { "previousFundingTimestamp", null }, - { "previousFundingDatetime", null }, - { "interval", this.parseFundingInterval(this.safeString(data, "granularity")) }, - }; - } - - public virtual object parseFundingInterval(object interval) - { - object intervals = new Dictionary() { - { "3600000", "1h" }, - { "14400000", "4h" }, - { "28800000", "8h" }, - { "57600000", "16h" }, - { "86400000", "24h" }, - }; - return this.safeString(intervals, interval, interval); - } - - /** - * @method - * @name poloniexfutures#fetchMyTrades - * @description fetch all trades made by the user - * @see https://api-docs.poloniex.com/futures/api/fills#get-fillsdeprecated - * @param {string} symbol unified market symbol - * @param {int} [since] the earliest time in ms to fetch trades for - * @param {int} [limit] the maximum number of trades structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {string} [params.orderIdFills] filles for a specific order (other parameters can be ignored if specified) - * @param {string} [params.side] buy or sell - * @param {string} [params.type] limit, market, limit_stop or market_stop - * @param {int} [params.endAt] end time (milisecond) - * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} - */ - public async override Task fetchMyTrades(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() {}; - 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)["startAt"] = since; - } - object response = await this.privateGetFills(this.extend(request, parameters)); - // - // { - // "code": "200000", - // "data": { - // "currentPage":1, - // "pageSize":1, - // "totalNum":251915, - // "totalPage":251915, - // "items":[ - // { - // "symbol": "BTCUSDTPERP", //Ticker symbol of the contract - // "tradeId": "5ce24c1f0c19fc3c58edc47c", //Trade ID - // "orderId": "5ce24c16b210233c36ee321d", // Order ID - // "side": "sell", //Transaction side - // "liquidity": "taker", //Liquidity- taker or maker - // "price": "8302", //Filled price - // "size": 10, //Filled amount - // "value": "0.001204529", //Order value - // "feeRate": "0.0005", //Floating fees - // "fixFee": "0.00000006", //Fixed fees - // "feeCurrency": "XBT", //Charging currency - // "stop": "", //A mark to the stop order type - // "fee": "0.0000012022", //Transaction fee - // "orderType": "limit", //Order type - // "tradeType": "trade", //Trade type (trade, liquidation, ADL or settlement) - // "createdAt": 1558334496000, //Time the order created - // "settleCurrency": "XBT", //settlement currency - // "tradeTime": 1558334496000000000 //trade time in nanosecond - // } - // ] - // } - // } - // - object data = this.safeValue(response, "data", new Dictionary() {}); - object trades = this.safeList(data, "items", new List() {}); - return this.parseTrades(trades, market, since, limit); - } - - /** - * @method - * @name poloniexfutures#setMarginMode - * @description set margin mode to 'cross' or 'isolated' - * @see https://api-docs.poloniex.com/futures/api/margin-mode#change-margin-mode - * @param {string} marginMode "0" (isolated) or "1" (cross) - * @param {string} symbol unified market symbol - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} response from the exchange - */ - public async override Task setMarginMode(object marginMode, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - if (isTrue(isEqual(symbol, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " setMarginMode() requires a symbol argument")) ; - } - if (isTrue(isTrue(isTrue(isTrue((!isEqual(marginMode, "0"))) && isTrue((!isEqual(marginMode, "1")))) && isTrue((!isEqual(marginMode, "isolated")))) && isTrue((!isEqual(marginMode, "cross"))))) - { - throw new ArgumentsRequired ((string)add(this.id, " setMarginMode() marginMode must be 0/isolated or 1/cross")) ; - } - await this.loadMarkets(); - if (isTrue(isEqual(marginMode, "isolated"))) - { - marginMode = "0"; - } - if (isTrue(isEqual(marginMode, "cross"))) - { - marginMode = "1"; - } - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - { "marginType", this.parseToInt(marginMode) }, - }; - return await this.privatePostMarginTypeChange(request); - } - - public override object sign(object path, object api = null, object method = null, object parameters = null, object headers = null, object body = null) - { - api ??= "public"; - method ??= "GET"; - parameters ??= new Dictionary(); - object url = getValue(getValue(this.urls, "api"), api); - object versions = this.safeValue(this.options, "versions", new Dictionary() {}); - object apiVersions = this.safeValue(versions, api, new Dictionary() {}); - object methodVersions = this.safeValue(apiVersions, method, new Dictionary() {}); - object defaultVersion = this.safeString(methodVersions, path, this.version); - object version = this.safeString(parameters, "version", defaultVersion); - object tail = add(add(add("/api/", version), "/"), this.implodeParams(path, parameters)); - url = add(url, tail); - object query = this.omit(parameters, this.extractParams(path)); - object queryLength = getArrayLength(new List(((IDictionary)query).Keys)); - if (isTrue(isEqual(api, "public"))) - { - if (isTrue(queryLength)) - { - url = add(url, add("?", this.urlencode(query))); - } - } else - { - this.checkRequiredCredentials(); - object endpoint = add("/api/v1/", this.implodeParams(path, parameters)); - object bodyEncoded = this.urlencode(query); - if (isTrue(isTrue(!isEqual(method, "GET")) && isTrue(!isEqual(method, "HEAD")))) - { - body = query; - } else - { - if (isTrue(isTrue(queryLength) && isTrue(!isEqual(bodyEncoded, "")))) - { - url = add(url, add("?", bodyEncoded)); - endpoint = add(endpoint, add("?", bodyEncoded)); - } - } - object now = ((object)this.milliseconds()).ToString(); - object endpart = ""; - if (isTrue(!isEqual(body, null))) - { - body = this.json(query); - endpart = body; - } - object payload = add(add(add(now, method), endpoint), endpart); - object signature = this.hmac(this.encode(payload), this.encode(this.secret), sha256, "base64"); - headers = new Dictionary() { - { "PF-API-SIGN", signature }, - { "PF-API-TIMESTAMP", now }, - { "PF-API-KEY", this.apiKey }, - { "PF-API-PASSPHRASE", this.password }, - }; - ((IDictionary)headers)["Content-Type"] = "application/json"; - } - return new Dictionary() { - { "url", url }, - { "method", method }, - { "body", body }, - { "headers", headers }, - }; - } - - public override object handleErrors(object code, object reason, object url, object method, object headers, object body, object response, object requestHeaders, object requestBody) - { - if (!isTrue(response)) - { - this.throwBroadlyMatchedException(getValue(this.exceptions, "broad"), body, body); - return null; - } - // - // bad - // { "code": "400100", "msg": "validation.createOrder.clientOidIsRequired" } - // good - // { code: "200000", data: { ... }} - // - object errorCode = this.safeString(response, "code"); - object message = this.safeString(response, "msg", ""); - object feedback = add(add(this.id, " "), message); - this.throwExactlyMatchedException(getValue(this.exceptions, "exact"), message, feedback); - this.throwExactlyMatchedException(getValue(this.exceptions, "exact"), errorCode, feedback); - this.throwBroadlyMatchedException(getValue(this.exceptions, "broad"), body, feedback); - return null; - } -} diff --git a/cs/ccxt/exchanges/pro/bitcoincom.cs b/cs/ccxt/exchanges/pro/bitcoincom.cs deleted file mode 100644 index 7db208826f626..0000000000000 --- a/cs/ccxt/exchanges/pro/bitcoincom.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace ccxt.pro; - -// 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 bitcoincom { public bitcoincom(object args = null) : base(args) { } } -public partial class bitcoincom : hitbtc -{ - public override object describe() - { - // eslint-disable-next-line new-cap - object describeExtended = this.getDescribeForExtendedWsExchange(new ccxt.bitcoincom(), new ccxt.hitbtc(), base.describe()); - return this.deepExtend(describeExtended, new Dictionary() { - { "id", "bitcoincom" }, - { "name", "bitcoin.com" }, - { "countries", new List() {"KN"} }, - { "urls", new Dictionary() { - { "logo", "https://user-images.githubusercontent.com/1294454/97296144-514fa300-1861-11eb-952b-3d55d492200b.jpg" }, - { "api", new Dictionary() { - { "ws", "wss://api.fmfw.io/api/2/ws" }, - } }, - } }, - { "fees", new Dictionary() { - { "trading", new Dictionary() { - { "maker", this.parseNumber("0.0015") }, - { "taker", this.parseNumber("0.002") }, - } }, - } }, - }); - } -} diff --git a/cs/ccxt/exchanges/pro/bitfinex1.cs b/cs/ccxt/exchanges/pro/bitfinex1.cs deleted file mode 100644 index 0b6d4d28e11fd..0000000000000 --- a/cs/ccxt/exchanges/pro/bitfinex1.cs +++ /dev/null @@ -1,743 +0,0 @@ -namespace ccxt.pro; - -// 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 bitfinex1 { public bitfinex1(object args = null) : base(args) { } } -public partial class bitfinex1 : ccxt.bitfinex1 -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "has", new Dictionary() { - { "ws", true }, - { "watchTicker", true }, - { "watchTickers", false }, - { "watchOrderBook", true }, - { "watchTrades", true }, - { "watchTradesForSymbols", false }, - { "watchBalance", false }, - { "watchOHLCV", false }, - } }, - { "urls", new Dictionary() { - { "api", new Dictionary() { - { "ws", new Dictionary() { - { "public", "wss://api-pub.bitfinex.com/ws/1" }, - { "private", "wss://api.bitfinex.com/ws/1" }, - } }, - } }, - } }, - { "options", new Dictionary() { - { "watchOrderBook", new Dictionary() { - { "prec", "P0" }, - { "freq", "F0" }, - } }, - { "ordersLimit", 1000 }, - } }, - }); - } - - public async virtual Task subscribe(object channel, object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object marketId = getValue(market, "id"); - object url = getValue(getValue(getValue(this.urls, "api"), "ws"), "public"); - object messageHash = add(add(channel, ":"), marketId); - // const channel = 'trades'; - object request = new Dictionary() { - { "event", "subscribe" }, - { "channel", channel }, - { "symbol", marketId }, - { "messageHash", messageHash }, - }; - return await this.watch(url, messageHash, this.deepExtend(request, parameters), messageHash); - } - - /** - * @method - * @name bitfinex1#watchTrades - * @description get the list of most recent trades for a particular symbol - * @see https://docs.bitfinex.com/v1/reference/ws-public-trades - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task watchTrades(object symbol, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - symbol = this.symbol(symbol); - object trades = await this.subscribe("trades", symbol, parameters); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(trades, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySinceLimit(trades, since, limit, "timestamp", true); - } - - /** - * @method - * @name bitfinex1#watchTicker - * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - * @see https://docs.bitfinex.com/v1/reference/ws-public-ticker - * @param {string} symbol unified symbol of the market to fetch the ticker for - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task watchTicker(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - return await this.subscribe("ticker", symbol, parameters); - } - - public virtual void handleTrades(WebSocketClient client, object message, object subscription) - { - // - // initial snapshot - // - // [ - // 2, - // [ - // [ null, 1580565020, 9374.9, 0.005 ], - // [ null, 1580565004, 9374.9, 0.005 ], - // [ null, 1580565003, 9374.9, 0.005 ], - // ] - // ] - // - // when a trade does not have an id yet - // - // // channel id, update type, seq, time, price, amount - // [ 2, "te", "28462857-BTCUSD", 1580565041, 9374.9, 0.005 ], - // - // when a trade already has an id - // - // // channel id, update type, seq, trade id, time, price, amount - // [ 2, "tu", "28462857-BTCUSD", 413357662, 1580565041, 9374.9, 0.005 ] - // - object channel = this.safeValue(subscription, "channel"); - object marketId = this.safeString(subscription, "pair"); - object messageHash = add(add(channel, ":"), marketId); - object tradesLimit = this.safeInteger(this.options, "tradesLimit", 1000); - object market = this.safeMarket(marketId); - object symbol = getValue(market, "symbol"); - object data = this.safeValue(message, 1); - object stored = this.safeValue(this.trades, symbol); - if (isTrue(isEqual(stored, null))) - { - stored = new ArrayCache(tradesLimit); - ((IDictionary)this.trades)[(string)symbol] = stored; - } - if (isTrue(((data is IList) || (data.GetType().IsGenericType && data.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))))) - { - object trades = this.parseTrades(data, market); - for (object i = 0; isLessThan(i, getArrayLength(trades)); postFixIncrement(ref i)) - { - callDynamically(stored, "append", new object[] {getValue(trades, i)}); - } - } else - { - object second = this.safeString(message, 1); - if (isTrue(!isEqual(second, "tu"))) - { - return; - } - object trade = this.parseTrade(message, market); - callDynamically(stored, "append", new object[] {trade}); - } - callDynamically(client as WebSocketClient, "resolve", new object[] {stored, messageHash}); - } - - public override object parseTrade(object trade, object market = null) - { - // - // snapshot trade - // - // // null, time, price, amount - // [ null, 1580565020, 9374.9, 0.005 ], - // - // when a trade does not have an id yet - // - // // channel id, update type, seq, time, price, amount - // [ 2, "te", "28462857-BTCUSD", 1580565041, 9374.9, 0.005 ], - // - // when a trade already has an id - // - // // channel id, update type, seq, trade id, time, price, amount - // [ 2, "tu", "28462857-BTCUSD", 413357662, 1580565041, 9374.9, 0.005 ] - // - if (!isTrue(((trade is IList) || (trade.GetType().IsGenericType && trade.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))))) - { - return base.parseTrade(trade, market); - } - object tradeLength = getArrayLength(trade); - object eventVar = this.safeString(trade, 1); - object id = null; - if (isTrue(isEqual(eventVar, "tu"))) - { - id = this.safeString(trade, subtract(tradeLength, 4)); - } - object timestamp = this.safeTimestamp(trade, subtract(tradeLength, 3)); - object price = this.safeString(trade, subtract(tradeLength, 2)); - object amount = this.safeString(trade, subtract(tradeLength, 1)); - object side = null; - if (isTrue(!isEqual(amount, null))) - { - side = ((bool) isTrue(Precise.stringGt(amount, "0"))) ? "buy" : "sell"; - amount = Precise.stringAbs(amount); - } - object seq = this.safeString(trade, 2); - object parts = ((string)seq).Split(new [] {((string)"-")}, StringSplitOptions.None).ToList(); - object marketId = this.safeString(parts, 1); - if (isTrue(!isEqual(marketId, null))) - { - marketId = ((string)marketId).Replace((string)"t", (string)""); - } - object symbol = this.safeSymbol(marketId, market); - object takerOrMaker = null; - object orderId = null; - return this.safeTrade(new Dictionary() { - { "info", trade }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "symbol", symbol }, - { "id", id }, - { "order", orderId }, - { "type", null }, - { "takerOrMaker", takerOrMaker }, - { "side", side }, - { "price", price }, - { "amount", amount }, - { "cost", null }, - { "fee", null }, - }); - } - - public virtual void handleTicker(WebSocketClient client, object message, object subscription) - { - // - // [ - // 2, // 0 CHANNEL_ID integer Channel ID - // 236.62, // 1 BID float Price of last highest bid - // 9.0029, // 2 BID_SIZE float Size of the last highest bid - // 236.88, // 3 ASK float Price of last lowest ask - // 7.1138, // 4 ASK_SIZE float Size of the last lowest ask - // -1.02, // 5 DAILY_CHANGE float Amount that the last price has changed since yesterday - // 0, // 6 DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms - // 236.52, // 7 LAST_PRICE float Price of the last trade. - // 5191.36754297, // 8 VOLUME float Daily volume - // 250.01, // 9 HIGH float Daily high - // 220.05, // 10 LOW float Daily low - // ] - // - object marketId = this.safeString(subscription, "pair"); - object symbol = this.safeSymbol(marketId); - object channel = "ticker"; - object messageHash = add(add(channel, ":"), marketId); - object last = this.safeString(message, 7); - object change = this.safeString(message, 5); - object open = null; - if (isTrue(isTrue((!isEqual(last, null))) && isTrue((!isEqual(change, null))))) - { - open = Precise.stringSub(last, change); - } - object result = this.safeTicker(new Dictionary() { - { "symbol", symbol }, - { "timestamp", null }, - { "datetime", null }, - { "high", this.safeString(message, 9) }, - { "low", this.safeString(message, 10) }, - { "bid", this.safeString(message, 1) }, - { "bidVolume", null }, - { "ask", this.safeString(message, 3) }, - { "askVolume", null }, - { "vwap", null }, - { "open", this.parseNumber(open) }, - { "close", this.parseNumber(last) }, - { "last", this.parseNumber(last) }, - { "previousClose", null }, - { "change", this.parseNumber(change) }, - { "percentage", this.safeString(message, 6) }, - { "average", null }, - { "baseVolume", this.safeString(message, 8) }, - { "quoteVolume", null }, - { "info", message }, - }); - ((IDictionary)this.tickers)[(string)symbol] = result; - callDynamically(client as WebSocketClient, "resolve", new object[] {result, messageHash}); - } - - /** - * @method - * @name bitfinex1#watchOrderBook - * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://docs.bitfinex.com/v1/reference/ws-public-order-books - * @param {string} symbol unified symbol of the market to fetch the order book for - * @param {int} [limit] the maximum amount of order book entries to return - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols - */ - public async override Task watchOrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - if (isTrue(!isEqual(limit, null))) - { - if (isTrue(isTrue((!isEqual(limit, 25))) && isTrue((!isEqual(limit, 100))))) - { - throw new ExchangeError ((string)add(this.id, " watchOrderBook limit argument must be undefined, 25 or 100")) ; - } - } - object options = this.safeValue(this.options, "watchOrderBook", new Dictionary() {}); - object prec = this.safeString(options, "prec", "P0"); - object freq = this.safeString(options, "freq", "F0"); - object request = new Dictionary() { - { "prec", prec }, - { "freq", freq }, - { "len", limit }, - }; - object orderbook = await this.subscribe("book", symbol, this.deepExtend(request, parameters)); - return (orderbook as IOrderBook).limit(); - } - - public virtual void handleOrderBook(WebSocketClient client, object message, object subscription) - { - // - // first message (snapshot) - // - // [ - // 18691, // channel id - // [ - // [ 7364.8, 10, 4.354802 ], // price, count, size > 0 = bid - // [ 7364.7, 1, 0.00288831 ], - // [ 7364.3, 12, 0.048 ], - // [ 7364.9, 3, -0.42028976 ], // price, count, size < 0 = ask - // [ 7365, 1, -0.25 ], - // [ 7365.5, 1, -0.00371937 ], - // ] - // ] - // - // subsequent updates - // - // [ - // 30, // channel id - // 9339.9, // price - // 0, // count - // -1, // size > 0 = bid, size < 0 = ask - // ] - // - object marketId = this.safeString(subscription, "pair"); - object symbol = this.safeSymbol(marketId); - object channel = "book"; - object messageHash = add(add(channel, ":"), marketId); - object prec = this.safeString(subscription, "prec", "P0"); - object isRaw = (isEqual(prec, "R0")); - // if it is an initial snapshot - if (isTrue(((getValue(message, 1) is IList) || (getValue(message, 1).GetType().IsGenericType && getValue(message, 1).GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))))) - { - object limit = this.safeInteger(subscription, "len"); - if (isTrue(isRaw)) - { - // raw order books - ((IDictionary)this.orderbooks)[(string)symbol] = this.indexedOrderBook(new Dictionary() {}, limit); - } else - { - // P0, P1, P2, P3, P4 - ((IDictionary)this.orderbooks)[(string)symbol] = this.countedOrderBook(new Dictionary() {}, limit); - } - object orderbook = getValue(this.orderbooks, symbol); - if (isTrue(isRaw)) - { - object deltas = getValue(message, 1); - for (object i = 0; isLessThan(i, getArrayLength(deltas)); postFixIncrement(ref i)) - { - object delta = getValue(deltas, i); - object id = this.safeString(delta, 0); - object price = this.safeFloat(delta, 1); - object delta2Value = getValue(delta, 2); - object size = ((bool) isTrue((isLessThan(delta2Value, 0)))) ? prefixUnaryNeg(ref delta2Value) : delta2Value; - object side = ((bool) isTrue((isLessThan(delta2Value, 0)))) ? "asks" : "bids"; - object bookside = getValue(orderbook, side); - (bookside as IOrderBookSide).storeArray(new List() {price, size, id}); - } - } else - { - object deltas = getValue(message, 1); - for (object i = 0; isLessThan(i, getArrayLength(deltas)); postFixIncrement(ref i)) - { - object delta = getValue(deltas, i); - object delta2 = getValue(delta, 2); - object size = ((bool) isTrue((isLessThan(delta2, 0)))) ? prefixUnaryNeg(ref delta2) : delta2; - object side = ((bool) isTrue((isLessThan(delta2, 0)))) ? "asks" : "bids"; - object countedBookSide = getValue(orderbook, side); - (countedBookSide as IOrderBookSide).storeArray(new List() {getValue(delta, 0), size, getValue(delta, 1)}); - } - } - callDynamically(client as WebSocketClient, "resolve", new object[] {orderbook, messageHash}); - } else - { - object orderbook = getValue(this.orderbooks, symbol); - if (isTrue(isRaw)) - { - object id = this.safeString(message, 1); - object price = this.safeString(message, 2); - object message3 = getValue(message, 3); - object size = ((bool) isTrue((isLessThan(message3, 0)))) ? prefixUnaryNeg(ref message3) : message3; - object side = ((bool) isTrue((isLessThan(message3, 0)))) ? "asks" : "bids"; - object bookside = getValue(orderbook, side); - // price = 0 means that you have to remove the order from your book - object amount = ((bool) isTrue(Precise.stringGt(price, "0"))) ? size : "0"; - (bookside as IOrderBookSide).storeArray(new List {this.parseNumber(price), this.parseNumber(amount), id}); - } else - { - object message3Value = getValue(message, 3); - object size = ((bool) isTrue((isLessThan(message3Value, 0)))) ? prefixUnaryNeg(ref message3Value) : message3Value; - object side = ((bool) isTrue((isLessThan(message3Value, 0)))) ? "asks" : "bids"; - object countedBookSide = getValue(orderbook, side); - (countedBookSide as IOrderBookSide).storeArray(new List() {getValue(message, 1), size, getValue(message, 2)}); - } - callDynamically(client as WebSocketClient, "resolve", new object[] {orderbook, messageHash}); - } - } - - public virtual void handleHeartbeat(WebSocketClient client, object message) - { - // - // every second (approx) if no other updates are sent - // - // { "event": "heartbeat" } - // - object eventVar = this.safeString(message, "event"); - callDynamically(client as WebSocketClient, "resolve", new object[] {message, eventVar}); - } - - public virtual object handleSystemStatus(WebSocketClient client, object message) - { - // - // todo: answer the question whether handleSystemStatus should be renamed - // and unified as handleStatus for any usage pattern that - // involves system status and maintenance updates - // - // { - // "event": "info", - // "version": 2, - // "serverId": "e293377e-7bb7-427e-b28c-5db045b2c1d1", - // "platform": { status: 1 }, // 1 for operative, 0 for maintenance - // } - // - return message; - } - - public virtual object handleSubscriptionStatus(WebSocketClient client, object message) - { - // - // { - // "event": "subscribed", - // "channel": "book", - // "chanId": 67473, - // "symbol": "tBTCUSD", - // "prec": "P0", - // "freq": "F0", - // "len": "25", - // "pair": "BTCUSD" - // } - // - object channelId = this.safeString(message, "chanId"); - ((IDictionary)((WebSocketClient)client).subscriptions)[(string)channelId] = message; - return message; - } - - public async virtual Task authenticate(object parameters = null) - { - parameters ??= new Dictionary(); - object url = getValue(getValue(getValue(this.urls, "api"), "ws"), "private"); - var client = this.client(url); - var future = client.future("authenticated"); - object method = "auth"; - object authenticated = this.safeValue(((WebSocketClient)client).subscriptions, method); - if (isTrue(isEqual(authenticated, null))) - { - object nonce = this.milliseconds(); - object payload = add("AUTH", ((object)nonce).ToString()); - object signature = this.hmac(this.encode(payload), this.encode(this.secret), sha384, "hex"); - object request = new Dictionary() { - { "apiKey", this.apiKey }, - { "authSig", signature }, - { "authNonce", nonce }, - { "authPayload", payload }, - { "event", method }, - { "filter", new List() {"trading", "wallet"} }, - }; - this.spawn(this.watch, new object[] { url, method, request, 1}); - } - return await (future as Exchange.Future); - } - - public virtual void handleAuthenticationMessage(WebSocketClient client, object message) - { - object status = this.safeString(message, "status"); - if (isTrue(isEqual(status, "OK"))) - { - // we resolve the future here permanently so authentication only happens once - var future = this.safeValue((client as WebSocketClient).futures, "authenticated"); - (future as Future).resolve(true); - } else - { - var error = new AuthenticationError(this.json(message)); - ((WebSocketClient)client).reject(error, "authenticated"); - // allows further authentication attempts - object method = this.safeString(message, "event"); - if (isTrue(inOp(((WebSocketClient)client).subscriptions, method))) - { - ((IDictionary)((WebSocketClient)client).subscriptions).Remove((string)method); - } - } - } - - public async virtual Task watchOrder(object id, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object url = getValue(getValue(getValue(this.urls, "api"), "ws"), "private"); - await this.authenticate(); - return await this.watch(url, id, null, 1); - } - - /** - * @method - * @name bitfinex1#watchOrders - * @description watches information on multiple orders made by the user - * @see https://docs.bitfinex.com/v1/reference/ws-auth-order-updates - * @see https://docs.bitfinex.com/v1/reference/ws-auth-order-snapshots - * @param {string} symbol unified market symbol of the market orders were made in - * @param {int} [since] the earliest time in ms to fetch orders for - * @param {int} [limit] the maximum number of order structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task watchOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - await this.authenticate(); - if (isTrue(!isEqual(symbol, null))) - { - symbol = this.symbol(symbol); - } - object url = getValue(getValue(getValue(this.urls, "api"), "ws"), "private"); - object orders = await this.watch(url, "os", null, 1); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(orders, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true); - } - - public virtual void handleOrders(WebSocketClient client, object message, object subscription) - { - // - // order snapshot - // - // [ - // 0, - // "os", - // [ - // [ - // 45287766631, - // "ETHUST", - // -0.07, - // -0.07, - // "EXCHANGE LIMIT", - // "ACTIVE", - // 210, - // 0, - // "2020-05-16T13:17:46Z", - // 0, - // 0, - // 0 - // ] - // ] - // ] - // - // order cancel - // - // [ - // 0, - // "oc", - // [ - // 45287766631, - // "ETHUST", - // -0.07, - // -0.07, - // "EXCHANGE LIMIT", - // "CANCELED", - // 210, - // 0, - // "2020-05-16T13:17:46Z", - // 0, - // 0, - // 0, - // ] - // ] - // - object data = this.safeValue(message, 2, new List() {}); - object messageType = this.safeString(message, 1); - if (isTrue(isEqual(messageType, "os"))) - { - for (object i = 0; isLessThan(i, getArrayLength(data)); postFixIncrement(ref i)) - { - object value = getValue(data, i); - this.handleOrder(client as WebSocketClient, value); - } - } else - { - this.handleOrder(client as WebSocketClient, data); - } - if (isTrue(!isEqual(this.orders, null))) - { - callDynamically(client as WebSocketClient, "resolve", new object[] {this.orders, "os"}); - } - } - - public virtual object parseWsOrderStatus(object status) - { - object statuses = new Dictionary() { - { "ACTIVE", "open" }, - { "CANCELED", "canceled" }, - }; - return this.safeString(statuses, status, status); - } - - public virtual object handleOrder(WebSocketClient client, object order) - { - // [ 45287766631, - // "ETHUST", - // -0.07, - // -0.07, - // "EXCHANGE LIMIT", - // "CANCELED", - // 210, - // 0, - // "2020-05-16T13:17:46Z", - // 0, - // 0, - // 0 ] - object id = this.safeString(order, 0); - object marketId = this.safeString(order, 1); - object symbol = this.safeSymbol(marketId); - object amount = this.safeString(order, 2); - object remaining = this.safeString(order, 3); - object side = "buy"; - if (isTrue(Precise.stringLt(amount, "0"))) - { - amount = Precise.stringAbs(amount); - remaining = Precise.stringAbs(remaining); - side = "sell"; - } - object type = this.safeString(order, 4); - if (isTrue(isGreaterThan(getIndexOf(type, "LIMIT"), -1))) - { - type = "limit"; - } else if (isTrue(isGreaterThan(getIndexOf(type, "MARKET"), -1))) - { - type = "market"; - } - object status = this.parseWsOrderStatus(this.safeString(order, 5)); - object price = this.safeString(order, 6); - object rawDatetime = this.safeString(order, 8); - object timestamp = this.parse8601(rawDatetime); - object parsed = this.safeOrder(new Dictionary() { - { "info", order }, - { "id", id }, - { "clientOrderId", null }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "lastTradeTimestamp", null }, - { "symbol", symbol }, - { "type", type }, - { "side", side }, - { "price", price }, - { "stopPrice", null }, - { "triggerPrice", null }, - { "average", null }, - { "amount", amount }, - { "remaining", remaining }, - { "filled", null }, - { "status", status }, - { "fee", null }, - { "cost", null }, - { "trades", null }, - }); - if (isTrue(isEqual(this.orders, null))) - { - object limit = this.safeInteger(this.options, "ordersLimit", 1000); - this.orders = new ArrayCacheBySymbolById(limit); - } - object orders = this.orders; - callDynamically(orders, "append", new object[] {parsed}); - callDynamically(client as WebSocketClient, "resolve", new object[] {parsed, id}); - return parsed; - } - - public override void handleMessage(WebSocketClient client, object message) - { - if (isTrue(((message is IList) || (message.GetType().IsGenericType && message.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(List<>)))))) - { - object channelId = this.safeString(message, 0); - // - // [ - // 1231, - // "hb", - // ] - // - if (isTrue(isEqual(getValue(message, 1), "hb"))) - { - return; // skip heartbeats within subscription channels for now - } - object subscription = this.safeValue(((WebSocketClient)client).subscriptions, channelId, new Dictionary() {}); - object channel = this.safeString(subscription, "channel"); - object name = this.safeString(message, 1); - object methods = new Dictionary() { - { "book", this.handleOrderBook }, - { "ticker", this.handleTicker }, - { "trades", this.handleTrades }, - { "os", this.handleOrders }, - { "on", this.handleOrders }, - { "oc", this.handleOrders }, - }; - object method = this.safeValue2(methods, channel, name); - if (isTrue(!isEqual(method, null))) - { - DynamicInvoker.InvokeMethod(method, new object[] { client, message, subscription}); - } - } else - { - // todo add bitfinex handleErrorMessage - // - // { - // "event": "info", - // "version": 2, - // "serverId": "e293377e-7bb7-427e-b28c-5db045b2c1d1", - // "platform": { status: 1 }, // 1 for operative, 0 for maintenance - // } - // - object eventVar = this.safeString(message, "event"); - if (isTrue(!isEqual(eventVar, null))) - { - object methods = new Dictionary() { - { "info", this.handleSystemStatus }, - { "subscribed", this.handleSubscriptionStatus }, - { "auth", this.handleAuthenticationMessage }, - }; - object method = this.safeValue(methods, eventVar); - if (isTrue(!isEqual(method, null))) - { - DynamicInvoker.InvokeMethod(method, new object[] { client, message}); - } - } - } - } -} diff --git a/cs/ccxt/exchanges/pro/bitpanda.cs b/cs/ccxt/exchanges/pro/bitpanda.cs deleted file mode 100644 index 65b6cc53ff605..0000000000000 --- a/cs/ccxt/exchanges/pro/bitpanda.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ccxt.pro; - -// 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 bitpanda { public bitpanda(object args = null) : base(args) { } } -public partial class bitpanda : onetrading -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "alias", true }, - { "id", "bitpanda" }, - }); - } -} diff --git a/cs/ccxt/exchanges/pro/bitstamp.cs b/cs/ccxt/exchanges/pro/bitstamp.cs index e0c22d4a3748f..c1eb54ae3281b 100644 --- a/cs/ccxt/exchanges/pro/bitstamp.cs +++ b/cs/ccxt/exchanges/pro/bitstamp.cs @@ -340,6 +340,7 @@ public virtual void handleOrders(WebSocketClient client, object message) // "price_str":"1000.00" // }, // "channel":"private-my_orders_ltcusd-4848701", + // "event": "order_deleted" // field only present for cancelOrder // } // object channel = this.safeString(message, "channel"); @@ -353,6 +354,7 @@ public virtual void handleOrders(WebSocketClient client, object message) object subscription = this.safeValue(((WebSocketClient)client).subscriptions, channel); object symbol = this.safeString(subscription, "symbol"); object market = this.market(symbol); + ((IDictionary)order)["event"] = this.safeString(message, "event"); object parsed = this.parseWsOrder(order, market); callDynamically(stored, "append", new object[] {parsed}); callDynamically(client as WebSocketClient, "resolve", new object[] {this.orders, channel}); @@ -361,23 +363,60 @@ public virtual void handleOrders(WebSocketClient client, object message) public override object parseWsOrder(object order, object market = null) { // - // { - // "id":"1463471322288128", - // "id_str":"1463471322288128", - // "order_type":1, - // "datetime":"1646127778", - // "microtimestamp":"1646127777950000", - // "amount":0.05, - // "amount_str":"0.05000000", - // "price":1000, - // "price_str":"1000.00" + // { + // "id": "1894876776091648", + // "id_str": "1894876776091648", + // "order_type": 0, + // "order_subtype": 0, + // "datetime": "1751451375", + // "microtimestamp": "1751451375070000", + // "amount": 1.1, + // "amount_str": "1.10000000", + // "amount_traded": "0", + // "amount_at_create": "1.10000000", + // "price": 10.23, + // "price_str": "10.23", + // "is_liquidation": false, + // "trade_account_id": 0 // } // object id = this.safeString(order, "id_str"); - object orderType = this.safeStringLower(order, "order_type"); + object orderTypeRaw = this.safeStringLower(order, "order_type"); + object side = ((bool) isTrue((isEqual(orderTypeRaw, "1")))) ? "sell" : "buy"; + object orderSubTypeRaw = this.safeStringLower(order, "order_subtype"); // https://www.bitstamp.net/websocket/v2/#:~:text=order_subtype + object orderType = null; + object timeInForce = null; + if (isTrue(isEqual(orderSubTypeRaw, "0"))) + { + orderType = "limit"; + } else if (isTrue(isEqual(orderSubTypeRaw, "2"))) + { + orderType = "market"; + } else if (isTrue(isEqual(orderSubTypeRaw, "4"))) + { + orderType = "limit"; + timeInForce = "IOC"; + } else if (isTrue(isEqual(orderSubTypeRaw, "6"))) + { + orderType = "limit"; + timeInForce = "FOK"; + } else if (isTrue(isEqual(orderSubTypeRaw, "8"))) + { + orderType = "limit"; + timeInForce = "GTD"; + } object price = this.safeString(order, "price_str"); object amount = this.safeString(order, "amount_str"); - object side = ((bool) isTrue((isEqual(orderType, "1")))) ? "sell" : "buy"; + object filled = this.safeString(order, "amount_traded"); + object eventVar = this.safeString(order, "event"); + object status = null; + if (isTrue(Precise.stringEq(filled, amount))) + { + status = "closed"; + } else if (isTrue(isEqual(eventVar, "order_deleted"))) + { + status = "canceled"; + } object timestamp = this.safeTimestamp(order, "datetime"); market = this.safeMarket(null, market); object symbol = getValue(market, "symbol"); @@ -389,8 +428,8 @@ public override object parseWsOrder(object order, object market = null) { "timestamp", timestamp }, { "datetime", this.iso8601(timestamp) }, { "lastTradeTimestamp", null }, - { "type", null }, - { "timeInForce", null }, + { "type", orderType }, + { "timeInForce", timeInForce }, { "postOnly", null }, { "side", side }, { "price", price }, @@ -399,9 +438,9 @@ public override object parseWsOrder(object order, object market = null) { "amount", amount }, { "cost", null }, { "average", null }, - { "filled", null }, + { "filled", filled }, { "remaining", null }, - { "status", null }, + { "status", status }, { "fee", null }, { "trades", null }, }, market); @@ -473,6 +512,7 @@ public virtual void handleSubject(WebSocketClient client, object message) // "price_str":"1000.00" // }, // "channel":"private-my_orders_ltcusd-4848701", + // "event": "order_deleted" // field only present for cancelOrder // } // object channel = this.safeString(message, "channel"); diff --git a/cs/ccxt/exchanges/pro/bybit.cs b/cs/ccxt/exchanges/pro/bybit.cs index b20fa3490a80a..2895fb02a33f4 100644 --- a/cs/ccxt/exchanges/pro/bybit.cs +++ b/cs/ccxt/exchanges/pro/bybit.cs @@ -2743,7 +2743,8 @@ public virtual object handleUnSubscribe(WebSocketClient client, object message) { object unsubHash = getValue(messageHashes, j); object subHash = getValue(subMessageHashes, j); - this.cleanUnsubscription(client as WebSocketClient, subHash, unsubHash); + object usePrefix = isTrue((isEqual(subHash, "orders"))) || isTrue((isEqual(subHash, "myTrades"))); + this.cleanUnsubscription(client as WebSocketClient, subHash, unsubHash, usePrefix); } this.cleanCache(subscription); } diff --git a/cs/ccxt/exchanges/pro/hyperliquid.cs b/cs/ccxt/exchanges/pro/hyperliquid.cs index 93a7f068a8bb9..27bd9b0dd2cc1 100644 --- a/cs/ccxt/exchanges/pro/hyperliquid.cs +++ b/cs/ccxt/exchanges/pro/hyperliquid.cs @@ -179,7 +179,7 @@ public async override Task watchOrderBook(object symbol, object limit = { "method", "subscribe" }, { "subscription", new Dictionary() { { "type", "l2Book" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, } }, }; object message = this.extend(request, parameters); @@ -211,7 +211,7 @@ public async override Task unWatchOrderBook(object symbol, object parame { "method", "unsubscribe" }, { "subscription", new Dictionary() { { "type", "l2Book" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, } }, }; object message = this.extend(request, parameters); @@ -554,7 +554,7 @@ public async override Task watchTrades(object symbol, object since = nul { "method", "subscribe" }, { "subscription", new Dictionary() { { "type", "trades" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, } }, }; object message = this.extend(request, parameters); @@ -588,7 +588,7 @@ public async override Task unWatchTrades(object symbol, object parameter { "method", "unsubscribe" }, { "subscription", new Dictionary() { { "type", "trades" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, } }, }; object message = this.extend(request, parameters); @@ -729,7 +729,7 @@ public async override Task watchOHLCV(object symbol, object timeframe = { "method", "subscribe" }, { "subscription", new Dictionary() { { "type", "candle" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, { "interval", timeframe }, } }, }; @@ -765,7 +765,7 @@ public async virtual Task unWatchOHLCV(object symbol, object timeframe = { "method", "unsubscribe" }, { "subscription", new Dictionary() { { "type", "candle" }, - { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "base") : getValue(market, "id") }, + { "coin", ((bool) isTrue(getValue(market, "swap"))) ? getValue(market, "baseName") : getValue(market, "id") }, { "interval", timeframe }, } }, }; diff --git a/cs/ccxt/exchanges/pro/kraken.cs b/cs/ccxt/exchanges/pro/kraken.cs index 46940f3a0c343..8c196ff86e546 100644 --- a/cs/ccxt/exchanges/pro/kraken.cs +++ b/cs/ccxt/exchanges/pro/kraken.cs @@ -860,14 +860,12 @@ public async override Task watchOrderBook(object symbol, object limit = public async override Task watchOrderBookForSymbols(object symbols, object limit = null, object parameters = null) { parameters ??= new Dictionary(); - object request = new Dictionary() {}; + object requiredParams = new Dictionary() {}; if (isTrue(!isEqual(limit, null))) { if (isTrue(this.inArray(limit, new List() {10, 25, 100, 500, 1000}))) { - ((IDictionary)request)["params"] = new Dictionary() { - { "depth", limit }, - }; + ((IDictionary)requiredParams)["depth"] = limit; // default 10, valid options 10, 25, 100, 500, 1000 } else { throw new NotSupported ((string)add(this.id, " watchOrderBook accepts limit values of 10, 25, 100, 500 and 1000 only")) ; @@ -875,7 +873,7 @@ public async override Task watchOrderBookForSymbols(object symbols, obje } object orderbook = await this.watchMultiHelper("orderbook", "book", symbols, new Dictionary() { { "limit", limit }, - }, this.extend(request, parameters)); + }, this.extend(requiredParams, parameters)); return (orderbook as IOrderBook).limit(); } @@ -1900,22 +1898,23 @@ public virtual object handleErrorMessage(WebSocketClient client, object message) object errorMessage = this.safeString2(message, "errorMessage", "error"); if (isTrue(!isEqual(errorMessage, null))) { - object requestId = this.safeValue2(message, "reqid", "req_id"); - if (isTrue(!isEqual(requestId, null))) + // const requestId = this.safeValue2 (message, 'reqid', 'req_id'); + object broad = getValue(getValue(this.exceptions, "ws"), "broad"); + object broadKey = this.findBroadlyMatchedKey(broad, errorMessage); + object exception = null; + if (isTrue(isEqual(broadKey, null))) { - object broad = getValue(getValue(this.exceptions, "ws"), "broad"); - object broadKey = this.findBroadlyMatchedKey(broad, errorMessage); - object exception = null; - if (isTrue(isEqual(broadKey, null))) - { - exception = new ExchangeError( ((string)errorMessage)); // c# requirement to convert the errorMessage to string - } else - { - exception = this.newException(getValue(broad, broadKey), errorMessage); - } - ((WebSocketClient)client).reject(exception, requestId); - return false; + exception = new ExchangeError( ((string)errorMessage)); // c# requirement to convert the errorMessage to string + } else + { + exception = this.newException(getValue(broad, broadKey), errorMessage); } + // if (requestId !== undefined) { + // ((WebSocketClient)client).reject (exception, requestId); + // } else { + ((WebSocketClient)client).reject(exception); + // } + return false; } return true; } diff --git a/cs/ccxt/exchanges/pro/mexc.cs b/cs/ccxt/exchanges/pro/mexc.cs index 6ec26c5d679a5..d0b7c27d2f167 100644 --- a/cs/ccxt/exchanges/pro/mexc.cs +++ b/cs/ccxt/exchanges/pro/mexc.cs @@ -1589,7 +1589,7 @@ public async virtual Task unWatchTicker(object symbol, object parameters } url = getValue(getValue(getValue(this.urls, "api"), "ws"), "spot"); ((IDictionary)parameters)["unsubscribed"] = true; - this.watchSpotPublic(channel, messageHash, parameters); + await this.watchSpotPublic(channel, messageHash, parameters); } else { channel = "unsub.ticker"; @@ -1597,7 +1597,7 @@ public async virtual Task unWatchTicker(object symbol, object parameters { "symbol", getValue(market, "id") }, }; url = getValue(getValue(getValue(this.urls, "api"), "ws"), "swap"); - this.watchSwapPublic(channel, messageHash, requestParams, parameters); + await this.watchSwapPublic(channel, messageHash, requestParams, parameters); } var client = this.client(url); this.handleUnsubscriptions(client as WebSocketClient, new List() {messageHash}); @@ -1675,7 +1675,7 @@ public async override Task unWatchTickers(object symbols = null, object ((IList)messageHashes).Add("unsubscribe:ticker"); } var client = this.client(url); - this.watchMultiple(url, messageHashes, this.extend(request, parameters), messageHashes); + await this.watchMultiple(url, messageHashes, this.extend(request, parameters), messageHashes); this.handleUnsubscriptions(client as WebSocketClient, messageHashes); return null; } @@ -1724,7 +1724,7 @@ public async virtual Task unWatchBidsAsks(object symbols = null, object { "params", topics }, }; var client = this.client(url); - this.watchMultiple(url, messageHashes, this.extend(request, parameters), messageHashes); + await this.watchMultiple(url, messageHashes, this.extend(request, parameters), messageHashes); this.handleUnsubscriptions(client as WebSocketClient, messageHashes); return null; } @@ -1755,7 +1755,7 @@ public async virtual Task unWatchOHLCV(object symbol, object timeframe = url = getValue(getValue(getValue(this.urls, "api"), "ws"), "spot"); object channel = add(add(add("spot@public.kline.v3.api@", getValue(market, "id")), "@"), timeframeId); ((IDictionary)parameters)["unsubscribed"] = true; - this.watchSpotPublic(channel, messageHash, parameters); + await this.watchSpotPublic(channel, messageHash, parameters); } else { url = getValue(getValue(getValue(this.urls, "api"), "ws"), "swap"); @@ -1764,7 +1764,7 @@ public async virtual Task unWatchOHLCV(object symbol, object timeframe = { "symbol", getValue(market, "id") }, { "interval", timeframeId }, }; - this.watchSwapPublic(channel, messageHash, requestParams, parameters); + await this.watchSwapPublic(channel, messageHash, requestParams, parameters); } var client = this.client(url); this.handleUnsubscriptions(client as WebSocketClient, new List() {messageHash}); @@ -1792,7 +1792,7 @@ public async override Task unWatchOrderBook(object symbol, object parame url = getValue(getValue(getValue(this.urls, "api"), "ws"), "spot"); object channel = add("spot@public.increase.depth.v3.api@", getValue(market, "id")); ((IDictionary)parameters)["unsubscribed"] = true; - this.watchSpotPublic(channel, messageHash, parameters); + await this.watchSpotPublic(channel, messageHash, parameters); } else { url = getValue(getValue(getValue(this.urls, "api"), "ws"), "swap"); @@ -1800,7 +1800,7 @@ public async override Task unWatchOrderBook(object symbol, object parame object requestParams = new Dictionary() { { "symbol", getValue(market, "id") }, }; - this.watchSwapPublic(channel, messageHash, requestParams, parameters); + await this.watchSwapPublic(channel, messageHash, requestParams, parameters); } var client = this.client(url); this.handleUnsubscriptions(client as WebSocketClient, new List() {messageHash}); @@ -1829,7 +1829,7 @@ public async override Task unWatchTrades(object symbol, object parameter url = getValue(getValue(getValue(this.urls, "api"), "ws"), "spot"); object channel = add("spot@public.deals.v3.api@", getValue(market, "id")); ((IDictionary)parameters)["unsubscribed"] = true; - this.watchSpotPublic(channel, messageHash, parameters); + await this.watchSpotPublic(channel, messageHash, parameters); } else { url = getValue(getValue(getValue(this.urls, "api"), "ws"), "swap"); @@ -1837,7 +1837,7 @@ public async override Task unWatchTrades(object symbol, object parameter object requestParams = new Dictionary() { { "symbol", getValue(market, "id") }, }; - this.watchSwapPublic(channel, messageHash, requestParams, parameters); + await this.watchSwapPublic(channel, messageHash, requestParams, parameters); } var client = this.client(url); this.handleUnsubscriptions(client as WebSocketClient, new List() {messageHash}); diff --git a/cs/ccxt/exchanges/pro/poloniexfutures.cs b/cs/ccxt/exchanges/pro/poloniexfutures.cs deleted file mode 100644 index 3f65bfc5e1932..0000000000000 --- a/cs/ccxt/exchanges/pro/poloniexfutures.cs +++ /dev/null @@ -1,1143 +0,0 @@ -namespace ccxt.pro; - -// 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 poloniexfutures { public poloniexfutures(object args = null) : base(args) { } } -public partial class poloniexfutures : ccxt.poloniexfutures -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "has", new Dictionary() { - { "ws", true }, - { "cancelAllOrdersWs", false }, - { "cancelOrdersWs", false }, - { "cancelOrderWs", false }, - { "createOrderWs", false }, - { "editOrderWs", false }, - { "fetchBalanceWs", false }, - { "fetchOpenOrdersWs", false }, - { "fetchOrderWs", false }, - { "fetchTradesWs", false }, - { "watchOHLCV", false }, - { "watchOrderBook", true }, - { "watchTicker", true }, - { "watchTickers", false }, - { "watchTrades", true }, - { "watchTradesForSymbols", false }, - { "watchBalance", true }, - { "watchOrders", true }, - { "watchMyTrades", false }, - { "watchPosition", null }, - { "watchPositions", false }, - } }, - { "urls", new Dictionary() { - { "api", new Dictionary() { - { "ws", "wss://futures-apiws.poloniex.com/endpoint" }, - } }, - } }, - { "options", new Dictionary() { - { "tradesLimit", 1000 }, - { "ordersLimit", 1000 }, - { "watchTicker", new Dictionary() { - { "method", "/contractMarket/ticker" }, - } }, - { "watchOrders", new Dictionary() { - { "method", "/contractMarket/tradeOrders" }, - } }, - { "watchOrderBook", new Dictionary() { - { "method", "/contractMarket/level2" }, - { "snapshotDelay", 5 }, - { "snapshotMaxRetries", 3 }, - { "checksum", true }, - } }, - { "streamLimit", 5 }, - { "streamBySubscriptionsHash", new Dictionary() {} }, - { "streamIndex", -1 }, - } }, - { "streaming", new Dictionary() { - { "keepAlive", 30000 }, - { "maxPingPongMisses", 2 }, - } }, - }); - } - - public async virtual Task negotiate(object privateChannel, object parameters = null) - { - parameters ??= new Dictionary(); - object connectId = ((bool) isTrue(privateChannel)) ? "private" : "public"; - object urls = this.safeValue(this.options, "urls", new Dictionary() {}); - if (isTrue(inOp(urls, connectId))) - { - // return urls[connectId]; - object storedFuture = getValue(urls, connectId); - return await (storedFuture as Exchange.Future); - } - // we store an awaitable to the url - // so that multiple calls don't asynchronously - // fetch different urls and overwrite each other - ((IDictionary)urls)[(string)connectId] = this.spawn(this.negotiateHelper, new object[] { privateChannel, parameters}); - ((IDictionary)this.options)["urls"] = urls; - var future = getValue(urls, connectId); - return await (future as Exchange.Future); - } - - public async virtual Task negotiateHelper(object privateChannel, object parameters = null) - { - parameters ??= new Dictionary(); - object response = null; - object connectId = ((bool) isTrue(privateChannel)) ? "private" : "public"; - try - { - if (isTrue(privateChannel)) - { - response = await this.privatePostBulletPrivate(parameters); - } else - { - response = await this.publicPostBulletPublic(parameters); - } - object data = this.safeValue(response, "data", new Dictionary() {}); - object instanceServers = this.safeValue(data, "instanceServers", new List() {}); - object firstInstanceServer = this.safeValue(instanceServers, 0); - object pingInterval = this.safeInteger(firstInstanceServer, "pingInterval"); - object endpoint = this.safeString(firstInstanceServer, "endpoint"); - object token = this.safeString(data, "token"); - object result = add(add(endpoint, "?"), this.urlencode(new Dictionary() { - { "token", token }, - { "privateChannel", privateChannel }, - { "connectId", connectId }, -})); - var client = this.client(result); - client.keepAlive = pingInterval; - return result; - } catch(Exception e) - { - var future = this.safeValue(getValue(this.options, "urls"), connectId); - ((Future)future).reject(e); - ((IDictionary)getValue(this.options, "urls")).Remove((string)connectId); - } - return null; - } - - public virtual object requestId() - { - object requestId = this.sum(this.safeInteger(this.options, "requestId", 0), 1); - ((IDictionary)this.options)["requestId"] = requestId; - return requestId; - } - - /** - * @ignore - * @method - * @description Connects to a websocket channel - * @param {string} name name of the channel and suscriptionHash - * @param {bool} isPrivate true for the authenticated url, false for the public url - * @param {string} symbol is required for all public channels, not required for private channels (except position) - * @param {object} subscription subscription parameters - * @param {object} [params] extra parameters specific to the poloniex api - * @returns {object} data from the websocket stream - */ - public async virtual Task subscribe(object name, object isPrivate, object symbol = null, object subscription = null, object parameters = null) - { - parameters ??= new Dictionary(); - object url = await this.negotiate(isPrivate); - if (isTrue(!isEqual(symbol, null))) - { - object market = this.market(symbol); - object marketId = getValue(market, "id"); - name = add(name, add(":", marketId)); - } - object messageHash = name; - object tunnelId = await this.stream(url, messageHash); - object requestId = this.requestId(); - object subscribe = new Dictionary() { - { "id", requestId }, - { "type", "subscribe" }, - { "topic", name }, - { "privateChannel", isPrivate }, - { "response", true }, - { "tunnelId", tunnelId }, - }; - object subscriptionRequest = new Dictionary() { - { "id", requestId }, - }; - if (isTrue(isEqual(subscription, null))) - { - subscription = subscriptionRequest; - } else - { - subscription = this.extend(subscriptionRequest, subscription); - } - object request = this.extend(subscribe, parameters); - return await this.watch(url, messageHash, request, name, subscriptionRequest); - } - - public override void onClose(WebSocketClient client, object error) - { - ((IDictionary)this.options)["streamBySubscriptionsHash"] = new Dictionary() {}; - base.onClose(client as WebSocketClient, error); - } - - public async virtual Task stream(object url, object subscriptionHash) - { - object streamBySubscriptionsHash = this.safeValue(this.options, "streamBySubscriptionsHash", new Dictionary() {}); - object stream = this.safeString(streamBySubscriptionsHash, subscriptionHash); - if (isTrue(isEqual(stream, null))) - { - object streamIndex = this.safeInteger(this.options, "streamIndex", -1); - object streamLimit = this.safeValue(this.options, "streamLimit"); - streamIndex = add(streamIndex, 1); - object normalizedIndex = mod(streamIndex, streamLimit); - ((IDictionary)this.options)["streamIndex"] = streamIndex; - object streamIndexString = this.numberToString(normalizedIndex); - stream = add("stream-", streamIndexString); - ((IDictionary)getValue(this.options, "streamBySubscriptionsHash"))[(string)subscriptionHash] = stream; - object messageHash = add("tunnel:", stream); - object request = new Dictionary() { - { "id", messageHash }, - { "type", "openTunnel" }, - { "newTunnelId", stream }, - { "response", true }, - }; - object subscription = new Dictionary() { - { "id", messageHash }, - { "method", this.handleNewStream }, - }; - await this.watch(url, messageHash, request, messageHash, subscription); - } - return stream; - } - - public virtual void handleOrderBookSubscription(WebSocketClient client, object message, object subscription) - { - object symbol = this.safeString(subscription, "symbol"); - object limit = this.safeInteger(subscription, "limit"); - ((IDictionary)this.orderbooks)[(string)symbol] = this.orderBook(new Dictionary() {}, limit); - } - - public virtual object handleSubscriptionStatus(WebSocketClient client, object message) - { - // - // { - // "id": "1578090438322", - // "type": "ack" - // } - // - object id = this.safeString(message, "id"); - object subscriptionsById = this.indexBy(((WebSocketClient)client).subscriptions, "id"); - object subscription = this.safeValue(subscriptionsById, id, new Dictionary() {}); - object method = this.safeValue(subscription, "method"); - if (isTrue(!isEqual(method, null))) - { - DynamicInvoker.InvokeMethod(method, new object[] { client, message, subscription}); - } - return message; - } - - public virtual void handleNewStream(WebSocketClient client, object message, object subscription) - { - // - // { - // "id": "1545910840805", - // "type": "ack" - // } - // - object messageHash = this.safeString(message, "id"); - callDynamically(client as WebSocketClient, "resolve", new object[] {message, messageHash}); - } - - /** - * @method - * @name poloniexfutures#watchTicker - * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - * @see https://api-docs.poloniex.com/futures/websocket/public#get-real-time-symbol-ticker - * @param {string} symbol unified symbol of the market to fetch the ticker for - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task watchTicker(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - symbol = this.symbol(symbol); - object name = "/contractMarket/ticker"; - return await this.subscribe(name, false, symbol, null, parameters); - } - - /** - * @method - * @name poloniexfutures#watchTrades - * @description get the list of most recent trades for a particular symbol - * @see https://api-docs.poloniex.com/futures/websocket/public#full-matching-engine-datalevel-3 - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task watchTrades(object symbol, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object options = this.safeValue(this.options, "watchTrades"); - object name = this.safeString(options, "method", "/contractMarket/execution"); // can also be /contractMarket/snapshot - var nameparametersVariable = this.handleOptionAndParams(parameters, "method", "name", name); - name = ((IList)nameparametersVariable)[0]; - parameters = ((IList)nameparametersVariable)[1]; - symbol = this.symbol(symbol); - object trades = await this.subscribe(name, false, symbol, null, parameters); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(trades, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySinceLimit(trades, since, limit, "timestamp", true); - } - - /** - * @method - * @name poloniexfutures#watchOrderBook - * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://api-docs.poloniex.com/futures/websocket/public#level-2-market-data - * @param {string} symbol unified symbol of the market to fetch the order book for - * @param {int} [limit] not used by poloniexfutures watchOrderBook - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {string} [params.method] the method to use. Defaults to /contractMarket/level2 can also be /contractMarket/level3v2 to receive the raw stream of orders - * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols - */ - public async override Task watchOrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object options = this.safeValue(this.options, "watchOrderBook"); - object name = this.safeString(options, "method", "/contractMarket/level2"); // can also be /contractMarket/level2, /contractMarket/level2Depth5:{symbol}, /contractMarket/level2Depth50:{symbol} - var nameparametersVariable = this.handleOptionAndParams(parameters, "method", "name", name); - name = ((IList)nameparametersVariable)[0]; - parameters = ((IList)nameparametersVariable)[1]; - if (isTrue(isTrue(isEqual(name, "/contractMarket/level2")) && isTrue(!isEqual(limit, null)))) - { - if (isTrue(isTrue(!isEqual(limit, 5)) && isTrue(!isEqual(limit, 50)))) - { - throw new BadRequest ((string)add(this.id, " watchOrderBook limit argument must be none, 5 or 50 if using method /contractMarket/level2")) ; - } - name = add(name, add("Depth", this.numberToString(limit))); - } - object subscription = new Dictionary() { - { "symbol", symbol }, - { "limit", limit }, - { "method", this.handleOrderBookSubscription }, - }; - object orderbook = await this.subscribe(name, false, symbol, subscription, parameters); - return (orderbook as IOrderBook).limit(); - } - - /** - * @method - * @name poloniexfutures#watchOrders - * @description watches information on multiple orders made by the user - * @see https://api-docs.poloniex.com/futures/websocket/user-messages#private-messages - * @param {string} symbol filter by unified market symbol of the market orders were made in - * @param {int} [since] the earliest time in ms to fetch orders for - * @param {int} [limit] the maximum number of order structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {string} [params.method] the method to use will default to /contractMarket/tradeOrders. Set to /contractMarket/advancedOrders to watch stop orders - * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task watchOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object options = this.safeValue(this.options, "watchOrders"); - object name = this.safeString(options, "method", "/contractMarket/tradeOrders"); - object orders = await this.subscribe(name, true, null, null, parameters); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(orders, "getLimit", new object[] {symbol, limit}); - } - orders = this.filterBySymbolSinceLimit(orders, symbol, since, limit); - object length = getArrayLength(orders); - if (isTrue(isEqual(length, 0))) - { - return await this.watchOrders(symbol, since, limit, parameters); - } - return orders; - } - - /** - * @method - * @name poloniexfutures#watchBalance - * @description watch balance and get the amount of funds available for trading or funds locked in orders - * @see https://api-docs.poloniex.com/futures/websocket/user-messages#account-balance-events - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} - */ - public async override Task watchBalance(object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object name = "/contractAccount/wallet"; - return await this.subscribe(name, true, null, null, parameters); - } - - public virtual object handleTrade(WebSocketClient client, object message) - { - // - // { - // "data": { - // "makerUserId": "1410336", - // "symbol": "BTCUSDTPERP", - // "sequence": 267913, - // "side": "buy", - // "size": 2, - // "price": 28409.5, - // "takerOrderId": "6426f9f15782c8000776995f", - // "makerOrderId": "6426f9f141406b0008df976e", - // "takerUserId": "1410880", - // "tradeId": "6426f9f1de029f0001e334dd", - // "ts": 1680275953739092500, - // }, - // "subject": "match", - // "topic": "/contractMarket/execution:BTCUSDTPERP", - // "type": "message", - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object marketId = this.safeString(data, "symbol"); - if (isTrue(!isEqual(marketId, null))) - { - object trade = this.parseWsTrade(data); - object symbol = getValue(trade, "symbol"); - object messageHash = add("/contractMarket/execution:", marketId); - object stored = this.safeValue(this.trades, symbol); - if (isTrue(isEqual(stored, null))) - { - object tradesLimit = this.safeInteger(this.options, "tradesLimit", 1000); - stored = new ArrayCache(tradesLimit); - ((IDictionary)this.trades)[(string)symbol] = stored; - } - callDynamically(stored, "append", new object[] {trade}); - callDynamically(client as WebSocketClient, "resolve", new object[] {stored, messageHash}); - } - return message; - } - - public override object parseWsTrade(object trade, object market = null) - { - // - // handleTrade - // - // { - // "makerUserId": "1410880", - // "symbol": "BTCUSDTPERP", - // "sequence": 731390, - // "side": "sell", - // "size": 2, - // "price": 29372.4, - // "takerOrderId": "644ef0fdd64748000759218a", - // "makerOrderId": "644ef0fd25f4a50007f12fc5", - // "takerUserId": "1410880", - // "tradeId": "644ef0fdde029f0001eec346", - // "ts": 1682895101923194000 - // } - // - object marketId = this.safeString(trade, "symbol"); - market = this.safeMarket(marketId, market); - object timestamp = this.safeIntegerProduct(trade, "ts", 0.000001); - return this.safeTrade(new Dictionary() { - { "info", trade }, - { "id", this.safeString(trade, "tradeId") }, - { "symbol", this.safeString(market, "symbol") }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "order", this.safeString2(trade, "takerOrderId", "makerOrderId") }, - { "type", null }, - { "side", this.safeString(trade, "side") }, - { "takerOrMaker", null }, - { "price", this.safeString(trade, "price") }, - { "amount", this.safeString2(trade, "matchSize", "size") }, - { "cost", null }, - { "fee", null }, - }, market); - } - - public override object parseWsOrderTrade(object trade, object market = null) - { - // - // { - // "symbol": "BTC_USDT", - // "type": "LIMIT", - // "quantity": "1", - // "orderId": "32471407854219264", - // "tradeFee": "0", - // "clientOrderId": "", - // "accountType": "SPOT", - // "feeCurrency": "", - // "eventType": "place", - // "source": "API", - // "side": "BUY", - // "filledQuantity": "0", - // "filledAmount": "0", - // "matchRole": "MAKER", - // "state": "NEW", - // "tradeTime": 0, - // "tradeAmount": "0", - // "orderAmount": "0", - // "createTime": 1648708186922, - // "price": "47112.1", - // "tradeQty": "0", - // "tradePrice": "0", - // "tradeId": "0", - // "ts": 1648708187469 - // } - // - object timestamp = this.safeInteger(trade, "tradeTime"); - object marketId = this.safeString(trade, "symbol"); - return this.safeTrade(new Dictionary() { - { "info", trade }, - { "id", this.safeString(trade, "tradeId") }, - { "symbol", this.safeSymbol(marketId, market) }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "order", this.safeString(trade, "orderId") }, - { "type", this.safeStringLower(trade, "type") }, - { "side", this.safeString(trade, "side") }, - { "takerOrMaker", this.safeStringLower(trade, "matchRole") }, - { "price", this.safeString(trade, "price") }, - { "amount", this.safeString(trade, "tradeAmount") }, - { "cost", null }, - { "fee", new Dictionary() { - { "rate", null }, - { "cost", this.safeString(trade, "tradeFee") }, - { "currency", this.safeString(trade, "feeCurrency") }, - } }, - }, market); - } - - public virtual object handleOrder(WebSocketClient client, object message) - { - // - // { - // "data": { - // "symbol": "ADAUSDTPERP", - // "orderType": "limit", - // "side": "buy", - // "canceledSize": "1", - // "orderId": "642b4d4c0494cd0007c76813", - // "type": "canceled", - // "orderTime": "1680559436101909048", - // "size": "1", - // "filledSize": "0", - // "marginType": 1, - // "price": "0.25", - // "remainSize": "0", - // "clientOid": "112cbbf1-95a3-4917-957c-d3a87d81f853", - // "status": "done", - // "ts": 1680559677560686600 - // }, - // "subject": "orderChange", - // "topic": "/contractMarket/tradeOrders", - // "channelType": "private", - // "type": "message", - // "userId": "1139790" - // } - // stop order - // { - // "data": { - // "orderType": "stop", - // "symbol": "BTCUSDTPERP", - // "side": "buy", - // "stopPriceType": "TP", - // "orderId": "64514fe1850d2100074378f6", - // "type": "open", - // "createdAt": 1683050465847, - // "stopPrice": "29000", - // "size": 2, - // "stop": "up", - // "marginType": 0, - // "orderPrice": "28552.9", - // "ts": 1683050465847597300 - // }, - // "subject": "stopOrder", - // "topic": "/contractMarket/advancedOrders", - // "channelType": "private", - // "id": "64514fe1850d2100074378fa", - // "type": "message", - // "userId": "1160396" - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object orders = this.orders; - if (isTrue(isEqual(orders, null))) - { - object limit = this.safeInteger(this.options, "ordersLimit"); - orders = new ArrayCacheBySymbolById(limit); - this.orders = orders; - } - object messageHash = "/contractMarket/tradeOrders"; - object parsed = this.parseWsOrder(data); - callDynamically(orders, "append", new object[] {parsed}); - callDynamically(client as WebSocketClient, "resolve", new object[] {orders, messageHash}); - return message; - } - - public virtual object parseOrderStatus(object status, object type) - { - /** - * @ignore - * @method - * @param {string} status "match", "open", "done" - * @param {string} type "open", "match", "filled", "canceled", "update" - * @returns {string} - */ - object types = new Dictionary() { - { "canceled", "canceled" }, - { "cancel", "canceled" }, - { "filled", "closed" }, - }; - object parsedStatus = this.safeString(types, type); - if (isTrue(isEqual(parsedStatus, null))) - { - object statuses = new Dictionary() { - { "open", "open" }, - { "match", "open" }, - { "done", "closed" }, - }; - parsedStatus = this.safeString(statuses, status, status); - } - return parsedStatus; - } - - public override object parseWsOrder(object order, object market = null) - { - // - // { - // "symbol": "ADAUSDTPERP", - // "orderType": "limit", - // "side": "buy", - // "canceledSize": "1", - // "orderId": "642b4d4c0494cd0007c76813", - // "type": "canceled", - // "orderTime": "1680559436101909048", - // "size": "1", - // "filledSize": "0", - // "marginType": 1, - // "price": "0.25", - // "remainSize": "0", - // "clientOid": "112cbbf1-95a3-4917-957c-d3a87d81f853", - // "status": "done", - // "ts": 1680559677560686600 - // } - // stop - // { - // "orderType": "stop", - // "symbol": "BTCUSDTPERP", - // "side": "buy", - // "stopPriceType": "TP", - // "orderId": "64514fe1850d2100074378f6", - // "type": "open", - // "createdAt": 1683050465847, - // "stopPrice": "29000", - // "size": 2, - // "stop": "up", - // "marginType": 0, - // "orderPrice": "28552.9", - // "ts": 1683050465847597300 - // } - // - object id = this.safeString(order, "orderId"); - object clientOrderId = this.safeString(order, "clientOid"); - object marketId = this.safeString(order, "symbol"); - object timestamp = this.safeIntegerProduct2(order, "orderTime", "ts", 0.000001); - object status = this.safeString(order, "status"); - object messageType = this.safeString(order, "type"); - return this.safeOrder(new Dictionary() { - { "info", order }, - { "symbol", this.safeSymbol(marketId, market) }, - { "id", id }, - { "clientOrderId", clientOrderId }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "lastTradeTimestamp", null }, - { "type", this.safeString(order, "orderType") }, - { "timeInForce", null }, - { "postOnly", null }, - { "side", this.safeString(order, "side") }, - { "price", this.safeString2(order, "price", "orderPrice") }, - { "stopPrice", this.safeString(order, "stopPrice") }, - { "triggerPrice", null }, - { "amount", this.safeString(order, "size") }, - { "cost", null }, - { "average", null }, - { "filled", this.safeString(order, "filledSize") }, - { "remaining", this.safeString(order, "remainSize") }, - { "status", this.parseOrderStatus(status, messageType) }, - { "fee", null }, - { "trades", null }, - }); - } - - public virtual object handleTicker(WebSocketClient client, object message) - { - // - // { - // "subject": "ticker", - // "topic": "/contractMarket/ticker:BTCUSDTPERP", - // "data": { - // "symbol": "BTCUSDTPERP", // Market of the symbol - // "sequence": 45, // Sequence number which is used to judge the continuity of the pushed messages - // "side": "sell", // Transaction side of the last traded taker order - // "price": 3600.00, // Filled price - // "size": 16, // Filled quantity - // "tradeId": "5c9dcf4170744d6f5a3d32fb", // Order ID - // "bestBidSize": 795, // Best bid size - // "bestBidPrice": 3200.00, // Best bid - // "bestAskPrice": 3600.00, // Best ask size - // "bestAskSize": 284, // Best ask - // "ts": 1553846081210004941 // Filled time - nanosecond - // }, - // "type": "message", - // } - // - // { - // "topic": "/contractMarket/snapshot:BTCUSDTPERP", - // "subject": "snapshot.24h", - // "data": { - // "volume": 30449670, //24h Volume - // "turnover": 845169919063, //24h Turnover - // "lastPrice": 3551, //Last price - // "priceChgPct": 0.0043, //24h Change - // "ts": 1547697294838004923 //Snapshot time (nanosecond) - // } - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object messageHash = this.safeString(message, "topic"); - object symbol = this.getSymbolFromTopic(messageHash); - if (isTrue(!isEqual(symbol, null))) - { - object ticker = this.parseTicker(data); - ((IDictionary)this.tickers)[(string)symbol] = ticker; - callDynamically(client as WebSocketClient, "resolve", new object[] {ticker, messageHash}); - } - return message; - } - - public virtual void handleL3OrderBook(WebSocketClient client, object message) - { - // - // { - // "data": { - // "symbol": "BTCUSDTPERP", - // "sequence": 1679593048010, - // "orderId": "6426fec8586b9500089d64d8", - // "clientOid": "14e6ee8e-8757-462c-84db-ed12c2b62f55", - // "ts": 1680277192127513900 - // }, - // "subject": "received", - // "topic": "/contractMarket/level3v2:BTCUSDTPERP", - // "type": "message" - // } - // - // { - // "data": { - // "symbol": "BTCUSDTPERP", - // "sequence": 1679593047982, - // "side": "sell", - // "orderTime": "1680277191900131371", - // "size": "1", - // "orderId": "6426fec7d32b6e000790268b", - // "price": "28376.4", - // "ts": 1680277191939042300 - // }, - // "subject": "open", - // "topic": "/contractMarket/level3v2:BTCUSDTPERP", - // "type": "message" - // } - // - // { - // "data": { - // "symbol": "BTCUSDTPERP", - // "reason": "canceled", // or "filled" - // "sequence": 1679593047983, - // "orderId": "6426fec74026fa0008e7046f", - // "ts": 1680277191949842000 - // }, - // "subject": "done", - // "topic": "/contractMarket/level3v2:BTCUSDTPERP", - // "type": "message" - // } - // - object messageHash = this.safeString(message, "topic"); - object subject = this.safeString(message, "subject"); - if (isTrue(isEqual(subject, "received"))) - { - return; - } - // At the time of writting this, there is no implementation to easily convert each order into the orderbook so raw messages are returned - callDynamically(client as WebSocketClient, "resolve", new object[] {message, messageHash}); - } - - public virtual void handleLevel2(WebSocketClient client, object message) - { - // { - // "subject": "level2", - // "topic": "/contractMarket/level2:BTCUSDTPERP", - // "type": "message", - // "data": { - // "sequence": 18, // Sequence number which is used to judge the continuity of pushed messages - // "change": "5000.0,sell,83" // Price, side, quantity - // "timestamp": 1551770400000 - // } - // } - object topic = this.safeString(message, "topic"); - object isSnapshot = isGreaterThanOrEqual(getIndexOf(topic, "Depth"), 0); - if (isTrue(isSnapshot)) - { - this.handeL2Snapshot(client as WebSocketClient, message); - return; - } - this.handleL2OrderBook(client as WebSocketClient, message); - } - - public virtual void handleL2OrderBook(WebSocketClient client, object message) - { - // - // { - // "id": 1545910660740, - // "type": "subscribe", - // "topic": "/contractMarket/level2:BTCUSDTPERP", - // "response": true - // } - // - // { - // "subject": "level2", - // "topic": "/contractMarket/level2:BTCUSDTPERP", - // "type": "message", - // "data": { - // "sequence": 18, // Sequence number which is used to judge the continuity of pushed messages - // "change": "5000.0,sell,83" // Price, side, quantity - // "timestamp": 1551770400000 - // } - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object messageHash = this.safeString(message, "topic", ""); - object symbol = this.getSymbolFromTopic(messageHash); - object orderBook = this.safeValue(this.orderbooks, symbol); - if (isTrue(isEqual(orderBook, null))) - { - ((IDictionary)this.orderbooks)[(string)symbol] = this.orderBook(new Dictionary() {}); - orderBook = getValue(this.orderbooks, symbol); - ((IDictionary)orderBook)["symbol"] = symbol; - } - object nonce = this.safeInteger(orderBook, "nonce"); - if (isTrue(isEqual(nonce, null))) - { - object cacheLength = getArrayLength((orderBook as ccxt.pro.OrderBook).cache); - object snapshotDelay = this.handleOption("watchOrderBook", "snapshotDelay", 5); - if (isTrue(isEqual(cacheLength, snapshotDelay))) - { - object limit = 0; - this.spawn(this.loadOrderBook, new object[] { client, messageHash, symbol, limit, new Dictionary() {}}); - } - ((IList)(orderBook as ccxt.pro.OrderBook).cache).Add(data); - return; - } - try - { - this.handleDelta(orderBook, data); - callDynamically(client as WebSocketClient, "resolve", new object[] {orderBook, messageHash}); - } catch(Exception e) - { - ((IDictionary)this.orderbooks).Remove((string)symbol); - ((WebSocketClient)client).reject(e, messageHash); - } - } - - public virtual void handeL2Snapshot(WebSocketClient client, object message) - { - // - // { - // "type": "message", - // "topic": "/contractMarket/level2Depth5:BTCUSDTPERP", - // "subject": "level2", - // "data": { - // "asks": [ - // ["9993", "3"], - // ["9992", "3"], - // ["9991", "47"], - // ["9990", "32"], - // ["9989", "8"] - // ], - // "bids": [ - // ["9988", "56"], - // ["9987", "15"], - // ["9986", "100"], - // ["9985", "10"], - // ["9984", "10"] - // ], - // "timestamp": 1682993050531, - // } - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object messageHash = this.safeString(message, "topic", ""); - object symbol = this.getSymbolFromTopic(messageHash); - object timestamp = this.safeInteger(data, "timestamp"); - object snapshot = this.parseOrderBook(data, symbol, timestamp, "bids", "asks"); - object orderbook = this.orderBook(snapshot); - ((IDictionary)this.orderbooks)[(string)symbol] = orderbook; - callDynamically(client as WebSocketClient, "resolve", new object[] {orderbook, messageHash}); - } - - public virtual object getSymbolFromTopic(object topic) - { - object splitTopic = ((string)topic).Split(new [] {((string)":")}, StringSplitOptions.None).ToList(); - object marketId = this.safeString(splitTopic, 1); - return this.safeSymbol(marketId); - } - - public override object getCacheIndex(object orderbook, object cache) - { - object firstDelta = this.safeValue(cache, 0); - object nonce = this.safeInteger(orderbook, "nonce"); - object firstDeltaSequence = this.safeInteger(firstDelta, "sequence"); - if (isTrue(isGreaterThan(firstDeltaSequence, add(nonce, 1)))) - { - return -1; - } - for (object i = 0; isLessThan(i, getArrayLength(cache)); postFixIncrement(ref i)) - { - object delta = getValue(cache, i); - object sequence = this.safeInteger(delta, "sequence"); - if (isTrue(isEqual(nonce, subtract(sequence, 1)))) - { - return i; - } - } - return getArrayLength(cache); - } - - public override void handleDelta(object orderbook, object delta) - { - // - // { - // sequence: 123677914, - // lastSequence: 123677913, - // change: '80.36,buy,4924', - // changes: [ '80.19,buy,0',"80.15,buy,10794" ], - // timestamp: 1715643483528 - // }, - // - object sequence = this.safeInteger(delta, "sequence"); - object lastSequence = this.safeInteger(delta, "lastSequence"); - object nonce = this.safeInteger(orderbook, "nonce"); - if (isTrue(isGreaterThan(nonce, sequence))) - { - return; - } - if (isTrue(!isEqual(nonce, lastSequence))) - { - object checksum = this.handleOption("watchOrderBook", "checksum", true); - if (isTrue(checksum)) - { - throw new ChecksumError ((string)add(add(this.id, " "), this.orderbookChecksumMessage(""))) ; - } - } - object changes = this.safeList(delta, "changes"); - for (object i = 0; isLessThan(i, getArrayLength(changes)); postFixIncrement(ref i)) - { - object change = getValue(changes, i); - object splitChange = ((string)change).Split(new [] {((string)",")}, StringSplitOptions.None).ToList(); - object price = this.safeNumber(splitChange, 0); - object side = this.safeString(splitChange, 1); - object size = this.safeNumber(splitChange, 2); - object orderBookSide = ((bool) isTrue((isEqual(side, "buy")))) ? getValue(orderbook, "bids") : getValue(orderbook, "asks"); - (orderBookSide as IOrderBookSide).store(price, size); - } - object timestamp = this.safeInteger(delta, "timestamp"); - ((IDictionary)orderbook)["timestamp"] = timestamp; - ((IDictionary)orderbook)["datetime"] = this.iso8601(timestamp); - ((IDictionary)orderbook)["nonce"] = sequence; - } - - public virtual object handleBalance(WebSocketClient client, object message) - { - // - // { - // "data": { - // "currency": "USDT", - // "availableBalance": "4.0000000000", - // "timestamp": "1680557568670" - // }, - // "subject": "availableBalance.change", - // "topic": "/contractAccount/wallet", - // "channelType": "private", - // "id": "642b4600cae86800074b5ab7", - // "type": "message", - // "userId": "1139790" - // } - // - // { - // "data": { - // "currency": "USDT", - // "orderMargin": "0.0000000000", - // "timestamp": "1680558743307" - // }, - // "subject": "orderMargin.change", - // "topic": "/contractAccount/wallet", - // "channelType": "private", - // "id": "642b4a97b58e360007c3a237", - // "type": "message", - // "userId": "1139790" - // } - // - object data = this.safeValue(message, "data", new List() {}); - object messageHash = "/contractAccount/wallet"; - object currencyId = this.safeString(data, "currency"); - object currency = this.currency(currencyId); - object code = getValue(currency, "code"); - ((IDictionary)this.balance)[(string)code] = this.parseWsBalance(data); - callDynamically(client as WebSocketClient, "resolve", new object[] {getValue(this.balance, code), messageHash}); - return message; - } - - public virtual object parseWsBalance(object response) - { - // - // { - // "currency": "USDT", - // "availableBalance": "4.0000000000", - // "timestamp": "1680557568670" - // } - // - // { - // "currency": "USDT", - // "orderMargin": "0.0000000000", - // "timestamp": "1680558743307" - // } - // - object timestamp = this.safeInteger(response, "timestamp"); - object result = new Dictionary() { - { "info", response }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - }; - object currencyId = this.safeString(response, "currency"); - object code = this.safeCurrencyCode(currencyId); - object newAccount = this.account(); - ((IDictionary)newAccount)["free"] = this.safeString(response, "availableBalance"); - ((IDictionary)result)[(string)code] = newAccount; - return this.safeBalance(result); - } - - public virtual object handleSystemStatus(WebSocketClient client, object message) - { - // - // { - // "id": "1578090234088", // connectId - // "type": "welcome", - // } - // - return message; - } - - public virtual void handleSubject(WebSocketClient client, object message) - { - object subject = this.safeString(message, "subject"); - object methods = new Dictionary() { - { "auth", this.handleAuthenticate }, - { "received", this.handleL3OrderBook }, - { "open", this.handleL3OrderBook }, - { "update", this.handleL3OrderBook }, - { "done", this.handleL3OrderBook }, - { "level2", this.handleLevel2 }, - { "ticker", this.handleTicker }, - { "snapshot.24h", this.handleTicker }, - { "match", this.handleTrade }, - { "orderChange", this.handleOrder }, - { "stopOrder", this.handleOrder }, - { "availableBalance.change", this.handleBalance }, - { "orderMargin.change", this.handleBalance }, - }; - object method = this.safeValue(methods, subject); - if (isTrue(!isEqual(method, null))) - { - DynamicInvoker.InvokeMethod(method, new object[] { client, message}); - } - } - - public override object ping(WebSocketClient client) - { - object id = ((object)this.requestId()).ToString(); - return new Dictionary() { - { "id", id }, - { "type", "ping" }, - }; - } - - public virtual object handlePong(WebSocketClient client, object message) - { - client.lastPong = this.milliseconds(); - return message; - } - - public virtual void handleErrorMessage(WebSocketClient client, object message) - { - // - // { - // "code": 404, - // "data": "tunnel stream-0 is not exist", - // "id": "3", - // "type": "error" - // } - // - ((WebSocketClient)client).reject(message); - } - - public override void handleMessage(WebSocketClient client, object message) - { - object type = this.safeString(message, "type"); - object methods = new Dictionary() { - { "welcome", this.handleSystemStatus }, - { "ack", this.handleSubscriptionStatus }, - { "message", this.handleSubject }, - { "pong", this.handlePong }, - { "error", this.handleErrorMessage }, - }; - object method = this.safeValue(methods, type); - if (isTrue(!isEqual(method, null))) - { - DynamicInvoker.InvokeMethod(method, new object[] { client, message}); - } - } - - public virtual object handleAuthenticate(WebSocketClient client, object message) - { - // - // { - // "success": true, - // "ret_msg": '', - // "op": "auth", - // "conn_id": "ce3dpomvha7dha97tvp0-2xh" - // } - // - object data = this.safeValue(message, "data"); - object success = this.safeValue(data, "success"); - object messageHash = "authenticated"; - if (isTrue(success)) - { - callDynamically(client as WebSocketClient, "resolve", new object[] {message, messageHash}); - } else - { - var error = new AuthenticationError(add(add(this.id, " "), this.json(message))); - ((WebSocketClient)client).reject(error, messageHash); - if (isTrue(inOp(((WebSocketClient)client).subscriptions, messageHash))) - { - ((IDictionary)((WebSocketClient)client).subscriptions).Remove((string)messageHash); - } - } - return message; - } -} diff --git a/cs/ccxt/exchanges/pro/wazirx.cs b/cs/ccxt/exchanges/pro/wazirx.cs deleted file mode 100644 index 30b7b596785e7..0000000000000 --- a/cs/ccxt/exchanges/pro/wazirx.cs +++ /dev/null @@ -1,843 +0,0 @@ -namespace ccxt.pro; - -// 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 wazirx { public wazirx(object args = null) : base(args) { } } -public partial class wazirx : ccxt.wazirx -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "has", new Dictionary() { - { "ws", true }, - { "watchBalance", true }, - { "watchTicker", true }, - { "watchTickers", true }, - { "watchTrades", true }, - { "watchTradesForSymbols", false }, - { "watchMyTrades", true }, - { "watchOrders", true }, - { "watchOrderBook", true }, - { "watchOHLCV", true }, - } }, - { "urls", new Dictionary() { - { "api", new Dictionary() { - { "ws", "wss://stream.wazirx.com/stream" }, - } }, - } }, - { "options", new Dictionary() {} }, - { "streaming", new Dictionary() {} }, - { "exceptions", new Dictionary() {} }, - { "api", new Dictionary() { - { "private", new Dictionary() { - { "post", new Dictionary() { - { "create_auth_token", 1 }, - } }, - } }, - } }, - }); - } - - /** - * @method - * @name wazirx#watchBalance - * @description watch balance and get the amount of funds available for trading or funds locked in orders - * @see https://docs.wazirx.com/#account-update - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} - */ - public async override Task watchBalance(object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object token = await this.authenticate(parameters); - object messageHash = "balance"; - object url = getValue(getValue(this.urls, "api"), "ws"); - object subscribe = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {"outboundAccountPosition"} }, - { "auth_key", token }, - }; - object request = this.deepExtend(subscribe, parameters); - return await this.watch(url, messageHash, request, messageHash); - } - - public virtual void handleBalance(WebSocketClient client, object message) - { - // - // { - // "data": - // { - // "B": [ - // { - // "a":"wrx", - // "b":"2043856.426455209", - // "l":"3001318.98" - // } - // ], - // "E":1631683058909 - // }, - // "stream":"outboundAccountPosition" - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object balances = this.safeValue(data, "B", new List() {}); - object timestamp = this.safeInteger(data, "E"); - ((IDictionary)this.balance)["info"] = balances; - ((IDictionary)this.balance)["timestamp"] = timestamp; - ((IDictionary)this.balance)["datetime"] = this.iso8601(timestamp); - for (object i = 0; isLessThan(i, getArrayLength(balances)); postFixIncrement(ref i)) - { - object balance = getValue(balances, i); - object currencyId = this.safeString(balance, "a"); - object code = this.safeCurrencyCode(currencyId); - object available = this.safeString(balance, "b"); - object locked = this.safeString(balance, "l"); - object account = this.account(); - ((IDictionary)account)["free"] = available; - ((IDictionary)account)["used"] = locked; - ((IDictionary)this.balance)[(string)code] = account; - } - this.balance = this.safeBalance(this.balance); - object messageHash = "balance"; - callDynamically(client as WebSocketClient, "resolve", new object[] {this.balance, messageHash}); - } - - public override object parseWsTrade(object trade, object market = null) - { - // - // trade - // { - // "E": 1631681323000, Event time - // "S": "buy", Side - // "a": 26946138, Buyer order ID - // "b": 26946169, Seller order ID - // "m": true, Is buyer maker? - // "p": "7.0", Price - // "q": "15.0", Quantity - // "s": "btcinr", Symbol - // "t": 17376030 Trade ID - // } - // ownTrade - // { - // "E": 1631683058000, - // "S": "ask", - // "U": "inr", - // "a": 114144050, - // "b": 114144121, - // "f": "0.2", - // "m": true, - // "o": 26946170, - // "p": "5.0", - // "q": "20.0", - // "s": "btcinr", - // "t": 17376032, - // "w": "100.0" - // } - // - object timestamp = this.safeInteger(trade, "E"); - object marketId = this.safeString(trade, "s"); - market = this.safeMarket(marketId, market); - object feeCost = this.safeString(trade, "f"); - object feeCurrencyId = this.safeString(trade, "U"); - object isMaker = isEqual(this.safeValue(trade, "m"), true); - object fee = null; - if (isTrue(!isEqual(feeCost, null))) - { - fee = new Dictionary() { - { "cost", feeCost }, - { "currency", this.safeCurrencyCode(feeCurrencyId) }, - { "rate", null }, - }; - } - return this.safeTrade(new Dictionary() { - { "id", this.safeString(trade, "t") }, - { "info", trade }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "symbol", getValue(market, "symbol") }, - { "order", this.safeStringN(trade, new List() {"o"}) }, - { "type", null }, - { "side", this.safeString(trade, "S") }, - { "takerOrMaker", ((bool) isTrue(isMaker)) ? "maker" : "taker" }, - { "price", this.safeString(trade, "p") }, - { "amount", this.safeString(trade, "q") }, - { "cost", null }, - { "fee", fee }, - }, market); - } - - /** - * @method - * @name wazirx#watchTicker - * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - * @see https://docs.wazirx.com/#all-market-tickers-stream - * @param {string} symbol unified symbol of the market to fetch the ticker for - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task watchTicker(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object url = getValue(getValue(this.urls, "api"), "ws"); - object messageHash = add("ticker:", getValue(market, "symbol")); - object subscribeHash = "tickers"; - object stream = add("!", "ticker@arr"); - object subscribe = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {stream} }, - }; - object request = this.deepExtend(subscribe, parameters); - return await this.watch(url, messageHash, request, subscribeHash); - } - - /** - * @method - * @name wazirx#watchTickers - * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list - * @see https://docs.wazirx.com/#all-market-tickers-stream - * @param {string[]} symbols unified symbol of the market to fetch the ticker for - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task watchTickers(object symbols = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - symbols = this.marketSymbols(symbols); - object url = getValue(getValue(this.urls, "api"), "ws"); - object messageHash = "tickers"; - object stream = add("!", "ticker@arr"); - object subscribe = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {stream} }, - }; - object request = this.deepExtend(subscribe, parameters); - object tickers = await this.watch(url, messageHash, request, messageHash); - return this.filterByArray(tickers, "symbol", symbols, false); - } - - public virtual void handleTicker(WebSocketClient client, object message) - { - // - // { - // "data": - // [ - // { - // "E":1631625534000, // Event time - // "T":"SPOT", // Type - // "U":"wrx", // Quote unit - // "a":"0.0", // Best sell price - // "b":"0.0", // Best buy price - // "c":"5.0", // Last price - // "h":"5.0", // High price - // "l":"5.0", // Low price - // "o":"5.0", // Open price - // "q":"0.0", // Quantity - // "s":"btcwrx", // Symbol - // "u":"btc" // Base unit - // } - // ], - // "stream":"!ticker@arr" - // } - // - object data = this.safeValue(message, "data", new List() {}); - for (object i = 0; isLessThan(i, getArrayLength(data)); postFixIncrement(ref i)) - { - object ticker = getValue(data, i); - object parsedTicker = this.parseWSTicker(ticker); - object symbol = getValue(parsedTicker, "symbol"); - ((IDictionary)this.tickers)[(string)symbol] = parsedTicker; - object messageHash = add("ticker:", symbol); - callDynamically(client as WebSocketClient, "resolve", new object[] {parsedTicker, messageHash}); - } - callDynamically(client as WebSocketClient, "resolve", new object[] {this.tickers, "tickers"}); - } - - public virtual object parseWSTicker(object ticker, object market = null) - { - // - // { - // "E":1631625534000, // Event time - // "T":"SPOT", // Type - // "U":"wrx", // Quote unit - // "a":"0.0", // Best sell price - // "b":"0.0", // Best buy price - // "c":"5.0", // Last price - // "h":"5.0", // High price - // "l":"5.0", // Low price - // "o":"5.0", // Open price - // "q":"0.0", // Quantity - // "s":"btcwrx", // Symbol - // "u":"btc" // Base unit - // } - // - object marketId = this.safeString(ticker, "s"); - object timestamp = this.safeInteger(ticker, "E"); - return this.safeTicker(new Dictionary() { - { "symbol", this.safeSymbol(marketId, market) }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "high", this.safeString(ticker, "h") }, - { "low", this.safeString(ticker, "l") }, - { "bid", this.safeNumber(ticker, "b") }, - { "bidVolume", null }, - { "ask", this.safeNumber(ticker, "a") }, - { "askVolume", null }, - { "vwap", null }, - { "open", this.safeString(ticker, "o") }, - { "close", null }, - { "last", this.safeString(ticker, "l") }, - { "previousClose", null }, - { "change", null }, - { "percentage", null }, - { "average", null }, - { "baseVolume", null }, - { "quoteVolume", this.safeString(ticker, "q") }, - { "info", ticker }, - }, market); - } - - /** - * @method - * @name wazirx#watchTrades - * @description get the list of most recent trades for a particular symbol - * @see https://docs.wazirx.com/#trade-streams - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task watchTrades(object symbol, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - symbol = getValue(market, "symbol"); - object messageHash = add(getValue(market, "id"), "@trades"); - object url = getValue(getValue(this.urls, "api"), "ws"); - object message = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {messageHash} }, - }; - object request = this.extend(message, parameters); - object trades = await this.watch(url, messageHash, request, messageHash); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(trades, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySinceLimit(trades, since, limit, "timestamp", true); - } - - public virtual void handleTrades(WebSocketClient client, object message) - { - // - // { - // "data": { - // "trades": [{ - // "E": 1631681323000, Event time - // "S": "buy", Side - // "a": 26946138, Buyer order ID - // "b": 26946169, Seller order ID - // "m": true, Is buyer maker? - // "p": "7.0", Price - // "q": "15.0", Quantity - // "s": "btcinr", Symbol - // "t": 17376030 Trade ID - // }] - // }, - // "stream": "btcinr@trades" - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object rawTrades = this.safeValue(data, "trades", new List() {}); - object messageHash = this.safeString(message, "stream"); - object split = ((string)messageHash).Split(new [] {((string)"@")}, StringSplitOptions.None).ToList(); - object marketId = this.safeString(split, 0); - object market = this.safeMarket(marketId); - object symbol = this.safeSymbol(marketId, market); - object trades = this.safeValue(this.trades, symbol); - if (isTrue(isEqual(trades, null))) - { - object limit = this.safeInteger(this.options, "tradesLimit", 1000); - trades = new ArrayCache(limit); - ((IDictionary)this.trades)[(string)symbol] = trades; - } - for (object i = 0; isLessThan(i, getArrayLength(rawTrades)); postFixIncrement(ref i)) - { - object parsedTrade = this.parseWsTrade(getValue(rawTrades, i), market); - callDynamically(trades, "append", new object[] {parsedTrade}); - } - callDynamically(client as WebSocketClient, "resolve", new object[] {trades, messageHash}); - } - - /** - * @method - * @name wazirx#watchMyTrades - * @description watch trades by user - * @see https://docs.wazirx.com/#trade-update - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task watchMyTrades(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object token = await this.authenticate(parameters); - if (isTrue(!isEqual(symbol, null))) - { - object market = this.market(symbol); - symbol = getValue(market, "symbol"); - } - object url = getValue(getValue(this.urls, "api"), "ws"); - object messageHash = "myTrades"; - object message = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {"ownTrade"} }, - { "auth_key", token }, - }; - object request = this.deepExtend(message, parameters); - object trades = await this.watch(url, messageHash, request, messageHash); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(trades, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true); - } - - /** - * @method - * @name wazirx#watchOHLCV - * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market - * @see https://docs.wazirx.com/#kline-candlestick-stream - * @param {string} symbol unified symbol of the market to fetch OHLCV data for - * @param {string} timeframe the length of time each candle represents - * @param {int} [since] timestamp in ms of the earliest candle to fetch - * @param {int} [limit] the maximum amount of candles to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume - */ - public async override Task watchOHLCV(object symbol, object timeframe = null, object since = null, object limit = null, object parameters = null) - { - timeframe ??= "1m"; - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - symbol = getValue(market, "symbol"); - object url = getValue(getValue(this.urls, "api"), "ws"); - object messageHash = add(add(add("ohlcv:", symbol), ":"), timeframe); - object stream = add(add(getValue(market, "id"), "@kline_"), timeframe); - object message = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {stream} }, - }; - object request = this.deepExtend(message, parameters); - object ohlcv = await this.watch(url, messageHash, request, messageHash); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(ohlcv, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySinceLimit(ohlcv, since, limit, 0, true); - } - - public virtual void handleOHLCV(WebSocketClient client, object message) - { - // - // { - // "data": { - // "E":1631683058904, Event time - // "s": "btcinr", Symbol - // "t": 1638747660000, Kline start time - // "T": 1638747719999, Kline close time - // "i": "1m", Interval - // "o": "0.0010", Open price - // "c": "0.0020", Close price - // "h": "0.0025", High price - // "l": "0.0015", Low price - // "v": "1000", Base asset volume - // }, - // "stream": "btcinr@kline_1m" - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object marketId = this.safeString(data, "s"); - object market = this.safeMarket(marketId); - object symbol = this.safeSymbol(marketId, market); - object timeframe = this.safeString(data, "i"); - ((IDictionary)this.ohlcvs)[(string)symbol] = this.safeValue(this.ohlcvs, symbol, new Dictionary() {}); - object stored = this.safeValue(getValue(this.ohlcvs, symbol), timeframe); - if (isTrue(isEqual(stored, null))) - { - object limit = this.safeInteger(this.options, "OHLCVLimit", 1000); - stored = new ArrayCacheByTimestamp(limit); - ((IDictionary)getValue(this.ohlcvs, symbol))[(string)timeframe] = stored; - } - object parsed = this.parseWsOHLCV(data, market); - callDynamically(stored, "append", new object[] {parsed}); - object messageHash = add(add(add("ohlcv:", symbol), ":"), timeframe); - callDynamically(client as WebSocketClient, "resolve", new object[] {stored, messageHash}); - } - - public override object parseWsOHLCV(object ohlcv, object market = null) - { - // - // { - // "E":1631683058904, Event time - // "s": "btcinr", Symbol - // "t": 1638747660000, Kline start time - // "T": 1638747719999, Kline close time - // "i": "1m", Interval - // "o": "0.0010", Open price - // "c": "0.0020", Close price - // "h": "0.0025", High price - // "l": "0.0015", Low price - // "v": "1000", Base asset volume - // } - // - return new List {this.safeInteger(ohlcv, "t"), this.safeNumber(ohlcv, "o"), this.safeNumber(ohlcv, "c"), this.safeNumber(ohlcv, "h"), this.safeNumber(ohlcv, "l"), this.safeNumber(ohlcv, "v")}; - } - - /** - * @method - * @name wazirx#watchOrderBook - * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://docs.wazirx.com/#depth-stream - * @param {string} symbol unified symbol of the market to fetch the order book for - * @param {int} [limit] the maximum amount of order book entries to return - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols - */ - public async override Task watchOrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - symbol = getValue(market, "symbol"); - object url = getValue(getValue(this.urls, "api"), "ws"); - object messageHash = add("orderbook:", symbol); - object stream = add(getValue(market, "id"), "@depth"); - object subscribe = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {stream} }, - }; - object request = this.deepExtend(subscribe, parameters); - object orderbook = await this.watch(url, messageHash, request, messageHash); - return (orderbook as IOrderBook).limit(); - } - - public override void handleDelta(object bookside, object delta) - { - object bidAsk = this.parseBidAsk(delta, 0, 1); - (bookside as IOrderBookSide).storeArray(bidAsk); - } - - public override void handleDeltas(object bookside, object deltas) - { - for (object i = 0; isLessThan(i, getArrayLength(deltas)); postFixIncrement(ref i)) - { - this.handleDelta(bookside, getValue(deltas, i)); - } - } - - public virtual void handleOrderBook(WebSocketClient client, object message) - { - // - // { - // "data": { - // "E": 1659475095000, - // "a": [ - // ["23051.0", "1.30141"], - // ], - // "b": [ - // ["22910.0", "1.30944"], - // ], - // "s": "btcusdt" - // }, - // "stream": "btcusdt@depth" - // } - // - object data = this.safeValue(message, "data", new Dictionary() {}); - object timestamp = this.safeInteger(data, "E"); - object marketId = this.safeString(data, "s"); - object market = this.safeMarket(marketId); - object symbol = getValue(market, "symbol"); - object messageHash = add("orderbook:", symbol); - // const currentOrderBook = this.safeValue (this.orderbooks, symbol); - if (!isTrue((inOp(this.orderbooks, symbol)))) - { - object snapshot = this.parseOrderBook(data, symbol, timestamp, "b", "a"); - ((IDictionary)this.orderbooks)[(string)symbol] = this.orderBook(snapshot); - } else - { - object orderbook = getValue(this.orderbooks, symbol); - object asks = this.safeList(data, "a", new List() {}); - object bids = this.safeList(data, "b", new List() {}); - this.handleDeltas(getValue(orderbook, "asks"), asks); - this.handleDeltas(getValue(orderbook, "bids"), bids); - ((IDictionary)orderbook)["nonce"] = timestamp; - ((IDictionary)orderbook)["timestamp"] = timestamp; - ((IDictionary)orderbook)["datetime"] = this.iso8601(timestamp); - ((IDictionary)this.orderbooks)[(string)symbol] = orderbook; - } - callDynamically(client as WebSocketClient, "resolve", new object[] {getValue(this.orderbooks, symbol), messageHash}); - } - - public async override Task watchOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - if (isTrue(!isEqual(symbol, null))) - { - object market = this.market(symbol); - symbol = getValue(market, "symbol"); - } - object token = await this.authenticate(parameters); - object messageHash = "orders"; - object message = new Dictionary() { - { "event", "subscribe" }, - { "streams", new List() {"orderUpdate"} }, - { "auth_key", token }, - }; - object url = getValue(getValue(this.urls, "api"), "ws"); - object request = this.deepExtend(message, parameters); - object orders = await this.watch(url, messageHash, request, messageHash, request); - if (isTrue(this.newUpdates)) - { - limit = callDynamically(orders, "getLimit", new object[] {symbol, limit}); - } - return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true); - } - - public virtual void handleOrder(WebSocketClient client, object message) - { - // - // { - // "data": { - // "E": 1631683058904, - // "O": 1631683058000, - // "S": "ask", - // "V": "70.0", - // "X": "wait", - // "i": 26946170, - // "m": true, - // "o": "sell", - // "p": "5.0", - // "q": "70.0", - // "s": "wrxinr", - // "v": "0.0" - // }, - // "stream": "orderUpdate" - // } - // - object order = this.safeValue(message, "data", new Dictionary() {}); - object parsedOrder = this.parseWsOrder(order); - if (isTrue(isEqual(this.orders, null))) - { - object limit = this.safeInteger(this.options, "ordersLimit", 1000); - this.orders = new ArrayCacheBySymbolById(limit); - } - object orders = this.orders; - callDynamically(orders, "append", new object[] {parsedOrder}); - object messageHash = "orders"; - callDynamically(client as WebSocketClient, "resolve", new object[] {this.orders, messageHash}); - messageHash = add(messageHash, add(":", getValue(parsedOrder, "symbol"))); - callDynamically(client as WebSocketClient, "resolve", new object[] {this.orders, messageHash}); - } - - public override object parseWsOrder(object order, object market = null) - { - // - // { - // "E": 1631683058904, - // "O": 1631683058000, - // "S": "ask", - // "V": "70.0", - // "X": "wait", - // "i": 26946170, - // "m": true, - // "o": "sell", - // "p": "5.0", - // "q": "70.0", - // "s": "wrxinr", - // "v": "0.0" - // } - // - object timestamp = this.safeInteger(order, "O"); - object marketId = this.safeString(order, "s"); - object status = this.safeString(order, "X"); - market = this.safeMarket(marketId); - return this.safeOrder(new Dictionary() { - { "info", order }, - { "id", this.safeString(order, "i") }, - { "clientOrderId", this.safeString(order, "c") }, - { "datetime", this.iso8601(timestamp) }, - { "timestamp", timestamp }, - { "lastTradeTimestamp", null }, - { "symbol", getValue(market, "symbol") }, - { "type", ((bool) isTrue(this.safeValue(order, "m"))) ? "limit" : "market" }, - { "timeInForce", null }, - { "postOnly", null }, - { "side", this.safeString(order, "o") }, - { "price", this.safeString(order, "p") }, - { "stopPrice", null }, - { "triggerPrice", null }, - { "amount", this.safeString(order, "V") }, - { "filled", null }, - { "remaining", this.safeString(order, "q") }, - { "cost", null }, - { "average", this.safeString(order, "v") }, - { "status", this.parseOrderStatus(status) }, - { "fee", null }, - { "trades", null }, - }, market); - } - - public virtual void handleMyTrades(WebSocketClient client, object message) - { - // - // { - // "data": { - // "E": 1631683058000, - // "S": "ask", - // "U": "usdt", - // "a": 114144050, - // "b": 114144121, - // "f": "0.2", - // "ga": "0.0", - // "gc": "usdt", - // "m": true, - // "o": 26946170, - // "p": "5.0", - // "q": "20.0", - // "s": "btcusdt", - // "t": 17376032, - // "w": "100.0" - // }, - // "stream": "ownTrade" - // } - // - object trade = this.safeValue(message, "data", new Dictionary() {}); - object messageHash = "myTrades"; - object myTrades = null; - if (isTrue(isEqual(this.myTrades, null))) - { - object limit = this.safeInteger(this.options, "tradesLimit", 1000); - myTrades = new ArrayCacheBySymbolById(limit); - this.myTrades = myTrades; - } else - { - myTrades = this.myTrades; - } - object parsedTrade = this.parseWsTrade(trade); - callDynamically(myTrades, "append", new object[] {parsedTrade}); - callDynamically(client as WebSocketClient, "resolve", new object[] {myTrades, messageHash}); - } - - public virtual object handleConnected(WebSocketClient client, object message) - { - // - // { - // "data": { - // "timeout_duration": 1800 - // }, - // "event": "connected" - // } - // - return message; - } - - public virtual object handleSubscribed(WebSocketClient client, object message) - { - // - // { - // "data": { - // "streams": ["!ticker@arr"] - // }, - // "event": "subscribed", - // "id": 0 - // } - // - return message; - } - - public virtual void handleError(WebSocketClient client, object message) - { - throw new ExchangeError ((string)add(add(this.id, " "), this.json(message))) ; - } - - public override void handleMessage(WebSocketClient client, object message) - { - object status = this.safeString(message, "status"); - if (isTrue(isEqual(status, "error"))) - { - this.handleError(client as WebSocketClient, message); - return; - } - object eventVar = this.safeString(message, "event"); - object eventHandlers = new Dictionary() { - { "error", this.handleError }, - { "connected", this.handleConnected }, - { "subscribed", this.handleSubscribed }, - }; - object eventHandler = this.safeValue(eventHandlers, eventVar); - if (isTrue(!isEqual(eventHandler, null))) - { - DynamicInvoker.InvokeMethod(eventHandler, new object[] { client, message}); - return; - } - object stream = this.safeString(message, "stream", ""); - object streamHandlers = new Dictionary() { - { "ticker@arr", this.handleTicker }, - { "@depth", this.handleOrderBook }, - { "@kline", this.handleOHLCV }, - { "@trades", this.handleTrades }, - { "outboundAccountPosition", this.handleBalance }, - { "orderUpdate", this.handleOrder }, - { "ownTrade", this.handleMyTrades }, - }; - object streams = new List(((IDictionary)streamHandlers).Keys); - for (object i = 0; isLessThan(i, getArrayLength(streams)); postFixIncrement(ref i)) - { - object streamContains = isGreaterThan(getIndexOf(stream, getValue(streams, i)), -1); - if (isTrue(streamContains)) - { - object handler = getValue(streamHandlers, getValue(streams, i)); - DynamicInvoker.InvokeMethod(handler, new object[] { client, message}); - return; - } - } - throw new NotSupported ((string)add(add(this.id, " this message type is not supported yet. Message: "), this.json(message))) ; - } - - public async virtual Task authenticate(object parameters = null) - { - parameters ??= new Dictionary(); - object url = getValue(getValue(this.urls, "api"), "ws"); - var client = this.client(url); - object messageHash = "authenticated"; - object now = this.milliseconds(); - object subscription = this.safeValue(((WebSocketClient)client).subscriptions, messageHash); - object expires = this.safeInteger(subscription, "expires"); - if (isTrue(isTrue(isEqual(subscription, null)) || isTrue(isGreaterThan(now, expires)))) - { - subscription = await this.privatePostCreateAuthToken(); - ((IDictionary)subscription)["expires"] = add(now, multiply(this.safeInteger(subscription, "timeout_duration"), 1000)); - // - // { - // "auth_key": "Xx***dM", - // "timeout_duration": 900 - // } - // - ((IDictionary)((WebSocketClient)client).subscriptions)[(string)messageHash] = subscription; - } - return this.safeString(subscription, "auth_key"); - } -} diff --git a/cs/ccxt/exchanges/pro/wrappers/bitcoincom.cs b/cs/ccxt/exchanges/pro/wrappers/bitcoincom.cs deleted file mode 100644 index d7ad6484c4549..0000000000000 --- a/cs/ccxt/exchanges/pro/wrappers/bitcoincom.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ccxt.pro; - -// 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 class Bitcoincom: bitcoincom { public Bitcoincom(object args = null) : base(args) { } } -public partial class bitcoincom -{ - -} diff --git a/cs/ccxt/exchanges/pro/wrappers/bitfinex1.cs b/cs/ccxt/exchanges/pro/wrappers/bitfinex1.cs deleted file mode 100644 index c4b663a1e165a..0000000000000 --- a/cs/ccxt/exchanges/pro/wrappers/bitfinex1.cs +++ /dev/null @@ -1,130 +0,0 @@ -namespace ccxt.pro; - -// 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 class Bitfinex1: bitfinex1 { public Bitfinex1(object args = null) : base(args) { } } -public partial class bitfinex1 -{ - /// - /// get the list of most recent trades for a particular symbol - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest trade to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of trades to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> WatchTrades(string symbol, 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.watchTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task WatchTicker(string symbol, Dictionary parameters = null) - { - var res = await this.watchTicker(symbol, parameters); - return new Ticker(res); - } - /// - /// watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - /// - /// - /// See
- /// - /// - /// limit - /// - /// int : the maximum amount of order book entries to return - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols. - public async Task WatchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) - { - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.watchOrderBook(symbol, limit, parameters); - return ((ccxt.pro.IOrderBook) res).Copy(); - } - public async Task> WatchOrder(object id, string symbol = null, Dictionary parameters = null) - { - var res = await this.watchOrder(id, symbol, parameters); - return ((Dictionary)res); - } - /// - /// watches information on multiple orders made by the user - /// - /// - /// See
- /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch orders for - /// - /// - /// - /// limit - /// - /// int : the maximum number of order structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> WatchOrders(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.watchOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } -} diff --git a/cs/ccxt/exchanges/pro/wrappers/bitpanda.cs b/cs/ccxt/exchanges/pro/wrappers/bitpanda.cs deleted file mode 100644 index 7d3588ad758cb..0000000000000 --- a/cs/ccxt/exchanges/pro/wrappers/bitpanda.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ccxt.pro; - -// 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 class Bitpanda: bitpanda { public Bitpanda(object args = null) : base(args) { } } -public partial class bitpanda -{ - -} diff --git a/cs/ccxt/exchanges/pro/wrappers/poloniexfutures.cs b/cs/ccxt/exchanges/pro/wrappers/poloniexfutures.cs deleted file mode 100644 index b81c028e35f88..0000000000000 --- a/cs/ccxt/exchanges/pro/wrappers/poloniexfutures.cs +++ /dev/null @@ -1,156 +0,0 @@ -namespace ccxt.pro; - -// 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 class Poloniexfutures: poloniexfutures { public Poloniexfutures(object args = null) : base(args) { } } -public partial class poloniexfutures -{ - /// - /// watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task WatchTicker(string symbol, Dictionary parameters = null) - { - var res = await this.watchTicker(symbol, parameters); - return new Ticker(res); - } - /// - /// get the list of most recent trades for a particular symbol - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest trade to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of trades to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> WatchTrades(string symbol, 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.watchTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - /// - /// - /// See
- /// - /// - /// limit - /// - /// int : not used by poloniexfutures watchOrderBook - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.method - /// - /// string : the method to use. Defaults to /contractMarket/level2 can also be /contractMarket/level3v2 to receive the raw stream of orders - /// - /// - /// - ///
- /// object A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols. - public async Task WatchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) - { - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.watchOrderBook(symbol, limit, parameters); - return ((ccxt.pro.IOrderBook) res).Copy(); - } - /// - /// watches information on multiple orders made by the user - /// - /// - /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch orders for - /// - /// - /// - /// limit - /// - /// int : the maximum number of order structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.method - /// - /// string : the method to use will default to /contractMarket/tradeOrders. Set to /contractMarket/advancedOrders to watch stop orders - /// - /// - /// - ///
- /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> WatchOrders(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.watchOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// watch balance and get the amount of funds available for trading or funds locked in orders - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. - public async Task WatchBalance(Dictionary parameters = null) - { - var res = await this.watchBalance(parameters); - return new Balances(res); - } -} diff --git a/cs/ccxt/exchanges/pro/wrappers/wazirx.cs b/cs/ccxt/exchanges/pro/wrappers/wazirx.cs deleted file mode 100644 index 2207dbe1f4246..0000000000000 --- a/cs/ccxt/exchanges/pro/wrappers/wazirx.cs +++ /dev/null @@ -1,205 +0,0 @@ -namespace ccxt.pro; - -// 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 class Wazirx: wazirx { public Wazirx(object args = null) : base(args) { } } -public partial class wazirx -{ - /// - /// watch balance and get the amount of funds available for trading or funds locked in orders - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. - public async Task WatchBalance(Dictionary parameters = null) - { - var res = await this.watchBalance(parameters); - return new Balances(res); - } - /// - /// watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task WatchTicker(string symbol, Dictionary parameters = null) - { - var res = await this.watchTicker(symbol, parameters); - return new Ticker(res); - } - /// - /// watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task WatchTickers(List symbols = null, Dictionary parameters = null) - { - var res = await this.watchTickers(symbols, parameters); - return new Tickers(res); - } - /// - /// get the list of most recent trades for a particular symbol - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest trade to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of trades to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> WatchTrades(string symbol, 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.watchTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// watch trades by user - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest trade to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of trades to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> WatchMyTrades(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.watchMyTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// watches historical candlestick data containing the open, high, low, and close price, and the volume of a market - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest candle to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of candles to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// int[][] A list of candles ordered as timestamp, open, high, low, close, volume. - public async Task> WatchOHLCV(string symbol, string timeframe = "1m", 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.watchOHLCV(symbol, timeframe, since, limit, parameters); - return ((IList)res).Select(item => new OHLCV(item)).ToList(); - } - /// - /// watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - /// - /// - /// See
- /// - /// - /// limit - /// - /// int : the maximum amount of order book entries to return - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols. - public async Task WatchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) - { - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.watchOrderBook(symbol, limit, parameters); - return ((ccxt.pro.IOrderBook) res).Copy(); - } - public async Task> WatchOrders(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.watchOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } -} diff --git a/cs/ccxt/exchanges/vertex.cs b/cs/ccxt/exchanges/vertex.cs index 6f3fce56e4ee1..60966b9e1f074 100644 --- a/cs/ccxt/exchanges/vertex.cs +++ b/cs/ccxt/exchanges/vertex.cs @@ -2539,7 +2539,9 @@ public async override Task cancelAllOrders(object symbol = null, object { response = await this.v1GatewayPostExecute(this.extend(request, parameters)); } - return response; + return new List {this.safeOrder(new Dictionary() { + { "info", response }, +})}; } /** @@ -2556,7 +2558,10 @@ public async override Task cancelAllOrders(object symbol = null, object public async override Task cancelOrder(object id, object symbol = null, object parameters = null) { parameters ??= new Dictionary(); - return await this.cancelOrders(new List() {id}, symbol, parameters); + object order = await this.cancelOrders(new List() {id}, symbol, parameters); + return this.safeOrder(new Dictionary() { + { "info", order }, + }); } /** diff --git a/cs/ccxt/exchanges/wavesexchange.cs b/cs/ccxt/exchanges/wavesexchange.cs index 5059f206f68b2..d3ce2241bf9f9 100644 --- a/cs/ccxt/exchanges/wavesexchange.cs +++ b/cs/ccxt/exchanges/wavesexchange.cs @@ -2330,13 +2330,27 @@ public override object parseTrade(object trade, object market = null) object order1 = this.safeValue(data, "order1"); object order2 = this.safeValue(data, "order2"); object order = null; - // order2 arrived after order1 + // at first, detect if response is from `fetch_my_trades` if (isTrue(isEqual(this.safeString(order1, "senderPublicKey"), this.apiKey))) { order = order1; - } else + } else if (isTrue(isEqual(this.safeString(order2, "senderPublicKey"), this.apiKey))) { order = order2; + } else + { + // response is from `fetch_trades`, so find only taker order + object date1 = this.safeString(order1, "timestamp"); + object date2 = this.safeString(order2, "timestamp"); + object ts1 = this.parse8601(date1); + object ts2 = this.parse8601(date2); + if (isTrue(isGreaterThan(ts1, ts2))) + { + order = order1; + } else + { + order = order2; + } } object symbol = null; object assetPair = this.safeValue(order, "assetPair"); diff --git a/cs/ccxt/exchanges/wazirx.cs b/cs/ccxt/exchanges/wazirx.cs deleted file mode 100644 index e76398434b9a0..0000000000000 --- a/cs/ccxt/exchanges/wazirx.cs +++ /dev/null @@ -1,1477 +0,0 @@ -namespace ccxt; - -// 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 wazirx : Exchange -{ - public override object describe() - { - return this.deepExtend(base.describe(), new Dictionary() { - { "id", "wazirx" }, - { "name", "WazirX" }, - { "countries", new List() {"IN"} }, - { "version", "v2" }, - { "rateLimit", 1000 }, - { "pro", true }, - { "has", new Dictionary() { - { "CORS", false }, - { "spot", true }, - { "margin", false }, - { "swap", false }, - { "future", false }, - { "option", false }, - { "addMargin", false }, - { "cancelAllOrders", true }, - { "cancelOrder", true }, - { "closeAllPositions", false }, - { "closePosition", false }, - { "createOrder", true }, - { "createReduceOnlyOrder", false }, - { "createStopLimitOrder", true }, - { "createStopMarketOrder", true }, - { "createStopOrder", true }, - { "fetchBalance", true }, - { "fetchBidsAsks", false }, - { "fetchBorrowInterest", false }, - { "fetchBorrowRate", false }, - { "fetchBorrowRateHistories", false }, - { "fetchBorrowRateHistory", false }, - { "fetchBorrowRates", false }, - { "fetchBorrowRatesPerSymbol", false }, - { "fetchClosedOrders", false }, - { "fetchCrossBorrowRate", false }, - { "fetchCrossBorrowRates", false }, - { "fetchCurrencies", true }, - { "fetchDepositAddress", true }, - { "fetchDepositAddresses", false }, - { "fetchDepositAddressesByNetwork", false }, - { "fetchDeposits", true }, - { "fetchDepositsWithdrawals", false }, - { "fetchFundingHistory", false }, - { "fetchFundingInterval", false }, - { "fetchFundingIntervals", false }, - { "fetchFundingRate", false }, - { "fetchFundingRateHistory", false }, - { "fetchFundingRates", false }, - { "fetchGreeks", false }, - { "fetchIndexOHLCV", false }, - { "fetchIsolatedBorrowRate", false }, - { "fetchIsolatedBorrowRates", false }, - { "fetchIsolatedPositions", false }, - { "fetchLeverage", false }, - { "fetchLeverages", false }, - { "fetchLeverageTiers", false }, - { "fetchLiquidations", false }, - { "fetchMarginAdjustmentHistory", false }, - { "fetchMarginMode", false }, - { "fetchMarginModes", false }, - { "fetchMarketLeverageTiers", false }, - { "fetchMarkets", true }, - { "fetchMarkOHLCV", false }, - { "fetchMarkPrices", false }, - { "fetchMyLiquidations", false }, - { "fetchMySettlementHistory", false }, - { "fetchMyTrades", false }, - { "fetchOHLCV", true }, - { "fetchOpenInterest", false }, - { "fetchOpenInterestHistory", false }, - { "fetchOpenOrders", true }, - { "fetchOption", false }, - { "fetchOptionChain", false }, - { "fetchOrder", false }, - { "fetchOrderBook", true }, - { "fetchOrders", true }, - { "fetchPosition", false }, - { "fetchPositionHistory", false }, - { "fetchPositionMode", false }, - { "fetchPositions", false }, - { "fetchPositionsForSymbol", false }, - { "fetchPositionsHistory", false }, - { "fetchPositionsRisk", false }, - { "fetchPremiumIndexOHLCV", false }, - { "fetchSettlementHistory", false }, - { "fetchStatus", true }, - { "fetchTicker", true }, - { "fetchTickers", true }, - { "fetchTime", true }, - { "fetchTrades", true }, - { "fetchTradingFee", false }, - { "fetchTradingFees", false }, - { "fetchTransactionFees", false }, - { "fetchTransactions", false }, - { "fetchTransfers", false }, - { "fetchUnderlyingAssets", false }, - { "fetchVolatilityHistory", false }, - { "fetchWithdrawals", true }, - { "reduceMargin", false }, - { "repayCrossMargin", false }, - { "repayIsolatedMargin", false }, - { "setLeverage", false }, - { "setMargin", false }, - { "setMarginMode", false }, - { "setPositionMode", false }, - { "transfer", false }, - { "withdraw", false }, - } }, - { "urls", new Dictionary() { - { "logo", "https://user-images.githubusercontent.com/1294454/148647666-c109c20b-f8ac-472f-91c3-5f658cb90f49.jpeg" }, - { "api", new Dictionary() { - { "rest", "https://api.wazirx.com/sapi/v1" }, - } }, - { "www", "https://wazirx.com" }, - { "doc", "https://docs.wazirx.com/#public-rest-api-for-wazirx" }, - { "fees", "https://wazirx.com/fees" }, - { "referral", "https://wazirx.com/invite/k7rrnks5" }, - } }, - { "api", new Dictionary() { - { "public", new Dictionary() { - { "get", new Dictionary() { - { "exchangeInfo", 1 }, - { "depth", 0.5 }, - { "ping", 1 }, - { "systemStatus", 1 }, - { "tickers/24hr", 1 }, - { "ticker/24hr", 1 }, - { "time", 1 }, - { "trades", 1 }, - { "klines", 1 }, - } }, - } }, - { "private", new Dictionary() { - { "get", new Dictionary() { - { "account", 1 }, - { "allOrders", 1 }, - { "funds", 1 }, - { "historicalTrades", 1 }, - { "openOrders", 1 }, - { "order", 0.5 }, - { "myTrades", 0.5 }, - { "coins", 12 }, - { "crypto/withdraws", 12 }, - { "crypto/deposits/address", 60 }, - { "sub_account/fund_transfer/history", 1 }, - { "sub_account/accounts", 1 }, - } }, - { "post", new Dictionary() { - { "order", 0.1 }, - { "order/test", 0.5 }, - } }, - { "delete", new Dictionary() { - { "order", 0.1 }, - { "openOrders", 1 }, - } }, - } }, - } }, - { "fees", new Dictionary() { - { "WRX", new Dictionary() { - { "maker", this.parseNumber("0.0") }, - { "taker", this.parseNumber("0.0") }, - } }, - } }, - { "precisionMode", TICK_SIZE }, - { "exceptions", new Dictionary() { - { "exact", new Dictionary() { - { "-1121", typeof(BadSymbol) }, - { "1999", typeof(BadRequest) }, - { "2002", typeof(InsufficientFunds) }, - { "2005", typeof(BadRequest) }, - { "2078", typeof(PermissionDenied) }, - { "2098", typeof(BadRequest) }, - { "2031", typeof(InvalidOrder) }, - { "2113", typeof(BadRequest) }, - { "2115", typeof(BadRequest) }, - { "2136", typeof(RateLimitExceeded) }, - { "94001", typeof(InvalidOrder) }, - } }, - } }, - { "timeframes", new Dictionary() { - { "1m", "1m" }, - { "5m", "5m" }, - { "30m", "30m" }, - { "1h", "1h" }, - { "2h", "2h" }, - { "4h", "4h" }, - { "6h", "6h" }, - { "12h", "12h" }, - { "1d", "1d" }, - { "1w", "1w" }, - } }, - { "options", new Dictionary() { - { "recvWindow", 10000 }, - { "networks", new Dictionary() {} }, - } }, - { "features", new Dictionary() { - { "spot", new Dictionary() { - { "sandbox", false }, - { "createOrder", new Dictionary() { - { "marginMode", false }, - { "triggerPrice", true }, - { "triggerDirection", false }, - { "triggerPriceType", null }, - { "stopLossPrice", false }, - { "takeProfitPrice", false }, - { "attachedStopLossTakeProfit", null }, - { "timeInForce", new Dictionary() { - { "IOC", false }, - { "FOK", false }, - { "PO", false }, - { "GTD", false }, - } }, - { "hedged", false }, - { "trailing", false }, - { "leverage", false }, - { "marketBuyByCost", false }, - { "marketBuyRequiresPrice", false }, - { "selfTradePrevention", false }, - { "iceberg", false }, - } }, - { "createOrders", null }, - { "fetchMyTrades", null }, - { "fetchOrder", null }, - { "fetchOpenOrders", new Dictionary() { - { "marginMode", false }, - { "limit", null }, - { "trigger", false }, - { "trailing", false }, - { "symbolRequired", true }, - } }, - { "fetchOrders", new Dictionary() { - { "marginMode", false }, - { "limit", 1000 }, - { "daysBack", 100000 }, - { "untilDays", 100000 }, - { "trigger", false }, - { "trailing", false }, - { "symbolRequired", true }, - } }, - { "fetchClosedOrders", null }, - { "fetchOHLCV", new Dictionary() { - { "limit", 2000 }, - } }, - } }, - { "swap", new Dictionary() { - { "linear", null }, - { "inverse", null }, - } }, - { "future", new Dictionary() { - { "linear", null }, - { "inverse", null }, - } }, - } }, - }); - } - - /** - * @method - * @name wazirx#fetchMarkets - * @see https://docs.wazirx.com/#exchange-info - * @description retrieves data on all markets for wazirx - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} an array of objects representing market data - */ - public async override Task fetchMarkets(object parameters = null) - { - parameters ??= new Dictionary(); - object response = await this.publicGetExchangeInfo(parameters); - // - // { - // "timezone":"UTC", - // "serverTime":1641336850932, - // "symbols":[ - // { - // "symbol":"btcinr", - // "status":"trading", - // "baseAsset":"btc", - // "quoteAsset":"inr", - // "baseAssetPrecision":5, - // "quoteAssetPrecision":0, - // "orderTypes":[ - // "limit", - // "stop_limit" - // ], - // "isSpotTradingAllowed":true, - // "filters":[ - // { - // "filterType":"PRICE_FILTER", - // "minPrice":"1", - // "tickSize":"1" - // } - // ] - // }, - // - object markets = this.safeValue(response, "symbols", new List() {}); - return this.parseMarkets(markets); - } - - public override object parseMarket(object market) - { - object id = this.safeString(market, "symbol"); - object baseId = this.safeString(market, "baseAsset"); - object quoteId = this.safeString(market, "quoteAsset"); - object bs = this.safeCurrencyCode(baseId); - object quote = this.safeCurrencyCode(quoteId); - object isSpot = this.safeValue(market, "isSpotTradingAllowed"); - object filters = this.safeValue(market, "filters"); - object minPrice = null; - for (object j = 0; isLessThan(j, getArrayLength(filters)); postFixIncrement(ref j)) - { - object filter = getValue(filters, j); - object filterType = this.safeString(filter, "filterType"); - if (isTrue(isEqual(filterType, "PRICE_FILTER"))) - { - minPrice = this.safeNumber(filter, "minPrice"); - } - } - object fee = this.safeValue(this.fees, quote, new Dictionary() {}); - object takerString = this.safeString(fee, "taker", "0.2"); - takerString = Precise.stringDiv(takerString, "100"); - object makerString = this.safeString(fee, "maker", "0.2"); - makerString = Precise.stringDiv(makerString, "100"); - object status = this.safeString(market, "status"); - return new Dictionary() { - { "id", id }, - { "symbol", add(add(bs, "/"), quote) }, - { "base", bs }, - { "quote", quote }, - { "settle", null }, - { "baseId", baseId }, - { "quoteId", quoteId }, - { "settleId", null }, - { "type", "spot" }, - { "spot", isSpot }, - { "margin", false }, - { "swap", false }, - { "future", false }, - { "option", false }, - { "active", (isEqual(status, "trading")) }, - { "contract", false }, - { "linear", null }, - { "inverse", null }, - { "taker", this.parseNumber(takerString) }, - { "maker", this.parseNumber(makerString) }, - { "contractSize", null }, - { "expiry", null }, - { "expiryDatetime", null }, - { "strike", null }, - { "optionType", null }, - { "precision", new Dictionary() { - { "amount", this.parseNumber(this.parsePrecision(this.safeString(market, "baseAssetPrecision"))) }, - { "price", this.parseNumber(this.parsePrecision(this.safeString(market, "quoteAssetPrecision"))) }, - } }, - { "limits", new Dictionary() { - { "leverage", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - { "price", new Dictionary() { - { "min", minPrice }, - { "max", null }, - } }, - { "amount", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - { "cost", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - } }, - { "created", null }, - { "info", market }, - }; - } - - /** - * @method - * @name wazirx#fetchOHLCV - * @see https://docs.wazirx.com/#kline-candlestick-data - * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market - * @param {string} symbol unified symbol of the market to fetch OHLCV data for - * @param {string} timeframe the length of time each candle represents. Available values [1m,5m,15m,30m,1h,2h,4h,6h,12h,1d,1w] - * @param {int} [since] timestamp in ms of the earliest candle to fetch - * @param {int} [limit] the maximum amount of candles to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {int} [params.until] timestamp in s of the latest candle to fetch - * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume - */ - public async override Task fetchOHLCV(object symbol, object timeframe = null, object since = null, object limit = null, object parameters = null) - { - timeframe ??= "1m"; - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - { "interval", this.safeString(this.timeframes, timeframe, timeframe) }, - }; - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit"] = mathMin(limit, 2000); - } - object until = this.safeInteger(parameters, "until"); - parameters = this.omit(parameters, new List() {"until"}); - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["startTime"] = this.parseToInt(divide(since, 1000)); - } - if (isTrue(!isEqual(until, null))) - { - ((IDictionary)request)["endTime"] = until; - } - object response = await this.publicGetKlines(this.extend(request, parameters)); - // - // [ - // [1669014360,1402001,1402001,1402001,1402001,0], - // ... - // ] - // - return this.parseOHLCVs(response, market, timeframe, since, limit); - } - - public override object parseOHLCV(object ohlcv, object market = null) - { - // - // [1669014300,1402001,1402001,1402001,1402001,0], - // - return new List {this.safeTimestamp(ohlcv, 0), this.safeNumber(ohlcv, 1), this.safeNumber(ohlcv, 2), this.safeNumber(ohlcv, 3), this.safeNumber(ohlcv, 4), this.safeNumber(ohlcv, 5)}; - } - - /** - * @method - * @name wazirx#fetchOrderBook - * @see https://docs.wazirx.com/#order-book - * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @param {string} symbol unified symbol of the market to fetch the order book for - * @param {int} [limit] the maximum amount of order book entries to return - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols - */ - public async override Task fetchOrderBook(object symbol, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit"] = limit; // [1, 5, 10, 20, 50, 100, 500, 1000] - } - object response = await this.publicGetDepth(this.extend(request, parameters)); - // - // { - // "timestamp":1559561187, - // "asks":[ - // ["8540.0","1.5"], - // ["8541.0","0.0042"] - // ], - // "bids":[ - // ["8530.0","0.8814"], - // ["8524.0","1.4"] - // ] - // } - // - object timestamp = this.safeInteger(response, "timestamp"); - return this.parseOrderBook(response, symbol, timestamp); - } - - /** - * @method - * @name wazirx#fetchTicker - * @see https://docs.wazirx.com/#24hr-ticker-price-change-statistics - * @description fetches 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 - * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task fetchTicker(object symbol, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object ticker = await this.publicGetTicker24hr(this.extend(request, parameters)); - // - // { - // "symbol":"wrxinr", - // "baseAsset":"wrx", - // "quoteAsset":"inr", - // "openPrice":"94.77", - // "lowPrice":"92.7", - // "highPrice":"95.17", - // "lastPrice":"94.03", - // "volume":"1118700.0", - // "bidPrice":"94.02", - // "askPrice":"94.03", - // "at":1641382455000 - // } - // - return this.parseTicker(ticker, market); - } - - /** - * @method - * @name wazirx#fetchTickers - * @see https://docs.wazirx.com/#24hr-tickers-price-change-statistics - * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market - * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure} - */ - public async override Task fetchTickers(object symbols = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object tickers = await this.publicGetTickers24hr(); - // - // [ - // { - // "symbol":"btcinr", - // "baseAsset":"btc", - // "quoteAsset":"inr", - // "openPrice":"3698486", - // "lowPrice":"3641155.0", - // "highPrice":"3767999.0", - // "lastPrice":"3713212.0", - // "volume":"254.11582", - // "bidPrice":"3715021.0", - // "askPrice":"3715022.0", - // } - // ... - // ] - // - object result = new Dictionary() {}; - for (object i = 0; isLessThan(i, getArrayLength(tickers)); postFixIncrement(ref i)) - { - object ticker = getValue(tickers, i); - object parsedTicker = this.parseTicker(ticker); - object symbol = getValue(parsedTicker, "symbol"); - ((IDictionary)result)[(string)symbol] = parsedTicker; - } - return this.filterByArrayTickers(result, "symbol", symbols); - } - - /** - * @method - * @name wazirx#fetchTrades - * @see https://docs.wazirx.com/#recent-trades-list - * @description get the list of most recent trades for a particular symbol - * @param {string} symbol unified symbol of the market to fetch trades for - * @param {int} [since] timestamp in ms of the earliest trade to fetch - * @param {int} [limit] the maximum amount of trades to fetch - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} - */ - public async override Task fetchTrades(object symbol, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit"] = mathMin(limit, 1000); // Default 500; max 1000. - } - object method = this.safeString(this.options, "fetchTradesMethod", "publicGetTrades"); - object response = null; - if (isTrue(isEqual(method, "privateGetHistoricalTrades"))) - { - response = await this.privateGetHistoricalTrades(this.extend(request, parameters)); - } else - { - response = await this.publicGetTrades(this.extend(request, parameters)); - } - // [ - // { - // "id":322307791, - // "price":"93.7", - // "qty":"0.7", - // "quoteQty":"65.59", - // "time":1641386701000, - // "isBuyerMaker":false - // }, - // ] - return this.parseTrades(response, market, since, limit); - } - - public override object parseTrade(object trade, object market = null) - { - // - // { - // "id":322307791, - // "price":"93.7", - // "qty":"0.7", - // "quoteQty":"65.59", - // "time":1641386701000, - // "isBuyerMaker":false - // } - // - object id = this.safeString(trade, "id"); - object timestamp = this.safeInteger(trade, "time"); - object datetime = this.iso8601(timestamp); - market = this.safeMarket(null, market); - object isBuyerMaker = this.safeValue(trade, "isBuyerMaker"); - object side = ((bool) isTrue(isBuyerMaker)) ? "sell" : "buy"; - object price = this.safeNumber(trade, "price"); - object amount = this.safeNumber(trade, "qty"); - object cost = this.safeNumber(trade, "quoteQty"); - return this.safeTrade(new Dictionary() { - { "info", trade }, - { "id", id }, - { "timestamp", timestamp }, - { "datetime", datetime }, - { "symbol", getValue(market, "symbol") }, - { "order", id }, - { "type", null }, - { "side", side }, - { "takerOrMaker", null }, - { "price", price }, - { "amount", amount }, - { "cost", cost }, - { "fee", null }, - }, market); - } - - /** - * @method - * @name wazirx#fetchStatus - * @see https://docs.wazirx.com/#system-status - * @description the latest known information on the availability of the exchange API - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure} - */ - public async override Task fetchStatus(object parameters = null) - { - parameters ??= new Dictionary(); - object response = await this.publicGetSystemStatus(parameters); - // - // { - // "status":"normal", // normal, system maintenance - // "message":"System is running normally." - // } - // - object status = this.safeString(response, "status"); - return new Dictionary() { - { "status", ((bool) isTrue((isEqual(status, "normal")))) ? "ok" : "maintenance" }, - { "updated", null }, - { "eta", null }, - { "url", null }, - { "info", response }, - }; - } - - /** - * @method - * @name wazirx#fetchTime - * @see https://docs.wazirx.com/#check-server-time - * @description fetches the current integer timestamp in milliseconds from the exchange server - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {int} the current integer timestamp in milliseconds from the exchange server - */ - public async override Task fetchTime(object parameters = null) - { - parameters ??= new Dictionary(); - object response = await this.publicGetTime(parameters); - // - // { - // "serverTime":1635467280514 - // } - // - return this.safeInteger(response, "serverTime"); - } - - public override object parseTicker(object ticker, object market = null) - { - // - // { - // "symbol":"btcinr", - // "baseAsset":"btc", - // "quoteAsset":"inr", - // "openPrice":"3698486", - // "lowPrice":"3641155.0", - // "highPrice":"3767999.0", - // "lastPrice":"3713212.0", - // "volume":"254.11582", // base volume - // "bidPrice":"3715021.0", - // "askPrice":"3715022.0", - // "at":1641382455000 // only on fetchTicker - // } - // - object marketId = this.safeString(ticker, "symbol"); - market = this.safeMarket(marketId, market); - object symbol = getValue(market, "symbol"); - object last = this.safeString(ticker, "lastPrice"); - object open = this.safeString(ticker, "openPrice"); - object high = this.safeString(ticker, "highPrice"); - object low = this.safeString(ticker, "lowPrice"); - object baseVolume = this.safeString(ticker, "volume"); - object bid = this.safeString(ticker, "bidPrice"); - object ask = this.safeString(ticker, "askPrice"); - object timestamp = this.safeInteger(ticker, "at"); - return this.safeTicker(new Dictionary() { - { "symbol", symbol }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "high", high }, - { "low", low }, - { "bid", bid }, - { "bidVolume", null }, - { "ask", ask }, - { "askVolume", null }, - { "vwap", null }, - { "open", open }, - { "close", last }, - { "last", last }, - { "previousClose", null }, - { "change", null }, - { "percentage", null }, - { "average", null }, - { "baseVolume", baseVolume }, - { "quoteVolume", null }, - { "info", ticker }, - }, market); - } - - public override object parseBalance(object response) - { - object result = new Dictionary() { - { "info", response }, - }; - for (object i = 0; isLessThan(i, getArrayLength(response)); postFixIncrement(ref i)) - { - object balance = getValue(response, i); - object id = this.safeString(balance, "asset"); - object code = this.safeCurrencyCode(id); - object account = this.account(); - ((IDictionary)account)["free"] = this.safeString(balance, "free"); - ((IDictionary)account)["used"] = this.safeString(balance, "locked"); - ((IDictionary)result)[(string)code] = account; - } - return this.safeBalance(result); - } - - /** - * @method - * @name wazirx#fetchBalance - * @see https://docs.wazirx.com/#fund-details-user_data - * @description query for balance and get the amount of funds available for trading or funds locked in orders - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} - */ - public async override Task fetchBalance(object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object response = await this.privateGetFunds(parameters); - // - // [ - // { - // "asset":"inr", - // "free":"0.0", - // "locked":"0.0" - // }, - // ] - // - return this.parseBalance(response); - } - - /** - * @method - * @name wazirx#fetchOrders - * @see https://docs.wazirx.com/#all-orders-user_data - * @description fetches information on multiple orders made by the user - * @param {string} symbol unified market symbol of the market orders were made in - * @param {int} [since] the earliest time in ms to fetch orders for - * @param {int} [limit] the maximum number of order structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task fetchOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - if (isTrue(isEqual(symbol, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " fetchOrders() requires a symbol argument")) ; - } - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["startTime"] = since; - } - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit"] = limit; - } - object response = await this.privateGetAllOrders(this.extend(request, parameters)); - // - // [ - // { - // "id": 28, - // "symbol": "wrxinr", - // "price": "9293.0", - // "origQty": "10.0", - // "executedQty": "8.2", - // "status": "cancel", - // "type": "limit", - // "side": "sell", - // "createdTime": 1499827319559, - // "updatedTime": 1499827319559 - // }, - // { - // "id": 30, - // "symbol": "wrxinr", - // "price": "9293.0", - // "stopPrice": "9200.0", - // "origQty": "10.0", - // "executedQty": "0.0", - // "status": "cancel", - // "type": "stop_limit", - // "side": "sell", - // "createdTime": 1499827319559, - // "updatedTime": 1507725176595 - // } - // ] - // - object orders = this.parseOrders(response, market, since, limit); - orders = this.filterBy(orders, "symbol", symbol); - return orders; - } - - /** - * @method - * @name wazirx#fetchOpenOrders - * @see https://docs.wazirx.com/#current-open-orders-user_data - * @description fetch all unfilled currently open orders - * @param {string} symbol unified market symbol - * @param {int} [since] the earliest time in ms to fetch open orders for - * @param {int} [limit] the maximum number of open orders structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task fetchOpenOrders(object symbol = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() {}; - object market = null; - if (isTrue(!isEqual(symbol, null))) - { - market = this.market(symbol); - ((IDictionary)request)["symbol"] = getValue(market, "id"); - } - object response = await this.privateGetOpenOrders(this.extend(request, parameters)); - // [ - // { - // "id": 28, - // "symbol": "wrxinr", - // "price": "9293.0", - // "origQty": "10.0", - // "executedQty": "8.2", - // "status": "cancel", - // "type": "limit", - // "side": "sell", - // "createdTime": 1499827319559, - // "updatedTime": 1499827319559 - // }, - // { - // "id": 30, - // "symbol": "wrxinr", - // "price": "9293.0", - // "stopPrice": "9200.0", - // "origQty": "10.0", - // "executedQty": "0.0", - // "status": "cancel", - // "type": "stop_limit", - // "side": "sell", - // "createdTime": 1499827319559, - // "updatedTime": 1507725176595 - // } - // ] - object orders = this.parseOrders(response, market, since, limit); - return orders; - } - - /** - * @method - * @name wazirx#cancelAllOrders - * @see https://docs.wazirx.com/#cancel-all-open-orders-on-a-symbol-trade - * @description cancel all open orders in a market - * @param {string} symbol unified market symbol of the market to cancel orders in - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task cancelAllOrders(object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - if (isTrue(isEqual(symbol, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " cancelAllOrders() requires a symbol argument")) ; - } - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object response = await this.privateDeleteOpenOrders(this.extend(request, parameters)); - // - // [ - // { - // id: "4565421197", - // symbol: "adausdt", - // type: "limit", - // side: "buy", - // status: "wait", - // price: "0.41", - // origQty: "11.00", - // executedQty: "0.00", - // avgPrice: "0.00", - // createdTime: "1718089507000", - // updatedTime: "1718089507000", - // clientOrderId: "93d2a838-e272-405d-91e7-3a7bc6d3a003" - // } - // ] - // - return this.parseOrders(response); - } - - /** - * @method - * @name wazirx#cancelOrder - * @see https://docs.wazirx.com/#cancel-order-trade - * @description cancels an open order - * @param {string} id order id - * @param {string} symbol unified symbol of the market the order was made in - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task cancelOrder(object id, object symbol = null, object parameters = null) - { - parameters ??= new Dictionary(); - if (isTrue(isEqual(symbol, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " cancelOrder() requires a symbol argument")) ; - } - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - { "orderId", id }, - }; - object response = await this.privateDeleteOrder(this.extend(request, parameters)); - return this.parseOrder(response); - } - - /** - * @method - * @name wazirx#createOrder - * @see https://docs.wazirx.com/#new-order-trade - * @description create a trade order - * @param {string} symbol unified symbol of the market to create an order in - * @param {string} type 'market' or 'limit' - * @param {string} side 'buy' or 'sell' - * @param {float} amount how much of currency you want to trade in units of base currency - * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} - */ - public async override Task createOrder(object symbol, object type, object side, object amount, object price = null, object parameters = null) - { - parameters ??= new Dictionary(); - type = ((string)type).ToLower(); - if (isTrue(isTrue((!isEqual(type, "limit"))) && isTrue((!isEqual(type, "stop_limit"))))) - { - throw new ExchangeError ((string)add(this.id, " createOrder() supports limit and stop_limit orders only")) ; - } - if (isTrue(isEqual(price, null))) - { - throw new ExchangeError ((string)add(this.id, " createOrder() requires a price argument")) ; - } - await this.loadMarkets(); - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - { "side", side }, - { "quantity", amount }, - { "type", "limit" }, - }; - ((IDictionary)request)["price"] = this.priceToPrecision(symbol, price); - object triggerPrice = this.safeString2(parameters, "triggerPrice", "stopPrice"); - if (isTrue(!isEqual(triggerPrice, null))) - { - ((IDictionary)request)["type"] = "stop_limit"; - ((IDictionary)request)["stopPrice"] = this.priceToPrecision(symbol, triggerPrice); - } - object response = await this.privatePostOrder(this.extend(request, parameters)); - // { - // "id": 28, - // "symbol": "wrxinr", - // "price": "9293.0", - // "origQty": "10.0", - // "executedQty": "8.2", - // "status": "wait", - // "type": "limit", - // "side": "sell", - // "createdTime": 1499827319559, - // "updatedTime": 1499827319559 - // } - return this.parseOrder(response, market); - } - - public override object parseOrder(object order, object market = null) - { - // - // { - // "id": 1949417813, - // "symbol": "ltcusdt", - // "type": "limit", - // "side": "sell", - // "status": "done", - // "price": "146.2", - // "origQty": "0.05", - // "executedQty": "0.05", - // "avgPrice": "0.00", - // "createdTime": 1641252564000, - // "updatedTime": 1641252564000 - // "clientOrderId": "93d2a838-e272-405d-91e7-3a7bc6d3a003" - // } - // - object created = this.safeInteger(order, "createdTime"); - object updated = this.safeInteger(order, "updatedTime"); - object marketId = this.safeString(order, "symbol"); - object symbol = this.safeSymbol(marketId, market); - object amount = this.safeString(order, "quantity"); - object filled = this.safeString(order, "executedQty"); - object status = this.parseOrderStatus(this.safeString(order, "status")); - object id = this.safeString(order, "id"); - object price = this.safeString(order, "price"); - object type = this.safeStringLower(order, "type"); - object side = this.safeStringLower(order, "side"); - return this.safeOrder(new Dictionary() { - { "info", order }, - { "id", id }, - { "clientOrderId", this.safeString(order, "clientOrderId") }, - { "timestamp", created }, - { "datetime", this.iso8601(created) }, - { "lastTradeTimestamp", updated }, - { "status", status }, - { "symbol", symbol }, - { "type", type }, - { "timeInForce", null }, - { "postOnly", null }, - { "side", side }, - { "price", price }, - { "amount", amount }, - { "filled", filled }, - { "remaining", null }, - { "cost", null }, - { "fee", null }, - { "average", this.safeString(order, "avgPrice") }, - { "trades", new List() {} }, - }, market); - } - - public virtual object parseOrderStatus(object status) - { - object statuses = new Dictionary() { - { "wait", "open" }, - { "done", "closed" }, - { "cancel", "canceled" }, - }; - return this.safeString(statuses, status, status); - } - - /** - * @method - * @name wazirx#fetchCurrencies - * @description fetches all available currencies on an exchange - * @see https://docs.wazirx.com/#all-coins-39-information-user_data - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @returns {object} an associative dictionary of currencies - */ - public async override Task fetchCurrencies(object parameters = null) - { - parameters ??= new Dictionary(); - if (!isTrue(this.checkRequiredCredentials(false))) - { - return null; - } - object response = await this.privateGetCoins(parameters); - // - // [ - // { - // "currency": "btc", - // "name": "Bitcoin", - // "networkList": [ - // { - // "addressRegex": "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$", - // "confirmations": 4, - // "depositDesc": { - // "description": "" - // }, - // "depositDust": "0.00000001", - // "depositEnable": true, - // "disclaimer": "• \u003cb\u003eSend only using the Bitcoin network.\u003c/b\u003e Using any other network will result in loss of funds.\u003cbr/\u003e• \u003cb\u003eDeposit only BTC to this deposit address.\u003c/b\u003e Depositing any other asset will result in a loss of funds.\u003cbr/\u003e", - // "fullName": null, - // "hidden": { - // "deposit": false, - // "withdraw": false - // }, - // "isDefault": true, - // "maxWithdrawAmount": "3", - // "minConfirm": 4, - // "minWithdrawAmount": "0.003", - // "name": "Bitcoin", - // "network": "btc", - // "order": 3, - // "precision": 8, - // "requestId": "6d67a13d-26f7-4941-9856-94eba4adfe78", - // "shortName": "BTC", - // "specialTip": "Please ensure to select \u003cb\u003eBitcoin\u003c/b\u003e network at sender's wallet.", - // "withdrawConsent": { - // "helpUrl": null, - // "message": "I confirm that this withdrawal of crypto assets is being done to my own wallet, as specified above. I authorize you to share travel rule information with the destination wallet service provider wherever applicable." - // }, - // "withdrawDesc": { - // "description": "" - // }, - // "withdrawEnable": true, - // "withdrawFee": "0.0015" - // } - // ], - // "rapidListed": false - // } - // ] - // - object result = new Dictionary() {}; - for (object i = 0; isLessThan(i, getArrayLength(response)); postFixIncrement(ref i)) - { - object currency = getValue(response, i); - object currencyId = this.safeString(currency, "currency"); - object code = this.safeCurrencyCode(currencyId); - object name = this.safeString(currency, "name"); - object chains = this.safeList(currency, "networkList", new List() {}); - object networks = new Dictionary() {}; - object minPrecision = null; - object minWithdrawFeeString = null; - object minWithdrawString = null; - object maxWithdrawString = null; - object minDepositString = null; - object deposit = false; - object withdraw = false; - for (object j = 0; isLessThan(j, getArrayLength(chains)); postFixIncrement(ref j)) - { - object chain = getValue(chains, j); - object networkId = this.safeString(chain, "network"); - object networkCode = this.networkIdToCode(networkId); - object precision = this.parseNumber(this.parsePrecision(this.safeString(chain, "precision"))); - minPrecision = ((bool) isTrue((isEqual(minPrecision, null)))) ? precision : mathMin(minPrecision, precision); - object depositAllowed = this.safeBool(chain, "depositEnable"); - deposit = ((bool) isTrue((depositAllowed))) ? depositAllowed : deposit; - object withdrawAllowed = this.safeBool(chain, "withdrawEnable"); - withdraw = ((bool) isTrue((withdrawAllowed))) ? withdrawAllowed : withdraw; - object withdrawFeeString = this.safeString(chain, "withdrawFee"); - if (isTrue(!isEqual(withdrawFeeString, null))) - { - minWithdrawFeeString = ((bool) isTrue((isEqual(minWithdrawFeeString, null)))) ? withdrawFeeString : Precise.stringMin(withdrawFeeString, minWithdrawFeeString); - } - object minNetworkWithdrawString = this.safeString(chain, "minWithdrawAmount"); - if (isTrue(!isEqual(minNetworkWithdrawString, null))) - { - minWithdrawString = ((bool) isTrue((isEqual(minWithdrawString, null)))) ? minNetworkWithdrawString : Precise.stringMin(minNetworkWithdrawString, minWithdrawString); - } - object maxNetworkWithdrawString = this.safeString(chain, "maxWithdrawAmount"); - if (isTrue(!isEqual(maxNetworkWithdrawString, null))) - { - maxWithdrawString = ((bool) isTrue((isEqual(maxWithdrawString, null)))) ? maxNetworkWithdrawString : Precise.stringMin(maxNetworkWithdrawString, maxWithdrawString); - } - object minNetworkDepositString = this.safeString(chain, "depositDust"); - if (isTrue(!isEqual(minNetworkDepositString, null))) - { - minDepositString = ((bool) isTrue((isEqual(minDepositString, null)))) ? minNetworkDepositString : Precise.stringMin(minNetworkDepositString, minDepositString); - } - ((IDictionary)networks)[(string)networkCode] = new Dictionary() { - { "info", chain }, - { "id", networkId }, - { "network", networkCode }, - { "active", isTrue(depositAllowed) && isTrue(withdrawAllowed) }, - { "deposit", depositAllowed }, - { "withdraw", withdrawAllowed }, - { "fee", this.parseNumber(withdrawFeeString) }, - { "precision", precision }, - { "limits", new Dictionary() { - { "withdraw", new Dictionary() { - { "min", this.parseNumber(minNetworkWithdrawString) }, - { "max", this.parseNumber(maxNetworkWithdrawString) }, - } }, - { "deposit", new Dictionary() { - { "min", this.parseNumber(minNetworkDepositString) }, - { "max", null }, - } }, - } }, - }; - } - ((IDictionary)result)[(string)code] = new Dictionary() { - { "info", currency }, - { "code", code }, - { "id", currencyId }, - { "name", name }, - { "active", isTrue(deposit) && isTrue(withdraw) }, - { "deposit", deposit }, - { "withdraw", withdraw }, - { "fee", this.parseNumber(minWithdrawFeeString) }, - { "precision", minPrecision }, - { "limits", new Dictionary() { - { "amount", new Dictionary() { - { "min", null }, - { "max", null }, - } }, - { "withdraw", new Dictionary() { - { "min", this.parseNumber(minWithdrawString) }, - { "max", this.parseNumber(maxWithdrawString) }, - } }, - { "deposit", new Dictionary() { - { "min", this.parseNumber(minDepositString) }, - { "max", null }, - } }, - } }, - { "networks", networks }, - }; - } - return result; - } - - /** - * @method - * @name wazirx#fetchDepositAddress - * @description fetch the deposit address for a currency associated with this account - * @see https://docs.wazirx.com/#deposit-address-supporting-network-user_data - * @param {string} code unified currency code of the currency for the deposit address - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {string} [params.network] unified network code, you can get network from fetchCurrencies - * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} - */ - public async override Task fetchDepositAddress(object code, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object currency = this.currency(code); - object networkCode = this.safeString(parameters, "network"); - parameters = this.omit(parameters, "network"); - if (isTrue(isEqual(networkCode, null))) - { - throw new ArgumentsRequired ((string)add(this.id, " fetchDepositAddress() requires a network parameter")) ; - } - object request = new Dictionary() { - { "coin", getValue(currency, "id") }, - { "network", this.networkCodeToId(networkCode, code) }, - }; - object response = await this.privateGetCryptoDepositsAddress(this.extend(request, parameters)); - // - // { - // "address": "bc1qrzpyzh69pfclpqy7c3yg8rkjsy49se7642v4q3", - // "coin": "btc", - // "url": "https: //live.blockcypher.com/btc/address/bc1qrzpyzh69pfclpqy7c3yg8rkjsy49se7642v4q3" - // } - // - return new Dictionary() { - { "info", response }, - { "currency", code }, - { "network", this.networkCodeToId(networkCode, code) }, - { "address", this.safeString(response, "address") }, - { "tag", null }, - }; - } - - /** - * @method - * @name wazirx#fetchWithdrawals - * @description fetch all withdrawals made from an account - * @see https://docs.wazirx.com/#withdraw-history-supporting-network-user_data - * @param {string} code unified currency code - * @param {int} [since] the earliest time in ms to fetch withdrawals for - * @param {int} [limit] the maximum number of withdrawals structures to retrieve - * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {int} [params.until] the latest time in ms to fetch entries for - * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} - */ - public async override Task fetchWithdrawals(object code = null, object since = null, object limit = null, object parameters = null) - { - parameters ??= new Dictionary(); - await this.loadMarkets(); - object request = new Dictionary() {}; - object currency = null; - if (isTrue(!isEqual(code, null))) - { - currency = this.currency(code); - ((IDictionary)request)["coin"] = getValue(currency, "id"); - } - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["limit"] = limit; - } - object until = this.safeInteger(parameters, "until"); - parameters = this.omit(parameters, new List() {"until"}); - if (isTrue(!isEqual(since, null))) - { - ((IDictionary)request)["startTime"] = since; - } - if (isTrue(!isEqual(until, null))) - { - ((IDictionary)request)["endTime"] = until; - } - object response = await this.privateGetCryptoWithdraws(this.extend(request, parameters)); - // - // [ - // { - // "address": "0x94df8b352de7f46f64b01d3666bf6e936e44ce60", - // "amount": "8.91000000", - // "createdAt": "2019-10-12 09:12:02", - // "lastUpdated": "2019-10-12 11:12:02", - // "coin": "USDT", - // "id": "b6ae22b3aa844210a7041aee7589627c", - // "withdrawOrderId": "WITHDRAWtest123", - // "network": "ETH", - // "status": 1, - // "transactionFee": "0.004", - // "failureInfo":"The address is not valid. Please confirm with the recipient", - // "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268" - // } - // ] - // - return this.parseTransactions(response, currency, since, limit); - } - - public virtual object parseTransactionStatus(object status) - { - object statuses = new Dictionary() { - { "0", "ok" }, - { "1", "fail" }, - { "2", "pending" }, - { "3", "canceled" }, - }; - return this.safeString(statuses, status, status); - } - - public override object parseTransaction(object transaction, object currency = null) - { - // - // { - // "address": "0x94df8b352de7f46f64b01d3666bf6e936e44ce60", - // "amount": "8.91000000", - // "createdAt": "2019-10-12 09:12:02", - // "lastUpdated": "2019-10-12 11:12:02", - // "coin": "USDT", - // "id": "b6ae22b3aa844210a7041aee7589627c", - // "withdrawOrderId": "WITHDRAWtest123", - // "network": "ETH", - // "status": 1, - // "transactionFee": "0.004", - // "failureInfo": "The address is not valid. Please confirm with the recipient", - // "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268" - // } - // - object currencyId = this.safeString(transaction, "coin"); - object code = this.safeCurrencyCode(currencyId, currency); - object timestamp = this.parse8601(this.safeString(transaction, "createdAt")); - object updated = this.parse8601(this.safeString(transaction, "lastUpdated")); - object status = this.parseTransactionStatus(this.safeString(transaction, "status")); - object feeCost = this.safeNumber(transaction, "transactionFee"); - object fee = null; - if (isTrue(!isEqual(feeCost, null))) - { - fee = new Dictionary() { - { "cost", feeCost }, - { "currency", code }, - }; - } - return new Dictionary() { - { "info", transaction }, - { "id", this.safeString(transaction, "id") }, - { "txid", this.safeString(transaction, "txId") }, - { "timestamp", timestamp }, - { "datetime", this.iso8601(timestamp) }, - { "network", this.networkIdToCode(this.safeString(transaction, "network")) }, - { "address", this.safeString(transaction, "address") }, - { "addressTo", this.safeString(transaction, "address") }, - { "addressFrom", null }, - { "tag", null }, - { "tagTo", null }, - { "tagFrom", null }, - { "type", "withdrawal" }, - { "amount", this.safeNumber(transaction, "amount") }, - { "currency", code }, - { "status", status }, - { "updated", updated }, - { "fee", fee }, - { "internal", null }, - { "comment", null }, - }; - } - - public override object sign(object path, object api = null, object method = null, object parameters = null, object headers = null, object body = null) - { - api ??= "public"; - method ??= "GET"; - parameters ??= new Dictionary(); - object url = add(add(getValue(getValue(this.urls, "api"), "rest"), "/"), path); - if (isTrue(isEqual(api, "public"))) - { - if (isTrue(getArrayLength(new List(((IDictionary)parameters).Keys)))) - { - url = add(url, add("?", this.urlencode(parameters))); - } - } - if (isTrue(isEqual(api, "private"))) - { - this.checkRequiredCredentials(); - object timestamp = this.milliseconds(); - object data = this.extend(new Dictionary() { - { "recvWindow", getValue(this.options, "recvWindow") }, - { "timestamp", timestamp }, - }, parameters); - data = this.keysort(data); - object signature = this.hmac(this.encode(this.urlencode(data)), this.encode(this.secret), sha256); - url = add(url, add("?", this.urlencode(data))); - url = add(url, add(add("&", "signature="), signature)); - headers = new Dictionary() { - { "Content-Type", "application/x-www-form-urlencoded" }, - { "X-Api-Key", this.apiKey }, - }; - } - return new Dictionary() { - { "url", url }, - { "method", method }, - { "body", body }, - { "headers", headers }, - }; - } - - public override object handleErrors(object code, object reason, object url, object method, object headers, object body, object response, object requestHeaders, object requestBody) - { - // - // {"code":2098,"message":"Request out of receiving window."} - // - if (isTrue(isEqual(response, null))) - { - return null; - } - object errorCode = this.safeString(response, "code"); - if (isTrue(!isEqual(errorCode, null))) - { - object feedback = add(add(this.id, " "), body); - this.throwExactlyMatchedException(getValue(this.exceptions, "exact"), errorCode, feedback); - throw new ExchangeError ((string)feedback) ; - } - return null; - } -} diff --git a/cs/ccxt/exchanges/woo.cs b/cs/ccxt/exchanges/woo.cs index 3e00173d27e41..8cf6db58f8e89 100644 --- a/cs/ccxt/exchanges/woo.cs +++ b/cs/ccxt/exchanges/woo.cs @@ -95,7 +95,7 @@ public override object describe() { "fetchTickers", false }, { "fetchTime", true }, { "fetchTrades", true }, - { "fetchTradingFee", false }, + { "fetchTradingFee", true }, { "fetchTradingFees", true }, { "fetchTransactions", "emulated" }, { "fetchTransfers", true }, @@ -227,19 +227,56 @@ public override object describe() { "v3", new Dictionary() { { "public", new Dictionary() { { "get", new Dictionary() { - { "insuranceFund", 3 }, + { "systemInfo", 1 }, + { "instruments", 1 }, + { "token", 1 }, + { "tokenNetwork", 1 }, + { "tokenInfo", 1 }, + { "marketTrades", 1 }, + { "marketTradesHistory", 1 }, + { "orderbook", 1 }, + { "kline", 1 }, + { "klineHistory", 1 }, + { "futures", 1 }, + { "fundingRate", 1 }, + { "fundingRateHistory", 1 }, + { "insuranceFund", 1 }, } }, } }, { "private", new Dictionary() { { "get", new Dictionary() { + { "trade/order", 2 }, + { "trade/orders", 1 }, + { "trade/algoOrder", 1 }, + { "trade/algoOrders", 1 }, + { "trade/transaction", 1 }, + { "trade/transactionHistory", 5 }, + { "trade/tradingFee", 5 }, + { "account/info", 60 }, + { "account/tokenConfig", 1 }, + { "account/symbolConfig", 1 }, + { "account/subAccounts/all", 60 }, + { "account/referral/summary", 60 }, + { "account/referral/rewardHistory", 60 }, + { "account/credentials", 60 }, + { "asset/balances", 1 }, + { "asset/token/history", 60 }, + { "asset/transfer/history", 30 }, + { "asset/wallet/history", 60 }, + { "asset/wallet/deposit", 60 }, + { "asset/staking/yieldHistory", 60 }, + { "futures/positions", 3.33 }, + { "futures/leverage", 60 }, + { "futures/defaultMarginMode", 60 }, + { "futures/fundingFee/history", 30 }, + { "spotMargin/interestRate", 60 }, + { "spotMargin/interestHistory", 60 }, + { "spotMargin/maxMargin", 60 }, { "algo/order/{oid}", 1 }, { "algo/orders", 1 }, { "balances", 1 }, - { "accountinfo", 60 }, { "positions", 3.33 }, { "buypower", 1 }, - { "referrals", 60 }, - { "referral_rewards", 60 }, { "convert/exchangeInfo", 1 }, { "convert/assetInfo", 1 }, { "convert/rfq", 60 }, @@ -247,16 +284,34 @@ public override object describe() { "convert/trades", 1 }, } }, { "post", new Dictionary() { + { "trade/order", 2 }, + { "trade/algoOrder", 5 }, + { "trade/cancelAllAfter", 1 }, + { "account/tradingMode", 120 }, + { "account/listenKey", 20 }, + { "asset/transfer", 30 }, + { "asset/wallet/withdraw", 60 }, + { "spotMargin/leverage", 120 }, + { "spotMargin/interestRepay", 60 }, { "algo/order", 5 }, { "convert/rft", 60 }, } }, { "put", new Dictionary() { + { "trade/order", 2 }, + { "trade/algoOrder", 2 }, + { "futures/leverage", 60 }, + { "futures/positionMode", 120 }, { "order/{oid}", 2 }, { "order/client/{client_order_id}", 2 }, { "algo/order/{oid}", 2 }, { "algo/order/client/{client_order_id}", 2 }, } }, { "delete", new Dictionary() { + { "trade/order", 1 }, + { "trade/orders", 1 }, + { "trade/algoOrder", 1 }, + { "trade/algoOrders", 1 }, + { "trade/allOrders", 1 }, { "algo/order/{order_id}", 1 }, { "algo/orders/pending", 1 }, { "algo/orders/pending/{symbol}", 1 }, @@ -431,22 +486,23 @@ public override object describe() * @method * @name woo#fetchStatus * @description the latest known information on the availability of the exchange API - * @see https://docs.woox.io/#get-system-maintenance-status-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure} */ public async override Task fetchStatus(object parameters = null) { parameters ??= new Dictionary(); - object response = await this.v1PublicGetSystemInfo(parameters); + object response = await this.v3PublicGetSystemInfo(parameters); // // { // "success": true, // "data": { - // "status": "0", - // "msg": "System is functioning properly." + // "status": 0, + // "msg": "System is functioning properly.", + // "estimatedEndTime": 1749963600362 // }, - // "timestamp": "1709274106602" + // "timestamp": 1751442989564 // } // object data = this.safeDict(response, "data", new Dictionary() {}); @@ -474,22 +530,23 @@ public async override Task fetchStatus(object parameters = null) * @method * @name woo#fetchTime * @description fetches the current integer timestamp in milliseconds from the exchange server - * @see https://docs.woox.io/#get-system-maintenance-status-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the exchange server */ public async override Task fetchTime(object parameters = null) { parameters ??= new Dictionary(); - object response = await this.v1PublicGetSystemInfo(parameters); + object response = await this.v3PublicGetSystemInfo(parameters); // // { // "success": true, // "data": { - // "status": "0", - // "msg": "System is functioning properly." + // "status": 0, + // "msg": "System is functioning properly.", + // "estimatedEndTime": 1749963600362 // }, - // "timestamp": "1709274106602" + // "timestamp": 1751442989564 // } // return this.safeInteger(response, "timestamp"); @@ -499,7 +556,7 @@ public async override Task fetchTime(object parameters = null) * @method * @name woo#fetchMarkets * @description retrieves data on all markets for woo - * @see https://docs.woox.io/#exchange-information + * @see https://developer.woox.io/api-reference/endpoint/public_data/instruments * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} an array of objects representing market data */ @@ -510,30 +567,42 @@ public async override Task fetchMarkets(object parameters = null) { await this.loadTimeDifference(); } - object response = await this.v1PublicGetInfo(parameters); + object response = await this.v3PublicGetInstruments(parameters); // - // { - // "rows": [ - // { - // "symbol": "SPOT_AAVE_USDT", - // "quote_min": 0, - // "quote_max": 100000, - // "quote_tick": 0.01, - // "base_min": 0.01, - // "base_max": 7284, - // "base_tick": 0.0001, - // "min_notional": 10, - // "price_range": 0.1, - // "created_time": "0", - // "updated_time": "1639107647.988", - // "is_stable": 0 + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "SPOT_AAVE_USDT", + // "status": "TRADING", + // "baseAsset": "AAVE", + // "baseAssetMultiplier": 1, + // "quoteAsset": "USDT", + // "quoteMin": "0", + // "quoteMax": "100000", + // "quoteTick": "0.01", + // "baseMin": "0.005", + // "baseMax": "5000", + // "baseTick": "0.0001", + // "minNotional": "1", + // "bidCapRatio": "1.1", + // "bidFloorRatio": null, + // "askCapRatio": null, + // "askFloorRatio": "0.9", + // "orderMode": "NORMAL", + // "impactNotional": null, + // "isAllowedRpi": false, + // "tickGranularity": null + // } + // ] // }, - // ... - // "success": true - // } + // "timestamp": 1751512951338 + // } // - object data = this.safeList(response, "rows", new List() {}); - return this.parseMarkets(data); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); + return this.parseMarkets(rows); } public override object parseMarket(object market) @@ -575,7 +644,7 @@ public override object parseMarket(object market) linear = true; inverse = false; } - object active = isEqual(this.safeString(market, "is_trading"), "1"); + object active = isEqual(this.safeString(market, "status"), "TRADING"); return new Dictionary() { { "id", marketId }, { "symbol", symbol }, @@ -601,8 +670,8 @@ public override object parseMarket(object market) { "strike", null }, { "optionType", null }, { "precision", new Dictionary() { - { "amount", this.safeNumber(market, "base_tick") }, - { "price", this.safeNumber(market, "quote_tick") }, + { "amount", this.safeNumber(market, "baseTick") }, + { "price", this.safeNumber(market, "quoteTick") }, } }, { "limits", new Dictionary() { { "leverage", new Dictionary() { @@ -610,19 +679,19 @@ public override object parseMarket(object market) { "max", null }, } }, { "amount", new Dictionary() { - { "min", this.safeNumber(market, "base_min") }, - { "max", this.safeNumber(market, "base_max") }, + { "min", this.safeNumber(market, "baseMin") }, + { "max", this.safeNumber(market, "baseMax") }, } }, { "price", new Dictionary() { - { "min", this.safeNumber(market, "quote_min") }, - { "max", this.safeNumber(market, "quote_max") }, + { "min", this.safeNumber(market, "quoteMin") }, + { "max", this.safeNumber(market, "quoteMax") }, } }, { "cost", new Dictionary() { - { "min", this.safeNumber(market, "min_notional") }, + { "min", this.safeNumber(market, "minNotional") }, { "max", null }, } }, } }, - { "created", this.safeTimestamp(market, "created_time") }, + { "created", null }, { "info", market }, }; } @@ -631,7 +700,7 @@ public override object parseMarket(object market) * @method * @name woo#fetchTrades * @description get the list of most recent trades for a particular symbol - * @see https://docs.woox.io/#market-trades-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/marketTrades * @param {string} symbol unified symbol of the market to fetch trades for * @param {int} [since] timestamp in ms of the earliest trade to fetch * @param {int} [limit] the maximum amount of trades to fetch @@ -650,38 +719,28 @@ public async override Task fetchTrades(object symbol, object since = nul { ((IDictionary)request)["limit"] = limit; } - object response = await this.v1PublicGetMarketTrades(this.extend(request, parameters)); + object response = await this.v3PublicGetMarketTrades(this.extend(request, parameters)); // - // { - // "success": true, - // "rows": [ - // { - // "symbol": "SPOT_BTC_USDT", - // "side": "SELL", - // "executed_price": 46222.35, - // "executed_quantity": 0.0012, - // "executed_timestamp": "1641241162.329" - // }, - // { - // "symbol": "SPOT_BTC_USDT", - // "side": "SELL", - // "executed_price": 46222.35, - // "executed_quantity": 0.0012, - // "executed_timestamp": "1641241162.329" - // }, - // { - // "symbol": "SPOT_BTC_USDT", - // "side": "BUY", - // "executed_price": 46224.32, - // "executed_quantity": 0.00039, - // "executed_timestamp": "1641241162.287" + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "SPOT_BTC_USDT", + // "side": "SELL", + // "source": 0, + // "executedPrice": "108741.01", + // "executedQuantity": "0.02477", + // "executedTimestamp": 1751513940144 + // } + // ] // }, - // ... - // ] - // } + // "timestamp": 1751513988543 + // } // - object resultResponse = this.safeList(response, "rows", new List() {}); - return this.parseTrades(resultResponse, market, since, limit); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); + return this.parseTrades(rows, market, since, limit); } public override object parseTrade(object trade, object market = null) @@ -692,36 +751,49 @@ public override object parseTrade(object trade, object market = null) // { // "symbol": "SPOT_BTC_USDT", // "side": "SELL", - // "executed_price": 46222.35, - // "executed_quantity": 0.0012, - // "executed_timestamp": "1641241162.329" + // "source": 0, + // "executedPrice": "108741.01", + // "executedQuantity": "0.02477", + // "executedTimestamp": 1751513940144 // } // // fetchOrderTrades, fetchOrder // // { - // "id": "99119876", - // "symbol": "SPOT_WOO_USDT", - // "fee": "0.0024", + // "id": 1734947821, + // "symbol": "SPOT_LTC_USDT", + // "orderId": 60780383217, + // "executedPrice": 87.86, + // "executedQuantity": 0.1, + // "fee": 0.0001, + // "realizedPnl": null, + // "feeAsset": "LTC", + // "orderTag": "default", // "side": "BUY", - // "executed_timestamp": "1641481113.084", - // "order_id": "87001234", - // "order_tag": "default", <-- this param only in "fetchOrderTrades" - // "executed_price": "1", - // "executed_quantity": "12", - // "fee_asset": "WOO", - // "is_maker": "1" + // "executedTimestamp": "1752055173.630", + // "isMaker": 0 // } // object isFromFetchOrder = (inOp(trade, "id")); - object timestamp = this.safeTimestamp(trade, "executed_timestamp"); + object timestampString = this.safeString2(trade, "executed_timestamp", "executedTimestamp"); + object timestamp = null; + if (isTrue(!isEqual(timestampString, null))) + { + if (isTrue(isGreaterThan(getIndexOf(timestampString, "."), -1))) + { + timestamp = this.safeTimestamp2(trade, "executed_timestamp", "executedTimestamp"); + } else + { + timestamp = this.safeInteger(trade, "executedTimestamp"); + } + } object marketId = this.safeString(trade, "symbol"); market = this.safeMarket(marketId, market); object symbol = getValue(market, "symbol"); - object price = this.safeString(trade, "executed_price"); - object amount = this.safeString(trade, "executed_quantity"); - object order_id = this.safeString(trade, "order_id"); - object fee = this.parseTokenAndFeeTemp(trade, "fee_asset", "fee"); + object price = this.safeString2(trade, "executed_price", "executedPrice"); + object amount = this.safeString2(trade, "executed_quantity", "executedQuantity"); + object order_id = this.safeString2(trade, "order_id", "orderId"); + object fee = this.parseTokenAndFeeTemp(trade, new List() {"fee_asset", "feeAsset"}, new List() {"fee"}); object feeCost = this.safeString(fee, "cost"); if (isTrue(!isEqual(feeCost, null))) { @@ -733,7 +805,7 @@ public override object parseTrade(object trade, object market = null) object takerOrMaker = null; if (isTrue(isFromFetchOrder)) { - object isMaker = isEqual(this.safeString(trade, "is_maker"), "1"); + object isMaker = isEqual(this.safeString2(trade, "is_maker", "isMaker"), "1"); takerOrMaker = ((bool) isTrue(isMaker)) ? "maker" : "taker"; } return this.safeTrade(new Dictionary() { @@ -753,13 +825,13 @@ public override object parseTrade(object trade, object market = null) }, market); } - public virtual object parseTokenAndFeeTemp(object item, object feeTokenKey, object feeAmountKey) + public virtual object parseTokenAndFeeTemp(object item, object feeTokenKeys, object feeAmountKeys) { - object feeCost = this.safeString(item, feeAmountKey); + object feeCost = this.safeStringN(item, feeAmountKeys); object fee = null; if (isTrue(!isEqual(feeCost, null))) { - object feeCurrencyId = this.safeString(item, feeTokenKey); + object feeCurrencyId = this.safeStringN(item, feeTokenKeys); object feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId); fee = new Dictionary() { { "cost", feeCost }, @@ -769,11 +841,60 @@ public virtual object parseTokenAndFeeTemp(object item, object feeTokenKey, obje return fee; } + public virtual object parseTradingFee(object fee, object market = null) + { + object marketId = this.safeString(fee, "symbol"); + object symbol = this.safeSymbol(marketId, market); + return new Dictionary() { + { "info", fee }, + { "symbol", symbol }, + { "maker", this.parseNumber(Precise.stringDiv(this.safeString(fee, "makerFee"), "100")) }, + { "taker", this.parseNumber(Precise.stringDiv(this.safeString(fee, "takerFee"), "100")) }, + { "percentage", null }, + { "tierBased", null }, + }; + } + + /** + * @method + * @name woo#fetchTradingFee + * @description fetch the trading fees for a market + * @see https://developer.woox.io/api-reference/endpoint/trading/get_tradingFee + * @param {string} symbol unified market symbol + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account + * @param {string} [params.subType] "linear" or "inverse" + * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure} + */ + public async override Task fetchTradingFee(object symbol, object parameters = null) + { + parameters ??= new Dictionary(); + await this.loadMarkets(); + object market = this.market(symbol); + object request = new Dictionary() { + { "symbol", getValue(market, "id") }, + }; + object response = await this.v3PrivateGetTradeTradingFee(this.extend(request, parameters)); + // + // { + // "success": true, + // "data": { + // "symbol": "SPOT_BTC_USDT", + // "takerFee": "10", + // "makerFee": "8" + // }, + // "timestamp": 1751858977368 + // } + // + object data = this.safeDict(response, "data", new Dictionary() {}); + return this.parseTradingFee(data, market); + } + /** * @method * @name woo#fetchTradingFees * @description fetch the trading fees for multiple markets - * @see https://docs.woox.io/#get-account-information-new + * @see https://developer.woox.io/api-reference/endpoint/account/get_account_info * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols */ @@ -781,33 +902,36 @@ public async override Task fetchTradingFees(object parameters = null) { parameters ??= new Dictionary(); await this.loadMarkets(); - object response = await this.v3PrivateGetAccountinfo(parameters); + object response = await this.v3PrivateGetAccountInfo(parameters); // // { // "success": true, // "data": { - // "applicationId": "dsa", - // "account": "dsa", - // "alias": "haha", - // "accountMode": "MARGIN", - // "leverage": 1, - // "takerFeeRate": 1, - // "makerFeeRate": 1, - // "interestRate": 1, - // "futuresTakerFeeRate": 1, - // "futuresMakerFeeRate": 1, + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "account": "carlos_jose_lima@yahoo.com", + // "alias": "carlos_jose_lima@yahoo.com", // "otpauth": true, - // "marginRatio": 1, - // "openMarginRatio": 1, - // "initialMarginRatio": 1, - // "maintenanceMarginRatio": 1, - // "totalCollateral": 1, - // "freeCollateral": 1, - // "totalAccountValue": 1, - // "totalVaultValue": 1, - // "totalStakingValue": 1 + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "makerFeeRate": 0, + // "takerFeeRate": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.55629469", + // "freeCollateral": "165.55629469", + // "totalAccountValue": "167.32418611", + // "totalTradingValue": "167.32418611", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" // }, - // "timestamp": 1673323685109 + // "timestamp": 1752062807915 // } // object data = this.safeDict(response, "data", new Dictionary() {}); @@ -1098,8 +1222,8 @@ public async override Task createTrailingPercentOrder(object symbol, obj * @method * @name woo#createOrder * @description create a trade order - * @see https://docs.woox.io/#send-order - * @see https://docs.woox.io/#send-algo-order + * @see https://developer.woox.io/api-reference/endpoint/trading/post_order + * @see https://developer.woox.io/api-reference/endpoint/trading/post_algo_order * @param {string} symbol unified symbol of the market to create an order in * @param {string} type 'market' or 'limit' * @param {string} side 'buy' or 'sell' @@ -1139,7 +1263,7 @@ public async override Task createOrder(object symbol, object type, objec parameters = ((IList)marginModeparametersVariable)[1]; if (isTrue(!isEqual(marginMode, null))) { - ((IDictionary)request)["margin_mode"] = this.encodeMarginMode(marginMode); + ((IDictionary)request)["marginMode"] = this.encodeMarginMode(marginMode); } object triggerPrice = this.safeString2(parameters, "triggerPrice", "stopPrice"); object stopLoss = this.safeValue(parameters, "stopLoss"); @@ -1155,38 +1279,34 @@ public async override Task createOrder(object symbol, object type, objec object isMarket = isEqual(orderType, "MARKET"); object timeInForce = this.safeStringLower(parameters, "timeInForce"); object postOnly = this.isPostOnly(isMarket, null, parameters); - object reduceOnlyKey = ((bool) isTrue(isConditional)) ? "reduceOnly" : "reduce_only"; - object clientOrderIdKey = ((bool) isTrue(isConditional)) ? "clientOrderId" : "client_order_id"; - object orderQtyKey = ((bool) isTrue(isConditional)) ? "quantity" : "order_quantity"; - object priceKey = ((bool) isTrue(isConditional)) ? "price" : "order_price"; - object typeKey = ((bool) isTrue(isConditional)) ? "type" : "order_type"; - ((IDictionary)request)[(string)typeKey] = orderType; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID + object clientOrderIdKey = ((bool) isTrue(isConditional)) ? "clientAlgoOrderId" : "clientOrderId"; + ((IDictionary)request)["type"] = orderType; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID if (!isTrue(isConditional)) { if (isTrue(postOnly)) { - ((IDictionary)request)["order_type"] = "POST_ONLY"; + ((IDictionary)request)["type"] = "POST_ONLY"; } else if (isTrue(isEqual(timeInForce, "fok"))) { - ((IDictionary)request)["order_type"] = "FOK"; + ((IDictionary)request)["type"] = "FOK"; } else if (isTrue(isEqual(timeInForce, "ioc"))) { - ((IDictionary)request)["order_type"] = "IOC"; + ((IDictionary)request)["type"] = "IOC"; } } if (isTrue(reduceOnly)) { - ((IDictionary)request)[(string)reduceOnlyKey] = reduceOnly; + ((IDictionary)request)["reduceOnly"] = reduceOnly; } if (isTrue(!isTrue(isMarket) && isTrue(!isEqual(price, null)))) { - ((IDictionary)request)[(string)priceKey] = this.priceToPrecision(symbol, price); + ((IDictionary)request)["price"] = this.priceToPrecision(symbol, price); } if (isTrue(isTrue(isMarket) && !isTrue(isConditional))) { // for market buy it requires the amount of quote currency to spend - object cost = this.safeString2(parameters, "cost", "order_amount"); - parameters = this.omit(parameters, new List() {"cost", "order_amount"}); + object cost = this.safeStringN(parameters, new List() {"cost", "order_amount", "orderAmount"}); + parameters = this.omit(parameters, new List() {"cost", "order_amount", "orderAmount"}); object isPriceProvided = !isEqual(price, null); if (isTrue(isTrue(getValue(market, "spot")) && isTrue((isTrue(isPriceProvided) || isTrue((!isEqual(cost, null))))))) { @@ -1201,14 +1321,14 @@ public async override Task createOrder(object symbol, object type, objec object costRequest = Precise.stringMul(amountString, priceString); quoteAmount = this.costToPrecision(symbol, costRequest); } - ((IDictionary)request)["order_amount"] = quoteAmount; + ((IDictionary)request)["amount"] = quoteAmount; } else { - ((IDictionary)request)["order_quantity"] = this.amountToPrecision(symbol, amount); + ((IDictionary)request)["quantity"] = this.amountToPrecision(symbol, amount); } } else if (isTrue(!isEqual(algoType, "POSITIONAL_TP_SL"))) { - ((IDictionary)request)[(string)orderQtyKey] = this.amountToPrecision(symbol, amount); + ((IDictionary)request)["quantity"] = this.amountToPrecision(symbol, amount); } object clientOrderId = this.safeStringN(parameters, new List() {"clOrdID", "clientOrderId", "client_order_id"}); if (isTrue(!isEqual(clientOrderId, null))) @@ -1279,45 +1399,15 @@ public async override Task createOrder(object symbol, object type, objec object response = null; if (isTrue(isConditional)) { - response = await this.v3PrivatePostAlgoOrder(this.extend(request, parameters)); + response = await this.v3PrivatePostTradeAlgoOrder(this.extend(request, parameters)); } else { - response = await this.v1PrivatePostOrder(this.extend(request, parameters)); - } - // { - // "success": true, - // "timestamp": "1641383206.489", - // "order_id": "86980774", - // "order_type": "LIMIT", - // "order_price": "1", // null for "MARKET" order - // "order_quantity": "12", // null for "MARKET" order - // "order_amount": null, // NOT-null for "MARKET" order - // "client_order_id": "0" - // } - // stop orders - // { - // "success": true, - // "data": { - // "rows": [ - // { - // "orderId": "1578938", - // "clientOrderId": "0", - // "algoType": "STOP_LOSS", - // "quantity": "0.1" - // } - // ] - // }, - // "timestamp": "1686149372216" - // } - object data = this.safeDict(response, "data"); - if (isTrue(!isEqual(data, null))) - { - object rows = this.safeList(data, "rows", new List() {}); - return this.parseOrder(getValue(rows, 0), market); + response = await this.v3PrivatePostTradeOrder(this.extend(request, parameters)); } - object order = this.parseOrder(response, market); - ((IDictionary)order)["type"] = type; - return order; + object data = this.safeDict(response, "data", new Dictionary() {}); + data = this.safeDict(this.safeList(data, "rows"), 0, data); + ((IDictionary)data)["timestamp"] = this.safeString(response, "timestamp"); + return this.parseOrder(data, market); } public virtual object encodeMarginMode(object mode) @@ -1438,9 +1528,8 @@ public async override Task editOrder(object id, object symbol, object ty /** * @method * @name woo#cancelOrder - * @see https://docs.woox.io/#cancel-algo-order - * @see https://docs.woox.io/#cancel-order - * @see https://docs.woox.io/#cancel-order-by-client_order_id + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_order + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_algo_order * @description cancels an open order * @param {string} id order id * @param {string} symbol unified symbol of the market the order was made in @@ -1466,48 +1555,57 @@ public async override Task cancelOrder(object id, object symbol = null, object request = new Dictionary() {}; object clientOrderIdUnified = this.safeString2(parameters, "clOrdID", "clientOrderId"); object clientOrderIdExchangeSpecific = this.safeString(parameters, "client_order_id", clientOrderIdUnified); + parameters = this.omit(parameters, new List() {"clOrdID", "clientOrderId", "client_order_id"}); object isByClientOrder = !isEqual(clientOrderIdExchangeSpecific, null); object response = null; if (isTrue(isTrigger)) { - ((IDictionary)request)["order_id"] = id; - response = await this.v3PrivateDeleteAlgoOrderOrderId(this.extend(request, parameters)); + if (isTrue(isByClientOrder)) + { + ((IDictionary)request)["clientAlgoOrderId"] = clientOrderIdExchangeSpecific; + } else + { + ((IDictionary)request)["algoOrderId"] = id; + } + response = await this.v3PrivateDeleteTradeAlgoOrder(this.extend(request, parameters)); } else { ((IDictionary)request)["symbol"] = getValue(market, "id"); if (isTrue(isByClientOrder)) { - ((IDictionary)request)["client_order_id"] = clientOrderIdExchangeSpecific; - parameters = this.omit(parameters, new List() {"clOrdID", "clientOrderId", "client_order_id"}); - response = await this.v1PrivateDeleteClientOrder(this.extend(request, parameters)); + ((IDictionary)request)["clientOrderId"] = clientOrderIdExchangeSpecific; } else { - ((IDictionary)request)["order_id"] = id; - response = await this.v1PrivateDeleteOrder(this.extend(request, parameters)); + ((IDictionary)request)["orderId"] = id; } + response = await this.v3PrivateDeleteTradeOrder(this.extend(request, parameters)); } // - // { success: true, status: "CANCEL_SENT" } + // { + // "success": true, + // "data": { + // "status": "CANCEL_SENT" + // }, + // "timestamp": 1751940315838 + // } // - object extendParams = new Dictionary() { - { "symbol", symbol }, - }; + object data = this.safeDict(response, "data", new Dictionary() {}); + ((IDictionary)data)["timestamp"] = this.safeString(response, "timestamp"); if (isTrue(isByClientOrder)) { - ((IDictionary)extendParams)["client_order_id"] = clientOrderIdExchangeSpecific; + ((IDictionary)data)["clientOrderId"] = clientOrderIdExchangeSpecific; } else { - ((IDictionary)extendParams)["id"] = id; + ((IDictionary)data)["orderId"] = id; } - return this.extend(this.parseOrder(response), extendParams); + return this.parseOrder(data, market); } /** * @method * @name woo#cancelAllOrders - * @see https://docs.woox.io/#cancel-all-pending-orders - * @see https://docs.woox.io/#cancel-orders - * @see https://docs.woox.io/#cancel-all-pending-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_all_order + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_algo_orders * @description cancel all open orders in a market * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint @@ -1520,33 +1618,40 @@ public async override Task cancelAllOrders(object symbol = null, object await this.loadMarkets(); object trigger = this.safeBool2(parameters, "stop", "trigger"); parameters = this.omit(parameters, new List() {"stop", "trigger"}); - if (isTrue(trigger)) + object request = new Dictionary() {}; + if (isTrue(!isEqual(symbol, null))) { - return await this.v3PrivateDeleteAlgoOrdersPending(parameters); + object market = this.market(symbol); + ((IDictionary)request)["symbol"] = getValue(market, "id"); } - if (isTrue(isEqual(symbol, null))) + object response = null; + if (isTrue(trigger)) + { + response = await this.v3PrivateDeleteTradeAlgoOrders(parameters); + } else { - throw new ArgumentsRequired ((string)add(this.id, " cancelOrders() requires a symbol argument")) ; + response = await this.v3PrivateDeleteTradeOrders(this.extend(request, parameters)); } - object market = this.market(symbol); - object request = new Dictionary() { - { "symbol", getValue(market, "id") }, - }; - object response = await this.v1PrivateDeleteOrders(this.extend(request, parameters)); // // { - // "success":true, - // "status":"CANCEL_ALL_SENT" + // "success": true, + // "data": { + // "status": "CANCEL_ALL_SENT" + // }, + // "timestamp": 1751941988134 // } // - return new List {this.safeOrder(response)}; + object data = this.safeDict(response, "data", new Dictionary() {}); + return new List {this.safeOrder(new Dictionary() { + { "info", data }, +})}; } /** * @method * @name woo#cancelAllOrdersAfter * @description dead man's switch, cancel all orders after the given timeout - * @see https://docs.woox.io/#cancel-all-after + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_all_after * @param {number} timeout time in milliseconds, 0 represents cancel the timer * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} the api result @@ -1556,26 +1661,26 @@ public async override Task cancelAllOrdersAfter(object timeout, object p parameters ??= new Dictionary(); await this.loadMarkets(); object request = new Dictionary() { - { "trigger_after", ((bool) isTrue((isGreaterThan(timeout, 0)))) ? timeout : 0 }, + { "triggerAfter", ((bool) isTrue((isGreaterThan(timeout, 0)))) ? mathMin(timeout, 900000) : 0 }, }; - object response = await this.v1PrivatePostOrderCancelAllAfter(this.extend(request, parameters)); + object response = await this.v3PrivatePostTradeCancelAllAfter(this.extend(request, parameters)); // - // { - // "success": true, - // "data": { - // "expected_trigger_time": 1711534302938 - // }, - // "timestamp": 1711534302943 + // { + // "success": true, + // "timestamp": 123, + // "data": { + // "expectedTriggerTime": 123 // } + // } // - return new List {this.safeOrder(response)}; + return response; } /** * @method * @name woo#fetchOrder - * @see https://docs.woox.io/#get-algo-order - * @see https://docs.woox.io/#get-order + * @see https://developer.woox.io/api-reference/endpoint/trading/get_order + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_order * @description fetches information on an order made by the user * @param {string} id the order id * @param {string} symbol unified symbol of the market the order was made in @@ -1587,7 +1692,11 @@ public async override Task fetchOrder(object id, object symbol = null, o { parameters ??= new Dictionary(); await this.loadMarkets(); - object market = ((bool) isTrue((!isEqual(symbol, null)))) ? this.market(symbol) : null; + object market = null; + if (isTrue(!isEqual(symbol, null))) + { + market = this.market(symbol); + } object trigger = this.safeBool2(parameters, "stop", "trigger"); parameters = this.omit(parameters, new List() {"stop", "trigger"}); object request = new Dictionary() {}; @@ -1595,62 +1704,35 @@ public async override Task fetchOrder(object id, object symbol = null, o object response = null; if (isTrue(trigger)) { - ((IDictionary)request)["oid"] = id; - response = await this.v3PrivateGetAlgoOrderOid(this.extend(request, parameters)); - } else if (isTrue(clientOrderId)) - { - ((IDictionary)request)["client_order_id"] = clientOrderId; - response = await this.v1PrivateGetClientOrderClientOrderId(this.extend(request, parameters)); + if (isTrue(!isEqual(clientOrderId, null))) + { + ((IDictionary)request)["clientAlgoOrderId"] = id; + } else + { + ((IDictionary)request)["algoOrderId"] = id; + } + response = await this.v3PrivateGetTradeAlgoOrder(this.extend(request, parameters)); } else { - ((IDictionary)request)["oid"] = id; - response = await this.v1PrivateGetOrderOid(this.extend(request, parameters)); + if (isTrue(!isEqual(clientOrderId, null))) + { + ((IDictionary)request)["clientOrderId"] = clientOrderId; + } else + { + ((IDictionary)request)["orderId"] = id; + } + response = await this.v3PrivateGetTradeOrder(this.extend(request, parameters)); } - // - // { - // "success": true, - // "symbol": "SPOT_WOO_USDT", - // "status": "FILLED", // FILLED, NEW - // "side": "BUY", - // "created_time": "1641480933.000", - // "order_id": "87541111", - // "order_tag": "default", - // "price": "1", - // "type": "LIMIT", - // "quantity": "12", - // "amount": null, - // "visible": "12", - // "executed": "12", // or any partial amount - // "total_fee": "0.0024", - // "fee_asset": "WOO", - // "client_order_id": null, - // "average_executed_price": "1", - // "Transactions": [ - // { - // "id": "99111647", - // "symbol": "SPOT_WOO_USDT", - // "fee": "0.0024", - // "side": "BUY", - // "executed_timestamp": "1641482113.084", - // "order_id": "87541111", - // "executed_price": "1", - // "executed_quantity": "12", - // "fee_asset": "WOO", - // "is_maker": "1" - // } - // ] - // } - // - object orders = this.safeDict(response, "data", response); - return this.parseOrder(orders, market); + object data = this.safeDict(response, "data", new Dictionary() {}); + return this.parseOrder(data, market); } /** * @method * @name woo#fetchOrders * @description fetches information on multiple orders made by the user - * @see https://docs.woox.io/#get-orders - * @see https://docs.woox.io/#get-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve @@ -1658,7 +1740,6 @@ public async override Task fetchOrder(object id, object symbol = null, o * @param {boolean} [params.trigger] whether the order is a trigger/algo order * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default) * @param {string} [params.side] 'buy' or 'sell' - * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ @@ -1677,8 +1758,7 @@ public async override Task fetchOrders(object symbol = null, object sinc object request = new Dictionary() {}; object market = null; object trigger = this.safeBool2(parameters, "stop", "trigger"); - object trailing = this.safeBool(parameters, "trailing", false); - parameters = this.omit(parameters, new List() {"stop", "trailing", "trigger"}); + parameters = this.omit(parameters, new List() {"stop", "trigger"}); if (isTrue(!isEqual(symbol, null))) { market = this.market(symbol); @@ -1686,69 +1766,28 @@ public async override Task fetchOrders(object symbol = null, object sinc } if (isTrue(!isEqual(since, null))) { - if (isTrue(isTrue(trigger) || isTrue(trailing))) - { - ((IDictionary)request)["createdTimeStart"] = since; - } else - { - ((IDictionary)request)["start_t"] = since; - } + ((IDictionary)request)["startTime"] = since; } - if (isTrue(!isEqual(limit, null))) - { - ((IDictionary)request)["size"] = limit; - } else + object until = this.safeInteger(parameters, "until"); // unified in milliseconds + parameters = this.omit(parameters, new List() {"until"}); + if (isTrue(!isEqual(until, null))) { - ((IDictionary)request)["size"] = ((bool) isTrue(trailing)) ? 50 : 500; + ((IDictionary)request)["endTime"] = until; } - if (isTrue(trigger)) - { - ((IDictionary)request)["algoType"] = "stop"; - } else if (isTrue(trailing)) + if (isTrue(!isEqual(limit, null))) { - ((IDictionary)request)["algoType"] = "TRAILING_STOP"; + ((IDictionary)request)["size"] = mathMin(limit, 500); } object response = null; - if (isTrue(isTrue(trigger) || isTrue(trailing))) + if (isTrue(trigger)) { - response = await this.v3PrivateGetAlgoOrders(this.extend(request, parameters)); + response = await this.v3PrivateGetTradeAlgoOrders(this.extend(request, parameters)); } else { - response = await this.v1PrivateGetOrders(this.extend(request, parameters)); + response = await this.v3PrivateGetTradeOrders(this.extend(request, parameters)); } - // - // { - // "success":true, - // "meta":{ - // "total":1, - // "records_per_page":100, - // "current_page":1 - // }, - // "rows":[ - // { - // "symbol":"PERP_BTC_USDT", - // "status":"FILLED", - // "side":"SELL", - // "created_time":"1611617776.000", - // "updated_time":"1611617776.000", - // "order_id":52121167, - // "order_tag":"default", - // "price":null, - // "type":"MARKET", - // "quantity":0.002, - // "amount":null, - // "visible":0, - // "executed":0.002, - // "total_fee":0.01732885, - // "fee_asset":"USDT", - // "client_order_id":null, - // "average_executed_price":28881.41 - // } - // ] - // } - // - object data = this.safeValue(response, "data", response); - object orders = this.safeList(data, "rows"); + object data = this.safeValue(response, "data", new Dictionary() {}); + object orders = this.safeList(data, "rows", new List() {}); return this.parseOrders(orders, market, since, limit); } @@ -1756,8 +1795,8 @@ public async override Task fetchOrders(object symbol = null, object sinc * @method * @name woo#fetchOpenOrders * @description fetches information on multiple orders made by the user - * @see https://docs.woox.io/#get-orders - * @see https://docs.woox.io/#get-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve @@ -1783,8 +1822,8 @@ public async override Task fetchOpenOrders(object symbol = null, object * @method * @name woo#fetchClosedOrders * @description fetches information on multiple orders made by the user - * @see https://docs.woox.io/#get-orders - * @see https://docs.woox.io/#get-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve @@ -1819,85 +1858,109 @@ public virtual object parseTimeInForce(object timeInForce) public override object parseOrder(object order, object market = null) { // - // Possible input functions: - // * createOrder - // * cancelOrder - // * fetchOrder - // * fetchOrders - // const isFromFetchOrder = ('order_tag' in order); TO_DO - // - // stop order after creating it: - // { - // "orderId": "1578938", - // "clientOrderId": "0", - // "algoType": "STOP_LOSS", - // "quantity": "0.1" - // } - // stop order after fetching it: - // { - // "algoOrderId": "1578958", - // "clientOrderId": "0", - // "rootAlgoOrderId": "1578958", - // "parentAlgoOrderId": "0", - // "symbol": "SPOT_LTC_USDT", - // "orderTag": "default", - // "algoType": "STOP_LOSS", - // "side": "BUY", - // "quantity": "0.1", - // "isTriggered": false, - // "triggerPrice": "100", - // "triggerStatus": "USELESS", - // "type": "LIMIT", - // "rootAlgoStatus": "CANCELLED", - // "algoStatus": "CANCELLED", - // "triggerPriceType": "MARKET_PRICE", - // "price": "75", - // "triggerTime": "0", - // "totalExecutedQuantity": "0", - // "averageExecutedPrice": "0", - // "totalFee": "0", - // "feeAsset": '', - // "reduceOnly": false, - // "createdTime": "1686149609.744", - // "updatedTime": "1686149903.362" - // } - // - object timestamp = this.safeTimestampN(order, new List() {"timestamp", "created_time", "createdTime"}); - object orderId = this.safeStringN(order, new List() {"order_id", "orderId", "algoOrderId"}); - object clientOrderId = this.omitZero(this.safeString2(order, "client_order_id", "clientOrderId")); // Somehow, this always returns 0 for limit order + // createOrder + // { + // "orderId": 60667653330, + // "clientOrderId": 0, + // "type": "LIMIT", + // "price": 60, + // "quantity": 0.1, + // "amount": null, + // "bidAskLevel": null, + // "timestamp": 1751871779855 + // } + // + // createOrder - algo + // { + // "orderId": "1578938", + // "clientOrderId": "0", + // "algoType": "STOP_LOSS", + // "quantity": "0.1", + // "timestamp": "1686149372216" + // } + // + // fetchOrder + // { + // "orderId": 60780315704, + // "clientOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "orderTag": "default", + // "side": "BUY", + // "quantity": 0.1, + // "amount": null, + // "type": "LIMIT", + // "status": "NEW", + // "price": 60, + // "executed": 0, + // "visible": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "LTC", + // "totalRebate": 0, + // "rebateAsset": "USDT", + // "reduceOnly": false, + // "createdTime": "1752049062.496", + // "realizedPnl": null, + // "positionSide": "BOTH", + // "bidAskLevel": null + // } + // + // fetchOrder - algo + // { + // "algoOrderId": 10399260, + // "clientAlgoOrderId": 0, + // "rootAlgoOrderId": 10399260, + // "parentAlgoOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "algoOrderTag": "default", + // "algoType": "TAKE_PROFIT", + // "side": "BUY", + // "quantity": 0.1, + // "isTriggered": false, + // "triggerPrice": 65, + // "triggerStatus": "USELESS", + // "type": "LIMIT", + // "rootAlgoStatus": "NEW", + // "algoStatus": "NEW", + // "triggerPriceType": "MARKET_PRICE", + // "price": 60, + // "triggerTime": "0", + // "totalExecutedQuantity": 0, + // "visibleQuantity": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "", + // "totalRebate": 0, + // "rebateAsset": "", + // "reduceOnly": false, + // "createdTime": "1752049747.732", + // "updatedTime": "1752049747.732", + // "positionSide": "BOTH" + // } + // + object timestamp = this.safeTimestamp(order, "createdTime"); + if (isTrue(isEqual(timestamp, null))) + { + timestamp = this.safeInteger(order, "timestamp"); + } + object orderId = this.safeString2(order, "orderId", "algoOrderId"); + object clientOrderId = this.omitZero(this.safeString2(order, "clientOrderId", "clientAlgoOrderId")); // Somehow, this always returns 0 for limit order object marketId = this.safeString(order, "symbol"); market = this.safeMarket(marketId, market); object symbol = getValue(market, "symbol"); - object price = this.safeString2(order, "order_price", "price"); - object amount = this.safeString2(order, "order_quantity", "quantity"); // This is base amount - object cost = this.safeString2(order, "order_amount", "amount"); // This is quote amount - object orderType = this.safeStringLower2(order, "order_type", "type"); + object price = this.safeString(order, "price"); + object amount = this.safeString(order, "quantity"); // This is base amount + object cost = this.safeString(order, "amount"); // This is quote amount + object orderType = this.safeStringLower(order, "type"); object status = this.safeValue2(order, "status", "algoStatus"); object side = this.safeStringLower(order, "side"); object filled = this.omitZero(this.safeValue2(order, "executed", "totalExecutedQuantity")); - object average = this.omitZero(this.safeString2(order, "average_executed_price", "averageExecutedPrice")); + object average = this.omitZero(this.safeString(order, "averageExecutedPrice")); // const remaining = Precise.stringSub (cost, filled); - object fee = this.safeNumber2(order, "total_fee", "totalFee"); - object feeCurrency = this.safeString2(order, "fee_asset", "feeAsset"); - object transactions = this.safeValue(order, "Transactions"); + object fee = this.safeNumber(order, "totalFee"); + object feeCurrency = this.safeString(order, "feeAsset"); object triggerPrice = this.safeNumber(order, "triggerPrice"); - object takeProfitPrice = null; - object stopLossPrice = null; - object childOrders = this.safeValue(order, "childOrders"); - if (isTrue(!isEqual(childOrders, null))) - { - object first = this.safeValue(childOrders, 0); - object innerChildOrders = this.safeValue(first, "childOrders", new List() {}); - object innerChildOrdersLength = getArrayLength(innerChildOrders); - if (isTrue(isGreaterThan(innerChildOrdersLength, 0))) - { - object takeProfitOrder = this.safeValue(innerChildOrders, 0); - object stopLossOrder = this.safeValue(innerChildOrders, 1); - takeProfitPrice = this.safeNumber(takeProfitOrder, "triggerPrice"); - stopLossPrice = this.safeNumber(stopLossOrder, "triggerPrice"); - } - } - object lastUpdateTimestamp = this.safeTimestamp2(order, "updatedTime", "updated_time"); + object lastUpdateTimestamp = this.safeTimestamp(order, "updatedTime"); return this.safeOrder(new Dictionary() { { "id", orderId }, { "clientOrderId", clientOrderId }, @@ -1910,18 +1973,18 @@ public override object parseOrder(object order, object market = null) { "type", orderType }, { "timeInForce", this.parseTimeInForce(orderType) }, { "postOnly", null }, - { "reduceOnly", this.safeBool(order, "reduce_only") }, + { "reduceOnly", this.safeBool(order, "reduceOnly") }, { "side", side }, { "price", price }, { "triggerPrice", triggerPrice }, - { "takeProfitPrice", takeProfitPrice }, - { "stopLossPrice", stopLossPrice }, + { "takeProfitPrice", null }, + { "stopLossPrice", null }, { "average", average }, { "amount", amount }, { "filled", filled }, { "remaining", null }, { "cost", cost }, - { "trades", transactions }, + { "trades", null }, { "fee", new Dictionary() { { "cost", fee }, { "currency", feeCurrency }, @@ -1954,7 +2017,7 @@ public virtual object parseOrderStatus(object status) * @method * @name woo#fetchOrderBook * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://docs.woox.io/#orderbook-snapshot-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/orderbook * @param {string} symbol unified symbol of the market to fetch the order book for * @param {int} [limit] the maximum amount of order book entries to return * @param {object} [params] extra parameters specific to the exchange API endpoint @@ -1970,41 +2033,46 @@ public async override Task fetchOrderBook(object symbol, object limit = }; if (isTrue(!isEqual(limit, null))) { - limit = mathMin(limit, 1000); - ((IDictionary)request)["max_level"] = limit; + ((IDictionary)request)["maxLevel"] = limit; } - object response = await this.v1PublicGetOrderbookSymbol(this.extend(request, parameters)); + object response = await this.v3PublicGetOrderbook(this.extend(request, parameters)); // - // { - // "success": true, - // "timestamp": "1641562961192", - // "asks": [ - // { price: '0.921', quantity: "76.01" }, - // { price: '0.933', quantity: "477.10" }, - // ... - // ], - // "bids": [ - // { price: '0.940', quantity: "13502.47" }, - // { price: '0.932', quantity: "43.91" }, - // ... - // ] // } + // { + // "success": true, + // "timestamp": 1751620923344, + // "data": { + // "asks": [ + // { + // "price": "108924.86", + // "quantity": "0.032126" + // } + // ], + // "bids": [ + // { + // "price": "108924.85", + // "quantity": "1.714147" + // } + // ] + // } + // } // + object data = this.safeDict(response, "data", new Dictionary() {}); object timestamp = this.safeInteger(response, "timestamp"); - return this.parseOrderBook(response, symbol, timestamp, "bids", "asks", "price", "quantity"); + return this.parseOrderBook(data, symbol, timestamp, "bids", "asks", "price", "quantity"); } /** * @method * @name woo#fetchOHLCV - * @see https://docs.woox.io/#kline-public - * @see https://docs.woox.io/#kline-historical-data-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/klineHistory * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market * @param {string} symbol unified symbol of the market to fetch OHLCV data for * @param {string} timeframe the length of time each candle represents * @param {int} [since] timestamp in ms of the earliest candle to fetch * @param {int} [limit] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms))) * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {int} [params.until] the latest time in ms to fetch entries for * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume */ public async override Task fetchOHLCV(object symbol, object timeframe = null, object since = null, object limit = null, object parameters = null) @@ -2017,40 +2085,54 @@ public async override Task fetchOHLCV(object symbol, object timeframe = { "symbol", getValue(market, "id") }, { "type", this.safeString(this.timeframes, timeframe, timeframe) }, }; - object useHistEndpoint = !isEqual(since, null); - if (isTrue(isTrue((!isEqual(limit, null))) && isTrue((!isEqual(since, null))))) - { - object oneThousandCandles = multiply(multiply(this.parseTimeframe(timeframe), 1000), 999); // 999 because there will be delay between this and the request, causing the latest candle to be excluded sometimes - object startWithLimit = subtract(this.milliseconds(), oneThousandCandles); - useHistEndpoint = isLessThan(since, startWithLimit); - } - if (isTrue(useHistEndpoint)) - { - ((IDictionary)request)["start_time"] = since; - } else if (isTrue(!isEqual(limit, null))) + if (isTrue(!isEqual(limit, null))) { ((IDictionary)request)["limit"] = mathMin(limit, 1000); } - object response = null; - if (!isTrue(useHistEndpoint)) + if (isTrue(!isEqual(since, null))) { - response = await this.v1PublicGetKline(this.extend(request, parameters)); - } else + ((IDictionary)request)["after"] = since; + } + object until = this.safeInteger(parameters, "until"); + parameters = this.omit(parameters, "until"); + if (isTrue(!isEqual(until, null))) { - response = await this.v1PubGetHistKline(this.extend(request, parameters)); - response = this.safeDict(response, "data"); + ((IDictionary)request)["before"] = until; } - object rows = this.safeList(response, "rows", new List() {}); - return this.parseOHLCVs(rows, market, timeframe, since, limit); - } - - public override object parseOHLCV(object ohlcv, object market = null) - { - // example response in fetchOHLCV - return new List {this.safeInteger(ohlcv, "start_timestamp"), this.safeNumber(ohlcv, "open"), this.safeNumber(ohlcv, "high"), this.safeNumber(ohlcv, "low"), this.safeNumber(ohlcv, "close"), this.safeNumber(ohlcv, "volume")}; - } - - /** + object response = await this.v3PublicGetKlineHistory(this.extend(request, parameters)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "SPOT_BTC_USDT", + // "open": "108994.16", + // "close": "108994.16", + // "high": "108994.16", + // "low": "108994.16", + // "volume": "0", + // "amount": "0", + // "type": "1m", + // "startTimestamp": 1751622120000, + // "endTimestamp": 1751622180000 + // } + // ] + // }, + // "timestamp": 1751622205410 + // } + // + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); + return this.parseOHLCVs(rows, market, timeframe, since, limit); + } + + public override object parseOHLCV(object ohlcv, object market = null) + { + return new List {this.safeInteger(ohlcv, "startTimestamp"), this.safeNumber(ohlcv, "open"), this.safeNumber(ohlcv, "high"), this.safeNumber(ohlcv, "low"), this.safeNumber(ohlcv, "close"), this.safeNumber(ohlcv, "volume")}; + } + + /** * @method * @name woo#fetchOrderTrades * @description fetch all the trades made from a single order @@ -2101,7 +2183,7 @@ public async override Task fetchOrderTrades(object id, object symbol = n * @method * @name woo#fetchMyTrades * @description fetch all trades made by the user - * @see https://docs.woox.io/#get-trade-history + * @see https://developer.woox.io/api-reference/endpoint/trading/get_transactions * @param {string} symbol unified market symbol * @param {int} [since] the earliest time in ms to fetch trades for * @param {int} [limit] the maximum number of trades structures to retrieve @@ -2130,43 +2212,50 @@ public async override Task fetchMyTrades(object symbol = null, object si } if (isTrue(!isEqual(since, null))) { - ((IDictionary)request)["start_t"] = since; + ((IDictionary)request)["startTime"] = since; } - var requestparametersVariable = this.handleUntilOption("end_t", request, parameters); - request = ((IList)requestparametersVariable)[0]; - parameters = ((IList)requestparametersVariable)[1]; - if (isTrue(!isEqual(limit, null))) + object until = this.safeInteger(parameters, "until"); // unified in milliseconds + parameters = this.omit(parameters, new List() {"until"}); + if (isTrue(!isEqual(until, null))) { - ((IDictionary)request)["size"] = limit; - } else + ((IDictionary)request)["endTime"] = until; + } + if (isTrue(!isEqual(limit, null))) { - ((IDictionary)request)["size"] = 500; + ((IDictionary)request)["limit"] = limit; } - object response = await this.v1PrivateGetClientTrades(this.extend(request, parameters)); - // { - // "success": true, - // "meta": { - // "records_per_page": 25, - // "current_page": 1 - // }, - // "rows": [ - // { - // "id": 5, - // "symbol": "SPOT_BTC_USDT", - // "order_id": 211, - // "order_tag": "default", - // "executed_price": 10892.84, - // "executed_quantity": 0.002, - // "is_maker": 0, - // "side": "SELL", - // "fee": 0, - // "fee_asset": "USDT", - // "executed_timestamp": "1566264290.250" + object response = await this.v3PrivateGetTradeTransactionHistory(this.extend(request, parameters)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "id": 1734947821, + // "symbol": "SPOT_LTC_USDT", + // "orderId": 60780383217, + // "executedPrice": 87.86, + // "executedQuantity": 0.1, + // "fee": 0.0001, + // "realizedPnl": null, + // "feeAsset": "LTC", + // "orderTag": "default", + // "side": "BUY", + // "executedTimestamp": "1752055173.630", + // "isMaker": 0 + // } + // ], + // "meta": { + // "total": 1, + // "recordsPerPage": 100, + // "currentPage": 1 + // } // }, - // ... - // ] - // } - object trades = this.safeList(response, "rows", new List() {}); + // "timestamp": 1752055545121 + // } + // + object data = this.safeDict(response, "data", new Dictionary() {}); + object trades = this.safeList(data, "rows", new List() {}); return this.parseTrades(trades, market, since, limit, parameters); } @@ -2174,31 +2263,68 @@ public async override Task fetchMyTrades(object symbol = null, object si * @method * @name woo#fetchAccounts * @description fetch all the accounts associated with a profile - * @see https://docs.woox.io/#get-assets-of-subaccounts + * @see https://developer.woox.io/api-reference/endpoint/account/get_account_info + * @see https://developer.woox.io/api-reference/endpoint/account/sub_accounts * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type */ public async override Task fetchAccounts(object parameters = null) { parameters ??= new Dictionary(); - object response = await this.v1PrivateGetSubAccountAssets(parameters); + object mainAccountPromise = this.v3PrivateGetAccountInfo(parameters); // // { - // "rows": [{ - // "application_id": "13e4fc34-e2ff-4cb7-b1e4-4c22fee7d365", - // "account": "Main", - // "usdt_balance": "4.0" - // }, - // { - // "application_id": "432952aa-a401-4e26-aff6-972920aebba3", - // "account": "subaccount", - // "usdt_balance": "1.0" - // } - // ], - // "success": true + // "success": true, + // "data": { + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "account": "carlos_jose_lima@yahoo.com", + // "alias": "carlos_jose_lima@yahoo.com", + // "otpauth": true, + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.55629469", + // "freeCollateral": "165.55629469", + // "totalAccountValue": "167.32418611", + // "totalTradingValue": "167.32418611", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" + // }, + // "timestamp": 1752062807915 // } // - object rows = this.safeList(response, "rows", new List() {}); + object subAccountPromise = this.v3PrivateGetAccountSubAccountsAll(parameters); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "applicationId": "6b43de5c-0955-4887-9862-d84e4689f9fe", + // "name": "sub_account_2", + // "createdTime": "1606897264.994" + // }, + // ] + // }, + // "timestamp": 1721295317627 + // } + // + var mainAccountResponsesubAccountResponseVariable = await promiseAll(new List() {mainAccountPromise, subAccountPromise}); + var mainAccountResponse = ((IList) mainAccountResponsesubAccountResponseVariable)[0]; + var subAccountResponse = ((IList) mainAccountResponsesubAccountResponseVariable)[1]; + object mainData = this.safeDict(mainAccountResponse, "data", new Dictionary() {}); + object mainRows = new List() {mainData}; + object subData = this.safeDict(subAccountResponse, "data", new Dictionary() {}); + object subRows = this.safeList(subData, "rows", new List() {}); + object rows = this.arrayConcat(mainRows, subRows); return this.parseAccounts(rows, parameters); } @@ -2206,18 +2332,41 @@ public override object parseAccount(object account) { // // { - // "application_id": "336952aa-a401-4e26-aff6-972920aebba3", - // "account": "subaccount", - // "usdt_balance": "1.0", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "account": "carlos_jose_lima@yahoo.com", + // "alias": "carlos_jose_lima@yahoo.com", + // "otpauth": true, + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.55629469", + // "freeCollateral": "165.55629469", + // "totalAccountValue": "167.32418611", + // "totalTradingValue": "167.32418611", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" + // } + // + // { + // "applicationId": "6b43de5c-0955-4887-9862-d84e4689f9fe", + // "name": "sub_account_2", + // "createdTime": "1606897264.994" // } // - object accountId = this.safeString(account, "account"); return new Dictionary() { { "info", account }, - { "id", this.safeString(account, "application_id") }, - { "name", accountId }, + { "id", this.safeString(account, "applicationId") }, + { "name", this.safeStringN(account, new List() {"name", "account", "alias"}) }, { "code", null }, - { "type", ((bool) isTrue(isEqual(accountId, "Main"))) ? "main" : "subaccount" }, + { "type", this.safeStringLower(account, "accountType", "subaccount") }, }; } @@ -2283,7 +2432,7 @@ public override object parseBalance(object response) * @method * @name woo#fetchDepositAddress * @description fetch the deposit address for a currency associated with this account - * @see https://docs.woox.io/#get-token-deposit-address + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_deposit * @param {string} code unified currency code * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} @@ -2294,20 +2443,27 @@ public async override Task fetchDepositAddress(object code, object param parameters ??= new Dictionary(); await this.loadMarkets(); object currency = this.currency(code); - object specialNetworkId = null; - var specialNetworkIdparametersVariable = this.getDedicatedNetworkId(currency, parameters); - specialNetworkId = ((IList)specialNetworkIdparametersVariable)[0]; - parameters = ((IList)specialNetworkIdparametersVariable)[1]; + object networkCode = null; + var networkCodeparametersVariable = this.handleNetworkCodeAndParams(parameters); + networkCode = ((IList)networkCodeparametersVariable)[0]; + parameters = ((IList)networkCodeparametersVariable)[1]; object request = new Dictionary() { - { "token", specialNetworkId }, + { "token", getValue(currency, "id") }, + { "network", this.networkCodeToId(networkCode) }, }; - object response = await this.v1PrivateGetAssetDeposit(this.extend(request, parameters)); - // { - // "success": true, - // "address": "3Jmtjx5544T4smrit9Eroe4PCrRkpDeKjP", - // "extra": '' - // } - return this.parseDepositAddress(response, currency); + object response = await this.v3PrivateGetAssetWalletDeposit(this.extend(request, parameters)); + // + // { + // "success": true, + // "data": { + // "address": "0x31d64B3230f8baDD91dE1710A65DF536aF8f7cDa", + // "extra": "" + // }, + // "timestamp": 1721300689532 + // } + // + object data = this.safeDict(response, "data", new Dictionary() {}); + return this.parseDepositAddress(data, currency); } public virtual object getDedicatedNetworkId(object currency, object parameters) @@ -2349,15 +2505,23 @@ public async virtual Task getAssetHistoryRows(object code = null, object if (isTrue(!isEqual(code, null))) { currency = this.currency(code); - ((IDictionary)request)["balance_token"] = getValue(currency, "id"); + ((IDictionary)request)["token"] = getValue(currency, "id"); + } + object networkCode = null; + var networkCodeparametersVariable = this.handleNetworkCodeAndParams(parameters); + networkCode = ((IList)networkCodeparametersVariable)[0]; + parameters = ((IList)networkCodeparametersVariable)[1]; + if (isTrue(!isEqual(networkCode, null))) + { + ((IDictionary)request)["network"] = this.networkCodeToId(networkCode); } if (isTrue(!isEqual(since, null))) { - ((IDictionary)request)["start_t"] = since; + ((IDictionary)request)["startTime"] = since; } if (isTrue(!isEqual(limit, null))) { - ((IDictionary)request)["pageSize"] = limit; + ((IDictionary)request)["size"] = mathMin(limit, 1000); } object transactionType = this.safeString(parameters, "type"); parameters = this.omit(parameters, "type"); @@ -2365,49 +2529,51 @@ public async virtual Task getAssetHistoryRows(object code = null, object { ((IDictionary)request)["type"] = transactionType; } - object response = await this.v1PrivateGetAssetHistory(this.extend(request, parameters)); - // { - // "rows": [ - // { - // "id": "22010508193900165", - // "token": "TRON_USDT", - // "extra": '', - // "amount": "13.75848500", - // "status": "COMPLETED", - // "account": null, - // "description": null, - // "user_id": "42222", - // "application_id": "6ad2b303-f354-45c0-8105-9f5f19d0e335", - // "external_id": "220105081900134", - // "target_address": "TXnyFSnAYad3YCaqtwMw9jvXKkeU39NLnK", - // "source_address": "TYDzsYUEpvnYmQk4zGP9sWWcTEd2MiAtW6", - // "type": "BALANCE", - // "token_side": "DEPOSIT", - // "tx_id": "35b0004022f6b3ad07f39a0b7af199f6b258c2c3e2c7cdc93c67efa74fd625ee", - // "fee_token": '', - // "fee_amount": "0.00000000", - // "created_time": "1641370779.442", - // "updated_time": "1641370779.465", - // "is_new_target_address": null, - // "confirmed_number": "29", - // "confirming_threshold": "27", - // "audit_tag": "1", - // "audit_result": "0", - // "balance_token": null, // TODO -write to support, that this seems broken. here should be the token id - // "network_name": null // TODO -write to support, that this seems broken. here should be the network id - // } - // ], - // "meta": { total: '1', records_per_page: "25", current_page: "1" }, - // "success": true - // } - return new List() {currency, this.safeList(response, "rows", new List() {})}; + object response = await this.v3PrivateGetAssetWalletHistory(this.extend(request, parameters)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "createdTime": "1734964440.523", + // "updatedTime": "1734964614.081", + // "id": "24122314340000585", + // "externalId": "241223143600621", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "token": "ARB_USDCNATIVE", + // "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635", + // "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4", + // "extra": "", + // "type": "BALANCE", + // "tokenSide": "WITHDRAW", + // "amount": "10.00000000", + // "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6", + // "feeToken": "USDC", + // "feeAmount": "2", + // "status": "COMPLETED", + // "confirmingThreshold": null, + // "confirmedNumber": null + // } + // ], + // "meta": { + // "total": 1, + // "records_per_page": 25, + // "current_page": 1 + // } + // }, + // "timestamp": 1752485344719 + // } + // + object data = this.safeDict(response, "data", new Dictionary() {}); + return new List() {currency, this.safeList(data, "rows", new List() {})}; } /** * @method * @name woo#fetchLedger * @description fetch the history of changes, actions done by the user or operations that altered balance of the user - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} [code] unified currency code, default is undefined * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined * @param {int} [limit] max number of ledger entries to return, default is undefined @@ -2425,22 +2591,43 @@ public async override Task fetchLedger(object code = null, object since public override object parseLedgerEntry(object item, object currency = null) { + // + // { + // "createdTime": "1734964440.523", + // "updatedTime": "1734964614.081", + // "id": "24122314340000585", + // "externalId": "241223143600621", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "token": "ARB_USDCNATIVE", + // "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635", + // "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4", + // "extra": "", + // "type": "BALANCE", + // "tokenSide": "WITHDRAW", + // "amount": "10.00000000", + // "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6", + // "feeToken": "USDC", + // "feeAmount": "2", + // "status": "COMPLETED", + // "confirmingThreshold": null, + // "confirmedNumber": null + // } + // object networkizedCode = this.safeString(item, "token"); - object currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency); - object code = getValue(currencyDefined, "code"); + object code = this.safeCurrencyCode(networkizedCode, currency); currency = this.safeCurrency(code, currency); object amount = this.safeNumber(item, "amount"); - object side = this.safeString(item, "token_side"); + object side = this.safeString(item, "tokenSide"); object direction = ((bool) isTrue((isEqual(side, "DEPOSIT")))) ? "in" : "out"; - object timestamp = this.safeTimestamp(item, "created_time"); - object fee = this.parseTokenAndFeeTemp(item, "fee_token", "fee_amount"); + object timestamp = this.safeTimestamp(item, "createdTime"); + object fee = this.parseTokenAndFeeTemp(item, new List() {"feeToken"}, new List() {"feeAmount"}); return this.safeLedgerEntry(new Dictionary() { { "info", item }, { "id", this.safeString(item, "id") }, { "currency", code }, { "account", this.safeString(item, "account") }, { "referenceAccount", null }, - { "referenceId", this.safeString(item, "tx_id") }, + { "referenceId", this.safeString(item, "txId") }, { "status", this.parseTransactionStatus(this.safeString(item, "status")) }, { "amount", amount }, { "before", null }, @@ -2486,7 +2673,7 @@ public virtual object getCurrencyFromChaincode(object networkizedCode, object cu * @method * @name woo#fetchDeposits * @description fetch all deposits made to an account - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} code unified currency code * @param {int} [since] the earliest time in ms to fetch deposits for * @param {int} [limit] the maximum number of deposits structures to retrieve @@ -2497,7 +2684,7 @@ public async override Task fetchDeposits(object code = null, object sinc { parameters ??= new Dictionary(); object request = new Dictionary() { - { "token_side", "DEPOSIT" }, + { "tokenSide", "DEPOSIT" }, }; return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, parameters)); } @@ -2506,7 +2693,7 @@ public async override Task fetchDeposits(object code = null, object sinc * @method * @name woo#fetchWithdrawals * @description fetch all withdrawals made from an account - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} code unified currency code * @param {int} [since] the earliest time in ms to fetch withdrawals for * @param {int} [limit] the maximum number of withdrawals structures to retrieve @@ -2517,7 +2704,7 @@ public async override Task fetchWithdrawals(object code = null, object s { parameters ??= new Dictionary(); object request = new Dictionary() { - { "token_side", "WITHDRAW" }, + { "tokenSide", "WITHDRAW" }, }; return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, parameters)); } @@ -2526,7 +2713,7 @@ public async override Task fetchWithdrawals(object code = null, object s * @method * @name woo#fetchDepositsWithdrawals * @description fetch history of deposits and withdrawals - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined @@ -2542,39 +2729,49 @@ public async override Task fetchDepositsWithdrawals(object code = null, object currencyRows = await this.getAssetHistoryRows(code, since, limit, this.extend(request, parameters)); object currency = this.safeValue(currencyRows, 0); object rows = this.safeList(currencyRows, 1); - // - // { - // "rows":[], - // "meta":{ - // "total":0, - // "records_per_page":25, - // "current_page":1 - // }, - // "success":true - // } - // return this.parseTransactions(rows, currency, since, limit, parameters); } public override object parseTransaction(object transaction, object currency = null) { - // example in fetchLedger + // + // { + // "createdTime": "1734964440.523", + // "updatedTime": "1734964614.081", + // "id": "24122314340000585", + // "externalId": "241223143600621", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "token": "ARB_USDCNATIVE", + // "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635", + // "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4", + // "extra": "", + // "type": "BALANCE", + // "tokenSide": "WITHDRAW", + // "amount": "10.00000000", + // "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6", + // "feeToken": "USDC", + // "feeAmount": "2", + // "status": "COMPLETED", + // "confirmingThreshold": null, + // "confirmedNumber": null + // } + // object networkizedCode = this.safeString(transaction, "token"); object currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency); object code = getValue(currencyDefined, "code"); - object movementDirection = this.safeStringLower(transaction, "token_side"); + object movementDirection = this.safeStringLower2(transaction, "token_side", "tokenSide"); if (isTrue(isEqual(movementDirection, "withdraw"))) { movementDirection = "withdrawal"; } - object fee = this.parseTokenAndFeeTemp(transaction, "fee_token", "fee_amount"); - object addressTo = this.safeString(transaction, "target_address"); - object addressFrom = this.safeString(transaction, "source_address"); - object timestamp = this.safeTimestamp(transaction, "created_time"); + object fee = this.parseTokenAndFeeTemp(transaction, new List() {"fee_token", "feeToken"}, new List() {"fee_amount", "feeAmount"}); + object addressTo = this.safeString2(transaction, "target_address", "targetAddress"); + object addressFrom = this.safeString2(transaction, "source_address", "sourceAddress"); + object timestamp = this.safeTimestamp2(transaction, "created_time", "createdTime"); return new Dictionary() { { "info", transaction }, - { "id", this.safeString2(transaction, "id", "withdraw_id") }, - { "txid", this.safeString(transaction, "tx_id") }, + { "id", this.safeStringN(transaction, new List() {"id", "withdraw_id", "withdrawId"}) }, + { "txid", this.safeString2(transaction, "tx_id", "txId") }, { "timestamp", timestamp }, { "datetime", this.iso8601(timestamp) }, { "address", null }, @@ -2587,7 +2784,7 @@ public override object parseTransaction(object transaction, object currency = nu { "amount", this.safeNumber(transaction, "amount") }, { "currency", code }, { "status", this.parseTransactionStatus(this.safeString(transaction, "status")) }, - { "updated", this.safeTimestamp(transaction, "updated_time") }, + { "updated", this.safeTimestamp2(transaction, "updated_time", "updatedTime") }, { "comment", null }, { "internal", null }, { "fee", fee }, @@ -2653,7 +2850,7 @@ public async override Task transfer(object code, object amount, object f * @method * @name woo#fetchTransfers * @description fetch a history of internal transfers made on an account - * @see https://docs.woox.io/#get-transfer-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_transfer_history * @param {string} code unified currency code of the currency transferred * @param {int} [since] the earliest time in ms to fetch transfers for * @param {int} [limit] the maximum number of transfers structures to retrieve @@ -2665,47 +2862,60 @@ public async override Task fetchTransfers(object code = null, object sin { parameters ??= new Dictionary(); object request = new Dictionary() {}; + object currency = null; + if (isTrue(!isEqual(code, null))) + { + currency = this.currency(code); + } if (isTrue(!isEqual(limit, null))) { ((IDictionary)request)["size"] = limit; } if (isTrue(!isEqual(since, null))) { - ((IDictionary)request)["start_t"] = since; + ((IDictionary)request)["startTime"] = since; } object until = this.safeInteger(parameters, "until"); // unified in milliseconds parameters = this.omit(parameters, new List() {"until"}); if (isTrue(!isEqual(until, null))) { - ((IDictionary)request)["end_t"] = until; + ((IDictionary)request)["endTime"] = until; } - object response = await this.v1PrivateGetAssetMainSubTransferHistory(this.extend(request, parameters)); + object response = await this.v3PrivateGetAssetTransferHistory(this.extend(request, parameters)); // // { - // "rows": [ - // { - // "id": 46704, - // "token": "USDT", - // "amount": 30000.00000000, - // "status": "COMPLETED", - // "from_application_id": "0f1bd3cd-dba2-4563-b8bb-0adb1bfb83a3", - // "to_application_id": "c01e6940-a735-4022-9b6c-9d3971cdfdfa", - // "from_user": "LeverageLow", - // "to_user": "dev", - // "created_time": "1709022325.427", - // "updated_time": "1709022325.542" + // "success": true, + // "data": { + // "rows": [ + // { + // "id": 225, + // "token": "USDT", + // "amount": "1000000", + // "status": "COMPLETED", + // "from": { + // "applicationId": "046b5c5c-5b44-4d27-9593-ddc32c0a08ae", + // "accountName": "Main" + // }, + // "to": { + // "applicationId": "082ae5ae-e26a-4fb1-be5b-03e5b4867663", + // "accountName": "sub001" + // }, + // "createdTime": "1642660941.534", + // "updatedTime": "1642660941.950" + // } + // ], + // "meta": { + // "total": 46, + // "recordsPerPage": 1, + // "currentPage": 1 // } - // ], - // "meta": { - // "total": 50, - // "records_per_page": 25, - // "current_page": 1 // }, - // "success": true + // "timestamp": 1721295317627 // } // - object data = this.safeList(response, "rows", new List() {}); - return this.parseTransfers(data, null, since, limit, parameters); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); + return this.parseTransfers(rows, currency, since, limit, parameters); } public override object parseTransfer(object transfer, object currency = null) @@ -2724,6 +2934,22 @@ public override object parseTransfer(object transfer, object currency = null) // "created_time": "1709022325.427", // "updated_time": "1709022325.542" // } + // { + // "id": 225, + // "token": "USDT", + // "amount": "1000000", + // "status": "COMPLETED", + // "from": { + // "applicationId": "046b5c5c-5b44-4d27-9593-ddc32c0a08ae", + // "accountName": "Main" + // }, + // "to": { + // "applicationId": "082ae5ae-e26a-4fb1-be5b-03e5b4867663", + // "accountName": "sub001" + // }, + // "createdTime": "1642660941.534", + // "updatedTime": "1642660941.950" + // } // // transfer // { @@ -2731,24 +2957,24 @@ public override object parseTransfer(object transfer, object currency = null) // "id": 200 // } // - object networkizedCode = this.safeString(transfer, "token"); - object currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency); - object code = getValue(currencyDefined, "code"); - object timestamp = this.safeTimestamp(transfer, "created_time"); + object code = this.safeCurrencyCode(this.safeString(transfer, "token"), currency); + object timestamp = this.safeTimestamp(transfer, "createdTime"); object success = this.safeBool(transfer, "success"); object status = null; if (isTrue(!isEqual(success, null))) { status = ((bool) isTrue(success)) ? "ok" : "failed"; } + object fromAccount = this.safeDict(transfer, "from", new Dictionary() {}); + object toAccount = this.safeDict(transfer, "to", new Dictionary() {}); return new Dictionary() { { "id", this.safeString(transfer, "id") }, { "timestamp", timestamp }, { "datetime", this.iso8601(timestamp) }, { "currency", code }, { "amount", this.safeNumber(transfer, "amount") }, - { "fromAccount", this.safeString(transfer, "from_application_id") }, - { "toAccount", this.safeString(transfer, "to_application_id") }, + { "fromAccount", this.safeString(fromAccount, "applicationId") }, + { "toAccount", this.safeString(toAccount, "applicationId") }, { "status", this.parseTransferStatus(this.safeString(transfer, "status", status)) }, { "info", transfer }, }; @@ -2901,7 +3127,7 @@ public override object sign(object path, object section = null, object method = } else { this.checkRequiredCredentials(); - if (isTrue(isTrue(isEqual(method, "POST")) && isTrue((isTrue(isEqual(path, "algo/order")) || isTrue(isEqual(path, "order")))))) + if (isTrue(isTrue(isEqual(method, "POST")) && isTrue((isTrue(isEqual(path, "trade/algoOrder")) || isTrue(isEqual(path, "trade/order")))))) { object isSandboxMode = this.safeBool(this.options, "sandboxMode", false); if (!isTrue(isSandboxMode)) @@ -2929,10 +3155,11 @@ public override object sign(object path, object section = null, object method = if (isTrue(isEqual(version, "v3"))) { auth = add(add(add(add(add(ts, method), "/"), version), "/"), pathWithParams); - if (isTrue(isTrue(isTrue(isEqual(method, "POST")) || isTrue(isEqual(method, "PUT"))) || isTrue(isEqual(method, "DELETE")))) + if (isTrue(isTrue(isEqual(method, "POST")) || isTrue(isEqual(method, "PUT")))) { body = this.json(parameters); auth = add(auth, body); + ((IDictionary)headers)["content-type"] = "application/json"; } else { if (isTrue(getArrayLength(new List(((IDictionary)parameters).Keys)))) @@ -2942,7 +3169,6 @@ public override object sign(object path, object section = null, object method = auth = add(auth, add("?", query)); } } - ((IDictionary)headers)["content-type"] = "application/json"; } else { auth = this.urlencode(parameters); @@ -2994,25 +3220,26 @@ public override object parseIncome(object income, object market = null) { // // { - // "id":666666, - // "symbol":"PERP_BTC_USDT", - // "funding_rate":0.00001198, - // "mark_price":28941.04000000, - // "funding_fee":0.00069343, - // "payment_type":"Pay", - // "status":"COMPLETED", - // "created_time":"1653616000.666", - // "updated_time":"1653616000.605" + // "id": 1286360, + // "symbol": "PERP_BTC_USDT", + // "fundingRate": -0.00001445, + // "markPrice": "26930.60000000", + // "fundingFee": "9.56021744", + // "fundingIntervalHours": 8, + // "paymentType": "Pay", + // "status": "COMPLETED", + // "createdTime": 1696060873259, + // "updatedTime": 1696060873286 // } // object marketId = this.safeString(income, "symbol"); object symbol = this.safeSymbol(marketId, market); - object amount = this.safeString(income, "funding_fee"); + object amount = this.safeString(income, "fundingFee"); object code = this.safeCurrencyCode("USD"); object id = this.safeString(income, "id"); - object timestamp = this.safeTimestamp(income, "updated_time"); - object rate = this.safeNumber(income, "funding_rate"); - object paymentType = this.safeString(income, "payment_type"); + object timestamp = this.safeInteger(income, "updatedTime"); + object rate = this.safeNumber(income, "fundingRate"); + object paymentType = this.safeString(income, "paymentType"); amount = ((bool) isTrue((isEqual(paymentType, "Pay")))) ? Precise.stringNeg(amount) : amount; return new Dictionary() { { "info", income }, @@ -3030,7 +3257,7 @@ public override object parseIncome(object income, object market = null) * @method * @name woo#fetchFundingHistory * @description fetch the history of funding payments paid and received on this account - * @see https://docs.woox.io/#get-funding-fee-history + * @see https://developer.woox.io/api-reference/endpoint/futures/get_fundingFee_history * @param {string} [symbol] unified market symbol * @param {int} [since] the earliest time in ms to fetch funding history for * @param {int} [limit] the maximum number of funding history structures to retrieve @@ -3048,7 +3275,7 @@ public async override Task fetchFundingHistory(object symbol = null, obj parameters = ((IList)paginateparametersVariable)[1]; if (isTrue(paginate)) { - return await this.fetchPaginatedCallCursor("fetchFundingHistory", symbol, since, limit, parameters, "page", "page", 1, 500); + return await this.fetchPaginatedCallIncremental("fetchFundingHistory", symbol, since, limit, parameters, "page", 500); } object request = new Dictionary() {}; object market = null; @@ -3059,74 +3286,71 @@ public async override Task fetchFundingHistory(object symbol = null, obj } if (isTrue(!isEqual(since, null))) { - ((IDictionary)request)["start_t"] = since; + ((IDictionary)request)["startTime"] = since; } - if (isTrue(!isEqual(limit, null))) + object until = this.safeInteger(parameters, "until"); // unified in milliseconds + parameters = this.omit(parameters, new List() {"until"}); + if (isTrue(!isEqual(until, null))) { - ((IDictionary)request)["size"] = limit; - } else + ((IDictionary)request)["endTime"] = until; + } + if (isTrue(!isEqual(limit, null))) { - ((IDictionary)request)["size"] = 5000; + ((IDictionary)request)["size"] = mathMin(limit, 500); } - object response = await this.v1PrivateGetFundingFeeHistory(this.extend(request, parameters)); + object response = await this.v3PrivateGetFuturesFundingFeeHistory(this.extend(request, parameters)); // // { - // "rows":[ - // { - // "id":666666, - // "symbol":"PERP_BTC_USDT", - // "funding_rate":0.00001198, - // "mark_price":28941.04000000, - // "funding_fee":0.00069343, - // "payment_type":"Pay", - // "status":"COMPLETED", - // "created_time":"1653616000.666", - // "updated_time":"1653616000.605" - // } - // ], - // "meta":{ - // "total":235, - // "records_per_page":25, - // "current_page":1 + // "success": true, + // "data": { + // "meta": { + // "total": 670, + // "recordsPerPage": 25, + // "currentPage": 1 + // }, + // "rows": [ + // { + // "id": 1286360, + // "symbol": "PERP_BTC_USDT", + // "fundingRate": -0.00001445, + // "markPrice": "26930.60000000", + // "fundingFee": "9.56021744", + // "fundingIntervalHours": 8, + // "paymentType": "Pay", + // "status": "COMPLETED", + // "createdTime": 1696060873259, + // "updatedTime": 1696060873286 + // } + // ] // }, - // "success":true + // "timestamp": 1721351502594 // } // - object meta = this.safeDict(response, "meta", new Dictionary() {}); - object cursor = this.safeInteger(meta, "current_page"); - object result = this.safeList(response, "rows", new List() {}); - object resultLength = getArrayLength(result); - if (isTrue(isGreaterThan(resultLength, 0))) - { - object lastItem = getValue(result, subtract(resultLength, 1)); - ((IDictionary)lastItem)["page"] = cursor; - ((List)result)[Convert.ToInt32(subtract(resultLength, 1))] = lastItem; - } - return this.parseIncomes(result, market, since, limit); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); + return this.parseIncomes(rows, market, since, limit); } public override object parseFundingRate(object fundingRate, object market = null) { // // { - // "success": true, - // "timestamp": 1727427915529, // "symbol": "PERP_BTC_USDT", - // "est_funding_rate": -0.00092719, - // "est_funding_rate_timestamp": 1727427899060, - // "last_funding_rate": -0.00092610, - // "last_funding_rate_timestamp": 1727424000000, - // "next_funding_time": 1727452800000, - // "last_funding_rate_interval": 8, - // "est_funding_rate_interval": 8 + // "estFundingRate": "-0.00000441", + // "estFundingRateTimestamp": 1751623979022, + // "lastFundingRate": "-0.00004953", + // "lastFundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "lastFundingIntervalHours": 8, + // "estFundingIntervalHours": 8 // } // object symbol = this.safeString(fundingRate, "symbol"); market = this.market(symbol); - object nextFundingTimestamp = this.safeInteger(fundingRate, "next_funding_time"); - object estFundingRateTimestamp = this.safeInteger(fundingRate, "est_funding_rate_timestamp"); - object lastFundingRateTimestamp = this.safeInteger(fundingRate, "last_funding_rate_timestamp"); - object intervalString = this.safeString(fundingRate, "est_funding_rate_interval"); + object nextFundingTimestamp = this.safeInteger(fundingRate, "nextFundingTime"); + object estFundingRateTimestamp = this.safeInteger(fundingRate, "estFundingRateTimestamp"); + object lastFundingRateTimestamp = this.safeInteger(fundingRate, "lastFundingRateTimestamp"); + object intervalString = this.safeString(fundingRate, "estFundingIntervalHours"); return new Dictionary() { { "info", fundingRate }, { "symbol", getValue(market, "symbol") }, @@ -3136,13 +3360,13 @@ public override object parseFundingRate(object fundingRate, object market = null { "estimatedSettlePrice", null }, { "timestamp", estFundingRateTimestamp }, { "datetime", this.iso8601(estFundingRateTimestamp) }, - { "fundingRate", this.safeNumber(fundingRate, "est_funding_rate") }, + { "fundingRate", this.safeNumber(fundingRate, "estFundingRate") }, { "fundingTimestamp", nextFundingTimestamp }, { "fundingDatetime", this.iso8601(nextFundingTimestamp) }, { "nextFundingRate", null }, { "nextFundingTimestamp", null }, { "nextFundingDatetime", null }, - { "previousFundingRate", this.safeNumber(fundingRate, "last_funding_rate") }, + { "previousFundingRate", this.safeNumber(fundingRate, "lastFundingRate") }, { "previousFundingTimestamp", lastFundingRateTimestamp }, { "previousFundingDatetime", this.iso8601(lastFundingRateTimestamp) }, { "interval", add(intervalString, "h") }, @@ -3153,7 +3377,7 @@ public override object parseFundingRate(object fundingRate, object market = null * @method * @name woo#fetchFundingInterval * @description fetch the current funding rate interval - * @see https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure} @@ -3168,7 +3392,7 @@ public async override Task fetchFundingInterval(object symbol, object pa * @method * @name woo#fetchFundingRate * @description fetch the current funding rate - * @see https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure} @@ -3181,29 +3405,38 @@ public async override Task fetchFundingRate(object symbol, object parame object request = new Dictionary() { { "symbol", getValue(market, "id") }, }; - object response = await this.v1PublicGetFundingRateSymbol(this.extend(request, parameters)); + object response = await this.v3PublicGetFundingRate(this.extend(request, parameters)); // // { // "success": true, - // "timestamp": 1727428037877, - // "symbol": "PERP_BTC_USDT", - // "est_funding_rate": -0.00092674, - // "est_funding_rate_timestamp": 1727428019064, - // "last_funding_rate": -0.00092610, - // "last_funding_rate_timestamp": 1727424000000, - // "next_funding_time": 1727452800000, - // "last_funding_rate_interval": 8, - // "est_funding_rate_interval": 8 + // "data": { + // "rows": [ + // { + // "symbol": "PERP_BTC_USDT", + // "estFundingRate": "-0.00000441", + // "estFundingRateTimestamp": 1751623979022, + // "lastFundingRate": "-0.00004953", + // "lastFundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "lastFundingIntervalHours": 8, + // "estFundingIntervalHours": 8 + // } + // ] + // }, + // "timestamp": 1751624037798 // } // - return this.parseFundingRate(response, market); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); + object first = this.safeDict(rows, 0, new Dictionary() {}); + return this.parseFundingRate(first, market); } /** * @method * @name woo#fetchFundingRates * @description fetch the funding rate for multiple markets - * @see https://docs.woox.io/#get-predicted-funding-rate-for-all-markets-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate * @param {string[]|undefined} symbols list of unified market symbols * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols @@ -3213,24 +3446,29 @@ public async override Task fetchFundingRates(object symbols = null, obje parameters ??= new Dictionary(); await this.loadMarkets(); symbols = this.marketSymbols(symbols); - object response = await this.v1PublicGetFundingRates(parameters); + object response = await this.v3PublicGetFundingRate(parameters); // // { - // "success":true, - // "rows":[ - // { - // "symbol":"PERP_AAVE_USDT", - // "est_funding_rate":-0.00003447, - // "est_funding_rate_timestamp":1653633959001, - // "last_funding_rate":-0.00002094, - // "last_funding_rate_timestamp":1653631200000, - // "next_funding_time":1653634800000 - // } - // ], - // "timestamp":1653633985646 + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "PERP_BTC_USDT", + // "estFundingRate": "-0.00000441", + // "estFundingRateTimestamp": 1751623979022, + // "lastFundingRate": "-0.00004953", + // "lastFundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "lastFundingIntervalHours": 8, + // "estFundingIntervalHours": 8 + // } + // ] + // }, + // "timestamp": 1751624037798 // } // - object rows = this.safeList(response, "rows", new List() {}); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); return this.parseFundingRates(rows, symbols); } @@ -3238,7 +3476,7 @@ public async override Task fetchFundingRates(object symbols = null, obje * @method * @name woo#fetchFundingRateHistory * @description fetches historical funding rate prices - * @see https://docs.woox.io/#get-funding-rate-history-for-one-market-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRateHistory * @param {string} symbol unified symbol of the market to fetch the funding rate history for * @param {int} [since] timestamp in ms of the earliest funding rate to fetch * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch @@ -3259,51 +3497,57 @@ public async override Task fetchFundingRateHistory(object symbol = null, { return await this.fetchPaginatedCallIncremental("fetchFundingRateHistory", symbol, since, limit, parameters, "page", 25); } - object request = new Dictionary() {}; - if (isTrue(!isEqual(symbol, null))) + if (isTrue(isEqual(symbol, null))) { - object market = this.market(symbol); - symbol = getValue(market, "symbol"); - ((IDictionary)request)["symbol"] = getValue(market, "id"); + throw new ArgumentsRequired ((string)add(this.id, " fetchFundingRateHistory() requires a symbol argument")) ; } + object market = this.market(symbol); + symbol = getValue(market, "symbol"); + object request = new Dictionary() { + { "symbol", getValue(market, "id") }, + }; if (isTrue(!isEqual(since, null))) { - ((IDictionary)request)["start_t"] = this.parseToInt(divide(since, 1000)); + ((IDictionary)request)["startTime"] = since; } - var requestparametersVariable = this.handleUntilOption("end_t", request, parameters, 0.001); + var requestparametersVariable = this.handleUntilOption("endTime", request, parameters); request = ((IList)requestparametersVariable)[0]; parameters = ((IList)requestparametersVariable)[1]; - object response = await this.v1PublicGetFundingRateHistory(this.extend(request, parameters)); + object response = await this.v3PublicGetFundingRateHistory(this.extend(request, parameters)); // // { - // "success":true, - // "meta":{ - // "total":2464, - // "records_per_page":25, - // "current_page":1 - // }, - // "rows":[ - // { - // "symbol":"PERP_BTC_USDT", - // "funding_rate":0.00000629, - // "funding_rate_timestamp":1653638400000, - // "next_funding_time":1653642000000 + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "PERP_BTC_USDT", + // "fundingRate": "-0.00004953", + // "fundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "markPrice": "108708" + // } + // ], + // "meta": { + // "total": 11690, + // "recordsPerPage": 25, + // "currentPage": 1 // } - // ], - // "timestamp":1653640814885 + // }, + // "timestamp": 1751632390031 // } // - object result = this.safeList(response, "rows"); + object data = this.safeDict(response, "data", new Dictionary() {}); + object rows = this.safeList(data, "rows", new List() {}); object rates = new List() {}; - for (object i = 0; isLessThan(i, getArrayLength(result)); postFixIncrement(ref i)) + for (object i = 0; isLessThan(i, getArrayLength(rows)); postFixIncrement(ref i)) { - object entry = getValue(result, i); + object entry = getValue(rows, i); object marketId = this.safeString(entry, "symbol"); - object timestamp = this.safeInteger(entry, "funding_rate_timestamp"); + object timestamp = this.safeInteger(entry, "fundingRateTimestamp"); ((IList)rates).Add(new Dictionary() { { "info", entry }, { "symbol", this.safeSymbol(marketId) }, - { "fundingRate", this.safeNumber(entry, "funding_rate") }, + { "fundingRate", this.safeNumber(entry, "fundingRate") }, { "timestamp", timestamp }, { "datetime", this.iso8601(timestamp) }, }); @@ -3316,7 +3560,7 @@ public async override Task fetchFundingRateHistory(object symbol = null, * @method * @name woo#setPositionMode * @description set hedged to true or false for a market - * @see https://docs.woox.io/#update-position-mode + * @see https://developer.woox.io/api-reference/endpoint/futures/position_mode * @param {bool} hedged set to true to use HEDGE_MODE, false for ONE_WAY * @param {string} symbol not used by woo setPositionMode * @param {object} [params] extra parameters specific to the exchange API endpoint @@ -3334,14 +3578,13 @@ public async override Task setPositionMode(object hedged, object symbol hedgeMode = "ONE_WAY"; } object request = new Dictionary() { - { "position_mode", hedgeMode }, + { "positionMode", hedgeMode }, }; - object response = await this.v1PrivatePostClientPositionMode(this.extend(request, parameters)); + object response = await this.v3PrivatePutFuturesPositionMode(this.extend(request, parameters)); // // { // "success": true, - // "data": {}, - // "timestamp": "1709195608551" + // "timestamp": 1752550492845 // } // return response; @@ -3351,11 +3594,12 @@ public async override Task setPositionMode(object hedged, object symbol * @method * @name woo#fetchLeverage * @description fetch the set leverage for a market - * @see https://docs.woox.io/#get-account-information-new + * @see https://developer.woox.io/api-reference/endpoint/account/get_account_info + * @see https://developer.woox.io/api-reference/endpoint/futures/get_leverage * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated' - * @param {string} [params.position_mode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' + * @param {string} [params.positionMode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure} */ public async override Task fetchLeverage(object symbol, object parameters = null) @@ -3366,7 +3610,7 @@ public async override Task fetchLeverage(object symbol, object parameter object response = null; if (isTrue(getValue(market, "spot"))) { - response = await this.v3PrivateGetAccountinfo(parameters); + response = await this.v3PrivateGetAccountInfo(parameters); } else if (isTrue(getValue(market, "swap"))) { object request = new Dictionary() { @@ -3376,8 +3620,8 @@ public async override Task fetchLeverage(object symbol, object parameter var marginModeparametersVariable = this.handleMarginModeAndParams("fetchLeverage", parameters, "cross"); marginMode = ((IList)marginModeparametersVariable)[0]; parameters = ((IList)marginModeparametersVariable)[1]; - ((IDictionary)request)["margin_mode"] = this.encodeMarginMode(marginMode); - response = await this.v1PrivateGetClientFuturesLeverage(this.extend(request, parameters)); + ((IDictionary)request)["marginMode"] = this.encodeMarginMode(marginMode); + response = await this.v3PrivateGetFuturesLeverage(this.extend(request, parameters)); } else { throw new NotSupported ((string)add(add(add(this.id, " fetchLeverage() is not supported for "), getValue(market, "type")), " markets")) ; @@ -3390,8 +3634,12 @@ public override object parseLeverage(object leverage, object market = null) { object marketId = this.safeString(leverage, "symbol"); market = this.safeMarket(marketId, market); - object marginMode = this.safeStringLower(leverage, "default_margin_mode"); + object marginMode = this.safeStringLower(leverage, "marginMode"); object spotLeverage = this.safeInteger(leverage, "leverage"); + if (isTrue(isEqual(spotLeverage, 0))) + { + spotLeverage = null; + } object longLeverage = spotLeverage; object shortLeverage = spotLeverage; object details = this.safeList(leverage, "details", new List() {}); @@ -3399,7 +3647,7 @@ public override object parseLeverage(object leverage, object market = null) { object position = this.safeDict(details, i, new Dictionary() {}); object positionLeverage = this.safeInteger(position, "leverage"); - object side = this.safeString(position, "position_side"); + object side = this.safeString(position, "positionSide"); if (isTrue(isEqual(side, "BOTH"))) { longLeverage = positionLeverage; @@ -3425,13 +3673,13 @@ public override object parseLeverage(object leverage, object market = null) * @method * @name woo#setLeverage * @description set the level of leverage for a market - * @see https://docs.woox.io/#update-leverage-setting - * @see https://docs.woox.io/#update-futures-leverage-setting + * @see https://developer.woox.io/api-reference/endpoint/spot_margin/set_leverage + * @see https://developer.woox.io/api-reference/endpoint/futures/set_leverage * @param {float} leverage the rate of leverage (1, 2, 3, 4 or 5 for spot markets, 1, 2, 3, 4, 5, 10, 15, 20 for swap markets) * @param {string} [symbol] unified market symbol (is mandatory for swap markets) * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated' - * @param {string} [params.position_side] *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode. + * @param {string} [params.positionMode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' * @returns {object} response from the exchange */ public async override Task setLeverage(object leverage, object symbol = null, object parameters = null) @@ -3448,7 +3696,7 @@ public async override Task setLeverage(object leverage, object symbol = } if (isTrue(isTrue((isEqual(symbol, null))) || isTrue(getValue(market, "spot")))) { - return await this.v1PrivatePostClientLeverage(this.extend(request, parameters)); + return await this.v3PrivatePostSpotMarginLeverage(this.extend(request, parameters)); } else if (isTrue(getValue(market, "swap"))) { ((IDictionary)request)["symbol"] = getValue(market, "id"); @@ -3456,8 +3704,8 @@ public async override Task setLeverage(object leverage, object symbol = var marginModeparametersVariable = this.handleMarginModeAndParams("fetchLeverage", parameters, "cross"); marginMode = ((IList)marginModeparametersVariable)[0]; parameters = ((IList)marginModeparametersVariable)[1]; - ((IDictionary)request)["margin_mode"] = this.encodeMarginMode(marginMode); - return await this.v1PrivatePostClientFuturesLeverage(this.extend(request, parameters)); + ((IDictionary)request)["marginMode"] = this.encodeMarginMode(marginMode); + return await this.v3PrivatePutFuturesLeverage(this.extend(request, parameters)); } else { throw new NotSupported ((string)add(add(add(this.id, " fetchLeverage() is not supported for "), getValue(market, "type")), " markets")) ; @@ -3512,6 +3760,15 @@ public async virtual Task modifyMarginHelper(object symbol, object amoun return await this.v1PrivatePostClientIsolatedMargin(this.extend(request, parameters)); } + /** + * @method + * @name woo#fetchPosition + * @description fetch data on an open position + * @see https://developer.woox.io/api-reference/endpoint/futures/get_positions + * @param {string} symbol unified market symbol of the market the position is held in + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} + */ public async override Task fetchPosition(object symbol, object parameters = null) { parameters ??= new Dictionary(); @@ -3520,90 +3777,87 @@ public async override Task fetchPosition(object symbol, object parameter object request = new Dictionary() { { "symbol", getValue(market, "id") }, }; - object response = await this.v1PrivateGetPositionSymbol(this.extend(request, parameters)); + object response = await this.v3PrivateGetFuturesPositions(this.extend(request, parameters)); // // { - // "symbol": "PERP_ETH_USDT", - // "position_side": "BOTH", - // "leverage": 10, - // "margin_mode": "CROSS", - // "average_open_price": 3139.9, - // "isolated_margin_amount": 0.0, - // "isolated_margin_token": "", - // "opening_time": "1720627963.094", - // "mark_price": 3155.19169891, - // "pending_short_qty": 0.0, - // "pending_long_qty": 0.0, - // "holding": -0.7, - // "pnl_24_h": 0.0, - // "est_liq_price": 9107.40055552, - // "settle_price": 3151.0319904, // "success": true, - // "fee_24_h": 0.0, - // "isolated_frozen_long": 0.0, - // "isolated_frozen_short": 0.0, - // "timestamp": "1720867502.544" + // "data": { + // "positions": [ + // { + // "symbol": "PERP_LTC_USDT", + // "holding": "0.1", + // "pendingLongQty": "0", + // "pendingShortQty": "0", + // "settlePrice": "96.87", + // "averageOpenPrice": "96.87", + // "pnl24H": "0", + // "fee24H": "0.0048435", + // "markPrice": "96.83793449", + // "estLiqPrice": "0", + // "timestamp": 1752500555823, + // "adlQuantile": 2, + // "positionSide": "BOTH", + // "marginMode": "CROSS", + // "isolatedMarginToken": "", + // "isolatedMarginAmount": "0", + // "isolatedFrozenLong": "0", + // "isolatedFrozenShort": "0", + // "leverage": 10 + // } + // ] + // }, + // "timestamp": 1752500579848 // } // - return this.parsePosition(response, market); + object result = this.safeDict(response, "data", new Dictionary() {}); + object positions = this.safeList(result, "positions", new List() {}); + object first = this.safeDict(positions, 0, new Dictionary() {}); + return this.parsePosition(first, market); } + /** + * @method + * @name woo#fetchPositions + * @description fetch all open positions + * @see https://developer.woox.io/api-reference/endpoint/futures/get_positions + * @param {string[]} [symbols] list of unified market symbols + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} + */ public async override Task fetchPositions(object symbols = null, object parameters = null) { parameters ??= new Dictionary(); await this.loadMarkets(); - object response = await this.v3PrivateGetPositions(parameters); + object response = await this.v3PrivateGetFuturesPositions(parameters); // // { // "success": true, - // "data": - // { + // "data": { // "positions": [ // { - // "symbol": "PERP_ETH_USDT", - // "holding": -1.0, - // "pendingLongQty": 0.0, - // "pendingShortQty": 0.0, - // "settlePrice": 3143.2, - // "averageOpenPrice": 3143.2, - // "pnl24H": 0.0, - // "fee24H": 1.5716, - // "markPrice": 3134.97984158, - // "estLiqPrice": 3436.176349, - // "timestamp": 1720628031.463, - // "adlQuantile": 5, - // "positionSide": "BOTH", - // "marginMode": "ISOLATED", - // "isolatedMarginToken": "USDT", - // "isolatedMarginAmount": 314.62426, - // "isolatedFrozenLong": 0.0, - // "isolatedFrozenShort": 0.0, - // "leverage": 10 - // }, - // { - // "symbol": "PERP_SOL_USDT", - // "holding": -1.0, - // "pendingLongQty": 0.0, - // "pendingShortQty": 0.0, - // "settlePrice": 141.89933923, - // "averageOpenPrice": 171.38, - // "pnl24H": 0.0, - // "fee24H": 0.0, - // "markPrice": 141.65155427, - // "estLiqPrice": 4242.73548551, - // "timestamp": 1720616702.68, - // "adlQuantile": 5, + // "symbol": "PERP_LTC_USDT", + // "holding": "0.1", + // "pendingLongQty": "0", + // "pendingShortQty": "0", + // "settlePrice": "96.87", + // "averageOpenPrice": "96.87", + // "pnl24H": "0", + // "fee24H": "0.0048435", + // "markPrice": "96.83793449", + // "estLiqPrice": "0", + // "timestamp": 1752500555823, + // "adlQuantile": 2, // "positionSide": "BOTH", // "marginMode": "CROSS", // "isolatedMarginToken": "", - // "isolatedMarginAmount": 0.0, - // "isolatedFrozenLong": 0.0, - // "isolatedFrozenShort": 0.0, + // "isolatedMarginAmount": "0", + // "isolatedFrozenLong": "0", + // "isolatedFrozenShort": "0", // "leverage": 10 // } // ] // }, - // "timestamp": 1720628675078 + // "timestamp": 1752500579848 // } // object result = this.safeDict(response, "data", new Dictionary() {}); @@ -3640,24 +3894,24 @@ public override object parsePosition(object position, object market = null) // // v3PrivateGetPositions // { - // "symbol": "PERP_ETH_USDT", - // "holding": -1.0, - // "pendingLongQty": 0.0, // todo: check - // "pendingShortQty": 0.0, // todo: check - // "settlePrice": 3143.2, - // "averageOpenPrice": 3143.2, - // "pnl24H": 0.0, // todo: check - // "fee24H": 1.5716, // todo: check - // "markPrice": 3134.97984158, - // "estLiqPrice": 3436.176349, - // "timestamp": 1720628031.463, - // "adlQuantile": 5, + // "symbol": "PERP_LTC_USDT", + // "holding": "0.1", + // "pendingLongQty": "0", + // "pendingShortQty": "0", + // "settlePrice": "96.87", + // "averageOpenPrice": "96.87", + // "pnl24H": "0", + // "fee24H": "0.0048435", + // "markPrice": "96.83793449", + // "estLiqPrice": "0", + // "timestamp": 1752500555823, + // "adlQuantile": 2, // "positionSide": "BOTH", - // "marginMode": "ISOLATED", - // "isolatedMarginToken": "USDT", // todo: check - // "isolatedMarginAmount": 314.62426, // todo: check - // "isolatedFrozenLong": 0.0, // todo: check - // "isolatedFrozenShort": 0.0, // todo: check + // "marginMode": "CROSS", + // "isolatedMarginToken": "", + // "isolatedMarginAmount": "0", + // "isolatedFrozenLong": "0", + // "isolatedFrozenShort": "0", // "leverage": 10 // } // @@ -3674,7 +3928,18 @@ public override object parsePosition(object position, object market = null) } object contractSize = this.safeString(market, "contractSize"); object markPrice = this.safeString2(position, "markPrice", "mark_price"); - object timestamp = this.safeTimestamp(position, "timestamp"); + object timestampString = this.safeString(position, "timestamp"); + object timestamp = null; + if (isTrue(!isEqual(timestampString, null))) + { + if (isTrue(isGreaterThan(getIndexOf(timestampString, "."), -1))) + { + timestamp = this.safeTimestamp(position, "timestamp"); + } else + { + timestamp = this.safeInteger(position, "timestamp"); + } + } object entryPrice = this.safeString2(position, "averageOpenPrice", "average_open_price"); object priceDifference = Precise.stringSub(markPrice, entryPrice); object unrealisedPnl = Precise.stringMul(priceDifference, size); diff --git a/cs/ccxt/exchanges/woofipro.cs b/cs/ccxt/exchanges/woofipro.cs index 8cc24029a23f9..4a7728c55deaa 100644 --- a/cs/ccxt/exchanges/woofipro.cs +++ b/cs/ccxt/exchanges/woofipro.cs @@ -1901,9 +1901,9 @@ public async override Task cancelAllOrders(object symbol = null, object // } // } // - return new List() {new Dictionary() { + return new List {this.safeOrder(new Dictionary() { { "info", response }, -}}; +})}; } /** diff --git a/cs/ccxt/wrappers/apex.cs b/cs/ccxt/wrappers/apex.cs index 7b66149cb3c03..6635152f74e02 100644 --- a/cs/ccxt/wrappers/apex.cs +++ b/cs/ccxt/wrappers/apex.cs @@ -402,10 +402,10 @@ public async Task Transfer(string code, double amount, string fro /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// cancels an open order @@ -422,10 +422,10 @@ public async Task> CancelAllOrders(string symbol = nu /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// fetches information on an order made by the user diff --git a/cs/ccxt/wrappers/ascendex.cs b/cs/ccxt/wrappers/ascendex.cs index 7870b7fac13ce..250b80b05ef92 100644 --- a/cs/ccxt/wrappers/ascendex.cs +++ b/cs/ccxt/wrappers/ascendex.cs @@ -540,10 +540,10 @@ public async Task CancelOrder(string id, string symbol = null, Dictionary /// /// /// object[] a list with a single [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} with the response assigned to the info property. - public async Task CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return new Order(res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetch the deposit address for a currency associated with this account diff --git a/cs/ccxt/wrappers/bingx.cs b/cs/ccxt/wrappers/bingx.cs index 24dfb8b176034..8b9e743d851fe 100644 --- a/cs/ccxt/wrappers/bingx.cs +++ b/cs/ccxt/wrappers/bingx.cs @@ -1105,7 +1105,7 @@ public async Task> FetchCanceledAndClosedOrders(string symbol = null /// transfer currency internally between wallets on the same account /// /// - /// See
+ /// See
/// /// /// params @@ -1125,7 +1125,7 @@ public async Task Transfer(string code, double amount, string fro /// fetch a history of internal transfers made on an account /// /// - /// See
+ /// See
/// /// /// code diff --git a/cs/ccxt/wrappers/bitcoincom.cs b/cs/ccxt/wrappers/bitcoincom.cs deleted file mode 100644 index 162f0d86c28c3..0000000000000 --- a/cs/ccxt/wrappers/bitcoincom.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ccxt; - -// 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 bitcoincom -{ - -} diff --git a/cs/ccxt/wrappers/bitmart.cs b/cs/ccxt/wrappers/bitmart.cs index c014d98edf811..0937c10109ea6 100644 --- a/cs/ccxt/wrappers/bitmart.cs +++ b/cs/ccxt/wrappers/bitmart.cs @@ -762,10 +762,10 @@ public Dictionary CreateSpotOrderRequest(string symbol, string t /// ///
/// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders @@ -809,10 +809,10 @@ public async Task> CancelOrders(List ids, string symbol = nu /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } public async Task> FetchOrdersByStatus(object status, string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { diff --git a/cs/ccxt/wrappers/bitmex.cs b/cs/ccxt/wrappers/bitmex.cs index 97a9030c149ea..1560aab8da8f4 100644 --- a/cs/ccxt/wrappers/bitmex.cs +++ b/cs/ccxt/wrappers/bitmex.cs @@ -474,7 +474,7 @@ public async Task> FetchTrades(string symbol, Int64? since2 = 0, Int /// /// params.triggerDirection /// - /// object : the direction whenever the trigger happens with relation to price - 'above' or 'below' + /// object : the direction whenever the trigger happens with relation to price - 'ascending' or 'descending' /// /// /// diff --git a/cs/ccxt/wrappers/bitpanda.cs b/cs/ccxt/wrappers/bitpanda.cs deleted file mode 100644 index 6193169dc52b1..0000000000000 --- a/cs/ccxt/wrappers/bitpanda.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ccxt; - -// 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 bitpanda -{ - -} diff --git a/cs/ccxt/wrappers/bittrade.cs b/cs/ccxt/wrappers/bittrade.cs index faf9b8f21d84a..7cca0e07b5a4d 100644 --- a/cs/ccxt/wrappers/bittrade.cs +++ b/cs/ccxt/wrappers/bittrade.cs @@ -484,10 +484,10 @@ public async Task CreateOrder(string symbol, string type, string side, do /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/blofin.cs b/cs/ccxt/wrappers/blofin.cs index 191d13da5ac76..af585c35ebe7e 100644 --- a/cs/ccxt/wrappers/blofin.cs +++ b/cs/ccxt/wrappers/blofin.cs @@ -235,6 +235,12 @@ public async Task> FetchOHLCV(string symbol, string timeframe = "1m" /// boolean : default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) /// /// + /// + /// params.until + /// + /// int : timestamp in ms of the latest funding rate to fetch + /// + /// /// /// /// object[] a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}. @@ -966,10 +972,10 @@ public async Task FetchMarginMode(string symbol, Dictionary /// /// object response from the exchange. - public async Task SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) + public async Task> SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) { var res = await this.setMarginMode(marginMode, symbol, parameters); - return new MarginMode(res); + return ((Dictionary)res); } /// /// fetchs the position mode, hedged or one way diff --git a/cs/ccxt/wrappers/bybit.cs b/cs/ccxt/wrappers/bybit.cs index ee85a6137c271..802d1abc99b49 100644 --- a/cs/ccxt/wrappers/bybit.cs +++ b/cs/ccxt/wrappers/bybit.cs @@ -461,7 +461,7 @@ public async Task CreateMarketSellOrderWithCost(string symbol, double cos /// /// params.triggerDirection /// - /// string : *contract only* the direction for trigger orders, 'above' or 'below' + /// string : *contract only* the direction for trigger orders, 'ascending' or 'descending' /// /// /// @@ -800,10 +800,10 @@ public async Task> CancelOrdersForSymbols(List /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetches information on an order made by the user *classic accounts only* diff --git a/cs/ccxt/wrappers/coinbaseexchange.cs b/cs/ccxt/wrappers/coinbaseexchange.cs index fb94b0c5641fc..a0af697961a8a 100644 --- a/cs/ccxt/wrappers/coinbaseexchange.cs +++ b/cs/ccxt/wrappers/coinbaseexchange.cs @@ -519,10 +519,10 @@ public async Task CreateOrder(string symbol, string type, string side, do /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel all open orders @@ -539,10 +539,10 @@ public async Task> CancelOrder(string id, string symb /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } public async Task> FetchPaymentMethods(Dictionary parameters = null) { diff --git a/cs/ccxt/wrappers/coinbaseinternational.cs b/cs/ccxt/wrappers/coinbaseinternational.cs index 0686a074fee83..1261cc206e099 100644 --- a/cs/ccxt/wrappers/coinbaseinternational.cs +++ b/cs/ccxt/wrappers/coinbaseinternational.cs @@ -233,10 +233,10 @@ public async Task CreateDepositAddress(string code, Dictionary /// /// object A [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure}. - public async Task> SetMargin(string symbol, double amount, Dictionary parameters = null) + public async Task SetMargin(string symbol, double amount, Dictionary parameters = null) { var res = await this.setMargin(symbol, amount, parameters); - return ((Dictionary)res); + return new MarginModification(res); } public async Task> FetchDepositsWithdrawals(string code = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { diff --git a/cs/ccxt/wrappers/coinspot.cs b/cs/ccxt/wrappers/coinspot.cs index 445c7249e4449..30a59723aa0ac 100644 --- a/cs/ccxt/wrappers/coinspot.cs +++ b/cs/ccxt/wrappers/coinspot.cs @@ -182,11 +182,11 @@ public async Task> FetchMyTrades(string symbol = null, Int64? since2 /// /// /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CreateOrder(string symbol, string type, string side, double amount, double? price2 = 0, Dictionary parameters = null) + public async Task CreateOrder(string symbol, string type, string side, double amount, double? price2 = 0, Dictionary parameters = null) { var price = price2 == 0 ? null : (object)price2; var res = await this.createOrder(symbol, type, side, amount, price, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancels an open order diff --git a/cs/ccxt/wrappers/cryptocom.cs b/cs/ccxt/wrappers/cryptocom.cs index 22afa81f1d82f..b96a95b45fc1d 100644 --- a/cs/ccxt/wrappers/cryptocom.cs +++ b/cs/ccxt/wrappers/cryptocom.cs @@ -423,10 +423,10 @@ public Dictionary EditOrderRequest(string id, string symbol, dou /// /// /// object Returns exchange raw message{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// cancels an open order diff --git a/cs/ccxt/wrappers/cryptomus.cs b/cs/ccxt/wrappers/cryptomus.cs index fd77ee1f9f198..f234e832bba32 100644 --- a/cs/ccxt/wrappers/cryptomus.cs +++ b/cs/ccxt/wrappers/cryptomus.cs @@ -188,10 +188,10 @@ public async Task CreateOrder(string symbol, string type, string side, do /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } public async Task> FetchCanceledAndClosedOrders(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { diff --git a/cs/ccxt/wrappers/defx.cs b/cs/ccxt/wrappers/defx.cs index af59f6fab17bf..3c0d208933832 100644 --- a/cs/ccxt/wrappers/defx.cs +++ b/cs/ccxt/wrappers/defx.cs @@ -368,10 +368,10 @@ public async Task CreateOrder(string symbol, string type, string side, do /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel all open orders @@ -388,10 +388,10 @@ public async Task> CancelOrder(string id, string symb /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetch data on a single open contract trade position diff --git a/cs/ccxt/wrappers/derive.cs b/cs/ccxt/wrappers/derive.cs index 5bf7cdd6fde6b..436ca2a2adecb 100644 --- a/cs/ccxt/wrappers/derive.cs +++ b/cs/ccxt/wrappers/derive.cs @@ -293,10 +293,10 @@ public async Task EditOrder(string id, string symbol, string type, string /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel all open orders in a market @@ -320,10 +320,10 @@ public async Task> CancelOrder(string id, string symb /// /// /// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetches information on multiple orders made by the user diff --git a/cs/ccxt/wrappers/digifinex.cs b/cs/ccxt/wrappers/digifinex.cs index f24a6de4d24d8..2812e1336b0bb 100644 --- a/cs/ccxt/wrappers/digifinex.cs +++ b/cs/ccxt/wrappers/digifinex.cs @@ -382,10 +382,10 @@ public async Task CreateMarketBuyOrderWithCost(string symbol, double cost /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/bitfinex1.cs b/cs/ccxt/wrappers/foxbit.cs similarity index 55% rename from cs/ccxt/wrappers/bitfinex1.cs rename to cs/ccxt/wrappers/foxbit.cs index 64dfabf4defcd..4b888b89af57b 100644 --- a/cs/ccxt/wrappers/bitfinex1.cs +++ b/cs/ccxt/wrappers/foxbit.cs @@ -4,13 +4,13 @@ namespace ccxt; // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code -public partial class bitfinex1 +public partial class foxbit { /// - /// please use fetchDepositWithdrawFees instead + /// Retrieves data on all markets for foxbit. /// /// - /// See
+ /// See
/// /// /// params @@ -20,17 +20,17 @@ public partial class bitfinex1 /// /// ///
- /// object[] a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure}. - public async Task> FetchTransactionFees(List codes = null, Dictionary parameters = null) + /// object[] an array of objects representing market data. + public async Task> FetchMarkets(Dictionary parameters = null) { - var res = await this.fetchTransactionFees(codes, parameters); - return ((Dictionary)res); + var res = await this.fetchMarkets(parameters); + return ((IList)res).Select(item => new MarketInterface(item)).ToList(); } /// - /// fetch deposit and withdraw fees + /// Get last 24 hours ticker information, in real-time, for given market. /// /// - /// See
+ /// See
/// /// /// params @@ -40,17 +40,17 @@ public async Task> FetchTransactionFees(List /// /// ///
- /// object[] a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure}. - public async Task> FetchDepositWithdrawFees(List codes = null, Dictionary parameters = null) + /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. + public async Task FetchTicker(string symbol, Dictionary parameters = null) { - var res = await this.fetchDepositWithdrawFees(codes, parameters); - return ((Dictionary)res); + var res = await this.fetchTicker(symbol, parameters); + return new Ticker(res); } /// - /// fetch the trading fees for multiple markets + /// Retrieve the ticker data of all markets. /// /// - /// See
+ /// See
/// /// /// params @@ -60,18 +60,17 @@ public async Task> FetchDepositWithdrawFees(List /// ///
- /// object a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols. - public async Task FetchTradingFees(Dictionary parameters = null) + /// object a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}. + public async Task FetchTickers(List symbols = null, Dictionary parameters = null) { - var res = await this.fetchTradingFees(parameters); - return new TradingFees(res); + var res = await this.fetchTickers(symbols, parameters); + return new Tickers(res); } /// - /// retrieves data on all markets for bitfinex + /// fetch the trading fees for multiple markets /// /// - /// See
- /// See
+ /// See
/// /// /// params @@ -81,38 +80,24 @@ public async Task FetchTradingFees(Dictionary param /// /// ///
- /// object[] an array of objects representing market data. - public async Task> FetchMarkets(Dictionary parameters = null) + /// object a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols. + public async Task FetchTradingFees(Dictionary parameters = null) { - var res = await this.fetchMarkets(parameters); - return ((IList)res).Select(item => new MarketInterface(item)).ToList(); + var res = await this.fetchTradingFees(parameters); + return new TradingFees(res); } /// - /// query for balance and get the amount of funds available for trading or funds locked in orders + /// Exports a copy of the order book of a specific market. /// /// - /// See
+ /// See
/// /// - /// params + /// limit /// - /// object : extra parameters specific to the exchange API endpoint + /// int : the maximum amount of order book entries to return, the maximum is 100 /// /// - /// - ///
- /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. - public async Task FetchBalance(Dictionary parameters = null) - { - var res = await this.fetchBalance(parameters); - return new Balances(res); - } - /// - /// transfer currency internally between wallets on the same account - /// - /// - /// See
- /// /// /// params /// @@ -121,22 +106,29 @@ public async Task FetchBalance(Dictionary parameters = /// /// ///
- /// object a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}. - public async Task Transfer(string code, double amount, string fromAccount, string toAccount, Dictionary parameters = null) + /// object A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols. + public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) { - var res = await this.transfer(code, amount, fromAccount, toAccount, parameters); - return new TransferEntry(res); + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchOrderBook(symbol, limit, parameters); + return new OrderBook(res); } /// - /// fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data + /// Retrieve the trades of a specific market. /// /// - /// See
+ /// See
/// /// + /// since + /// + /// int : timestamp in ms of the earliest trade to fetch + /// + /// + /// /// limit /// - /// int : the maximum amount of order book entries to return + /// int : the maximum amount of trades to fetch /// /// /// @@ -147,19 +139,33 @@ public async Task Transfer(string code, double amount, string fro /// /// ///
- /// object A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols. - public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) + /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. + public async Task> FetchTrades(string symbol, 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.fetchOrderBook(symbol, limit, parameters); - return new OrderBook(res); + var res = await this.fetchTrades(symbol, since, limit, parameters); + return ((IList)res).Select(item => new Trade(item)).ToList(); } /// - /// fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market + /// Fetch historical candlestick data containing the open, high, low, and close price, and the volume of a market. /// /// + /// See
/// /// + /// since + /// + /// int : timestamp in ms of the earliest candle to fetch + /// + /// + /// + /// limit + /// + /// int : the maximum amount of candles to fetch + /// + /// + /// /// params /// /// object : extra parameters specific to the exchange API endpoint @@ -167,17 +173,19 @@ public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Di /// /// ///
- /// object a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task FetchTickers(List symbols = null, Dictionary parameters = null) + /// int[][] A list of candles ordered as timestamp, open, high, low, close, volume. + public async Task> FetchOHLCV(string symbol, string timeframe = "1m", Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { - var res = await this.fetchTickers(symbols, parameters); - return new Tickers(res); + var since = since2 == 0 ? null : (object)since2; + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchOHLCV(symbol, timeframe, since, limit, parameters); + return ((IList)res).Select(item => new OHLCV(item)).ToList(); } /// - /// fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market + /// Query for balance and get the amount of funds available for trading or funds locked in orders. /// /// - /// See
+ /// See
/// /// /// params @@ -187,28 +195,28 @@ public async Task FetchTickers(List symbols = null, Dictionary< /// /// ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task FetchTicker(string symbol, Dictionary parameters = null) + /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. + public async Task FetchBalance(Dictionary parameters = null) { - var res = await this.fetchTicker(symbol, parameters); - return new Ticker(res); + var res = await this.fetchBalance(parameters); + return new Balances(res); } /// - /// get the list of most recent trades for a particular symbol + /// Fetch all unfilled currently open orders. /// /// - /// See
+ /// See
/// /// /// since /// - /// int : timestamp in ms of the earliest trade to fetch + /// int : the earliest time in ms to fetch open orders for /// /// /// /// limit /// - /// int : the maximum amount of trades to fetch + /// int : the maximum number of open order structures to retrieve /// /// /// @@ -219,29 +227,30 @@ public async Task FetchTicker(string symbol, Dictionary /// /// ///
- /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> FetchTrades(string symbol, Int64? since2 = 0, Int64 limit = 50, Dictionary parameters = null) + /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. + public async Task> FetchOpenOrders(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { var since = since2 == 0 ? null : (object)since2; - var res = await this.fetchTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchOpenOrders(symbol, since, limit, parameters); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// - /// fetch all trades made by the user + /// Fetch all currently closed orders. /// /// - /// See
+ /// See
/// /// /// since /// - /// int : the earliest time in ms to fetch trades for + /// int : the earliest time in ms to fetch orders for /// /// /// /// limit /// - /// int : the maximum number of trades structures to retrieve + /// int : the maximum number of order structures to retrieve /// /// /// @@ -252,24 +261,38 @@ public async Task> FetchTrades(string symbol, Int64? since2 = 0, Int /// /// ///
- /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}. - public async Task> FetchMyTrades(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. + public async Task> FetchClosedOrders(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.fetchMyTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); + var res = await this.fetchClosedOrders(symbol, since, limit, parameters); + return ((IList)res).Select(item => new Order(item)).ToList(); + } + public async Task> FetchCanceledOrders(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.fetchCanceledOrders(symbol, since, limit, parameters); + return ((IList)res).Select(item => new Order(item)).ToList(); + } + public async Task> FetchOrdersByStatus(string status, 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.fetchOrdersByStatus(status, symbol, since, limit, parameters); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// - /// create a trade order + /// Create an order with the specified characteristics /// /// - /// See
+ /// See
/// /// /// price /// - /// float : the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders + /// float : the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders /// /// /// @@ -278,6 +301,30 @@ public async Task> FetchMyTrades(string symbol = null, Int64? since2 /// object : extra parameters specific to the exchange API endpoint /// /// + /// + /// params.timeInForce + /// + /// string : "GTC", "FOK", "IOC", "PO" + /// + /// + /// + /// params.triggerPrice + /// + /// float : The time in force for the order. One of GTC, FOK, IOC, PO. See .features or foxbit's doc to see more details. + /// + /// + /// + /// params.postOnly + /// + /// bool : true or false whether the order is post-only + /// + /// + /// + /// params.clientOrderId + /// + /// string : a unique identifier for the order + /// + /// /// ///
/// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -287,18 +334,31 @@ public async Task CreateOrder(string symbol, string type, string side, do var res = await this.createOrder(symbol, type, side, amount, price, parameters); return new Order(res); } - public async Task EditOrder(string id, string symbol, string type, string side, double? amount2 = 0, double? price2 = 0, Dictionary parameters = null) + /// + /// create a list of trade orders + /// + /// + /// See
+ /// + /// + /// params + /// + /// object : extra parameters specific to the exchange API endpoint + /// + /// + /// + ///
+ /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. + public async Task> CreateOrders(List orders, Dictionary parameters = null) { - var amount = amount2 == 0 ? null : (object)amount2; - var price = price2 == 0 ? null : (object)price2; - var res = await this.editOrder(id, symbol, type, side, amount, price, parameters); - return new Order(res); + var res = await this.createOrders(orders, parameters); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// - /// cancels an open order + /// Cancel open orders. /// /// - /// See
+ /// See
/// /// /// params @@ -308,17 +368,17 @@ public async Task EditOrder(string id, string symbol, string type, string /// /// ///
- /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. + /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); return new Order(res); } /// - /// cancel all open orders + /// Cancel all open orders or all open orders for a specific market. /// /// - /// See
+ /// See
/// /// /// params @@ -328,28 +388,48 @@ public async Task CancelOrder(string id, string symbol = null, Dictionary /// /// ///
- /// object response from exchange. + /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); return ((IList)res).Select(item => new Order(item)).ToList(); } /// - /// fetch all unfilled currently open orders + /// Get an order by ID. /// /// - /// See
+ /// See
+ /// + /// + /// params + /// + /// object : extra parameters specific to the exchange API endpoint + /// + /// + /// + ///
+ /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. + public async Task FetchOrder(string id, string symbol = null, Dictionary parameters = null) + { + var res = await this.fetchOrder(id, symbol, parameters); + return new Order(res); + } + /// + /// fetches information on multiple orders made by the user + /// + /// + /// See
/// /// /// since /// - /// int : the earliest time in ms to fetch open orders for + /// int : the earliest time in ms to fetch orders for /// /// /// /// limit /// - /// int : the maximum number of open orders structures to retrieve + /// int : the maximum number of order structures to retrieve /// /// /// @@ -358,32 +438,44 @@ public async Task> CancelAllOrders(string symbol = null, Dictionary< /// object : extra parameters specific to the exchange API endpoint /// /// + /// + /// params.state + /// + /// string : Enum: ACTIVE, CANCELED, FILLED, PARTIALLY_CANCELED, PARTIALLY_FILLED + /// + /// + /// + /// params.side + /// + /// string : Enum: BUY, SELL + /// + /// /// ///
/// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> FetchOpenOrders(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + public async Task> FetchOrders(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.fetchOpenOrders(symbol, since, limit, parameters); + var res = await this.fetchOrders(symbol, since, limit, parameters); return ((IList)res).Select(item => new Order(item)).ToList(); } /// - /// fetches information on multiple closed orders made by the user + /// Trade history queries will only have data available for the last 3 months, in descending order (most recents trades first). /// /// - /// See
+ /// See
/// /// /// since /// - /// int : the earliest time in ms to fetch orders for + /// int : the earliest time in ms to fetch trades for /// /// /// /// limit /// - /// int : the maximum number of order structures to retrieve + /// int : the maximum number of trade structures to retrieve /// /// /// @@ -394,19 +486,19 @@ public async Task> FetchOpenOrders(string symbol = null, Int64? sinc /// /// ///
- /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> FetchClosedOrders(string symbol = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}. + public async Task> FetchMyTrades(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.fetchClosedOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); + var res = await this.fetchMyTrades(symbol, since, limit, parameters); + return ((IList)res).Select(item => new Trade(item)).ToList(); } /// - /// fetches information on an order made by the user + /// Fetch the deposit address for a currency associated with this account. /// /// - /// See
+ /// See
/// /// /// params @@ -414,61 +506,85 @@ public async Task> FetchClosedOrders(string symbol = null, Int64? si /// object : extra parameters specific to the exchange API endpoint /// /// + /// + /// params.networkCode + /// + /// string : the blockchain network to create a deposit address on + /// + /// /// ///
- /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task FetchOrder(string id, string symbol = null, Dictionary parameters = null) + /// object an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}. + public async Task FetchDepositAddress(string code, Dictionary parameters = null) { - var res = await this.fetchOrder(id, symbol, parameters); - return new Order(res); + var res = await this.fetchDepositAddress(code, parameters); + return new DepositAddress(res); } /// - /// fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market + /// Fetch all deposits made to an account. /// /// - /// See
+ /// See
/// /// - /// since + /// code /// - /// int : timestamp in ms of the earliest candle to fetch + /// string : unified currency code /// /// /// - /// limit + /// since /// - /// int : the maximum amount of candles to fetch + /// int : the earliest time in ms to fetch deposits for /// /// /// - /// params + /// limit /// - /// object : extra parameters specific to the exchange API endpoint + /// int : the maximum number of deposit structures to retrieve /// /// /// - /// params.until + /// params /// - /// int : timestamp in ms of the latest candle to fetch + /// object : extra parameters specific to the exchange API endpoint /// /// /// ///
- /// int[][] A list of candles ordered as timestamp, open, high, low, close, volume. - public async Task> FetchOHLCV(string symbol, string timeframe = "1m", Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + /// object[] a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}. + public async Task> FetchDeposits(string code = 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.fetchOHLCV(symbol, timeframe, since, limit, parameters); - return ((IList)res).Select(item => new OHLCV(item)).ToList(); + var res = await this.fetchDeposits(code, since, limit, parameters); + return ((IList)res).Select(item => new Transaction(item)).ToList(); } /// - /// create a currency deposit address + /// Fetch all withdrawals made from an account. /// /// - /// See
+ /// See
/// /// + /// code + /// + /// string : unified currency code + /// + /// + /// + /// since + /// + /// int : the earliest time in ms to fetch withdrawals for + /// + /// + /// + /// limit + /// + /// int : the maximum number of withdrawal structures to retrieve + /// + /// + /// /// params /// /// object : extra parameters specific to the exchange API endpoint @@ -476,19 +592,40 @@ public async Task> FetchOHLCV(string symbol, string timeframe = "1m" /// /// ///
- /// object an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}. - public async Task CreateDepositAddress(string code, Dictionary parameters = null) + /// object[] a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}. + public async Task> FetchWithdrawals(string code = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { - var res = await this.createDepositAddress(code, parameters); - return new DepositAddress(res); + var since = since2 == 0 ? null : (object)since2; + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchWithdrawals(code, since, limit, parameters); + return ((IList)res).Select(item => new Transaction(item)).ToList(); } /// - /// fetch the deposit address for a currency associated with this account + /// Fetch all transactions (deposits and withdrawals) made from an account. /// /// - /// See
+ /// See
+ /// See
/// /// + /// code + /// + /// string : unified currency code + /// + /// + /// + /// since + /// + /// int : the earliest time in ms to fetch withdrawals for + /// + /// + /// + /// limit + /// + /// int : the maximum number of withdrawal structures to retrieve + /// + /// + /// /// params /// /// object : extra parameters specific to the exchange API endpoint @@ -496,28 +633,44 @@ public async Task CreateDepositAddress(string code, Dictionary /// ///
- /// object an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}. - public async Task FetchDepositAddress(string code, Dictionary parameters = null) + /// object[] a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}. + public async Task> FetchTransactions(string code = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { - var res = await this.fetchDepositAddress(code, parameters); - return new DepositAddress(res); + var since = since2 == 0 ? null : (object)since2; + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchTransactions(code, since, limit, parameters); + return ((IList)res).Select(item => new Transaction(item)).ToList(); } /// - /// fetch history of deposits and withdrawals + /// The latest known information on the availability of the exchange API. /// /// - /// See
+ /// See
/// /// - /// since + /// params /// - /// int : timestamp in ms of the earliest deposit/withdrawal, default is undefined + /// object : extra parameters specific to the exchange API endpoint /// /// + /// + ///
+ /// object a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}. + public async Task> FetchStatus(Dictionary parameters = null) + { + var res = await this.fetchStatus(parameters); + return ((Dictionary)res); + } + /// + /// Simultaneously cancel an existing order and create a new one. + /// + /// + /// See
+ /// /// - /// limit + /// price /// - /// int : max number of deposit/withdrawals to return, default is undefined + /// float : the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, used as stop_price on stop market orders /// /// /// @@ -528,19 +681,19 @@ public async Task FetchDepositAddress(string code, Dictionary /// ///
- /// object a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}. - public async Task> FetchDepositsWithdrawals(string code = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) + /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. + public async Task EditOrder(string id, string symbol, string type, string side, double? amount2 = 0, double? price2 = 0, Dictionary parameters = null) { - var since = since2 == 0 ? null : (object)since2; - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.fetchDepositsWithdrawals(code, since, limit, parameters); - return ((IList)res).Select(item => new Transaction(item)).ToList(); + var amount = amount2 == 0 ? null : (object)amount2; + var price = price2 == 0 ? null : (object)price2; + var res = await this.editOrder(id, symbol, type, side, amount, price, parameters); + return new Order(res); } /// - /// make a withdrawal + /// Make a withdrawal. /// /// - /// See
+ /// See
/// /// /// params @@ -557,12 +710,24 @@ public async Task Withdraw(string code, double amount, string addre return new Transaction(res); } /// - /// fetch all open positions + /// fetch the history of changes, actions done by the user or operations that altered balance of the user /// /// - /// See
+ /// See
/// /// + /// since + /// + /// int : timestamp in ms of the earliest ledger entry, default is undefined + /// + /// + /// + /// limit + /// + /// int : max number of ledger entrys to return, default is undefined + /// + /// + /// /// params /// /// object : extra parameters specific to the exchange API endpoint @@ -570,10 +735,12 @@ public async Task Withdraw(string code, double amount, string addre /// /// ///
- /// object[] a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}. - public async Task> FetchPositions(List symbols = null, Dictionary parameters = null) + /// object a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}. + public async Task> FetchLedger(string code = null, Int64? since2 = 0, Int64? limit2 = 0, Dictionary parameters = null) { - var res = await this.fetchPositions(symbols, parameters); - return ((Dictionary)res); + var since = since2 == 0 ? null : (object)since2; + var limit = limit2 == 0 ? null : (object)limit2; + var res = await this.fetchLedger(code, since, limit, parameters); + return ((IList)res).Select(item => new LedgerEntry(item)).ToList(); } } diff --git a/cs/ccxt/wrappers/htx.cs b/cs/ccxt/wrappers/htx.cs index 807c98bb274ab..61ac54aa6a10c 100644 --- a/cs/ccxt/wrappers/htx.cs +++ b/cs/ccxt/wrappers/htx.cs @@ -1037,10 +1037,10 @@ public async Task> CreateOrders(List orders, Dictionar /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders @@ -1105,10 +1105,10 @@ public async Task>> CancelOrders(object ids, str /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task>> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((IList)res).Select(item => (item as Dictionary)).ToList(); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// dead man's switch, cancel all orders after the given timeout diff --git a/cs/ccxt/wrappers/hyperliquid.cs b/cs/ccxt/wrappers/hyperliquid.cs index caecb74ebb962..2dbdbf042814b 100644 --- a/cs/ccxt/wrappers/hyperliquid.cs +++ b/cs/ccxt/wrappers/hyperliquid.cs @@ -98,6 +98,12 @@ public async Task> FetchSpotMarkets(Dictionary /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. @@ -263,6 +269,12 @@ public async Task> FetchOHLCV(string symbol, string timeframe = "1m" /// string : wallet address that made trades /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}. @@ -333,6 +345,12 @@ public async Task> FetchTrades(string symbol, Int64? since2 = 0, Int /// string : the vault address for order /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -406,13 +424,19 @@ public Dictionary CreateOrdersRequest(object orders, Dictionary< /// string : the vault address for order /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders @@ -439,6 +463,12 @@ public async Task> CancelOrder(string id, string symb /// string : the vault address /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -466,13 +496,19 @@ public async Task>> CancelOrders(List id /// string : the vault address /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrdersForSymbols(List orders, Dictionary parameters = null) + public async Task> CancelOrdersForSymbols(List orders, Dictionary parameters = null) { var res = await this.cancelOrdersForSymbols(orders, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// dead man's switch, cancel all orders after the given timeout @@ -491,6 +527,12 @@ public async Task> CancelOrdersForSymbols(List /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object the api result. @@ -558,6 +600,12 @@ public Dictionary EditOrdersRequest(object orders, Dictionary /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -683,6 +731,12 @@ public async Task> FetchFundingRateHistory(string symbo /// string : 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders' /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -839,6 +893,12 @@ public async Task> FetchCanceledAndClosedOrders(string symbol = null /// string : user address, will default to this.walletAddress if not provided /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -867,6 +927,12 @@ public async Task> FetchOrders(string symbol = null, Int64? since2 = /// string : user address, will default to this.walletAddress if not provided /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. @@ -906,6 +972,12 @@ public async Task FetchOrder(string id, string symbol = null, Dictionary< /// int : timestamp in ms of the latest trade /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}. @@ -960,6 +1032,12 @@ public async Task FetchPosition(string symbol, Dictionary /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object[] a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}. @@ -985,6 +1063,18 @@ public async Task> FetchPositions(List symbols = null, Di /// string : the rate of leverage, is required if setting trade mode (symbol) /// /// + /// + /// params.vaultAddress + /// + /// string : the vault address + /// + /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object response from the exchange. @@ -1088,6 +1178,12 @@ public async Task Withdraw(string code, double amount, string addre /// string : user address, will default to this.walletAddress if not provided /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}. @@ -1131,6 +1227,12 @@ public async Task FetchTradingFee(string symbol, Dictionary /// int : timestamp in ms of the latest ledger entry /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}. @@ -1170,6 +1272,12 @@ public async Task> FetchLedger(string code = null, Int64? sinc /// int : the latest time in ms to fetch withdrawals for /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object[] a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}. @@ -1209,6 +1317,12 @@ public async Task> FetchDeposits(string code = null, Int64? si /// int : the latest time in ms to fetch withdrawals for /// /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object[] a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}. @@ -1286,6 +1400,12 @@ public async Task FetchOpenInterest(string symbol, Dictionary /// + /// + /// params.subAccountAddress + /// + /// string : sub account user address + /// + /// /// /// /// object a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}. diff --git a/cs/ccxt/wrappers/krakenfutures.cs b/cs/ccxt/wrappers/krakenfutures.cs index 378948cc6b752..f2b0414e0257d 100644 --- a/cs/ccxt/wrappers/krakenfutures.cs +++ b/cs/ccxt/wrappers/krakenfutures.cs @@ -304,10 +304,10 @@ public async Task EditOrder(string id, string symbol, string type, string /// /// /// undefined undefined. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/kucoin.cs b/cs/ccxt/wrappers/kucoin.cs index 93dc10bd6359e..ee333c21144f6 100644 --- a/cs/ccxt/wrappers/kucoin.cs +++ b/cs/ccxt/wrappers/kucoin.cs @@ -714,10 +714,10 @@ public async Task CancelOrder(string id, string symbol = null, Dictionary /// /// /// undefined undefined. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetch a list of orders diff --git a/cs/ccxt/wrappers/kucoinfutures.cs b/cs/ccxt/wrappers/kucoinfutures.cs index 557b5c43d62b9..8ebcbc8912b6a 100644 --- a/cs/ccxt/wrappers/kucoinfutures.cs +++ b/cs/ccxt/wrappers/kucoinfutures.cs @@ -547,10 +547,10 @@ public Dictionary CreateContractOrderRequest(string symbol, stri /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders @@ -594,10 +594,10 @@ public async Task> CancelOrders(object ids, string symbol = null, Di /// /// /// undefined undefined. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetches a list of orders placed on the exchange @@ -1149,10 +1149,10 @@ public async Task FetchMarginMode(string symbol, Dictionary /// /// object response from the exchange. - public async Task SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) + public async Task> SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) { var res = await this.setMarginMode(marginMode, symbol, parameters); - return new MarginMode(res); + return ((Dictionary)res); } /// /// fetch the set leverage for a market diff --git a/cs/ccxt/wrappers/mexc.cs b/cs/ccxt/wrappers/mexc.cs index 21a3fd0b75d22..a779bbc0a1365 100644 --- a/cs/ccxt/wrappers/mexc.cs +++ b/cs/ccxt/wrappers/mexc.cs @@ -1572,9 +1572,9 @@ public async Task> FetchPositionsHistory(List symbols = n /// /// /// object response from the exchange. - public async Task SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) + public async Task> SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) { var res = await this.setMarginMode(marginMode, symbol, parameters); - return new Leverage(res); + return ((Dictionary)res); } } diff --git a/cs/ccxt/wrappers/modetrade.cs b/cs/ccxt/wrappers/modetrade.cs index 9f3c868412cee..9b25e2b6f069f 100644 --- a/cs/ccxt/wrappers/modetrade.cs +++ b/cs/ccxt/wrappers/modetrade.cs @@ -474,10 +474,10 @@ public async Task EditOrder(string id, string symbol, string type, string /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders @@ -528,10 +528,10 @@ public async Task> CancelOrders(List ids, string symbol = nu /// /// /// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task>> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((IList)res).Select(item => (item as Dictionary)).ToList(); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetches information on an order made by the user diff --git a/cs/ccxt/wrappers/ndax.cs b/cs/ccxt/wrappers/ndax.cs index f303b2ef1b3fa..f65284dd9fa94 100644 --- a/cs/ccxt/wrappers/ndax.cs +++ b/cs/ccxt/wrappers/ndax.cs @@ -341,10 +341,10 @@ public async Task> CancelAllOrders(string symbol = null, Dictionary< /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// fetch all unfilled currently open orders diff --git a/cs/ccxt/wrappers/okcoin.cs b/cs/ccxt/wrappers/okcoin.cs index 313276570c449..924fce725566f 100644 --- a/cs/ccxt/wrappers/okcoin.cs +++ b/cs/ccxt/wrappers/okcoin.cs @@ -316,10 +316,10 @@ public Dictionary CreateOrderRequest(string symbol, string type, /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/okx.cs b/cs/ccxt/wrappers/okx.cs index 512af3658f4b8..21affe48af73e 100644 --- a/cs/ccxt/wrappers/okx.cs +++ b/cs/ccxt/wrappers/okx.cs @@ -671,10 +671,10 @@ public async Task EditOrder(string id, string symbol, string type, string /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/onetrading.cs b/cs/ccxt/wrappers/onetrading.cs index 06b8a53792354..43832ca108217 100644 --- a/cs/ccxt/wrappers/onetrading.cs +++ b/cs/ccxt/wrappers/onetrading.cs @@ -266,10 +266,10 @@ public async Task CancelOrder(string id, string symbol = null, Dictionary /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/oxfun.cs b/cs/ccxt/wrappers/oxfun.cs index 8f4020a42de85..5216be718ca88 100644 --- a/cs/ccxt/wrappers/oxfun.cs +++ b/cs/ccxt/wrappers/oxfun.cs @@ -934,10 +934,10 @@ public async Task CancelOrder(string id, string symbol = null, Dictionary /// /// /// object response from exchange. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/paradex.cs b/cs/ccxt/wrappers/paradex.cs index 2bdf06ede2f70..6aa5f94d57868 100644 --- a/cs/ccxt/wrappers/paradex.cs +++ b/cs/ccxt/wrappers/paradex.cs @@ -356,10 +356,10 @@ public async Task CancelOrder(string id, string symbol = null, Dictionary /// /// /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetches information on an order made by the user diff --git a/cs/ccxt/wrappers/poloniexfutures.cs b/cs/ccxt/wrappers/poloniexfutures.cs deleted file mode 100644 index 9544ab43d9b87..0000000000000 --- a/cs/ccxt/wrappers/poloniexfutures.cs +++ /dev/null @@ -1,706 +0,0 @@ -namespace ccxt; - -// 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 poloniexfutures -{ - /// - /// retrieves data on all markets for poloniexfutures - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] an array of objects representing market data. - public async Task> FetchMarkets(Dictionary parameters = null) - { - var res = await this.fetchMarkets(parameters); - return ((IList)res).Select(item => new MarketInterface(item)).ToList(); - } - /// - /// fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task FetchTicker(string symbol, Dictionary parameters = null) - { - var res = await this.fetchTicker(symbol, parameters); - return new Ticker(res); - } - /// - /// fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task FetchTickers(List symbols = null, Dictionary parameters = null) - { - var res = await this.fetchTickers(symbols, parameters); - return new Tickers(res); - } - public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) - { - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.fetchOrderBook(symbol, limit, parameters); - return new OrderBook(res); - } - /// - /// fetches level 3 information on open orders with bid (buy) and ask (sell) prices, volumes and other data - /// - /// - /// See
- /// - /// - /// limit - /// - /// int : max number of orders to return, default is undefined - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object an [order book structure]{@link https://docs.ccxt.com/#/?id=order-book-structure}. - public async Task FetchL3OrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) - { - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.fetchL3OrderBook(symbol, limit, parameters); - return new OrderBook(res); - } - /// - /// get the list of most recent trades for a particular symbol - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest trade to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of trades to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> FetchTrades(string symbol, 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.fetchTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// fetches the current integer timestamp in milliseconds from the poloniexfutures server - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// int the current integer timestamp in milliseconds from the poloniexfutures server. - public async Task FetchTime(Dictionary parameters = null) - { - var res = await this.fetchTime(parameters); - return (Int64)res; - } - /// - /// fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest candle to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of candles to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// int[][] A list of candles ordered as timestamp, open, high, low, close, volume. - public async Task> FetchOHLCV(string symbol, string timeframe = "1m", 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.fetchOHLCV(symbol, timeframe, since, limit, parameters); - return ((IList)res).Select(item => new OHLCV(item)).ToList(); - } - /// - /// query for balance and get the amount of funds available for trading or funds locked in orders - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. - public async Task FetchBalance(Dictionary parameters = null) - { - var res = await this.fetchBalance(parameters); - return new Balances(res); - } - /// - /// Create an order on the exchange - /// - /// - /// See
- /// - /// - /// price - /// - /// float : the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.leverage - /// - /// float : Leverage size of the order - /// - /// - /// - /// params.triggerPrice - /// - /// float : The price at which a trigger order is triggered at - /// - /// - /// - /// params.reduceOnly - /// - /// bool : A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true. - /// - /// - /// - /// params.timeInForce - /// - /// string : GTC, GTT, IOC, or FOK, default is GTC, limit orders only - /// - /// - /// - /// params.postOnly - /// - /// string : Post only flag, invalid when timeInForce is IOC or FOK - /// - /// - /// - /// params.clientOid - /// - /// string : client order id, defaults to uuid if not passed - /// - /// - /// - /// params.remark - /// - /// string : remark for the order, length cannot exceed 100 utf8 characters - /// - /// - /// - /// params.stop - /// - /// string : 'up' or 'down', defaults to 'up' if side is sell and 'down' if side is buy, requires stopPrice - /// - /// - /// - /// params.stopPriceType - /// - /// string : TP, IP or MP, defaults to TP - /// - /// - /// - /// params.closeOrder - /// - /// bool : set to true to close position - /// - /// - /// - /// params.forceHold - /// - /// bool : A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default. - /// - /// - /// - ///
- /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task CreateOrder(string symbol, string type, string side, double amount, double? price2 = 0, Dictionary parameters = null) - { - var price = price2 == 0 ? null : (object)price2; - var res = await this.createOrder(symbol, type, side, amount, price, parameters); - return new Order(res); - } - /// - /// cancels an open order - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) - { - var res = await this.cancelOrder(id, symbol, parameters); - return new Order(res); - } - /// - /// fetch all open positions - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}. - public async Task> FetchPositions(List symbols = null, Dictionary parameters = null) - { - var res = await this.fetchPositions(symbols, parameters); - return ((IList)res).Select(item => new Position(item)).ToList(); - } - /// - /// fetch the history of funding payments paid and received on this account - /// - /// - /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch funding history for - /// - /// - /// - /// limit - /// - /// int : the maximum number of funding history structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [funding history structure]{@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(); - } - /// - /// cancel all open orders - /// - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.trigger - /// - /// object : When true, all the trigger orders will be cancelled - /// - /// - /// - /// - /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task>> CancelAllOrders(string symbol = null, Dictionary parameters = null) - { - var res = await this.cancelAllOrders(symbol, parameters); - return ((IList)res).Select(item => (item as Dictionary)).ToList(); - } - /// - /// fetches a list of orders placed on the exchange - /// - /// - /// See
- /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest order to retrieve - /// - /// - /// - /// limit - /// - /// int : The maximum number of orders to retrieve - /// - /// - /// - /// params - /// - /// object : exchange specific parameters - /// - /// - /// - /// params.stop - /// - /// bool : set to true to retrieve untriggered stop orders - /// - /// - /// - /// params.until - /// - /// int : End time in ms - /// - /// - /// - /// params.side - /// - /// string : buy or sell - /// - /// - /// - /// params.type - /// - /// string : limit or market - /// - /// - /// - ///
- /// undefined undefined. - public async Task> FetchOrdersByStatus(object status, 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.fetchOrdersByStatus(status, symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// fetch all unfilled currently open orders - /// - /// - /// See
- /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch open orders for - /// - /// - /// - /// limit - /// - /// int : the maximum number of open orders structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.until - /// - /// int : end time in ms - /// - /// - /// - /// params.side - /// - /// string : buy or sell - /// - /// - /// - /// params.type - /// - /// string : limit, or market - /// - /// - /// - ///
- /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> FetchOpenOrders(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.fetchOpenOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// fetches information on multiple closed orders made by the user - /// - /// - /// See
- /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch orders for - /// - /// - /// - /// limit - /// - /// int : the maximum number of order structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.until - /// - /// int : end time in ms - /// - /// - /// - /// params.side - /// - /// string : buy or sell - /// - /// - /// - /// params.type - /// - /// string : limit, or market - /// - /// - /// - ///
- /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> FetchClosedOrders(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.fetchClosedOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// fetches information on an order made by the user - /// - /// - /// See
- /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task FetchOrder(string id, string symbol = null, Dictionary parameters = null) - { - var res = await this.fetchOrder(id, symbol, parameters); - return new Order(res); - } - /// - /// fetch the current funding rate - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}. - public async Task FetchFundingRate(string symbol, Dictionary parameters = null) - { - var res = await this.fetchFundingRate(symbol, parameters); - return new FundingRate(res); - } - /// - /// fetch the current funding rate interval - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}. - public async Task FetchFundingInterval(string symbol, Dictionary parameters = null) - { - var res = await this.fetchFundingInterval(symbol, parameters); - return new FundingRate(res); - } - /// - /// fetch all trades made by the user - /// - /// - /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch trades for - /// - /// - /// - /// limit - /// - /// int : the maximum number of trades structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.orderIdFills - /// - /// string : filles for a specific order (other parameters can be ignored if specified) - /// - /// - /// - /// params.side - /// - /// string : buy or sell - /// - /// - /// - /// params.type - /// - /// string : limit, market, limit_stop or market_stop - /// - /// - /// - /// params.endAt - /// - /// int : end time (milisecond) - /// - /// - /// - ///
- /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}. - public async Task> FetchMyTrades(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.fetchMyTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// set margin mode to 'cross' or 'isolated' - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object response from the exchange. - public async Task> SetMarginMode(string marginMode, string symbol = null, Dictionary parameters = null) - { - var res = await this.setMarginMode(marginMode, symbol, parameters); - return ((Dictionary)res); - } -} diff --git a/cs/ccxt/wrappers/timex.cs b/cs/ccxt/wrappers/timex.cs index 9a7257ef35a0c..24492d92142f1 100644 --- a/cs/ccxt/wrappers/timex.cs +++ b/cs/ccxt/wrappers/timex.cs @@ -323,10 +323,10 @@ public async Task EditOrder(string id, string symbol, string type, string /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/vertex.cs b/cs/ccxt/wrappers/vertex.cs index a3f897fdb699d..b071f760d07fb 100644 --- a/cs/ccxt/wrappers/vertex.cs +++ b/cs/ccxt/wrappers/vertex.cs @@ -565,10 +565,10 @@ public async Task> FetchOrders(string symbol = null, Int64? since2 = /// /// /// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// cancels an open order @@ -586,10 +586,10 @@ public async Task> CancelAllOrders(string symbol = nu /// /// /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders diff --git a/cs/ccxt/wrappers/wazirx.cs b/cs/ccxt/wrappers/wazirx.cs deleted file mode 100644 index 568ccab7e23ac..0000000000000 --- a/cs/ccxt/wrappers/wazirx.cs +++ /dev/null @@ -1,431 +0,0 @@ -namespace ccxt; - -// 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 wazirx -{ - /// - /// retrieves data on all markets for wazirx - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] an array of objects representing market data. - public async Task> FetchMarkets(Dictionary parameters = null) - { - var res = await this.fetchMarkets(parameters); - return ((IList)res).Select(item => new MarketInterface(item)).ToList(); - } - /// - /// fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest candle to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of candles to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.until - /// - /// int : timestamp in s of the latest candle to fetch - /// - /// - /// - ///
- /// int[][] A list of candles ordered as timestamp, open, high, low, close, volume. - public async Task> FetchOHLCV(string symbol, string timeframe = "1m", 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.fetchOHLCV(symbol, timeframe, since, limit, parameters); - return ((IList)res).Select(item => new OHLCV(item)).ToList(); - } - /// - /// fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - /// - /// - /// See
- /// - /// - /// limit - /// - /// int : the maximum amount of order book entries to return - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols. - public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Dictionary parameters = null) - { - var limit = limit2 == 0 ? null : (object)limit2; - var res = await this.fetchOrderBook(symbol, limit, parameters); - return new OrderBook(res); - } - /// - /// fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task FetchTicker(string symbol, Dictionary parameters = null) - { - var res = await this.fetchTicker(symbol, parameters); - return new Ticker(res); - } - /// - /// fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}. - public async Task FetchTickers(List symbols = null, Dictionary parameters = null) - { - var res = await this.fetchTickers(symbols, parameters); - return new Tickers(res); - } - /// - /// get the list of most recent trades for a particular symbol - /// - /// - /// See
- /// - /// - /// since - /// - /// int : timestamp in ms of the earliest trade to fetch - /// - /// - /// - /// limit - /// - /// int : the maximum amount of trades to fetch - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// Trade[] a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}. - public async Task> FetchTrades(string symbol, 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.fetchTrades(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Trade(item)).ToList(); - } - /// - /// the latest known information on the availability of the exchange API - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}. - public async Task> FetchStatus(Dictionary parameters = null) - { - var res = await this.fetchStatus(parameters); - return ((Dictionary)res); - } - /// - /// fetches the current integer timestamp in milliseconds from the exchange server - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// int the current integer timestamp in milliseconds from the exchange server. - public async Task FetchTime(Dictionary parameters = null) - { - var res = await this.fetchTime(parameters); - return (Int64)res; - } - /// - /// query for balance and get the amount of funds available for trading or funds locked in orders - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}. - public async Task FetchBalance(Dictionary parameters = null) - { - var res = await this.fetchBalance(parameters); - return new Balances(res); - } - /// - /// fetches information on multiple orders made by the user - /// - /// - /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch orders for - /// - /// - /// - /// limit - /// - /// int : the maximum number of order structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> FetchOrders(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.fetchOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// fetch all unfilled currently open orders - /// - /// - /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch open orders for - /// - /// - /// - /// limit - /// - /// int : the maximum number of open orders structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// Order[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> FetchOpenOrders(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.fetchOpenOrders(symbol, since, limit, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// cancel all open orders in a market - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object[] a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) - { - var res = await this.cancelAllOrders(symbol, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); - } - /// - /// cancels an open order - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) - { - var res = await this.cancelOrder(id, symbol, parameters); - return new Order(res); - } - /// - /// create a trade order - /// - /// - /// See
- /// - /// - /// price - /// - /// float : the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - ///
- /// object an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task CreateOrder(string symbol, string type, string side, double amount, double? price2 = 0, Dictionary parameters = null) - { - var price = price2 == 0 ? null : (object)price2; - var res = await this.createOrder(symbol, type, side, amount, price, parameters); - return new Order(res); - } - /// - /// fetch the deposit address for a currency associated with this account - /// - /// - /// See
- /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.network - /// - /// string : unified network code, you can get network from fetchCurrencies - /// - /// - /// - ///
- /// object an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}. - public async Task FetchDepositAddress(string code, Dictionary parameters = null) - { - var res = await this.fetchDepositAddress(code, parameters); - return new DepositAddress(res); - } - /// - /// fetch all withdrawals made from an account - /// - /// - /// See
- /// - /// - /// since - /// - /// int : the earliest time in ms to fetch withdrawals for - /// - /// - /// - /// limit - /// - /// int : the maximum number of withdrawals structures to retrieve - /// - /// - /// - /// params - /// - /// object : extra parameters specific to the exchange API endpoint - /// - /// - /// - /// params.until - /// - /// int : the latest time in ms to fetch entries for - /// - /// - /// - ///
- /// object[] a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}. - public async Task> FetchWithdrawals(string code = 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.fetchWithdrawals(code, since, limit, parameters); - return ((IList)res).Select(item => new Transaction(item)).ToList(); - } -} diff --git a/cs/ccxt/wrappers/woo.cs b/cs/ccxt/wrappers/woo.cs index c217af9ea40cf..640cb8bef6478 100644 --- a/cs/ccxt/wrappers/woo.cs +++ b/cs/ccxt/wrappers/woo.cs @@ -10,7 +10,7 @@ public partial class woo /// the latest known information on the availability of the exchange API /// /// - /// See
+ /// See
/// /// /// params @@ -30,7 +30,7 @@ public async Task> FetchStatus(Dictionary /// - /// See
+ /// See
/// /// /// params @@ -50,7 +50,7 @@ public async Task FetchTime(Dictionary parameters = null) /// retrieves data on all markets for woo /// /// - /// See
+ /// See
/// /// /// params @@ -70,7 +70,7 @@ public async Task> FetchMarkets(Dictionary /// get the list of most recent trades for a particular symbol /// /// - /// See
+ /// See
/// /// /// since @@ -101,10 +101,42 @@ public async Task> FetchTrades(string symbol, Int64? since2 = 0, Int return ((IList)res).Select(item => new Trade(item)).ToList(); } /// + /// fetch the trading fees for a market + /// + /// + /// See
+ /// + /// + /// params + /// + /// object : extra parameters specific to the exchange API endpoint + /// + /// + /// + /// params.portfolioMargin + /// + /// boolean : set to true if you would like to fetch trading fees in a portfolio margin account + /// + /// + /// + /// params.subType + /// + /// string : "linear" or "inverse" + /// + /// + /// + ///
+ /// object a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}. + public async Task FetchTradingFee(string symbol, Dictionary parameters = null) + { + var res = await this.fetchTradingFee(symbol, parameters); + return new TradingFeeInterface(res); + } + /// /// fetch the trading fees for multiple markets /// /// - /// See
+ /// See
/// /// /// params @@ -218,8 +250,8 @@ public async Task CreateTrailingPercentOrder(string symbol, string type, /// create a trade order /// /// - /// See
- /// See
+ /// See
+ /// See
/// /// /// price @@ -373,9 +405,8 @@ public async Task EditOrder(string id, string symbol, string type, string /// cancels an open order /// /// - /// See
- /// See
- /// See
+ /// See
+ /// See
/// /// /// params @@ -392,18 +423,17 @@ public async Task EditOrder(string id, string symbol, string type, string /// ///
/// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel all open orders in a market /// /// - /// See
- /// See
- /// See
+ /// See
+ /// See
/// /// /// params @@ -420,16 +450,16 @@ public async Task> CancelOrder(string id, string symb /// ///
/// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((Dictionary)res); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// dead man's switch, cancel all orders after the given timeout /// /// - /// See
+ /// See
/// /// /// params @@ -440,17 +470,17 @@ public async Task> CancelAllOrders(string symbol = nu /// ///
/// object the api result. - public async Task> CancelAllOrdersAfter(Int64 timeout, Dictionary parameters = null) + public async Task> CancelAllOrdersAfter(Int64 timeout, Dictionary parameters = null) { var res = await this.cancelAllOrdersAfter(timeout, parameters); - return ((IList)res).Select(item => new Order(item)).ToList(); + return ((Dictionary)res); } /// /// fetches information on an order made by the user /// /// - /// See
- /// See
+ /// See
+ /// See
/// /// /// params @@ -476,8 +506,8 @@ public async Task FetchOrder(string id, string symbol = null, Dictionary< /// fetches information on multiple orders made by the user /// /// - /// See
- /// See
+ /// See
+ /// See
/// /// /// since @@ -516,12 +546,6 @@ public async Task FetchOrder(string id, string symbol = null, Dictionary< /// /// /// - /// params.trailing - /// - /// boolean : set to true if you want to fetch trailing orders - /// - /// - /// /// params.paginate /// /// boolean : set to true if you want to fetch orders with pagination @@ -541,8 +565,8 @@ public async Task> FetchOrders(string symbol = null, Int64? since2 = /// fetches information on multiple orders made by the user /// /// - /// See
- /// See
+ /// See
+ /// See
/// /// /// since @@ -606,8 +630,8 @@ public async Task> FetchOpenOrders(string symbol = null, Int64? sinc /// fetches information on multiple orders made by the user /// /// - /// See
- /// See
+ /// See
+ /// See
/// /// /// since @@ -671,7 +695,7 @@ public async Task> FetchClosedOrders(string symbol = null, Int64? si /// fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data /// /// - /// See
+ /// See
/// /// /// limit @@ -698,8 +722,7 @@ public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Di /// fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market /// /// - /// See
- /// See
+ /// See
/// /// /// since @@ -719,6 +742,12 @@ public async Task FetchOrderBook(string symbol, Int64? limit2 = 0, Di /// object : extra parameters specific to the exchange API endpoint ///
///
+ /// + /// params.until + /// + /// int : the latest time in ms to fetch entries for + /// + /// ///
///
/// int[][] A list of candles ordered as timestamp, open, high, low, close, volume. @@ -767,7 +796,7 @@ public async Task> FetchOrderTrades(string id, string symbol = null, /// fetch all trades made by the user /// /// - /// See
+ /// See
/// /// /// since @@ -807,7 +836,8 @@ public async Task> FetchMyTrades(string symbol = null, Int64? since2 /// fetch all the accounts associated with a profile /// /// - /// See
+ /// See
+ /// See
/// /// /// params @@ -847,7 +877,7 @@ public async Task FetchBalance(Dictionary parameters = /// fetch the deposit address for a currency associated with this account /// /// - /// See
+ /// See
/// /// /// params @@ -867,7 +897,7 @@ public async Task FetchDepositAddress(string code, Dictionary /// - /// See
+ /// See
/// /// /// code @@ -907,7 +937,7 @@ public async Task> FetchLedger(string code = null, Int64? sinc /// fetch all deposits made to an account /// /// - /// See
+ /// See
/// /// /// since @@ -941,7 +971,7 @@ public async Task> FetchDeposits(string code = null, Int64? si /// fetch all withdrawals made from an account /// /// - /// See
+ /// See
/// /// /// since @@ -975,7 +1005,7 @@ public async Task> FetchWithdrawals(string code = null, Int64? /// fetch history of deposits and withdrawals /// /// - /// See
+ /// See
/// /// /// code @@ -1035,7 +1065,7 @@ public async Task Transfer(string code, double amount, string fro /// fetch a history of internal transfers made on an account /// /// - /// See
+ /// See
/// /// /// since @@ -1095,7 +1125,7 @@ public async Task Withdraw(string code, double amount, string addre /// fetch the history of funding payments paid and received on this account /// /// - /// See
+ /// See
/// /// /// symbol @@ -1141,7 +1171,7 @@ public async Task> FetchFundingHistory(string symbol = null /// fetch the current funding rate interval /// /// - /// See
+ /// See
/// /// /// params @@ -1161,7 +1191,7 @@ public async Task FetchFundingInterval(string symbol, Dictionary /// - /// See
+ /// See
/// /// /// params @@ -1181,7 +1211,7 @@ public async Task FetchFundingRate(string symbol, Dictionary /// - /// See
+ /// See
/// /// /// params @@ -1201,7 +1231,7 @@ public async Task FetchFundingRates(List symbols = null, D /// fetches historical funding rate prices /// /// - /// See
+ /// See
/// /// /// since @@ -1247,7 +1277,7 @@ public async Task> FetchFundingRateHistory(string symbo /// set hedged to true or false for a market /// /// - /// See
+ /// See
/// /// /// params @@ -1267,7 +1297,8 @@ public async Task> SetPositionMode(bool hedged, strin /// fetch the set leverage for a market /// /// - /// See
+ /// See
+ /// See
/// /// /// params @@ -1282,7 +1313,7 @@ public async Task> SetPositionMode(bool hedged, strin /// /// /// - /// params.position_mode + /// params.positionMode /// /// string : *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' /// @@ -1299,8 +1330,8 @@ public async Task FetchLeverage(string symbol, Dictionary /// - /// See
- /// See
+ /// See
+ /// See
/// /// /// symbol @@ -1321,9 +1352,9 @@ public async Task FetchLeverage(string symbol, Dictionary /// /// - /// params.position_side + /// params.positionMode /// - /// string : *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode. + /// string : *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' /// /// /// @@ -1334,11 +1365,41 @@ public async Task> SetLeverage(Int64 leverage, string var res = await this.setLeverage(leverage, symbol, parameters); return ((Dictionary)res); } + /// + /// fetch data on an open position + /// + /// + /// See
+ /// + /// + /// params + /// + /// object : extra parameters specific to the exchange API endpoint + /// + /// + /// + ///
+ /// object a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}. public async Task FetchPosition(string symbol, Dictionary parameters = null) { var res = await this.fetchPosition(symbol, parameters); return new Position(res); } + /// + /// fetch all open positions + /// + /// + /// See
+ /// + /// + /// params + /// + /// object : extra parameters specific to the exchange API endpoint + /// + /// + /// + ///
+ /// object[] a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}. public async Task> FetchPositions(List symbols = null, Dictionary parameters = null) { var res = await this.fetchPositions(symbols, parameters); diff --git a/cs/ccxt/wrappers/woofipro.cs b/cs/ccxt/wrappers/woofipro.cs index 8eb3e2c6b5fb9..36fb359ab3256 100644 --- a/cs/ccxt/wrappers/woofipro.cs +++ b/cs/ccxt/wrappers/woofipro.cs @@ -474,10 +474,10 @@ public async Task EditOrder(string id, string symbol, string type, string ///
///
/// object An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task> CancelOrder(string id, string symbol = null, Dictionary parameters = null) + public async Task CancelOrder(string id, string symbol = null, Dictionary parameters = null) { var res = await this.cancelOrder(id, symbol, parameters); - return ((Dictionary)res); + return new Order(res); } /// /// cancel multiple orders @@ -528,10 +528,10 @@ public async Task> CancelOrders(List ids, string symbol = nu /// /// /// object an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}. - public async Task>> CancelAllOrders(string symbol = null, Dictionary parameters = null) + public async Task> CancelAllOrders(string symbol = null, Dictionary parameters = null) { var res = await this.cancelAllOrders(symbol, parameters); - return ((IList)res).Select(item => (item as Dictionary)).ToList(); + return ((IList)res).Select(item => new Order(item)).ToList(); } /// /// fetches information on an order made by the user diff --git a/cs/tests/BaseTest.Bridge.cs b/cs/tests/BaseTest.Bridge.cs index e9fa7de01d453..ddd62cd7da530 100644 --- a/cs/tests/BaseTest.Bridge.cs +++ b/cs/tests/BaseTest.Bridge.cs @@ -1,6 +1,7 @@ using System.Globalization; namespace Tests; + using ccxt; using dict = System.Collections.Generic.Dictionary; @@ -189,6 +190,6 @@ public partial class BaseTest { public void testLanguageSpecific() { - + MultithreadTest().Wait(); } } diff --git a/cs/tests/Generated/Base/test.safeTicker.cs b/cs/tests/Generated/Base/test.safeTicker.cs new file mode 100644 index 0000000000000..2eedac7bd1a79 --- /dev/null +++ b/cs/tests/Generated/Base/test.safeTicker.cs @@ -0,0 +1,131 @@ +using ccxt; +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 object preciseEqualStr(Exchange exchange, object result, object key, object expected) + { + return Precise.stringEq(exchange.safeString(result, key), expected); + } + public void testSafeTicker() + { + var exchange = new ccxt.Exchange(new Dictionary() { + { "id", "sampleexchange" }, + }); + // CASE 1 - by open + object ticker1 = new Dictionary() { + { "open", 5 }, + { "change", 1 }, + }; + object result1 = exchange.safeTicker(ticker1); + Assert(preciseEqualStr(exchange, result1, "percentage", "20.0")); + Assert(preciseEqualStr(exchange, result1, "average", "5.5")); + Assert(preciseEqualStr(exchange, result1, "close", "6.0")); + Assert(preciseEqualStr(exchange, result1, "last", "6.0")); + // CASE 2 - by open + object ticker2 = new Dictionary() { + { "open", 5 }, + { "percentage", 20 }, + }; + object result2 = exchange.safeTicker(ticker2); + Assert(preciseEqualStr(exchange, result2, "change", "1.0")); + Assert(preciseEqualStr(exchange, result2, "average", "5.5")); + Assert(preciseEqualStr(exchange, result2, "close", "6.0")); + Assert(preciseEqualStr(exchange, result2, "last", "6.0")); + // CASE 3 - by close + object ticker3 = new Dictionary() { + { "close", 6 }, + { "change", 1 }, + }; + object result3 = exchange.safeTicker(ticker3); + Assert(preciseEqualStr(exchange, result3, "open", "5.0")); + Assert(preciseEqualStr(exchange, result3, "percentage", "20.0")); + Assert(preciseEqualStr(exchange, result3, "average", "5.5")); + Assert(preciseEqualStr(exchange, result3, "last", "6.0")); + // CASE 4 - by close + object ticker4 = new Dictionary() { + { "close", 6 }, + { "percentage", 20 }, + }; + object result4 = exchange.safeTicker(ticker4); + Assert(preciseEqualStr(exchange, result4, "open", "5.0")); + Assert(preciseEqualStr(exchange, result4, "change", "1.0")); + Assert(preciseEqualStr(exchange, result4, "average", "5.5")); + Assert(preciseEqualStr(exchange, result4, "last", "6.0")); + // CASE 5 - by average + object ticker5 = new Dictionary() { + { "average", 5.5 }, + { "percentage", 20 }, + }; + object result5 = exchange.safeTicker(ticker5); + Assert(preciseEqualStr(exchange, result5, "open", "5.0")); + Assert(preciseEqualStr(exchange, result5, "change", "1.0")); + Assert(preciseEqualStr(exchange, result5, "close", "6.0")); + Assert(preciseEqualStr(exchange, result5, "last", "6.0")); + // CASE 6 + object ticker6 = new Dictionary() { + { "average", 5.5 }, + { "change", 1 }, + }; + object result6 = exchange.safeTicker(ticker6); + Assert(preciseEqualStr(exchange, result6, "open", "5.0")); + Assert(preciseEqualStr(exchange, result6, "percentage", "20.0")); + Assert(preciseEqualStr(exchange, result6, "close", "6.0")); + Assert(preciseEqualStr(exchange, result6, "last", "6.0")); + // CASE 7 - by open and close + object ticker7 = new Dictionary() { + { "open", 5 }, + { "close", 6 }, + }; + object result7 = exchange.safeTicker(ticker7); + Assert(preciseEqualStr(exchange, result7, "change", "1.0")); + Assert(preciseEqualStr(exchange, result7, "percentage", "20.0")); + Assert(preciseEqualStr(exchange, result7, "average", "5.5")); + Assert(preciseEqualStr(exchange, result7, "last", "6.0")); + // CASE 8 - full ticker + object ticker8 = new Dictionary() { + { "open", 5 }, + { "close", 6 }, + { "last", 6 }, + { "high", 6.5 }, + { "low", 4.5 }, + { "average", 5.5 }, + { "bid", 5.9 }, + { "bidVolume", 100 }, + { "ask", 6.1 }, + { "askVolume", 200 }, + { "change", 1 }, + { "percentage", 20 }, + { "vwap", 5.75 }, + { "baseVolume", 1000 }, + { "quoteVolume", 5750 }, + { "previousClose", 4.9 }, + { "indexPrice", 5.8 }, + { "markPrice", 5.9 }, + { "info", new Dictionary() {} }, + }; + object result8 = exchange.safeTicker(ticker8); + Assert(preciseEqualStr(exchange, result8, "open", "5.0")); + Assert(preciseEqualStr(exchange, result8, "high", "6.5")); + Assert(preciseEqualStr(exchange, result8, "low", "4.5")); + Assert(preciseEqualStr(exchange, result8, "close", "6.0")); + Assert(preciseEqualStr(exchange, result8, "last", "6.0")); + Assert(preciseEqualStr(exchange, result8, "change", "1.0")); + Assert(preciseEqualStr(exchange, result8, "percentage", "20.0")); + Assert(preciseEqualStr(exchange, result8, "average", "5.5")); + Assert(preciseEqualStr(exchange, result8, "bid", "5.9")); + Assert(preciseEqualStr(exchange, result8, "bidVolume", "100.0")); + Assert(preciseEqualStr(exchange, result8, "ask", "6.1")); + Assert(preciseEqualStr(exchange, result8, "askVolume", "200.0")); + Assert(preciseEqualStr(exchange, result8, "vwap", "5.75")); + Assert(preciseEqualStr(exchange, result8, "baseVolume", "1000.0")); + Assert(preciseEqualStr(exchange, result8, "quoteVolume", "5750.0")); + Assert(preciseEqualStr(exchange, result8, "previousClose", "4.9")); + Assert(preciseEqualStr(exchange, result8, "indexPrice", "5.8")); + Assert(preciseEqualStr(exchange, result8, "markPrice", "5.9")); + Assert(!isEqual(getValue(result8, "info"), null)); + } +} \ No newline at end of file diff --git a/cs/tests/Generated/Base/tests.init.cs b/cs/tests/Generated/Base/tests.init.cs index d0b49a2776137..e9d104ecdc68c 100644 --- a/cs/tests/Generated/Base/tests.init.cs +++ b/cs/tests/Generated/Base/tests.init.cs @@ -18,6 +18,7 @@ public void baseTestsInit() testNumberToString(); testPrecise(); testSafeMethods(); + testSafeTicker(); // testJson (); testSortBy(); testSum(); diff --git a/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs b/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs index bbf17cfd0d759..33ee02979d994 100644 --- a/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs +++ b/cs/tests/Generated/Exchange/Base/test.sharedMethods.cs @@ -631,6 +631,17 @@ public void assertOrderState(Exchange exchange, object skippedProperties, object return; } } + public object getActiveMarkets(Exchange exchange, object includeUnknown = null) + { + includeUnknown ??= true; + object filteredActive = exchange.filterBy(exchange.markets, "active", true); + if (isTrue(includeUnknown)) + { + object filteredUndefined = exchange.filterBy(exchange.markets, "active", null); + return exchange.arrayConcat(filteredActive, filteredUndefined); + } + return filteredActive; + } public object removeProxyOptions(Exchange exchange, object skippedProperties) { object proxyUrl = exchange.checkProxyUrlSettings(); diff --git a/cs/tests/Generated/Exchange/Base/test.ticker.cs b/cs/tests/Generated/Exchange/Base/test.ticker.cs index 9ef9c4ca739de..9a523f419c71b 100644 --- a/cs/tests/Generated/Exchange/Base/test.ticker.cs +++ b/cs/tests/Generated/Exchange/Base/test.ticker.cs @@ -42,18 +42,17 @@ public static void testTicker(Exchange exchange, object skippedProperties, objec testSharedMethods.assertStructure(exchange, skippedProperties, method, entry, format, emptyAllowedFor); testSharedMethods.assertTimestampAndDatetime(exchange, skippedProperties, method, entry); object logText = testSharedMethods.logTemplate(exchange, method, entry); - // + // check market object market = null; object symbolForMarket = ((bool) isTrue((!isEqual(symbol, null)))) ? symbol : exchange.safeString(entry, "symbol"); if (isTrue(isTrue(!isEqual(symbolForMarket, null)) && isTrue((inOp(exchange.markets, symbolForMarket))))) { market = exchange.market(symbolForMarket); } - object exchangeHasIndexMarkets = exchange.safeBool(exchange.has, "index", false); - object isStandardMarket = (isTrue(!isEqual(market, null)) && isTrue(exchange.inArray(getValue(market, "type"), new List() {"spot", "swap", "future", "option"}))); // only check "above zero" values if exchange is not supposed to have exotic index markets - object valuesShouldBePositive = isTrue(isStandardMarket) || isTrue((isTrue(isEqual(market, null)) && !isTrue(exchangeHasIndexMarkets))); - if (isTrue(valuesShouldBePositive)) + object isStandardMarket = (isTrue(!isEqual(market, null)) && isTrue(exchange.inArray(getValue(market, "type"), new List() {"spot", "swap", "future", "option"}))); + object valuesShouldBePositive = isStandardMarket; // || (market === undefined) atm, no check for index markets + if (isTrue(isTrue(valuesShouldBePositive) && !isTrue((inOp(skippedProperties, "positiveValues"))))) { testSharedMethods.assertGreater(exchange, skippedProperties, method, entry, "open", "0"); testSharedMethods.assertGreater(exchange, skippedProperties, method, entry, "high", "0"); @@ -69,15 +68,25 @@ public static void testTicker(Exchange exchange, object skippedProperties, objec testSharedMethods.assertGreaterOrEqual(exchange, skippedProperties, method, entry, "bidVolume", "0"); testSharedMethods.assertGreaterOrEqual(exchange, skippedProperties, method, entry, "baseVolume", "0"); testSharedMethods.assertGreaterOrEqual(exchange, skippedProperties, method, entry, "quoteVolume", "0"); + // + // close price + // object lastString = exchange.safeString(entry, "last"); object closeString = exchange.safeString(entry, "close"); assert(isTrue((isTrue((isEqual(closeString, null))) && isTrue((isEqual(lastString, null))))) || isTrue(Precise.stringEq(lastString, closeString)), add("`last` != `close`", logText)); - object baseVolume = exchange.safeString(entry, "baseVolume"); - object quoteVolume = exchange.safeString(entry, "quoteVolume"); - object high = exchange.safeString(entry, "high"); - object low = exchange.safeString(entry, "low"); + object openPrice = exchange.safeString(entry, "open"); + // + // base & quote volumes + // + object baseVolume = exchange.omitZero(exchange.safeString(entry, "baseVolume")); + object quoteVolume = exchange.omitZero(exchange.safeString(entry, "quoteVolume")); + object high = exchange.omitZero(exchange.safeString(entry, "high")); + object low = exchange.omitZero(exchange.safeString(entry, "low")); + object open = exchange.omitZero(exchange.safeString(entry, "open")); + object close = exchange.omitZero(exchange.safeString(entry, "close")); if (!isTrue((inOp(skippedProperties, "compareQuoteVolumeBaseVolume")))) { + // assert (baseVolumeDefined === quoteVolumeDefined, 'baseVolume or quoteVolume should be either both defined or both undefined' + logText); // No, exchanges might not report both values if (isTrue(isTrue(isTrue(isTrue((!isEqual(baseVolume, null))) && isTrue((!isEqual(quoteVolume, null)))) && isTrue((!isEqual(high, null)))) && isTrue((!isEqual(low, null))))) { object baseLow = Precise.stringMul(baseVolume, low); @@ -103,6 +112,23 @@ public static void testTicker(Exchange exchange, object skippedProperties, objec assert(Precise.stringLe(quoteVolume, baseHigh), add("quoteVolume should be <= baseVolume * high", logText)); } } + // open and close should be between High & Low + if (isTrue(isTrue(isTrue(!isEqual(high, null)) && isTrue(!isEqual(low, null))) && !isTrue((inOp(skippedProperties, "compareOHLC"))))) + { + if (isTrue(!isEqual(open, null))) + { + assert(Precise.stringGe(open, low), add("open should be >= low", logText)); + assert(Precise.stringLe(open, high), add("open should be <= high", logText)); + } + if (isTrue(!isEqual(close, null))) + { + assert(Precise.stringGe(close, low), add("close should be >= low", logText)); + assert(Precise.stringLe(close, high), add("close should be <= high", logText)); + } + } + // + // vwap + // object vwap = exchange.safeString(entry, "vwap"); if (isTrue(!isEqual(vwap, null))) { @@ -127,6 +153,58 @@ public static void testTicker(Exchange exchange, object skippedProperties, objec { testSharedMethods.assertGreater(exchange, skippedProperties, method, entry, "ask", exchange.safeString(entry, "bid")); } + object percentage = exchange.safeString(entry, "percentage"); + object change = exchange.safeString(entry, "change"); + if (!isTrue((inOp(skippedProperties, "maxIncrease")))) + { + // + // percentage + // + object maxIncrease = "100"; // for testing purposes, if "increased" value is more than 100x, tests should break as implementation might be wrong. however, if something rarest event happens and some coin really had that huge increase, the tests will shortly recover in few hours, as new 24-hour cycle would stabilize tests) + if (isTrue(!isEqual(percentage, null))) + { + // - should be above -100 and below MAX + assert(Precise.stringGe(percentage, "-100"), add("percentage should be above -100% ", logText)); + assert(Precise.stringLe(percentage, Precise.stringMul("+100", maxIncrease)), add(add(add("percentage should be below ", maxIncrease), "00% "), logText)); + } + // + // change + // + object approxValue = exchange.safeStringN(entry, new List() {"open", "close", "average", "bid", "ask", "vwap", "previousClose"}); + if (isTrue(!isEqual(change, null))) + { + // - should be between -price & +price*100 + assert(Precise.stringGe(change, Precise.stringNeg(approxValue)), add("change should be above -price ", logText)); + assert(Precise.stringLe(change, Precise.stringMul(approxValue, maxIncrease)), add(add(add("change should be below ", maxIncrease), "x price "), logText)); + } + } + // + // ensure all expected values are defined + // + if (isTrue(!isEqual(lastString, null))) + { + if (isTrue(!isEqual(percentage, null))) + { + // if one knows 'last' and 'percentage' values, then 'change', 'open' and 'average' values should be determinable. + assert(isTrue(!isEqual(openPrice, null)) && isTrue(!isEqual(change, null)), add("open & change should be defined if last & percentage are defined", logText)); // todo : add average price too + } else if (isTrue(!isEqual(change, null))) + { + // if one knows 'last' and 'change' values, then 'percentage', 'open' and 'average' values should be determinable. + assert(isTrue(!isEqual(openPrice, null)) && isTrue(!isEqual(percentage, null)), add("open & percentage should be defined if last & change are defined", logText)); // todo : add average price too + } + } else if (isTrue(!isEqual(openPrice, null))) + { + if (isTrue(!isEqual(percentage, null))) + { + // if one knows 'open' and 'percentage' values, then 'last', 'change' and 'average' values should be determinable. + assert(isTrue(!isEqual(lastString, null)) && isTrue(!isEqual(change, null)), add("last & change should be defined if open & percentage are defined", logText)); // todo : add average price too + } else if (isTrue(!isEqual(change, null))) + { + // if one knows 'open' and 'change' values, then 'last', 'percentage' and 'average' values should be determinable. + assert(isTrue(!isEqual(lastString, null)) && isTrue(!isEqual(percentage, null)), add("last & percentage should be defined if open & change are defined", logText)); // todo : add average price too + } + } + // // todo: rethink about this // else { // assert ((askString === undefined) && (bidString === undefined), 'ask & bid should be both defined or both undefined' + logText); diff --git a/cs/tests/Generated/Exchange/test.fetchTickers.cs b/cs/tests/Generated/Exchange/test.fetchTickers.cs index 306b205442071..5ca79c92b2a86 100644 --- a/cs/tests/Generated/Exchange/test.fetchTickers.cs +++ b/cs/tests/Generated/Exchange/test.fetchTickers.cs @@ -9,10 +9,11 @@ public partial class testMainClass : BaseTest { async static public Task testFetchTickers(Exchange exchange, object skippedProperties, object symbol) { - // const withoutSymbol = testFetchTickersHelper (exchange, skippedProperties, undefined); - // const withSymbol = testFetchTickersHelper (exchange, skippedProperties, [ symbol ]); - await promiseAll(new List {testFetchTickersHelper(exchange, skippedProperties, null), testFetchTickersHelper(exchange, skippedProperties, new List() {symbol})}); - return true; + object withoutSymbol = testFetchTickersHelper(exchange, skippedProperties, null); + object withSymbol = testFetchTickersHelper(exchange, skippedProperties, new List() {symbol}); + object results = await promiseAll(new List() {withoutSymbol, withSymbol}); + testFetchTickersAmounts(exchange, skippedProperties, getValue(results, 0)); + return results; } async static public Task testFetchTickersHelper(Exchange exchange, object skippedProperties, object argSymbols, object argParams = null) { @@ -33,7 +34,28 @@ async static public Task testFetchTickersHelper(Exchange exchange, objec object ticker = getValue(values, i); testTicker(exchange, skippedProperties, method, ticker, checkedSymbol); } - return true; + return response; + } + public static void testFetchTickersAmounts(Exchange exchange, object skippedProperties, object tickers) + { + object tickersValues = new List(((IDictionary)tickers).Values); + if (!isTrue((inOp(skippedProperties, "checkActiveSymbols")))) + { + // + // ensure all "active" symbols have tickers + // + object nonInactiveMarkets = testSharedMethods.getActiveMarkets(exchange); + object notInactiveSymbolsLength = getArrayLength(nonInactiveMarkets); + object obtainedTickersLength = getArrayLength(tickersValues); + object toleranceCoefficient = 0.01; // 1% tolerance, eg. when 100 active markets, we should have at least 99 tickers + assert(isGreaterThanOrEqual(obtainedTickersLength, multiply(notInactiveSymbolsLength, (subtract(1, toleranceCoefficient)))), add(add(add(add(add(add(add(exchange.id, " "), "fetchTickers"), " must return tickers for all active markets. but returned: "), ((object)obtainedTickersLength).ToString()), " tickers, "), ((object)notInactiveSymbolsLength).ToString()), " active markets")); + // + // ensure tickers length is less than markets length + // + object allMarkets = exchange.markets; + object allMarketsLength = getArrayLength(new List(((IDictionary)allMarkets).Keys)); + assert(isLessThanOrEqual(obtainedTickersLength, allMarketsLength), add(add(add(add(add(add(add(exchange.id, " "), "fetchTickers"), " must return <= than all markets, but returned: "), ((object)obtainedTickersLength).ToString()), " tickers, "), ((object)allMarketsLength).ToString()), " markets")); + } } } \ No newline at end of file diff --git a/cs/tests/Generated/TestMethods.cs b/cs/tests/Generated/TestMethods.cs index 5cba54521b2dc..7568611124aa8 100644 --- a/cs/tests/Generated/TestMethods.cs +++ b/cs/tests/Generated/TestMethods.cs @@ -903,7 +903,7 @@ public virtual void checkConstructor(Exchange exchange) // todo: this might be moved in base tests later if (isTrue(isEqual(exchange.id, "binance"))) { - assert(isEqual(exchange.hostname, null), "binance.com hostname should be empty"); + assert(isTrue(isEqual(exchange.hostname, null)) || isTrue(isEqual(exchange.hostname, "")), "binance.com hostname should be empty"); assert(isEqual(getValue(getValue(exchange.urls, "api"), "public"), "https://api.binance.com/api/v3"), add("https://api.binance.com/api/v3 does not match: ", getValue(getValue(exchange.urls, "api"), "public"))); assert((inOp(getValue(getValue(exchange.api, "sapi"), "get"), "lending/union/account")), add("SAPI should contain the endpoint lending/union/account, ", jsonStringify(getValue(getValue(exchange.api, "sapi"), "get")))); } else if (isTrue(isEqual(exchange.id, "binanceus"))) @@ -913,6 +913,24 @@ public virtual void checkConstructor(Exchange exchange) } } + public async virtual Task testReturnResponseHeaders(Exchange exchange) + { + if (isTrue(!isEqual(exchange.id, "binance"))) + { + return false; // this test is only for binance exchange for now + } + exchange.returnResponseHeaders = true; + object ticker = await exchange.fetchTicker("BTC/USDT"); + object info = getValue(ticker, "info"); + object headers = getValue(info, "responseHeaders"); + object headersKeys = new List(((IDictionary)headers).Keys); + assert(isGreaterThan(getArrayLength(headersKeys), 0), "Response headers should not be empty"); + object headerValues = new List(((IDictionary)headers).Values); + assert(isGreaterThan(getArrayLength(headerValues), 0), "Response headers values should not be empty"); + exchange.returnResponseHeaders = false; + return true; + } + public async virtual Task startTest(Exchange exchange, object symbol) { // we do not need to test aliases @@ -921,6 +939,7 @@ public async virtual Task startTest(Exchange exchange, object symbol) return true; } this.checkConstructor(exchange); + // await this.testReturnResponseHeaders (exchange); if (isTrue(isTrue(this.sandbox) || isTrue(getExchangeProp(exchange, "sandbox")))) { exchange.setSandboxMode(true); @@ -1727,7 +1746,7 @@ public async virtual Task runBrokerIdTests() // ----------------------------------------------------------------------------- // --- Init of brokerId tests functions----------------------------------------- // ----------------------------------------------------------------------------- - object promises = new List {this.testBinance(), this.testOkx(), this.testCryptocom(), this.testBybit(), this.testKucoin(), this.testKucoinfutures(), this.testBitget(), this.testMexc(), this.testHtx(), this.testWoo(), this.testBitmart(), this.testCoinex(), this.testBingx(), this.testPhemex(), this.testBlofin(), this.testHyperliquid(), this.testCoinbaseinternational(), this.testCoinbaseAdvanced(), this.testWoofiPro(), this.testOxfun(), this.testXT(), this.testVertex(), this.testParadex(), this.testHashkey(), this.testCoincatch(), this.testDefx(), this.testCryptomus(), this.testDerive(), this.testModeTrade()}; + object promises = new List {this.testBinance(), this.testOkx(), this.testCryptocom(), this.testBybit(), this.testKucoin(), this.testKucoinfutures(), this.testBitget(), this.testMexc(), this.testHtx(), this.testWoo(), this.testBitmart(), this.testCoinex(), this.testBingx(), this.testPhemex(), this.testBlofin(), this.testCoinbaseinternational(), this.testCoinbaseAdvanced(), this.testWoofiPro(), this.testOxfun(), this.testXT(), this.testVertex(), this.testParadex(), this.testHashkey(), this.testCoincatch(), this.testDefx(), this.testCryptomus(), this.testDerive(), this.testModeTrade()}; await promiseAll(promises); object successMessage = add(add("[", this.lang), "][TEST_SUCCESS] brokerId tests passed."); dump(add("[INFO]", successMessage)); @@ -2036,7 +2055,7 @@ public async virtual Task testWoo() await exchange.createOrder("BTC/USDT", "limit", "buy", 1, 20000); } catch(Exception e) { - spotOrderRequest = this.urlencodedToDict(exchange.last_request_body); + spotOrderRequest = jsonParse(exchange.last_request_body); } object brokerId = getValue(spotOrderRequest, "broker_id"); object idString = ((object)id).ToString(); @@ -2172,27 +2191,22 @@ public async virtual Task testBlofin() return true; } - public async virtual Task testHyperliquid() - { - Exchange exchange = this.initOfflineExchange("hyperliquid"); - object id = "1"; - object request = null; - try - { - await exchange.createOrder("SOL/USDC:USDC", "limit", "buy", 1, 100); - } catch(Exception e) - { - request = jsonParse(exchange.last_request_body); - } - object brokerId = ((object)(getValue(getValue(request, "action"), "brokerCode"))).ToString(); - assert(isEqual(brokerId, id), add(add(add("hyperliquid - brokerId: ", brokerId), " does not start with id: "), id)); - if (!isTrue(isSync())) - { - await close(exchange); - } - return true; - } - + // async testHyperliquid () { + // const exchange = this.initOfflineExchange ('hyperliquid'); + // const id = '1'; + // let request = undefined; + // try { + // await exchange.createOrder ('SOL/USDC:USDC', 'limit', 'buy', 1, 100); + // } catch (e) { + // request = jsonParse (exchange.last_request_body); + // } + // const brokerId = (request['action']['brokerCode']).toString (); + // assert (brokerId === id, 'hyperliquid - brokerId: ' + brokerId + ' does not start with id: ' + id); + // if (!isSync ()) { + // await close (exchange); + // } + // return true; + // } public async virtual Task testCoinbaseinternational() { Exchange exchange = this.initOfflineExchange("coinbaseinternational"); diff --git a/cs/tests/Multithread.cs b/cs/tests/Multithread.cs new file mode 100644 index 0000000000000..fb686eb4a42d0 --- /dev/null +++ b/cs/tests/Multithread.cs @@ -0,0 +1,32 @@ +using ccxt.pro; + +namespace Tests; + + +public partial class BaseTest +{ + + public static async Task MultithreadTest() + { + var exchange = new ccxt.pro.binance(); + exchange.setSandboxMode(true); + var symbol = "BTC/USDT"; + var parallelCount = 10; + + // Console.WriteLine("Prefetch..."); + var prefetchInfo = await exchange.loadMarkets(); + + // Console.WriteLine($"Starting parallel price fetch with {parallelCount} tasks..."); + var tasks = Enumerable.Range(0, parallelCount).Select(i => + Task.Run(async () => + { + var priceInfo = (Dictionary)await exchange.fetchTicker(symbol); + // Console.WriteLine($"Thread: {i,2} COMPLETE, Price: {priceInfo["ask"]}"); + })) + .ToArray(); + + await Task.WhenAll(tasks); + // Console.WriteLine("All tasks completed."); + Helper.Green(" [C#] Multithreaded test completed successfully."); + } +} \ No newline at end of file diff --git a/dist/ccxt.browser.js b/dist/ccxt.browser.js index 14fb810e9bfc0..af5dce440e133 100644 --- a/dist/ccxt.browser.js +++ b/dist/ccxt.browser.js @@ -800,6 +800,22 @@ class Exchange extends _base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchang /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Exchange); +/***/ }), + +/***/ 2597: +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2961); +// ------------------------------------------------------------------------------- + +class Exchange extends _base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .k { +} +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Exchange); + + /***/ }), /***/ 7418: @@ -4986,7 +5002,7 @@ class apex extends _abstract_apex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] } const response = await this.privatePostV3DeleteOpenOrders(this.extend(request, params)); const data = this.safeDict(response, 'data', {}); - return data; + return [this.parseOrder(data, market)]; } /** * @method @@ -5012,7 +5028,7 @@ class apex extends _abstract_apex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] response = await this.privatePostV3DeleteOrder(this.extend(request, params)); } const data = this.safeDict(response, 'data', {}); - return data; + return this.safeOrder(data); } /** * @method @@ -7939,9 +7955,9 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de // } // } // - return this.safeOrder({ - 'info': response, - }); + return [this.safeOrder({ + 'info': response, + })]; } parseDepositAddress(depositAddress, currency = undefined) { // @@ -9169,6 +9185,7 @@ class Exchange { '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 = false; this.origin = '*'; // CORS origin this.MAX_VALUE = Number.MAX_VALUE; // @@ -9827,6 +9844,9 @@ class Exchange { if (!skipFurtherErrorHandling) { this.handleHttpStatusCode(response.status, response.statusText, url, method, responseBody); } + if (json && !Array.isArray(json) && this.returnResponseHeaders) { + json['responseHeaders'] = responseHeaders; + } return json || responseBody; }); } @@ -11477,7 +11497,7 @@ class Exchange { // keep this in mind: // in JS: 1 == 1.0 is true; 1 === 1.0 is true // in Python: 1 == 1.0 is true - // in PHP 1 == 1.0 is true, but 1 === 1.0 is false + // in PHP 1 == 1.0 is true, but 1 === 1.0 is false. if (stringVersion.indexOf('.') >= 0) { return parseFloat(stringVersion); } @@ -12358,19 +12378,7 @@ class Exchange { const symbol = (market !== undefined) ? market['symbol'] : undefined; return this.filterBySymbolSinceLimit(results, symbol, since, limit); } - calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { - /** - * @method - * @description calculates the presumptive fee that would be charged for an order - * @param {string} symbol unified market symbol - * @param {string} type 'market' or 'limit' - * @param {string} side 'buy' or 'sell' - * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts - * @param {float} price the price for the order to be filled at, in units of the quote currency - * @param {string} takerOrMaker 'taker' or 'maker' - * @param {object} params - * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order - */ + calculateFeeWithRate(symbol, type, side, amount, price, takerOrMaker = 'taker', feeRate = undefined, params = {}) { if (type === 'market' && takerOrMaker === 'maker') { throw new _errors_js__WEBPACK_IMPORTED_MODULE_4__.ArgumentsRequired(this.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.'); } @@ -12407,7 +12415,7 @@ class Exchange { if (type === 'market') { takerOrMaker = 'taker'; } - const rate = this.safeString(market, takerOrMaker); + const rate = (feeRate !== undefined) ? this.numberToString(feeRate) : this.safeString(market, takerOrMaker); cost = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(cost, rate); return { 'type': takerOrMaker, @@ -12416,6 +12424,21 @@ class Exchange { 'cost': this.parseNumber(cost), }; } + calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) { + /** + * @method + * @description calculates the presumptive fee that would be charged for an order + * @param {string} symbol unified market symbol + * @param {string} type 'market' or 'limit' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts + * @param {float} price the price for the order to be filled at, in units of the quote currency + * @param {string} takerOrMaker 'taker' or 'maker' + * @param {object} params + * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order + */ + return this.calculateFeeWithRate(symbol, type, side, amount, price, takerOrMaker, undefined, params); + } safeLiquidation(liquidation, market = undefined) { const contracts = this.safeString(liquidation, 'contracts'); const contractSize = this.safeString(market, 'contractSize'); @@ -12581,7 +12604,7 @@ class Exchange { for (let i = 0; i < fees.length; i++) { const fee = fees[i]; const code = this.safeString(fee, 'currency'); - const feeCurrencyCode = code !== undefined ? code : i.toString(); + const feeCurrencyCode = (code !== undefined) ? code : i.toString(); if (feeCurrencyCode !== undefined) { const rate = this.safeString(fee, 'rate'); const cost = this.safeString(fee, 'cost'); @@ -12617,8 +12640,7 @@ class Exchange { } safeTicker(ticker, market = undefined) { let open = this.omitZero(this.safeString(ticker, 'open')); - let close = this.omitZero(this.safeString(ticker, 'close')); - let last = this.omitZero(this.safeString(ticker, 'last')); + let close = this.omitZero(this.safeString2(ticker, 'close', 'last')); let change = this.omitZero(this.safeString(ticker, 'change')); let percentage = this.omitZero(this.safeString(ticker, 'percentage')); let average = this.omitZero(this.safeString(ticker, 'average')); @@ -12628,17 +12650,55 @@ class Exchange { if (vwap === undefined) { vwap = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(this.omitZero(quoteVolume), baseVolume); } - if ((last !== undefined) && (close === undefined)) { - close = last; + // calculate open + if (change !== undefined) { + if (close === undefined && average !== undefined) { + close = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd(average, _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(change, '2')); + } + if (open === undefined && close !== undefined) { + open = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringSub(close, change); + } } - else if ((last === undefined) && (close !== undefined)) { - last = close; + else if (percentage !== undefined) { + if (close === undefined && average !== undefined) { + const openAddClose = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(average, '2'); + // openAddClose = open * (1 + (100 + percentage)/100) + const denominator = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd('2', _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(percentage, '100')); + const calcOpen = (open !== undefined) ? open : _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(openAddClose, denominator); + close = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(calcOpen, _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd('1', _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(percentage, '100'))); + } + if (open === undefined && close !== undefined) { + open = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(close, _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd('1', _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(percentage, '100'))); + } } - if ((last !== undefined) && (open !== undefined)) { - if (change === undefined) { - change = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringSub(last, open); + // change + if (change === undefined) { + if (close !== undefined && open !== undefined) { + change = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringSub(close, open); } - if (average === undefined) { + else if (close !== undefined && percentage !== undefined) { + change = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(percentage, '100'), _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(close, '100')); + } + else if (open !== undefined && percentage !== undefined) { + change = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(open, _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(percentage, '100')); + } + } + // calculate things according to "open" (similar can be done with "close") + if (open !== undefined) { + // percentage (using change) + if (percentage === undefined && change !== undefined) { + percentage = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(change, open), '100'); + } + // close (using change) + if (close === undefined && change !== undefined) { + close = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd(open, change); + } + // close (using average) + if (close === undefined && average !== undefined) { + close = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(average, '2'); + } + // average + if (average === undefined && close !== undefined) { let precision = 18; if (market !== undefined && this.isTickPrecision()) { const marketPrecision = this.safeDict(market, 'precision'); @@ -12647,20 +12707,12 @@ class Exchange { precision = this.precisionFromString(precisionPrice); } } - average = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd(last, open), '2', precision); + average = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringAdd(open, close), '2', precision); } } - if ((percentage === undefined) && (change !== undefined) && (open !== undefined) && _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringGt(open, '0')) { - percentage = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(_Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(change, open), '100'); - } - if ((change === undefined) && (percentage !== undefined) && (open !== undefined)) { - change = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringDiv(_Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringMul(percentage, open), '100'); - } - if ((open === undefined) && (last !== undefined) && (change !== undefined)) { - open = _Precise_js__WEBPACK_IMPORTED_MODULE_17__/* .Precise */ .Y.stringSub(last, change); - } // timestamp and symbol operations don't belong in safeTicker // they should be done in the derived classes + const closeParsed = this.parseNumber(this.omitZero(close)); return this.extend(ticker, { 'bid': this.parseNumber(this.omitZero(this.safeString(ticker, 'bid'))), 'bidVolume': this.safeNumber(ticker, 'bidVolume'), @@ -12669,8 +12721,8 @@ class Exchange { 'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high'))), 'low': this.parseNumber(this.omitZero(this.safeString(ticker, 'low'))), 'open': this.parseNumber(this.omitZero(open)), - 'close': this.parseNumber(this.omitZero(close)), - 'last': this.parseNumber(this.omitZero(last)), + 'close': closeParsed, + 'last': closeParsed, 'change': this.parseNumber(change), 'percentage': this.parseNumber(percentage), 'average': this.parseNumber(average), @@ -14588,10 +14640,10 @@ class Exchange { */ throw new _errors_js__WEBPACK_IMPORTED_MODULE_4__.NotSupported(this.id + ' fetchDepositsWithdrawals() is not supported yet'); } - async fetchDeposits(symbol = undefined, since = undefined, limit = undefined, params = {}) { + async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) { throw new _errors_js__WEBPACK_IMPORTED_MODULE_4__.NotSupported(this.id + ' fetchDeposits() is not supported yet'); } - async fetchWithdrawals(symbol = undefined, since = undefined, limit = undefined, params = {}) { + async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) { throw new _errors_js__WEBPACK_IMPORTED_MODULE_4__.NotSupported(this.id + ' fetchWithdrawals() is not supported yet'); } async fetchDepositsWs(code = undefined, since = undefined, limit = undefined, params = {}) { @@ -19229,13 +19281,13 @@ function Future() { }); p.resolve = function _resolve() { // eslint-disable-next-line prefer-rest-params - setTimeout(() => { + queueMicrotask(() => { resolve.apply(this, arguments); }); }; p.reject = function _reject() { // eslint-disable-next-line prefer-rest-params - setTimeout(() => { + queueMicrotask(() => { reject.apply(this, arguments); }); }; @@ -23426,12 +23478,14 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'options': { 'sandboxMode': false, 'fetchMargins': true, - 'fetchMarkets': [ - 'spot', - 'linear', - 'inverse', // allows CORS in browsers - // 'option', // does not allow CORS, enable outside of the browser only - ], + 'fetchMarkets': { + 'types': [ + 'spot', + 'linear', + 'inverse', // allows CORS in browsers + // 'option', // does not allow CORS, enable outside of the browser only + ], + }, 'loadAllOptions': false, 'fetchCurrencies': true, // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades, eapiPublicGetTrades @@ -25198,7 +25252,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa */ async fetchMarkets(params = {}) { const promisesRaw = []; - const rawFetchMarkets = this.safeList(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']); + let rawFetchMarkets = undefined; + const defaultTypes = ['spot', 'linear', 'inverse']; + const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets'); + if (fetchMarketsOptions !== undefined) { + rawFetchMarkets = this.safeList(fetchMarketsOptions, 'types', defaultTypes); + } + else { + // for backward-compatibility + rawFetchMarkets = this.safeList(this.options, 'fetchMarkets', defaultTypes); + } // handle loadAllOptions option const loadAllOptions = this.safeBool(this.options, 'loadAllOptions', false); if (loadAllOptions) { @@ -36528,7 +36591,11 @@ class binancecoinm extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'createStopMarketOrder': true, }, 'options': { - 'fetchMarkets': ['inverse'], + 'fetchMarkets': { + 'types': [ + 'inverse', + ], + }, 'defaultSubType': 'inverse', 'leverageBrackets': undefined, }, @@ -36591,7 +36658,9 @@ class binanceus extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] * }, }, 'options': { - 'fetchMarkets': ['spot'], + 'fetchMarkets': { + 'types': ['spot'], + }, 'defaultType': 'spot', 'fetchMargins': false, 'quoteOrderQty': false, @@ -36810,7 +36879,9 @@ class binanceusdm extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] 'createStopMarketOrder': true, }, 'options': { - 'fetchMarkets': ['linear'], + 'fetchMarkets': { + 'types': ['linear'], + }, 'defaultSubType': 'linear', // https://www.binance.com/en/support/faq/360033162192 // tier amount, maintenance margin, initial margin, @@ -36964,6 +37035,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" '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', // only swap is really "test" but since the API keys are the same, we want to keep all the functionalities when the user enables the sandboxmode @@ -37293,6 +37365,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'private': { 'get': { 'asset/transfer': 1, + 'asset/transferRecord': 5, 'capital/deposit/hisrec': 1, 'capital/withdraw/history': 1, }, @@ -37301,6 +37374,20 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" }, }, }, + 'asset': { + 'v1': { + 'private': { + 'post': { + 'transfer': 5, + }, + }, + 'public': { + 'get': { + 'transfer/supportCoins': 5, + }, + }, + }, + }, }, }, 'timeframes': { @@ -37365,16 +37452,19 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'options': { 'defaultType': 'spot', 'accountsByType': { - 'funding': 'FUND', - 'spot': 'SPOT', - 'swap': 'PFUTURES', - 'future': 'SFUTURES', + 'funding': 'fund', + 'spot': 'spot', + 'future': 'stdFutures', + 'swap': 'USDTMPerp', + 'linear': 'USDTMPerp', + 'inverse': 'coinMPerp', }, 'accountsById': { - 'FUND': 'funding', - 'SPOT': 'spot', - 'PFUTURES': 'swap', - 'SFUTURES': 'future', + 'fund': 'funding', + 'spot': 'spot', + 'stdFutures': 'future', + 'USDTMPerp': 'linear', + 'coinMPerp': 'inverse', }, 'recvWindow': 5 * 1000, 'broker': 'CCXT', @@ -37618,6 +37708,10 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'min': this.safeNumber(rawNetwork, 'withdrawMin'), 'max': this.safeNumber(rawNetwork, 'withdrawMax'), }, + 'deposit': { + 'min': this.safeNumber(rawNetwork, 'depositMin'), + 'max': undefined, + }, }; const precision = this.parseNumber(this.parsePrecision(this.safeString(rawNetwork, 'withdrawPrecision'))); networks[networkCode] = { @@ -37632,20 +37726,40 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'limits': limits, }; } - result[code] = this.safeCurrencyStructure({ - 'info': entry, - 'code': code, - 'id': currencyId, - 'precision': undefined, - 'name': name, - 'active': undefined, - 'deposit': undefined, - 'withdraw': undefined, - 'networks': networks, - 'fee': undefined, - 'limits': undefined, - 'type': 'crypto', // only cryptos now - }); + if (!(code in result)) { // the exchange could return the same currency with different networks + result[code] = { + 'info': entry, + 'code': code, + 'id': currencyId, + 'precision': undefined, + 'name': name, + 'active': undefined, + 'deposit': undefined, + 'withdraw': undefined, + 'networks': networks, + 'fee': undefined, + 'limits': undefined, + 'type': 'crypto', // only cryptos now + }; + } + else { + const existing = result[code]; + const existingNetworks = this.safeDict(existing, 'networks', {}); + const newNetworkCodes = Object.keys(networks); + for (let j = 0; j < newNetworkCodes.length; j++) { + const newNetworkCode = newNetworkCodes[j]; + if (!(newNetworkCode in existingNetworks)) { + existingNetworks[newNetworkCode] = networks[newNetworkCode]; + } + } + result[code]['networks'] = existingNetworks; + } + } + const codes = Object.keys(result); + for (let i = 0; i < codes.length; i++) { + const code = codes[i]; + const currency = result[code]; + result[code] = this.safeCurrencyStructure(currency); } return result; } @@ -41711,11 +41825,11 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" * @method * @name bingx#transfer * @description transfer currency internally between wallets on the same account - * @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20Transfer + * @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20Transfer%20New * @param {string} code unified currency code * @param {float} amount amount to transfer * @param {string} fromAccount account to transfer from (spot, swap, futures, or funding) - * @param {string} toAccount account to transfer to (spot, swap, futures, or funding) + * @param {string} toAccount account to transfer to (spot, swap (linear or inverse), future, or funding) * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure} */ @@ -41723,14 +41837,33 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" await this.loadMarkets(); const currency = this.currency(code); const accountsByType = this.safeDict(this.options, 'accountsByType', {}); - const fromId = this.safeString(accountsByType, fromAccount, fromAccount); - const toId = this.safeString(accountsByType, toAccount, toAccount); + let subType = undefined; + [subType, params] = this.handleSubTypeAndParams('transfer', undefined, params); + let fromId = this.safeString(accountsByType, fromAccount, fromAccount); + let toId = this.safeString(accountsByType, toAccount, toAccount); + if (fromId === 'swap') { + if (subType === 'inverse') { + fromId = 'coinMPerp'; + } + else { + fromId = 'USDTMPerp'; + } + } + if (toId === 'swap') { + if (subType === 'inverse') { + toId = 'coinMPerp'; + } + else { + toId = 'USDTMPerp'; + } + } const request = { + 'fromAccount': fromId, + 'toAccount': toId, 'asset': currency['id'], 'amount': this.currencyToPrecision(code, amount), - 'type': fromId + '_' + toId, }; - const response = await this.spotV3PrivateGetGetAssetTransfer(this.extend(request, params)); + const response = await this.apiAssetV1PrivatePostTransfer(this.extend(request, params)); // // { // "tranId": 1933130865269936128, @@ -41739,7 +41872,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" // return { 'info': response, - 'id': this.safeString(response, 'tranId'), + 'id': this.safeString(response, 'transferId'), 'timestamp': undefined, 'datetime': undefined, 'currency': code, @@ -41753,18 +41886,19 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" * @method * @name bingx#fetchTransfers * @description fetch a history of internal transfers made on an account - * @see https://bingx-api.github.io/docs/#/spot/account-api.html#Query%20User%20Universal%20Transfer%20History%20(USER_DATA) + * @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20transfer%20records%20new * @param {string} [code] unified currency code of the currency transferred * @param {int} [since] the earliest time in ms to fetch transfers for * @param {int} [limit] the maximum number of transfers structures to retrieve (default 10, max 100) * @param {object} [params] extra parameters specific to the exchange API endpoint - * @param {string} params.fromAccount (mandatory) transfer from (spot, swap, futures, or funding) - * @param {string} params.toAccount (mandatory) transfer to (spot, swap, futures, or funding) + * @param {string} params.fromAccount (mandatory) transfer from (spot, swap (linear or inverse), future, or funding) + * @param {string} params.toAccount (mandatory) transfer to (spot, swap(linear or inverse), future, or funding) * @param {boolean} [params.paginate] whether to paginate the results (default false) * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure} */ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) { await this.loadMarkets(); + let request = {}; let currency = undefined; if (code !== undefined) { currency = this.currency(code); @@ -41775,7 +41909,13 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" const fromId = this.safeString(accountsByType, fromAccount, fromAccount); const toId = this.safeString(accountsByType, toAccount, toAccount); if (fromId === undefined || toId === undefined) { - throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' fromAccount & toAccount parameter are required'); + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' fromAccount & toAccount parameters are required'); + } + if (fromAccount !== undefined) { + request['fromAccount'] = fromId; + } + if (toAccount !== undefined) { + request['toAccount'] = toId; } params = this.omit(params, ['fromAccount', 'toAccount']); const maxLimit = 100; @@ -41784,29 +41924,27 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" if (paginate) { return await this.fetchPaginatedCallDynamic('fetchTransfers', undefined, since, limit, params, maxLimit); } - let request = { - 'type': fromId + '_' + toId, - }; if (since !== undefined) { request['startTime'] = since; } if (limit !== undefined) { - request['size'] = limit; + request['pageSize'] = limit; } [request, params] = this.handleUntilOption('endTime', request, params); - const response = await this.spotV3PrivateGetAssetTransfer(this.extend(request, params)); + const response = await this.apiV3PrivateGetAssetTransferRecord(this.extend(request, params)); // // { - // "total": 3, + // "total": 2, // "rows": [ // { - // "asset": "USDT", - // "amount": "100.00000000000000000000", - // "type": "FUND_SFUTURES", + // "asset": "LTC", + // "amount": "0.05000000000000000000", // "status": "CONFIRMED", - // "tranId": 1067594500957016069, - // "timestamp": 1658388859000 - // }, + // "transferId": "1051461075661819338791", + // "timestamp": 1752202092000, + // "fromAccount": "spot", + // "toAccount": "USDTMPerp" + // } // ] // } // @@ -41814,15 +41952,14 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" return this.parseTransfers(rows, currency, since, limit); } parseTransfer(transfer, currency = undefined) { - const tranId = this.safeString(transfer, 'tranId'); + const tranId = this.safeString(transfer, 'transferId'); const timestamp = this.safeInteger(transfer, 'timestamp'); - const currencyCode = this.safeCurrencyCode(undefined, currency); + const currencyId = this.safeString(transfer, 'asset'); + const currencyCode = this.safeCurrencyCode(currencyId, currency); const status = this.safeString(transfer, 'status'); const accountsById = this.safeDict(this.options, 'accountsById', {}); - const typeId = this.safeString(transfer, 'type'); - const typeIdSplit = typeId.split('_'); - const fromId = this.safeString(typeIdSplit, 0); - const toId = this.safeString(typeIdSplit, 1); + const fromId = this.safeString(transfer, 'fromAccount'); + const toId = this.safeString(transfer, 'toAccount'); const fromAccount = this.safeString(accountsById, fromId, fromId); const toAccount = this.safeString(accountsById, toId, toId); return { @@ -42568,37 +42705,13 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" } parseDepositWithdrawFee(fee, currency = undefined) { // - // { - // "coin": "BTC", - // "name": "BTC", - // "networkList": [ - // { - // "name": "BTC", - // "network": "BTC", - // "isDefault": true, - // "minConfirm": "2", - // "withdrawEnable": true, - // "withdrawFee": "0.00035", - // "withdrawMax": "1.62842", - // "withdrawMin": "0.0005" - // }, - // { - // "name": "BTC", - // "network": "BEP20", - // "isDefault": false, - // "minConfirm": "15", - // "withdrawEnable": true, - // "withdrawFee": "0.00001", - // "withdrawMax": "1.62734", - // "withdrawMin": "0.0001" - // } - // ] - // } + // currencie structure // - const networkList = this.safeList(fee, 'networkList', []); - const networkListLength = networkList.length; + const networks = this.safeDict(fee, 'networks', {}); + const networkCodes = Object.keys(networks); + const networksLength = networkCodes.length; const result = { - 'info': fee, + 'info': networks, 'withdraw': { 'fee': undefined, 'percentage': undefined, @@ -42609,18 +42722,15 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" }, 'networks': {}, }; - if (networkListLength !== 0) { - for (let i = 0; i < networkListLength; i++) { - const network = networkList[i]; - const networkId = this.safeString(network, 'network'); - const isDefault = this.safeBool(network, 'isDefault'); - const currencyCode = this.safeString(currency, 'code'); - const networkCode = this.networkIdToCode(networkId, currencyCode); + if (networksLength !== 0) { + for (let i = 0; i < networksLength; i++) { + const networkCode = networkCodes[i]; + const network = networks[networkCode]; result['networks'][networkCode] = { 'deposit': { 'fee': undefined, 'percentage': undefined }, - 'withdraw': { 'fee': this.safeNumber(network, 'withdrawFee'), 'percentage': false }, + 'withdraw': { 'fee': this.safeNumber(network, 'fee'), 'percentage': false }, }; - if (isDefault) { + if (networksLength === 1) { result['withdraw']['fee'] = this.safeNumber(network, 'withdrawFee'); result['withdraw']['percentage'] = false; } @@ -42639,9 +42749,17 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" */ async fetchDepositWithdrawFees(codes = undefined, params = {}) { await this.loadMarkets(); - const response = await this.walletsV1PrivateGetCapitalConfigGetall(params); - const coins = this.safeList(response, 'data'); - return this.parseDepositWithdrawFees(coins, codes, 'coin'); + const response = await this.fetchCurrencies(params); + const depositWithdrawFees = {}; + const responseCodes = Object.keys(response); + for (let i = 0; i < responseCodes.length; i++) { + const code = responseCodes[i]; + if ((codes === undefined) || (this.inArray(code, codes))) { + const entry = response[code]; + depositWithdrawFees[code] = this.parseDepositWithdrawFee(entry); + } + } + return depositWithdrawFees; } /** * @method @@ -43382,8 +43500,15 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" } let url = this.implodeHostname(this.urls['api'][type]); path = this.implodeParams(path, params); - if (version === 'transfer') { - type = 'account/transfer'; + const versionIsTransfer = (version === 'transfer'); + const versionIsAsset = (version === 'asset'); + if (versionIsTransfer || versionIsAsset) { + if (versionIsTransfer) { + type = 'account/transfer'; + } + else { + type = 'api/asset'; + } version = section[2]; access = section[3]; } @@ -54146,7 +54271,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'cross': hasCrossMargin, 'isolated': hasIsolatedMargin, }; - isMarginTradingAllowed = hasCrossMargin || hasCrossMargin; + isMarginTradingAllowed = hasCrossMargin || hasIsolatedMargin; } else { if (symbolType === 'perpetual') { @@ -56372,82 +56497,35 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // "result": "success" // } // - // spot: fetchOrder - // - // { - // "userId": "7264631750", - // "symbol": "BTCUSDT", - // "orderId": "1111461743123927040", - // "clientOid": "63f95110-93b5-4309-8f77-46339f1bcf3c", - // "price": "25000.0000000000000000", - // "size": "0.0002000000000000", - // "orderType": "limit", - // "side": "buy", - // "status": "live", - // "priceAvg": "0", - // "baseVolume": "0.0000000000000000", - // "quoteVolume": "0.0000000000000000", - // "enterPointSource": "API", - // "feeDetail": "", - // "orderSource": "normal", - // "cTime": "1700719050198", - // "uTime": "1700719050198" - // } - // - // swap and future: fetchOrder - // - // { - // "symbol": "BTCUSDT", - // "size": "0.001", - // "orderId": "1111465253393825792", - // "clientOid": "1111465253431574529", - // "baseVolume": "0", - // "fee": "0", - // "price": "27000", - // "priceAvg": "", - // "state": "live", - // "side": "buy", - // "force": "gtc", - // "totalProfits": "0", - // "posSide": "long", - // "marginCoin": "USDT", - // "presetStopSurplusPrice": "", - // "presetStopLossPrice": "", - // "quoteVolume": "0", - // "orderType": "limit", - // "leverage": "20", - // "marginMode": "crossed", - // "reduceOnly": "NO", - // "enterPointSource": "API", - // "tradeSide": "open", - // "posMode": "hedge_mode", - // "orderSource": "normal", - // "cTime": "1700719887120", - // "uTime": "1700719887120" - // } - // - // spot: fetchOpenOrders + // spot: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders // // { // "userId": "7264631750", // "symbol": "BTCUSDT", // "orderId": "1111499608327360513", // "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6", - // "priceAvg": "25000.0000000000000000", - // "size": "0.0002000000000000", + // "size": "0.0002000000000000", // COST for 'buy market' order! AMOUNT in all other cases + // "price": "0", // in fetchOrder: 0 for market order, otherwise limit price (field not present in fetchOpenOrders // "orderType": "limit", // "side": "buy", // "status": "live", // "basePrice": "0", - // "baseVolume": "0.0000000000000000", - // "quoteVolume": "0.0000000000000000", + // "priceAvg": "25000.0000000000000000", // 0 if nothing filled + // "baseVolume": "0.0000000000000000", // 0 if nothing filled + // "quoteVolume": "0.0000000000000000", // 0 if nothing filled // "enterPointSource": "WEB", // "orderSource": "normal", // "cTime": "1700728077966", // "uTime": "1700728077966" + // "feeDetail": "{\\"newFees\\":{\\"c\\":0,\\"d\\":0,\\"deduction\\":false,\\"r\\":-0.0064699886,\\"t\\":-0.0064699886,\\"totalDeductionFee\\":0},\\"USDT\\":{\\"deduction\\":false,\\"feeCoinCode\\":\\"USDT\\",\\"totalDeductionFee\\":0,\\"totalFee\\":-0.0064699886000000}}", // might not be present in fetchOpenOrders + // "triggerPrice": null, + // "tpslType": "normal", + // "quoteCoin": "USDT", // not present in fetchOpenOrders + // "baseCoin": "DOT", // not present in fetchOpenOrders + // "cancelReason": "", // not present in fetchOpenOrders // } // - // spot stop: fetchOpenOrders, fetchCanceledAndClosedOrders + // spot trigger: fetchOpenOrders, fetchCanceledAndClosedOrders // // { // "orderId": "1111503385931620352", @@ -56488,18 +56566,19 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // "uTime": "1700729691866" // } // - // swap: fetchOpenOrders, fetchCanceledAndClosedOrders + // swap and future: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders // // { // "symbol": "BTCUSDT", - // "size": "0.002", - // "orderId": "1111488897767604224", - // "clientOid": "1111488897805352960", + // "size": "0.001", + // "orderId": "1111465253393825792", + // "clientOid": "1111465253431574529", // "baseVolume": "0", // "fee": "0", - // "price": "25000", + // "price": "27000", // "priceAvg": "", - // "status": "live", + // "state": "live", + // // "status": "live", // key for fetchOpenOrders, fetchClosedOrders // "side": "buy", // "force": "gtc", // "totalProfits": "0", @@ -56508,7 +56587,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // "quoteVolume": "0", // "leverage": "20", // "marginMode": "crossed", - // "enterPointSource": "web", + // "enterPointSource": "API", // "tradeSide": "open", // "posMode": "hedge_mode", // "orderType": "limit", @@ -56516,94 +56595,22 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // "presetStopSurplusPrice": "", // "presetStopLossPrice": "", // "reduceOnly": "NO", - // "cTime": "1700725524378", - // "uTime": "1700725524378" - // } + // "cTime": "1700719887120", + // "uTime": "1700719887120" // - // swap stop: fetchOpenOrders + // for swap trigger order, the additional below fields are present: // - // { // "planType": "normal_plan", - // "symbol": "BTCUSDT", - // "size": "0.001", - // "orderId": "1111491399869075457", - // "clientOid": "1111491399869075456", - // "price": "27000", // "callbackRatio": "", // "triggerPrice": "24000", // "triggerType": "mark_price", // "planStatus": "live", - // "side": "buy", - // "posSide": "long", - // "marginCoin": "USDT", - // "marginMode": "crossed", - // "enterPointSource": "API", - // "tradeSide": "open", - // "posMode": "hedge_mode", - // "orderType": "limit", - // "stopSurplusTriggerPrice": "", - // "stopSurplusExecutePrice": "", - // "stopSurplusTriggerType": "fill_price", - // "stopLossTriggerPrice": "", - // "stopLossExecutePrice": "", - // "stopLossTriggerType": "fill_price", - // "cTime": "1700726120917", - // "uTime": "1700726120917" - // } - // - // spot: fetchCanceledAndClosedOrders - // - // { - // "userId": "7264631750", - // "symbol": "BTCUSDT", - // "orderId": "1111499608327360513", - // "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6", - // "price": "25000.0000000000000000", - // "size": "0.0002000000000000", - // "orderType": "limit", - // "side": "buy", - // "status": "cancelled", - // "priceAvg": "0", - // "baseVolume": "0.0000000000000000", - // "quoteVolume": "0.0000000000000000", - // "enterPointSource": "WEB", - // "feeDetail": "", - // "orderSource": "normal", - // "cTime": "1700728077966", - // "uTime": "1700728911471" - // } - // - // swap stop: fetchCanceledAndClosedOrders - // - // { - // "planType": "normal_plan", - // "symbol": "BTCUSDT", - // "size": "0.001", - // "orderId": "1111491399869075457", - // "clientOid": "1111491399869075456", - // "planStatus": "cancelled", - // "price": "27000", - // "feeDetail": null, - // "baseVolume": "0", - // "callbackRatio": "", - // "triggerPrice": "24000", - // "triggerType": "mark_price", - // "side": "buy", - // "posSide": "long", - // "marginCoin": "USDT", - // "marginMode": "crossed", - // "enterPointSource": "API", - // "tradeSide": "open", - // "posMode": "hedge_mode", - // "orderType": "limit", // "stopSurplusTriggerPrice": "", // "stopSurplusExecutePrice": "", // "stopSurplusTriggerType": "fill_price", // "stopLossTriggerPrice": "", // "stopLossExecutePrice": "", // "stopLossTriggerType": "fill_price", - // "cTime": "1700726120917", - // "uTime": "1700727879652" // } // const errorMessage = this.safeString(order, 'errorMsg'); @@ -56694,6 +56701,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell // so the side of the reduceOnly order is inversed } + const orderType = this.safeString(order, 'orderType'); + const isBuyMarket = (side === 'buy') && (orderType === 'market'); + if (market['spot'] && isBuyMarket) { + // as noted in top comment, for 'buy market' the 'size' field is COST, not AMOUNT + size = this.safeString(order, 'baseVolume'); + } return this.safeOrder({ 'info': order, 'id': this.safeString2(order, 'orderId', 'data'), @@ -56703,7 +56716,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'lastTradeTimestamp': updateTimestamp, 'lastUpdateTimestamp': updateTimestamp, 'symbol': market['symbol'], - 'type': this.safeString(order, 'orderType'), + 'type': orderType, 'side': side, 'price': price, 'amount': size, @@ -66157,7 +66170,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa // } // if (market['swap']) { - return response; + return this.safeOrder({ 'info': response }); } const data = this.safeValue(response, 'data'); if (data === true) { @@ -66290,7 +66303,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa // "trace": "7f9c94e10f9d4513bc08a7bfc2a5559a.70.16954131323145323" // } // - return response; + return [this.safeOrder({ 'info': response })]; } async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) { if (symbol === undefined) { @@ -70563,7 +70576,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {object} [params.triggerPrice] the price at which a trigger order is triggered at - * @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'above' or 'below' + * @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'ascending' or 'descending' * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure} */ @@ -70593,7 +70606,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul const isTrailingAmountOrder = trailingAmount !== undefined; if (isTriggerOrder || isTrailingAmountOrder) { const triggerDirection = this.safeString(params, 'triggerDirection'); - const triggerAbove = (triggerDirection === 'above'); + const triggerAbove = ((triggerDirection === 'ascending') || (triggerDirection === 'above')); if ((type === 'limit') || (type === 'market')) { this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']); } @@ -70650,7 +70663,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul const isTrailingAmountOrder = trailingAmount !== undefined; if (isTrailingAmountOrder) { const triggerDirection = this.safeString(params, 'triggerDirection'); - const triggerAbove = (triggerDirection === 'above'); + const triggerAbove = ((triggerDirection === 'ascending') || (triggerDirection === 'above')); if ((type === 'limit') || (type === 'market')) { this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']); } @@ -73947,11 +73960,9 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // exchange-specific options 'options': { 'createMarketBuyOrderRequiresPrice': true, - 'fetchMarkets': [ - 'spot', - 'linear', - 'inverse', - ], + 'fetchMarkets': { + 'types': ['spot', 'linear', 'inverse'], + }, // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades 'fetchMyTradesMethod': 'v2PrivateGetMyTrades', 'hasAlreadyAuthenticatedSuccessfully': false, @@ -74401,9 +74412,18 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul */ async fetchMarkets(params = {}) { const promisesRaw = []; - const fetchMarkets = this.safeValue(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']); - for (let i = 0; i < fetchMarkets.length; i++) { - const marketType = fetchMarkets[i]; + let types = undefined; + const defaultTypes = ['spot', 'linear', 'inverse']; + const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets'); + if (fetchMarketsOptions !== undefined) { + types = this.safeList(fetchMarketsOptions, 'types', defaultTypes); + } + else { + // for backward-compatibility + types = this.safeList(this.options, 'fetchMarkets', defaultTypes); + } + for (let i = 0; i < types.length; i++) { + const marketType = types[i]; if (marketType === 'spot') { promisesRaw.push(this.spotV1PublicGetExchangeInfo(params)); } @@ -79365,6 +79385,7 @@ class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["de "Bitstamp.net is under scheduled maintenance. We'll be back soon.": _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OnMaintenance, 'Order could not be placed.': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeNotAvailable, 'Invalid offset.': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + 'Trading is currently unavailable for your account.': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended, // {"status": "error", "reason": {"__all__": ["Trading is currently unavailable for your account."]}, "response_code": "403.004"} }, 'broad': { 'Minimum order size is': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, @@ -90170,6 +90191,7 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) + * @param {int} [params.until] timestamp in ms of the latest funding rate to fetch * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} */ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -90180,7 +90202,7 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul let paginate = false; [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate'); if (paginate) { - return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params); + return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 100); } const market = this.market(symbol); const request = { @@ -90192,6 +90214,11 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul if (limit !== undefined) { request['limit'] = limit; } + const until = this.safeInteger(params, 'until'); + if (until !== undefined) { + request['after'] = until; + params = this.omit(params, 'until'); + } const response = await this.publicGetMarketFundingRateHistory(this.extend(request, params)); const rates = []; const data = this.safeList(response, 'data', []); @@ -97273,7 +97300,9 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'options': { 'usePrivateInstrumentsInfo': false, 'enableDemoTrading': false, - 'fetchMarkets': ['spot', 'linear', 'inverse', 'option'], + 'fetchMarkets': { + 'types': ['spot', 'linear', 'inverse', 'option'], + }, 'enableUnifiedMargin': undefined, 'enableUnifiedAccount': undefined, 'unifiedMarginStatus': undefined, @@ -97406,6 +97435,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" '4h': '4h', '1d': '1d', }, + 'useMarkPriceForPositionCollateral': false, // use mark price for position collateral }, 'features': { 'default': { @@ -97959,9 +97989,18 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" await this.loadTimeDifference(); } const promisesUnresolved = []; - const fetchMarkets = this.safeList(this.options, 'fetchMarkets', ['spot', 'linear', 'inverse']); - for (let i = 0; i < fetchMarkets.length; i++) { - const marketType = fetchMarkets[i]; + let types = undefined; + const defaultTypes = ['spot', 'linear', 'inverse', 'option']; + const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets'); + if (fetchMarketsOptions !== undefined) { + types = this.safeList(fetchMarketsOptions, 'types', defaultTypes); + } + else { + // for backward-compatibility + types = this.safeList(this.options, 'fetchMarkets', defaultTypes); + } + for (let i = 0; i < types.length; i++) { + const marketType = types[i]; if (marketType === 'spot') { promisesUnresolved.push(this.fetchSpotMarkets(params)); } @@ -100135,7 +100174,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" * @param {int} [params.isLeverage] *unified spot only* false then spot trading true then margin trading * @param {string} [params.tpslMode] *contract only* 'full' or 'partial' * @param {string} [params.mmp] *option only* market maker protection - * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'above' or 'below' + * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'ascending' or 'descending' * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at * @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at * @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at @@ -100160,7 +100199,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" const isTakeProfit = takeProfitPrice !== undefined; const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params, enableUnifiedAccount); let defaultMethod = undefined; - if (isTrailingAmountOrder || isStopLoss || isTakeProfit) { + if ((isTrailingAmountOrder || isStopLoss || isTakeProfit) && !market['spot']) { defaultMethod = 'privatePostV5PositionTradingStop'; } else { @@ -100241,7 +100280,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" const isLimit = lowerCaseType === 'limit'; const isBuy = side === 'buy'; let defaultMethod = undefined; - if (isTrailingAmountOrder || isStopLossTriggerOrder || isTakeProfitTriggerOrder) { + if ((isTrailingAmountOrder || isStopLossTriggerOrder || isTakeProfitTriggerOrder) && !market['spot']) { defaultMethod = 'privatePostV5PositionTradingStop'; } else { @@ -100390,9 +100429,9 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" } else { if (triggerDirection === undefined) { - throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' stop/trigger orders require a triggerDirection parameter, either "above" or "below" to determine the direction of the trigger.'); + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' stop/trigger orders require a triggerDirection parameter, either "ascending" or "descending" to determine the direction of the trigger.'); } - const isAsending = ((triggerDirection === 'above') || (triggerDirection === '1')); + const isAsending = ((triggerDirection === 'ascending') || (triggerDirection === 'above') || (triggerDirection === '1')); request['triggerDirection'] = isAsending ? 1 : 2; } request['triggerPrice'] = this.getPrice(symbol, triggerPrice); @@ -101077,7 +101116,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" const result = this.safeDict(response, 'result', {}); const orders = this.safeList(result, 'list'); if (!Array.isArray(orders)) { - return response; + return [this.safeOrder({ 'info': response })]; } return this.parseOrders(orders, market); } @@ -102804,12 +102843,14 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" } let collateralString = this.safeString(position, 'positionBalance'); const entryPrice = this.omitZero(this.safeStringN(position, ['entryPrice', 'avgPrice', 'avgEntryPrice'])); + const markPrice = this.safeString(position, 'markPrice'); const liquidationPrice = this.omitZero(this.safeString(position, 'liqPrice')); const leverage = this.safeString(position, 'leverage'); if (liquidationPrice !== undefined) { if (market['settle'] === 'USDC') { // (Entry price - Liq price) * Contracts + Maintenance Margin + (unrealised pnl) = Collateral - const difference = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringAbs(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringSub(entryPrice, liquidationPrice)); + const price = this.safeBool(this.options, 'useMarkPriceForPositionCollateral', false) ? markPrice : entryPrice; + const difference = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringAbs(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringSub(price, liquidationPrice)); collateralString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringAdd(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringAdd(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(difference, size), maintenanceMarginString), unrealisedPnl); } else { @@ -102865,7 +102906,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'contractSize': this.safeNumber(market, 'contractSize'), 'marginRatio': this.parseNumber(marginRatio), 'liquidationPrice': this.parseNumber(liquidationPrice), - 'markPrice': this.safeNumber(position, 'markPrice'), + 'markPrice': this.parseNumber(markPrice), 'lastPrice': this.safeNumber(position, 'avgExitPrice'), 'collateral': this.parseNumber(collateralString), 'marginMode': marginMode, @@ -104760,7 +104801,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'timestamp': timestamp, 'datetime': this.iso8601(timestamp), 'id': this.safeString(income, 'execId'), - 'amount': this.safeNumber(income, 'execQty'), + 'amount': this.safeNumber(income, 'execFee'), 'rate': this.safeNumber(income, 'feeRate'), }; } @@ -107471,6 +107512,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelOrder': true, 'cancelOrders': true, 'closeAllPositions': false, @@ -107485,6 +107529,8 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'createMarketSellOrder': true, 'createMarketSellOrderWithCost': false, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, 'createPostOnlyOrder': true, 'createReduceOnlyOrder': false, 'createStopLimitOrder': true, @@ -107495,8 +107541,12 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'fetchAccounts': true, 'fetchBalance': true, 'fetchBidsAsks': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCanceledOrders': true, 'fetchClosedOrders': true, 'fetchConvertQuote': true, @@ -107514,42 +107564,69 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'fetchDeposits': true, 'fetchDepositsWithdrawals': true, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchL2OrderBook': false, 'fetchLedger': true, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, 'fetchMyBuys': true, + 'fetchMyLiquidations': false, 'fetchMySells': true, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, 'fetchOHLCV': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, 'fetchPosition': true, + 'fetchPositionHistory': false, 'fetchPositionMode': false, 'fetchPositions': true, + 'fetchPositionsForSymbol': false, + 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTime': true, 'fetchTrades': true, 'fetchTradingFee': 'emulated', 'fetchTradingFees': true, + 'fetchVolatilityHistory': false, 'fetchWithdrawals': true, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'setLeverage': false, + 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'withdraw': true, @@ -107753,12 +107830,14 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'rate_limit_exceeded': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded, 'internal_server_error': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, 'UNSUPPORTED_ORDER_CONFIGURATION': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, - 'INSUFFICIENT_FUND': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + 'INSUFFICIENT_FUND': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds, 'PERMISSION_DENIED': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied, 'INVALID_ARGUMENT': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, 'PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + 'PREVIEW_INSUFFICIENT_FUND': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds, }, 'broad': { + 'Insufficient balance in source account': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds, 'request timestamp expired': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidNonce, 'order with this orderID was not found': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound, // {"error":"unknown","error_details":"order with this orderID was not found","message":"order with this orderID was not found"} }, @@ -112661,31 +112740,73 @@ class coinbaseexchange extends _abstract_coinbaseexchange_js__WEBPACK_IMPORTED_M 'swap': false, 'future': false, 'option': false, + 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelAllOrders': true, 'cancelOrder': true, + 'closeAllPositions': false, + 'closePosition': false, 'createDepositAddress': true, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'createStopLimitOrder': true, 'createStopMarketOrder': true, 'createStopOrder': true, 'fetchAccounts': true, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, + 'fetchBorrowRateHistories': false, + 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchClosedOrders': true, + 'fetchCrossBorrowRate': false, + 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': false, 'fetchDeposits': true, 'fetchDepositsWithdrawals': true, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, + 'fetchIndexOHLCV': false, + 'fetchIsolatedBorrowRate': false, + 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLedger': true, + 'fetchLeverage': false, + 'fetchLeverages': false, + 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, + 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, 'fetchOHLCV': true, + 'fetchOpenInterest': false, + 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, @@ -112697,6 +112818,8 @@ class coinbaseexchange extends _abstract_coinbaseexchange_js__WEBPACK_IMPORTED_M 'fetchPositionsForSymbol': false, 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, + 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTime': true, @@ -112704,7 +112827,16 @@ class coinbaseexchange extends _abstract_coinbaseexchange_js__WEBPACK_IMPORTED_M 'fetchTradingFee': false, 'fetchTradingFees': true, 'fetchTransactions': 'emulated', + 'fetchVolatilityHistory': false, 'fetchWithdrawals': true, + 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, + 'setLeverage': false, + 'setMargin': false, + 'setMarginMode': false, + 'setPositionMode': false, 'withdraw': true, }, 'timeframes': { @@ -114165,7 +114297,8 @@ class coinbaseexchange extends _abstract_coinbaseexchange_js__WEBPACK_IMPORTED_M market = this.market(symbol); request['product_id'] = market['symbol']; // the request will be more performant if you include it } - return await this[method](this.extend(request, params)); + const response = await this[method](this.extend(request, params)); + return this.safeOrder({ 'info': response }); } /** * @method @@ -114184,7 +114317,8 @@ class coinbaseexchange extends _abstract_coinbaseexchange_js__WEBPACK_IMPORTED_M market = this.market(symbol); request['product_id'] = market['symbol']; // the request will be more performant if you include it } - return await this.privateDeleteOrders(this.extend(request, params)); + const response = await this.privateDeleteOrders(this.extend(request, params)); + return [this.safeOrder({ 'info': response })]; } async fetchPaymentMethods(params = {}) { return await this.privateGetPaymentMethods(params); @@ -122585,30 +122719,59 @@ class coincheck extends _abstract_coincheck_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelOrder': true, 'closeAllPositions': false, 'closePosition': false, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, 'fetchDeposits': true, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLeverage': false, + 'fetchLeverages': false, + 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrderBook': true, 'fetchPosition': false, 'fetchPositionHistory': false, @@ -122618,13 +122781,19 @@ class coincheck extends _abstract_coincheck_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTrades': true, 'fetchTradingFee': false, 'fetchTradingFees': true, + 'fetchVolatilityHistory': false, 'fetchWithdrawals': true, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'setLeverage': false, + 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'ws': true, @@ -129634,32 +129803,60 @@ class coinmate extends _abstract_coinmate_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelOrder': true, 'closeAllPositions': false, 'closePosition': false, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, 'fetchDepositsWithdrawals': true, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, @@ -129671,14 +129868,20 @@ class coinmate extends _abstract_coinmate_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, 'fetchTradingFee': true, 'fetchTradingFees': false, 'fetchTransactions': 'emulated', + 'fetchVolatilityHistory': false, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'setLeverage': false, + 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'transfer': false, @@ -131006,6 +131209,7 @@ class coinmetro extends _abstract_coinmetro_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'options': { 'currenciesByIdForParseMarket': undefined, 'currencyIdsListForParseMarket': ['QRDO'], + 'skippedMarkets': ['VXVUSDT'], // broken markets which do not have enough info in API }, 'features': { 'spot': { @@ -131231,10 +131435,13 @@ class coinmetro extends _abstract_coinmetro_js__WEBPACK_IMPORTED_MODULE_0__/* [" * @returns {object[]} an array of objects representing market data */ async fetchMarkets(params = {}) { - const response = await this.publicGetMarkets(params); + const promises = []; + promises.push(this.publicGetMarkets(params)); if (this.safeValue(this.options, 'currenciesByIdForParseMarket') === undefined) { - await this.fetchCurrencies(); + promises.push(this.fetchCurrencies()); } + const responses = await Promise.all(promises); + const response = responses[0]; // // [ // { @@ -131250,7 +131457,16 @@ class coinmetro extends _abstract_coinmetro_js__WEBPACK_IMPORTED_MODULE_0__/* [" // ... // ] // - return this.parseMarkets(response); + const skippedMarkets = this.safeList(this.options, 'skippedMarkets', []); + const result = []; + for (let i = 0; i < response.length; i++) { + const market = this.parseMarket(response[i]); + if (this.inArray(market['id'], skippedMarkets)) { + continue; + } + result.push(market); + } + return result; } parseMarket(market) { const id = this.safeString(market, 'pair'); @@ -132846,18 +133062,28 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelOrder': true, 'closeAllPositions': false, 'closePosition': false, 'createMarketOrder': false, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'createStopLimitOrder': false, 'createStopMarketOrder': false, 'createStopOrder': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchClosedOrders': false, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, @@ -132866,20 +133092,38 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchDepositAddresses': true, 'fetchDepositAddressesByNetwork': false, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchPosition': false, @@ -132890,11 +133134,17 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, + 'fetchVolatilityHistory': false, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'setLeverage': false, + 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'ws': true, @@ -134098,6 +134348,9 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelAllOrders': true, 'cancelOrder': true, 'cancelOrders': false, @@ -134108,6 +134361,8 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'createMarketOrderWithCost': false, 'createMarketSellOrderWithCost': false, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'createStopLimitOrder': true, @@ -134119,8 +134374,11 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchBalance': true, 'fetchBidsAsks': false, 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCanceledOrders': false, 'fetchClosedOrder': false, 'fetchClosedOrders': true, @@ -134135,24 +134393,42 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchDepositWithdrawFee': false, 'fetchDepositWithdrawFees': false, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchL3OrderBook': false, 'fetchLedger': false, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, + 'fetchMarginMode': false, + 'fetchMarginModes': false, 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, 'fetchOHLCV': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrder': undefined, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrderBooks': false, @@ -134166,6 +134442,7 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, @@ -134178,12 +134455,14 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchTransactionFees': false, 'fetchTransactions': false, 'fetchTransfers': false, + 'fetchVolatilityHistory': false, 'fetchWithdrawal': undefined, 'fetchWithdrawals': true, 'fetchWithdrawalWhitelist': false, 'reduceMargin': false, 'repayCrossMargin': false, 'repayIsolatedMargin': false, + 'repayMargin': false, 'setLeverage': false, 'setMargin': false, 'setMarginMode': false, @@ -136281,33 +136560,61 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelOrder': true, 'closeAllPositions': false, 'closePosition': false, 'createMarketOrder': false, 'createOrder': true, + 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'createStopLimitOrder': false, 'createStopMarketOrder': false, 'createStopOrder': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, + 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrderBook': true, 'fetchPosition': false, 'fetchPositionHistory': false, @@ -136317,13 +136624,19 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'fetchPositionsHistory': false, 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTrades': true, 'fetchTradingFee': false, 'fetchTradingFees': false, + 'fetchVolatilityHistory': false, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'setLeverage': false, + 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'ws': false, @@ -136815,7 +137128,8 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de 'amount': amount, 'rate': price, }; - return await this[method](this.extend(request, params)); + const response = await this[method](this.extend(request, params)); + return this.parseOrder(response); } /** * @method @@ -138603,7 +138917,8 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* [" market = this.market(symbol); request['instrument_name'] = market['id']; } - return await this.v1PrivatePostPrivateCancelAllOrders(this.extend(request, params)); + const response = await this.v1PrivatePostPrivateCancelAllOrders(this.extend(request, params)); + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -140391,11 +140706,15 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelAllOrders': false, 'cancelAllOrdersAfter': false, 'cancelOrder': true, 'cancelOrders': false, 'cancelWithdraw': false, + 'closeAllPositions': false, 'closePosition': false, 'createConvertTrade': false, 'createDepositAddress': false, @@ -140405,6 +140724,8 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'createMarketSellOrderWithCost': false, 'createOrder': true, 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'createStopLimitOrder': false, 'createStopLossOrder': false, @@ -140416,6 +140737,12 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'createTriggerOrder': false, 'fetchAccounts': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, + 'fetchBorrowRateHistories': false, + 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCanceledAndClosedOrders': true, 'fetchCanceledOrders': false, 'fetchClosedOrder': false, @@ -140424,27 +140751,48 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'fetchConvertQuote': false, 'fetchConvertTrade': false, 'fetchConvertTradeHistory': false, + 'fetchCrossBorrowRate': false, + 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': false, 'fetchDeposits': false, 'fetchDepositsWithdrawals': false, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, + 'fetchIsolatedBorrowRate': false, + 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLedger': false, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': false, 'fetchOHLCV': false, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrder': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': false, @@ -140455,7 +140803,9 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'fetchPositions': false, 'fetchPositionsForSymbol': false, 'fetchPositionsHistory': false, + 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchStatus': false, 'fetchTicker': false, 'fetchTickers': true, @@ -140465,11 +140815,16 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'fetchTradingFees': true, 'fetchTransactions': false, 'fetchTransfers': false, + 'fetchVolatilityHistory': false, 'fetchWithdrawals': false, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'sandbox': false, 'setLeverage': false, 'setMargin': false, + 'setMarginMode': false, 'setPositionMode': false, 'transfer': false, 'withdraw': false, @@ -141083,7 +141438,7 @@ class cryptomus extends _abstract_cryptomus_js__WEBPACK_IMPORTED_MODULE_0__/* [" // "success": true // } // - return response; + return this.safeOrder({ 'info': response }); } /** * @method @@ -142988,7 +143343,7 @@ class defx extends _abstract_defx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // } // } // - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -150002,21 +150357,21 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa const unrealizedPnl = this.safeString(position, 'floating_profit_loss'); const initialMarginString = this.safeString(position, 'initial_margin'); const notionalString = this.safeString(position, 'size_currency'); + const notionalStringAbs = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringAbs(notionalString); const maintenanceMarginString = this.safeString(position, 'maintenance_margin'); - const currentTime = this.milliseconds(); return this.safePosition({ 'info': position, 'id': undefined, 'symbol': this.safeString(market, 'symbol'), - 'timestamp': currentTime, - 'datetime': this.iso8601(currentTime), + 'timestamp': undefined, + 'datetime': undefined, 'lastUpdateTimestamp': undefined, 'initialMargin': this.parseNumber(initialMarginString), - 'initialMarginPercentage': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(initialMarginString, notionalString), '100')), + 'initialMarginPercentage': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(initialMarginString, notionalStringAbs), '100')), 'maintenanceMargin': this.parseNumber(maintenanceMarginString), - 'maintenanceMarginPercentage': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(maintenanceMarginString, notionalString), '100')), + 'maintenanceMarginPercentage': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(maintenanceMarginString, notionalStringAbs), '100')), 'entryPrice': this.safeNumber(position, 'average_price'), - 'notional': this.parseNumber(notionalString), + 'notional': this.parseNumber(notionalStringAbs), 'leverage': this.safeInteger(position, 'leverage'), 'unrealizedPnl': this.parseNumber(unrealizedPnl), 'contracts': undefined, @@ -152772,7 +153127,7 @@ class derive extends _abstract_derive_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // "result": "ok" // } // - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -158272,11 +158627,15 @@ class ellipx extends _abstract_ellipx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelAllOrders': false, 'cancelAllOrdersAfter': false, 'cancelOrder': true, 'cancelOrders': false, 'cancelWithdraw': false, + 'closeAllPositions': false, 'closePosition': false, 'createConvertTrade': false, 'createDepositAddress': false, @@ -158286,6 +158645,8 @@ class ellipx extends _abstract_ellipx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'createMarketSellOrderWithCost': false, 'createOrder': true, 'createOrderWithTakeProfitAndStopLoss': false, + 'createOrderWithTakeProfitAndStopLossWs': false, + 'createPostOnlyOrder': false, 'createReduceOnlyOrder': false, 'createStopLimitOrder': false, 'createStopLossOrder': false, @@ -158297,6 +158658,12 @@ class ellipx extends _abstract_ellipx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'createTriggerOrder': false, 'fetchAccounts': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, + 'fetchBorrowRateHistories': false, + 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCanceledAndClosedOrders': false, 'fetchCanceledOrders': false, 'fetchClosedOrder': false, @@ -158305,27 +158672,48 @@ class ellipx extends _abstract_ellipx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'fetchConvertQuote': false, 'fetchConvertTrade': false, 'fetchConvertTradeHistory': false, + 'fetchCrossBorrowRate': false, + 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': true, 'fetchDeposits': false, 'fetchDepositsWithdrawals': false, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': false, 'fetchFundingRateHistory': false, 'fetchFundingRates': false, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, + 'fetchIsolatedBorrowRate': false, + 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLedger': false, 'fetchLeverage': false, + 'fetchLeverages': false, 'fetchLeverageTiers': false, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, + 'fetchMarketLeverageTiers': false, 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': false, 'fetchOHLCV': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrder': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, @@ -158336,7 +158724,9 @@ class ellipx extends _abstract_ellipx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'fetchPositions': false, 'fetchPositionsForSymbol': false, 'fetchPositionsHistory': false, + 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchStatus': false, 'fetchTicker': true, 'fetchTickers': false, @@ -158346,11 +158736,16 @@ class ellipx extends _abstract_ellipx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul 'fetchTradingFees': false, 'fetchTransactions': false, 'fetchTransfers': false, + 'fetchVolatilityHistory': false, 'fetchWithdrawals': false, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, + 'repayMargin': false, 'sandbox': false, 'setLeverage': false, 'setMargin': false, + 'setMarginMode': false, 'setPositionMode': false, 'transfer': false, 'withdraw': true, @@ -163142,6 +163537,2031 @@ class fmfwio extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A } +/***/ }), + +/***/ 448: +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ A: () => (/* binding */ foxbit) +/* harmony export */ }); +/* harmony import */ var _ccxt_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5147); +/* harmony import */ var _abstract_foxbit_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2597); +/* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2079); +/* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1579); +/* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4852); +// --------------------------------------------------------------------------- + + + + + +// --------------------------------------------------------------------------- +/** + * @class foxbit + * @augments Exchange + */ +class foxbit extends _abstract_foxbit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { + describe() { + return this.deepExtend(super.describe(), { + 'id': 'foxbit', + 'name': 'Foxbit', + 'countries': ['pt-BR'], + // 300 requests per 10 seconds = 30 requests per second + // rateLimit = 1000 ms / 30 requests ~= 33.334 + 'rateLimit': 33.334, + 'version': '1', + 'comment': 'Foxbit Exchange', + 'certified': false, + 'pro': false, + 'has': { + 'CORS': true, + 'spot': true, + 'margin': undefined, + 'swap': undefined, + 'future': undefined, + 'option': undefined, + 'cancelAllOrders': true, + 'cancelOrder': true, + 'createLimitBuyOrder': true, + 'createLimitSellOrder': true, + 'createMarketBuyOrder': true, + 'createMarketSellOrder': true, + 'createOrder': true, + 'fecthOrderBook': true, + 'fetchBalance': true, + 'fetchCanceledOrders': true, + 'fetchClosedOrders': true, + 'fetchCurrencies': true, + 'fetchDepositAddress': true, + 'fetchDeposits': true, + 'fetchL2OrderBook': true, + 'fetchLedger': true, + 'fetchMarkets': true, + 'fetchMyTrades': true, + 'fetchOHLCV': true, + 'fetchOpenOrders': true, + 'fetchOrder': true, + 'fetchOrders': true, + 'fetchTicker': true, + 'fetchTickers': true, + 'fetchTrades': true, + 'fetchTradingFee': true, + 'fetchTradingFees': true, + 'fetchTransactions': true, + 'fetchWithdrawals': true, + 'loadMarkets': true, + 'sandbox': false, + 'withdraw': true, + 'ws': false, + }, + '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/ba1435eb-1d59-4393-8de7-0db10a002fb3', + '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': _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__/* .DECIMAL_PLACES */ .fv, + 'exceptions': { + 'exact': { + // https://docs.foxbit.com.br/rest/v3/#tag/API-Codes/Errors + '400': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + '429': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded, + '404': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + '500': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, + '2001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError, + '2002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError, + '2003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError, + '2004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + '2005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied, + '3001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied, + '3002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied, + '3003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AccountSuspended, + '4001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + '4002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds, + '4003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + '4004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol, + '4005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest, + '4007': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, + '4008': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + '4009': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied, + '4011': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded, + '4012': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, + '5001': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeNotAvailable, + '5002': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OnMaintenance, + '5003': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OnMaintenance, + '5004': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + '5005': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, + '5006': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder, // Significant price deviation detected, exceeding acceptable limits. The order price is exceeding acceptable limits from market to complete your request. + }, + 'broad': { + // todo: add details messages that can be usefull here, like when market is not found + }, + }, + 'requiredCredentials': { + 'apiKey': true, + 'secret': true, + }, + '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, // 4 requests per 2 seconds + }, + }, + '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, // 1 requests per 2 seconds + }, + 'post': { + 'orders': 2, + 'orders/batch': 7.5, + 'orders/cancel-replace': 3, + 'withdrawals': 10, // 3 requests per second + }, + 'put': { + 'orders/cancel': 2, // 30 requests per 2 seconds + }, + }, + }, + 'status': { + 'public': { + 'get': { + 'status': 30, // 1 request per second + }, + }, + }, + }, + 'fees': { + 'trading': { + 'feeSide': 'get', + 'tierBased': false, + 'percentage': true, + 'taker': this.parseNumber('0.005'), + 'maker': this.parseNumber('0.0025'), + }, + }, + 'options': { + 'sandboxMode': false, + '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': false, + 'createOrder': { + 'marginMode': false, + 'triggerPrice': true, + 'triggerPriceType': { + 'last': true, + 'mark': false, + 'index': false, + }, + 'triggerDirection': false, + 'stopLossPrice': false, + 'takeProfitPrice': false, + 'attachedStopLossTakeProfit': undefined, + 'timeInForce': { + 'GTC': true, + 'FOK': true, + 'IOC': true, + 'PO': true, + 'GTD': false, + }, + 'hedged': false, + 'leverage': false, + 'marketBuyByCost': false, + 'marketBuyRequiresPrice': false, + 'selfTradePrevention': { + 'expire_maker': true, + 'expire_taker': true, + 'expire_both': true, + 'none': true, // foxbit prevents self trading by default, no params can change this + }, + 'trailing': false, + 'icebergAmount': false, + }, + 'createOrders': { + 'max': 5, + }, + 'fetchMyTrades': { + 'marginMode': false, + 'limit': 100, + 'daysBack': 90, + 'untilDays': 10000, + 'symbolRequired': true, + }, + 'fetchOrder': { + 'marginMode': false, + 'limit': 1, + 'daysBack': 90, + 'trigger': false, + 'trailing': false, + 'symbolRequired': false, + }, + 'fetchOpenOrders': { + 'marginMode': false, + 'limit': 100, + 'daysBack': 90, + 'trigger': false, + 'trailing': false, + 'symbolRequired': false, + }, + 'fetchOrders': { + 'marginMode': true, + 'limit': 100, + 'daysBack': 90, + 'untilDays': 10000, + 'trigger': false, + 'trailing': false, + 'symbolRequired': false, + }, + 'fetchClosedOrders': { + 'marginMode': true, + 'limit': 100, + 'daysBack': 90, + 'daysBackCanceled': 90, + 'untilDays': 10000, + 'trigger': false, + 'trailing': false, + 'symbolRequired': false, + }, + 'fetchOHLCV': { + 'limit': 500, + }, + }, + }, + }); + } + async fetchCurrencies(params = {}) { + const response = await this.v3PublicGetCurrencies(params); + // { + // "data": [ + // { + // "symbol": "btc", + // "name": "Bitcoin", + // "type": "CRYPTO", + // "precision": 8, + // "deposit_info": { + // "min_to_confirm": "1", + // "min_amount": "0.0001" + // }, + // "withdraw_info": { + // "enabled": true, + // "min_amount": "0.0001", + // "fee": "0.0001" + // }, + // "category": { + // "code": "cripto", + // "name": "Cripto" + // }, + // "networks": [ + // { + // "name": "Bitcoin", + // "code": "btc", + // "deposit_info": { + // status: "ENABLED", + // }, + // "withdraw_info": { + // "status": "ENABLED", + // "fee": "0.0001", + // }, + // "has_destination_tag": false + // } + // ] + // } + // ] + // } + const data = this.safeList(response, 'data', []); + const result = {}; + for (let i = 0; i < data.length; i++) { + const currency = data[i]; + const precision = this.safeInteger(currency, 'precision'); + const currencyId = this.safeString(currency, 'symbol'); + const name = this.safeString(currency, 'name'); + const code = this.safeCurrencyCode(currencyId); + const depositInfo = this.safeDict(currency, 'deposit_info'); + const withdrawInfo = this.safeDict(currency, 'withdraw_info'); + const networks = this.safeList(currency, 'networks', []); + const type = this.safeStringLower(currency, 'type'); + const parsedNetworks = {}; + for (let j = 0; j < networks.length; j++) { + const network = networks[j]; + const networkId = this.safeString(network, 'code'); + const networkCode = this.networkIdToCode(networkId, code); + const networkWithdrawInfo = this.safeDict(network, 'withdraw_info'); + const networkDepositInfo = this.safeDict(network, 'deposit_info'); + const isWithdrawEnabled = this.safeString(networkWithdrawInfo, 'status') === 'ENABLED'; + const isDepositEnabled = this.safeString(networkDepositInfo, 'status') === 'ENABLED'; + parsedNetworks[networkCode] = { + 'info': currency, + 'id': networkId, + 'network': networkCode, + 'name': this.safeString(network, 'name'), + 'deposit': isDepositEnabled, + 'withdraw': isWithdrawEnabled, + 'active': true, + 'precision': precision, + 'fee': this.safeNumber(networkWithdrawInfo, 'fee'), + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'deposit': { + 'min': this.safeNumber(depositInfo, 'min_amount'), + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeNumber(withdrawInfo, 'min_amount'), + 'max': undefined, + }, + }, + }; + } + if (this.safeDict(result, code) === undefined) { + result[code] = this.safeCurrencyStructure({ + 'id': currencyId, + 'code': code, + 'info': currency, + 'name': name, + 'active': true, + 'type': type, + 'deposit': this.safeBool(depositInfo, 'enabled', false), + 'withdraw': this.safeBool(withdrawInfo, 'enabled', false), + 'fee': this.safeNumber(withdrawInfo, 'fee'), + 'precision': precision, + 'limits': { + 'amount': { + 'min': undefined, + 'max': undefined, + }, + 'deposit': { + 'min': this.safeNumber(depositInfo, 'min_amount'), + 'max': undefined, + }, + 'withdraw': { + 'min': this.safeNumber(withdrawInfo, 'min_amount'), + 'max': undefined, + }, + }, + 'networks': parsedNetworks, + }); + } + } + return result; + } + /** + * @method + * @name foxbit#fetchMarkets + * @description Retrieves data on all markets for foxbit. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_index + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} an array of objects representing market data + */ + async fetchMarkets(params = {}) { + const response = await this.v3PublicGetMarkets(params); + // { + // "data": [ + // { + // "symbol": "btcbrl", + // "quantity_min": "0.00000236", + // "quantity_increment": "0.00000001", + // "quantity_precision": 8, + // "price_min": "0.0001", + // "price_increment": "0.0001", + // "price_precision": 4, + // "default_fees": { + // "maker": "0.001", + // "taker": "0.001" + // }, + // "base": { + // "symbol": "btc", + // "name": "Bitcoin", + // "type": "CRYPTO", + // "precision": 8, + // "category": { + // "code": "cripto", + // "name": "Cripto" + // }, + // "deposit_info": { + // "min_to_confirm": "1", + // "min_amount": "0.0001", + // "enabled": true + // }, + // "withdraw_info": { + // "enabled": true, + // "min_amount": "0.0001", + // "fee": "0.0001" + // }, + // "networks": [ + // { + // "name": "Bitcoin", + // "code": "bitcoin", + // "deposit_info": { + // "status": "ENABLED" + // }, + // "withdraw_info": { + // "status": "ENABLED", + // "fee": "0.0001" + // }, + // "has_destination_tag": false + // } + // ], + // "default_network_code": "bitcoin" + // }, + // "quote": { + // "symbol": "btc", + // "name": "Bitcoin", + // "type": "CRYPTO", + // "precision": 8, + // "category": { + // "code": "cripto", + // "name": "Cripto" + // }, + // "deposit_info": { + // "min_to_confirm": "1", + // "min_amount": "0.0001", + // "enabled": true + // }, + // "withdraw_info": { + // "enabled": true, + // "min_amount": "0.0001", + // "fee": "0.0001" + // }, + // "networks": [ + // { + // "name": "Bitcoin", + // "code": "bitcoin", + // "deposit_info": { + // "status": "ENABLED" + // }, + // "withdraw_info": { + // "status": "ENABLED", + // "fee": "0.0001" + // }, + // "has_destination_tag": false + // } + // ], + // "default_network_code": "bitcoin" + // }, + // "order_type": [ + // "LIMIT", + // "MARKET", + // "INSTANT", + // "STOP_LIMIT", + // "STOP_MARKET" + // ] + // } + // ] + // } + const markets = this.safeList(response, 'data', []); + return this.parseMarkets(markets); + } + /** + * @method + * @name foxbit#fetchTicker + * @description Get last 24 hours ticker information, in real-time, for given market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_ticker + * @param {string} symbol unified symbol of the market to fetch the ticker for + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure} + */ + async fetchTicker(symbol, params = {}) { + await this.loadMarkets(); + const market = this.market(symbol); + const request = { + 'market': market['id'], + }; + const response = await this.v3PublicGetMarketsMarketTicker24hr(this.extend(request, params)); + // { + // "data": [ + // { + // "market_symbol": "btcbrl", + // "last_trade": { + // "price": "358504.69340000", + // "volume": "0.00027893", + // "date": "2024-01-01T00:00:00.000Z" + // }, + // "rolling_24h": { + // "price_change": "3211.87290000", + // "price_change_percent": "0.90400726", + // "volume": "20.03206866", + // "trades_count": "4376", + // "open": "355292.82050000", + // "high": "362999.99990000", + // "low": "355002.88880000" + // }, + // "best": { + // "ask": { + // "price": "358504.69340000", + // "volume": "0.00027893" + // }, + // "bid": { + // "price": "358504.69340000", + // "volume": "0.00027893" + // } + // } + // } + // ] + // } + const data = this.safeList(response, 'data', []); + const result = this.safeDict(data, 0, {}); + return this.parseTicker(result, market); + } + /** + * @method + * @name foxbit#fetchTickers + * @description Retrieve the ticker data of all markets. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_tickers + * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure} + */ + async fetchTickers(symbols = undefined, params = {}) { + await this.loadMarkets(); + symbols = this.marketSymbols(symbols); + const response = await this.v3PublicGetMarketsTicker24hr(params); + // { + // "data": [ + // { + // "market_symbol": "btcbrl", + // "last_trade": { + // "price": "358504.69340000", + // "volume": "0.00027893", + // "date": "2024-01-01T00:00:00.000Z" + // }, + // "rolling_24h": { + // "price_change": "3211.87290000", + // "price_change_percent": "0.90400726", + // "volume": "20.03206866", + // "trades_count": "4376", + // "open": "355292.82050000", + // "high": "362999.99990000", + // "low": "355002.88880000" + // }, + // } + // ] + // } + const data = this.safeList(response, 'data', []); + return this.parseTickers(data, symbols); + } + /** + * @method + * @name foxbit#fetchTradingFees + * @description fetch the trading fees for multiple markets + * @see https://docs.foxbit.com.br/rest/v3/#tag/Member-Info/operation/MembersController_listTradingFees + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols + */ + async fetchTradingFees(params = {}) { + await this.loadMarkets(); + const response = await this.v3PrivateGetMeFeesTrading(params); + // [ + // { + // "market_symbol": "btcbrl", + // "maker": "0.0025", + // "taker": "0.005" + // } + // ] + const data = this.safeList(response, 'data', []); + const result = {}; + for (let i = 0; i < data.length; i++) { + const entry = data[i]; + const marketId = this.safeString(entry, 'market_symbol'); + const market = this.safeMarket(marketId); + const symbol = market['symbol']; + result[symbol] = this.parseTradingFee(entry, market); + } + return result; + } + /** + * @method + * @name foxbit#fetchOrderBook + * @description Exports a copy of the order book of a specific market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_findOrderbook + * @param {string} symbol unified symbol of the market to fetch the order book for + * @param {int} [limit] the maximum amount of order book entries to return, the maximum is 100 + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols + */ + async fetchOrderBook(symbol, limit = undefined, params = {}) { + await this.loadMarkets(); + const market = this.market(symbol); + const defaultLimit = 20; + const request = { + 'market': market['id'], + 'depth': (limit === undefined) ? defaultLimit : limit, + }; + const response = await this.v3PublicGetMarketsMarketOrderbook(this.extend(request, params)); + // { + // "sequence_id": 1234567890, + // "timestamp": 1713187921336, + // "bids": [ + // [ + // "3.00000000", + // "300.00000000" + // ], + // [ + // "1.70000000", + // "310.00000000" + // ] + // ], + // "asks": [ + // [ + // "3.00000000", + // "300.00000000" + // ], + // [ + // "2.00000000", + // "321.00000000" + // ] + // ] + // } + const timestamp = this.safeInteger(response, 'timestamp'); + return this.parseOrderBook(response, symbol, timestamp); + } + /** + * @method + * @name foxbit#fetchTrades + * @description Retrieve the trades of a specific market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_publicTrades + * @param {string} symbol unified symbol of the market to fetch trades for + * @param {int} [since] timestamp in ms of the earliest trade to fetch + * @param {int} [limit] the maximum amount of trades to fetch + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades} + */ + async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + const market = this.market(symbol); + const request = { + 'market': market['id'], + }; + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 200) { + request['page_size'] = 200; + } + } + // [ + // { + // "id": 1, + // "price": "329248.74700000", + // "volume": "0.00100000", + // "taker_side": "BUY", + // "created_at": "2024-01-01T00:00:00Z" + // } + // ] + const response = await this.v3PublicGetMarketsMarketTradesHistory(this.extend(request, params)); + const data = this.safeList(response, 'data', []); + return this.parseTrades(data, market, since, limit); + } + /** + * @method + * @name foxbit#fetchOHLCV + * @description Fetch historical candlestick data containing the open, high, low, and close price, and the volume of a market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Market-Data/operation/MarketsController_findCandlesticks + * @param {string} symbol unified symbol of the market to fetch OHLCV data for + * @param {string} timeframe the length of time each candle represents + * @param {int} [since] timestamp in ms of the earliest candle to fetch + * @param {int} [limit] the maximum amount of candles to fetch + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume + */ + async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + const market = this.market(symbol); + const interval = this.safeString(this.timeframes, timeframe, timeframe); + const request = { + 'market': market['id'], + 'interval': interval, + }; + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + if (limit !== undefined) { + request['limit'] = limit; + if (limit > 500) { + request['limit'] = 500; + } + } + const response = await this.v3PublicGetMarketsMarketCandlesticks(this.extend(request, params)); + // [ + // [ + // "1692918000000", // timestamp + // "127772.05150000", // open + // "128467.99980000", // high + // "127750.01000000", // low + // "128353.99990000", // close + // "1692918060000", // close timestamp + // "0.17080431", // base volume + // "21866.35948786", // quote volume + // 66, // number of trades + // "0.12073605", // taker buy base volume + // "15466.34096391" // taker buy quote volume + // ] + // ] + return this.parseOHLCVs(response, market, interval, since, limit); + } + /** + * @method + * @name foxbit#fetchBalance + * @description Query for balance and get the amount of funds available for trading or funds locked in orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Account/operation/AccountsController_all + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} + */ + async fetchBalance(params = {}) { + await this.loadMarkets(); + const response = await this.v3PrivateGetAccounts(params); + // { + // "data": [ + // { + // "currency_symbol": "btc", + // "balance": "10000.0", + // "balance_available": "9000.0", + // "balance_locked": "1000.0" + // } + // ] + // } + const accounts = this.safeList(response, 'data', []); + const result = { + 'info': response, + }; + for (let i = 0; i < accounts.length; i++) { + const account = accounts[i]; + const currencyId = this.safeString(account, 'currency_symbol'); + const currencyCode = this.safeCurrencyCode(currencyId); + const total = this.safeString(account, 'balance'); + const used = this.safeString(account, 'balance_locked'); + const free = this.safeString(account, 'balance_available'); + const balanceObj = { + 'free': free, + 'used': used, + 'total': total, + }; + result[currencyCode] = balanceObj; + } + return this.safeBalance(result); + } + /** + * @method + * @name foxbit#fetchOpenOrders + * @description Fetch all unfilled currently open orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders + * @param {string} symbol unified market symbol + * @param {int} [since] the earliest time in ms to fetch open orders for + * @param {int} [limit] the maximum number of open order structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersByStatus('ACTIVE', symbol, since, limit, params); + } + /** + * @method + * @name foxbit#fetchClosedOrders + * @description Fetch all currently closed orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders + * @param {string} symbol unified market symbol of the market orders were made in + * @param {int} [since] the earliest time in ms to fetch orders for + * @param {int} [limit] the maximum number of order structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersByStatus('FILLED', symbol, since, limit, params); + } + async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { + return await this.fetchOrdersByStatus('CANCELED', symbol, since, limit, params); + } + async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + let market = undefined; + const request = { + 'state': status, + }; + if (symbol !== undefined) { + market = this.market(symbol); + request['market_symbol'] = market['id']; + } + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 100) { + request['page_size'] = 100; + } + } + const response = await this.v3PrivateGetOrders(this.extend(request, params)); + const data = this.safeList(response, 'data', []); + return this.parseOrders(data); + } + /** + * @method + * @name foxbit#createOrder + * @description Create an order with the specified characteristics + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_create + * @param {string} symbol unified symbol of the market to create an order in + * @param {string} type 'market', 'limit', 'stop_market', 'stop_limit', 'instant' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much you want to trade in units of the base currency + * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.timeInForce] "GTC", "FOK", "IOC", "PO" + * @param {float} [params.triggerPrice] The time in force for the order. One of GTC, FOK, IOC, PO. See .features or foxbit's doc to see more details. + * @param {bool} [params.postOnly] true or false whether the order is post-only + * @param {string} [params.clientOrderId] a unique identifier for the order + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async createOrder(symbol, type, side, amount, price = undefined, params = {}) { + await this.loadMarkets(); + const market = this.market(symbol); + type = type.toUpperCase(); + if (type !== 'LIMIT' && type !== 'MARKET' && type !== 'STOP_MARKET' && type !== 'STOP_LIMIT' && type !== 'INSTANT') { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('Invalid order type: ' + type + '. Must be one of: limit, market, stop_market, stop_limit, instant.'); + } + const timeInForce = this.safeStringUpper(params, 'timeInForce'); + const postOnly = this.safeBool(params, 'postOnly', false); + const triggerPrice = this.safeNumber(params, 'triggerPrice'); + const request = { + 'market_symbol': market['id'], + 'side': side.toUpperCase(), + 'type': type, + }; + if (type === 'STOP_MARKET' || type === 'STOP_LIMIT') { + if (triggerPrice === undefined) { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('Invalid order type: ' + type + '. Must have triggerPrice.'); + } + } + if (timeInForce !== undefined) { + if (timeInForce === 'PO') { + request['post_only'] = true; + } + else { + request['time_in_force'] = timeInForce; + } + } + if (postOnly) { + request['post_only'] = true; + } + if (triggerPrice !== undefined) { + request['stop_price'] = this.priceToPrecision(symbol, triggerPrice); + } + if (type === 'INSTANT') { + request['amount'] = this.priceToPrecision(symbol, amount); + } + else { + request['quantity'] = this.amountToPrecision(symbol, amount); + } + if (type === 'LIMIT' || type === 'STOP_LIMIT') { + request['price'] = this.priceToPrecision(symbol, price); + } + const clientOrderId = this.safeString(params, 'clientOrderId'); + if (clientOrderId !== undefined) { + request['client_order_id'] = clientOrderId; + } + params = this.omit(params, ['timeInForce', 'postOnly', 'triggerPrice', 'clientOrderId']); + const response = await this.v3PrivatePostOrders(this.extend(request, params)); + // { + // "id": 1234567890, + // "sn": "OKMAKSDHRVVREK", + // "client_order_id": "451637946501" + // } + return this.parseOrder(response, market); + } + /** + * @method + * @name foxbit#createOrders + * @description create a list of trade orders + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/createBatch + * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async createOrders(orders, params = {}) { + await this.loadMarkets(); + const ordersRequests = []; + for (let i = 0; i < orders.length; i++) { + const order = this.safeDict(orders, i); + const symbol = this.safeString(order, 'symbol'); + const market = this.market(symbol); + const type = this.safeStringUpper(order, 'type'); + const orderParams = this.safeDict(order, 'params', {}); + if (type !== 'LIMIT' && type !== 'MARKET' && type !== 'STOP_MARKET' && type !== 'STOP_LIMIT' && type !== 'INSTANT') { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('Invalid order type: ' + type + '. Must be one of: limit, market, stop_market, stop_limit, instant.'); + } + const timeInForce = this.safeStringUpper(orderParams, 'timeInForce'); + const postOnly = this.safeBool(orderParams, 'postOnly', false); + const triggerPrice = this.safeNumber(orderParams, 'triggerPrice'); + const request = { + 'market_symbol': market['id'], + 'side': this.safeStringUpper(order, 'side'), + 'type': type, + }; + if (type === 'STOP_MARKET' || type === 'STOP_LIMIT') { + if (triggerPrice === undefined) { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('Invalid order type: ' + type + '. Must have triggerPrice.'); + } + } + if (timeInForce !== undefined) { + if (timeInForce === 'PO') { + request['post_only'] = true; + } + else { + request['time_in_force'] = timeInForce; + } + delete orderParams['timeInForce']; + } + if (postOnly) { + request['post_only'] = true; + delete orderParams['postOnly']; + } + if (triggerPrice !== undefined) { + request['stop_price'] = this.priceToPrecision(symbol, triggerPrice); + delete orderParams['triggerPrice']; + } + if (type === 'INSTANT') { + request['amount'] = this.priceToPrecision(symbol, this.safeString(order, 'amount')); + } + else { + request['quantity'] = this.amountToPrecision(symbol, this.safeString(order, 'amount')); + } + if (type === 'LIMIT' || type === 'STOP_LIMIT') { + request['price'] = this.priceToPrecision(symbol, this.safeString(order, 'price')); + } + ordersRequests.push(this.extend(request, orderParams)); + } + const createOrdersRequest = { 'data': ordersRequests }; + const response = await this.v3PrivatePostOrdersBatch(this.extend(createOrdersRequest, params)); + // { + // "data": [ + // { + // "side": "BUY", + // "type": "LIMIT", + // "market_symbol": "btcbrl", + // "client_order_id": "451637946501", + // "remark": "A remarkable note for the order.", + // "quantity": "0.42", + // "price": "250000.0", + // "post_only": true, + // "time_in_force": "GTC" + // } + // ] + // } + const data = this.safeList(response, 'data', []); + return this.parseOrders(data); + } + /** + * @method + * @name foxbit#cancelOrder + * @description Cancel open orders. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancel + * @param {string} id order id + * @param {string} symbol unified symbol of the market the order was made in + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async cancelOrder(id, symbol = undefined, params = {}) { + await this.loadMarkets(); + const request = { + 'id': this.parseNumber(id), + 'type': 'ID', + }; + const response = await this.v3PrivatePutOrdersCancel(this.extend(request, params)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "id": 123456789 + // } + // ] + // } + const data = this.safeList(response, 'data', []); + const result = this.safeDict(data, 0, {}); + return this.parseOrder(result); + } + /** + * @method + * @name foxbit#cancelAllOrders + * @description Cancel all open orders or all open orders for a specific market. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancel + * @param {string} symbol unified market symbol of the market to cancel orders in + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async cancelAllOrders(symbol = undefined, params = {}) { + await this.loadMarkets(); + const request = { + 'type': 'ALL', + }; + if (symbol !== undefined) { + const market = this.market(symbol); + request['type'] = 'MARKET'; + request['market_symbol'] = market['id']; + } + const response = await this.v3PrivatePutOrdersCancel(this.extend(request, params)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "id": 123456789 + // } + // ] + // } + return [this.safeOrder({ + 'info': response, + })]; + } + /** + * @method + * @name foxbit#fetchOrder + * @description Get an order by ID. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_findByOrderId + * @param id + * @param {string} symbol it is not used in the foxbit API + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async fetchOrder(id, symbol = undefined, params = {}) { + await this.loadMarkets(); + const request = { + 'id': id, + }; + const response = await this.v3PrivateGetOrdersByOrderIdId(this.extend(request, params)); + // { + // "id": "1234567890", + // "sn": "OKMAKSDHRVVREK", + // "client_order_id": "451637946501", + // "market_symbol": "btcbrl", + // "side": "BUY", + // "type": "LIMIT", + // "state": "ACTIVE", + // "price": "290000.0", + // "price_avg": "295333.3333", + // "quantity": "0.42", + // "quantity_executed": "0.41", + // "instant_amount": "290.0", + // "instant_amount_executed": "290.0", + // "created_at": "2021-02-15T22:06:32.999Z", + // "trades_count": "2", + // "remark": "A remarkable note for the order.", + // "funds_received": "290.0" + // } + return this.parseOrder(response, undefined); + } + /** + * @method + * @name foxbit#fetchOrders + * @description fetches information on multiple orders made by the user + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_listOrders + * @param {string} symbol unified market symbol of the market orders were made in + * @param {int} [since] the earliest time in ms to fetch orders for + * @param {int} [limit] the maximum number of order structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.state] Enum: ACTIVE, CANCELED, FILLED, PARTIALLY_CANCELED, PARTIALLY_FILLED + * @param {string} [params.side] Enum: BUY, SELL + * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + let market = undefined; + const request = {}; + if (symbol !== undefined) { + market = this.market(symbol); + request['market_symbol'] = market['id']; + } + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 100) { + request['page_size'] = 100; + } + } + const response = await this.v3PrivateGetOrders(this.extend(request, params)); + // { + // "data": [ + // { + // "id": "1234567890", + // "sn": "OKMAKSDHRVVREK", + // "client_order_id": "451637946501", + // "market_symbol": "btcbrl", + // "side": "BUY", + // "type": "LIMIT", + // "state": "ACTIVE", + // "price": "290000.0", + // "price_avg": "295333.3333", + // "quantity": "0.42", + // "quantity_executed": "0.41", + // "instant_amount": "290.0", + // "instant_amount_executed": "290.0", + // "created_at": "2021-02-15T22:06:32.999Z", + // "trades_count": "2", + // "remark": "A remarkable note for the order.", + // "funds_received": "290.0" + // } + // ] + // } + const list = this.safeList(response, 'data', []); + return this.parseOrders(list, market, since, limit); + } + /** + * @method + * @name foxbit#fetchMyTrades + * @description Trade history queries will only have data available for the last 3 months, in descending order (most recents trades first). + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/TradesController_all + * @param {string} symbol unified market symbol + * @param {int} [since] the earliest time in ms to fetch trades for + * @param {int} [limit] the maximum number of trade structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} + */ + async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) { + if (symbol === undefined) { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument'); + } + await this.loadMarkets(); + const market = this.market(symbol); + const request = { + 'market_symbol': market['id'], + }; + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 100) { + request['page_size'] = 100; + } + } + const response = await this.v3PrivateGetTrades(this.extend(request, params)); + // { + // "data": [ + // "id": 1234567890, + // "sn": "TC5JZVW2LLJ3IW", + // "order_id": 1234567890, + // "market_symbol": "btcbrl", + // "side": "BUY", + // "price": "290000.0", + // "quantity": "1.0", + // "fee": "0.01", + // "fee_currency_symbol": "btc", + // "created_at": "2021-02-15T22:06:32.999Z" + // ] + // } + const data = this.safeList(response, 'data', []); + return this.parseTrades(data, market, since, limit); + } + /** + * @method + * @name foxbit#fetchDepositAddress + * @description Fetch the deposit address for a currency associated with this account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_depositAddress + * @param {string} code unified currency code + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.networkCode] the blockchain network to create a deposit address on + * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} + */ + async fetchDepositAddress(code, params = {}) { + await this.loadMarkets(); + const currency = this.currency(code); + const request = { + 'currency_symbol': currency['id'], + }; + const [networkCode, paramsOmited] = this.handleNetworkCodeAndParams(params); + if (networkCode !== undefined) { + request['network_code'] = this.networkCodeToId(networkCode, code); + } + const response = await this.v3PrivateGetDepositsAddress(this.extend(request, paramsOmited)); + // { + // "currency_symbol": "btc", + // "address": "2N9sS8LgrY19rvcCWDmE1ou1tTVmqk4KQAB", + // "message": "Address was retrieved successfully", + // "destination_tag": "string", + // "network": { + // "name": "Bitcoin Network", + // "code": "btc" + // } + // } + return this.parseDepositAddress(response, currency); + } + /** + * @method + * @name foxbit#fetchDeposits + * @description Fetch all deposits made to an account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_listOrders + * @param {string} [code] unified currency code + * @param {int} [since] the earliest time in ms to fetch deposits for + * @param {int} [limit] the maximum number of deposit structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency(code); + } + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 100) { + request['page_size'] = 100; + } + } + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + const response = await this.v3PrivateGetDeposits(this.extend(request, params)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "state": "ACCEPTED", + // "currency_symbol": "btc", + // "amount": "1.0", + // "fee": "0.1", + // "created_at": "2022-02-18T22:06:32.999Z", + // "details_crypto": { + // "transaction_id": "e20f035387020c5d5ea18ad53244f09f3", + // "receiving_address": "2N2rTrnKEFcyJjEJqvVjgWZ3bKvKT7Aij61" + // } + // } + // ] + // } + const data = this.safeList(response, 'data', []); + return this.parseTransactions(data, currency, since, limit); + } + /** + * @method + * @name foxbit#fetchWithdrawals + * @description Fetch all withdrawals made from an account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_listWithdrawals + * @param {string} [code] unified currency code + * @param {int} [since] the earliest time in ms to fetch withdrawals for + * @param {int} [limit] the maximum number of withdrawal structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency(code); + } + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 100) { + request['page_size'] = 100; + } + } + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + const response = await this.v3PrivateGetWithdrawals(this.extend(request, params)); + // { + // "data": [ + // { + // "sn": "OKMAKSDHRVVREK", + // "state": "ACCEPTED", + // "rejection_reason": "monthly_limit_exceeded", + // "currency_symbol": "btc", + // "amount": "1.0", + // "fee": "0.1", + // "created_at": "2022-02-18T22:06:32.999Z", + // "details_crypto": { + // "transaction_id": "e20f035387020c5d5ea18ad53244f09f3", + // "destination_address": "2N2rTrnKEFcyJjEJqvVjgWZ3bKvKT7Aij61" + // }, + // "details_fiat": { + // "bank": { + // "code": "1", + // "branch": { + // "number": "1234567890", + // "digit": "1" + // }, + // "account": { + // "number": "1234567890", + // "digit": "1", + // "type": "CHECK" + // } + // } + // } + // } + // ] + // } + const data = this.safeList(response, 'data', []); + return this.parseTransactions(data, currency, since, limit); + } + /** + * @method + * @name foxbit#fetchTransactions + * @description Fetch all transactions (deposits and withdrawals) made from an account. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_listWithdrawals + * @see https://docs.foxbit.com.br/rest/v3/#tag/Deposit/operation/DepositsController_listOrders + * @param {string} [code] unified currency code + * @param {int} [since] the earliest time in ms to fetch withdrawals for + * @param {int} [limit] the maximum number of withdrawal structures to retrieve + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + async fetchTransactions(code = undefined, since = undefined, limit = undefined, params = {}) { + const withdrawals = await this.fetchWithdrawals(code, since, limit, params); + const deposits = await this.fetchDeposits(code, since, limit, params); + const allTransactions = this.arrayConcat(withdrawals, deposits); + const result = this.sortBy(allTransactions, 'timestamp'); + return result; + } + /** + * @method + * @name foxbit#fetchStatus + * @description The latest known information on the availability of the exchange API. + * @see https://status.foxbit.com/ + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure} + */ + async fetchStatus(params = {}) { + const response = await this.statusPublicGetStatus(params); + // { + // "data": { + // "id": 1, + // "attributes": { + // "status": "NORMAL", + // "createdAt": "2023-05-17T18:37:05.934Z", + // "updatedAt": "2024-04-17T02:33:50.945Z", + // "publishedAt": "2023-05-17T18:37:07.653Z", + // "locale": "pt-BR" + // } + // }, + // "meta": { + // } + // } + const data = this.safeDict(response, 'data', {}); + const attributes = this.safeDict(data, 'attributes', {}); + const statusRaw = this.safeString(attributes, 'status'); + const statusMap = { + 'NORMAL': 'ok', + 'UNDER_MAINTENANCE': 'maintenance', + }; + return { + 'status': this.safeString(statusMap, statusRaw, statusRaw), + 'updated': this.safeString(attributes, 'updatedAt'), + 'eta': undefined, + 'url': undefined, + 'info': response, + }; + } + /** + * @method + * @name foxbit#editOrder + * @description Simultaneously cancel an existing order and create a new one. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancelReplace + * @param {string} id order id + * @param {string} symbol unified symbol of the market to create an order in + * @param {string} type 'market' or 'limit' + * @param {string} side 'buy' or 'sell' + * @param {float} amount how much of the currency you want to trade in units of the base currency + * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, used as stop_price on stop market orders + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} + */ + async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) { + if (symbol === undefined) { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' editOrder() requires a symbol argument'); + } + type = type.toUpperCase(); + if (type !== 'LIMIT' && type !== 'MARKET' && type !== 'STOP_MARKET' && type !== 'INSTANT') { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder('Invalid order type: ' + type + '. Must be one of: LIMIT, MARKET, STOP_MARKET, INSTANT.'); + } + await this.loadMarkets(); + const market = this.market(symbol); + const request = { + 'mode': 'ALLOW_FAILURE', + 'cancel': { + 'type': 'ID', + 'id': this.parseNumber(id), + }, + 'create': { + 'type': type, + 'side': side.toUpperCase(), + 'market_symbol': market['id'], + }, + }; + if (type === 'LIMIT' || type === 'MARKET') { + request['create']['quantity'] = this.amountToPrecision(symbol, amount); + if (type === 'LIMIT') { + request['create']['price'] = this.priceToPrecision(symbol, price); + } + } + if (type === 'STOP_MARKET') { + request['create']['stop_price'] = this.priceToPrecision(symbol, price); + request['create']['quantity'] = this.amountToPrecision(symbol, amount); + } + if (type === 'INSTANT') { + request['create']['amount'] = this.priceToPrecision(symbol, amount); + } + const response = await this.v3PrivatePostOrdersCancelReplace(this.extend(request, params)); + // { + // "cancel": { + // "id": 123456789 + // }, + // "create": { + // "id": 1234567890, + // "client_order_id": "451637946501" + // } + // } + return this.parseOrder(response['create'], market); + } + /** + * @method + * @name foxbit#withdraw + * @description Make a withdrawal. + * @see https://docs.foxbit.com.br/rest/v3/#tag/Withdrawal/operation/WithdrawalsController_createWithdrawal + * @param {string} code unified currency code + * @param {float} amount the amount to withdraw + * @param {string} address the address to withdraw to + * @param {string} tag + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure} + */ + async withdraw(code, amount, address, tag = undefined, params = {}) { + [tag, params] = this.handleWithdrawTagAndParams(tag, params); + await this.loadMarkets(); + const currency = this.currency(code); + const request = { + 'currency_symbol': currency['id'], + 'amount': this.numberToString(amount), + 'destination_address': address, + }; + if (tag !== undefined) { + request['destination_tag'] = tag; + } + let networkCode = undefined; + [networkCode, params] = this.handleNetworkCodeAndParams(params); + if (networkCode !== undefined) { + request['network_code'] = this.networkCodeToId(networkCode); + } + const response = await this.v3PrivatePostWithdrawals(this.extend(request, params)); + // { + // "amount": "1", + // "currency_symbol": "xrp", + // "network_code": "ripple", + // "destination_address": "0x1234567890123456789012345678", + // "destination_tag": "123456" + // } + return this.parseTransaction(response); + } + /** + * @method + * @name foxbit#fetchLedger + * @description fetch the history of changes, actions done by the user or operations that altered balance of the user + * @see https://docs.foxbit.com.br/rest/v3/#tag/Account/operation/AccountsController_getTransactions + * @param {string} code unified currency code, default is undefined + * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined + * @param {int} [limit] max number of ledger entrys to return, default is undefined + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure} + */ + async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) { + await this.loadMarkets(); + const request = {}; + if (code === undefined) { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchLedger() requires a code argument'); + } + if (limit !== undefined) { + request['page_size'] = limit; + if (limit > 100) { + request['page_size'] = 100; + } + } + if (since !== undefined) { + request['start_time'] = this.iso8601(since); + } + const currency = this.currency(code); + request['symbol'] = currency['id']; + const response = await this.v3PrivateGetAccountsSymbolTransactions(this.extend(request, params)); + const data = this.safeList(response, 'data', []); + return this.parseLedger(data, currency, since, limit); + } + parseMarket(market) { + const id = this.safeString(market, 'symbol'); + const baseAssets = this.safeDict(market, 'base'); + const baseId = this.safeString(baseAssets, 'symbol'); + const quoteAssets = this.safeDict(market, 'quote'); + const quoteId = this.safeString(quoteAssets, 'symbol'); + const base = this.safeCurrencyCode(baseId); + const quote = this.safeCurrencyCode(quoteId); + const symbol = base + '/' + quote; + const fees = this.safeDict(market, 'default_fees'); + return this.safeMarketStructure({ + 'id': id, + 'symbol': symbol, + 'base': base, + 'quote': quote, + 'baseId': baseId, + 'quoteId': quoteId, + 'active': true, + 'type': 'spot', + 'spot': true, + 'margin': false, + 'future': false, + 'swap': false, + 'option': false, + 'contract': false, + 'settle': undefined, + 'settleId': undefined, + 'contractSize': undefined, + 'linear': undefined, + 'inverse': undefined, + 'expiry': undefined, + 'expiryDatetime': undefined, + 'strike': undefined, + 'optionType': undefined, + 'taker': this.safeNumber(fees, 'taker'), + 'maker': this.safeNumber(fees, 'maker'), + 'percentage': true, + 'tierBased': false, + 'feeSide': 'get', + 'precision': { + 'price': this.safeInteger(quoteAssets, 'precision'), + 'amount': this.safeInteger(baseAssets, 'precision'), + 'cost': this.safeInteger(quoteAssets, 'precision'), + }, + 'limits': { + 'amount': { + 'min': this.safeNumber(market, 'quantity_min'), + 'max': undefined, + }, + 'price': { + 'min': this.safeNumber(market, 'price_min'), + 'max': undefined, + }, + 'cost': { + 'min': undefined, + 'max': undefined, + }, + 'leverage': { + 'min': undefined, + 'max': undefined, + }, + }, + 'info': market, + }); + } + parseTradingFee(entry, market = undefined) { + return { + 'info': entry, + 'symbol': market['symbol'], + 'maker': this.safeNumber(entry, 'maker'), + 'taker': this.safeNumber(entry, 'taker'), + 'percentage': true, + 'tierBased': true, + }; + } + parseTicker(ticker, market = undefined) { + const marketId = this.safeString(ticker, 'market_symbol'); + const symbol = this.safeSymbol(marketId, market, undefined, 'spot'); + const rolling_24h = ticker['rolling_24h']; + const best = this.safeDict(ticker, 'best'); + const bestAsk = this.safeDict(best, 'ask'); + const bestBid = this.safeDict(best, 'bid'); + const lastTrade = ticker['last_trade']; + const lastPrice = this.safeString(lastTrade, 'price'); + return this.safeTicker({ + 'symbol': symbol, + 'timestamp': this.parseDate(this.safeString(lastTrade, 'date')), + 'datetime': this.iso8601(this.parseDate(this.safeString(lastTrade, 'date'))), + 'high': this.safeNumber(rolling_24h, 'high'), + 'low': this.safeNumber(rolling_24h, 'low'), + 'bid': this.safeNumber(bestBid, 'price'), + 'bidVolume': this.safeNumber(bestBid, 'volume'), + 'ask': this.safeNumber(bestAsk, 'price'), + 'askVolume': this.safeNumber(bestAsk, 'volume'), + 'vwap': undefined, + 'open': this.safeNumber(rolling_24h, 'open'), + 'close': lastPrice, + 'last': lastPrice, + 'previousClose': undefined, + 'change': this.safeString(rolling_24h, 'price_change'), + 'percentage': this.safeString(rolling_24h, 'price_change_percent'), + 'average': undefined, + 'baseVolume': this.safeString(rolling_24h, 'volume'), + 'quoteVolume': undefined, + 'info': ticker, + }, market); + } + parseOHLCV(ohlcv, market = undefined) { + return [ + this.safeInteger(ohlcv, 0), + this.safeNumber(ohlcv, 1), + this.safeNumber(ohlcv, 2), + this.safeNumber(ohlcv, 3), + this.safeNumber(ohlcv, 4), + this.safeNumber(ohlcv, 6), + ]; + } + parseTrade(trade, market = undefined) { + const timestamp = this.parseDate(this.safeString(trade, 'created_at')); + const price = this.safeString(trade, 'price'); + const amount = this.safeString(trade, 'volume', this.safeString(trade, 'quantity')); + const privateSideField = this.safeStringLower(trade, 'side'); + const side = this.safeStringLower(trade, 'taker_side', privateSideField); + const cost = _ccxt_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(price, amount); + const fee = { + 'currency': this.safeSymbol(this.safeString(trade, 'fee_currency_symbol')), + 'cost': this.safeNumber(trade, 'fee'), + 'rate': undefined, + }; + return this.safeTrade({ + 'id': this.safeString(trade, 'id'), + 'info': trade, + 'timestamp': timestamp, + 'datetime': this.iso8601(timestamp), + 'symbol': market['symbol'], + 'order': undefined, + 'type': undefined, + 'side': side, + 'takerOrMaker': undefined, + 'price': price, + 'amount': amount, + 'cost': cost, + 'fee': fee, + }, market); + } + parseOrderStatus(status) { + const statuses = { + 'PARTIALLY_CANCELED': 'open', + 'ACTIVE': 'open', + 'PARTIALLY_FILLED': 'open', + 'FILLED': 'closed', + 'PENDING_CANCEL': 'canceled', + 'CANCELED': 'canceled', + }; + return this.safeString(statuses, status, status); + } + parseOrder(order, market = undefined) { + let symbol = this.safeString(order, 'market_symbol'); + if (market === undefined && symbol !== undefined) { + market = this.market(symbol); + } + if (market !== undefined) { + symbol = market['symbol']; + } + const timestamp = this.parseDate(this.safeString(order, 'created_at')); + const price = this.safeString(order, 'price'); + const filled = this.safeString(order, 'quantity_executed'); + const remaining = this.safeString(order, 'quantity'); + // TODO: validate logic of amount here, should this be calculated? + let amount = undefined; + if (remaining !== undefined && filled !== undefined) { + amount = _ccxt_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringAdd(remaining, filled); + } + let cost = this.safeString(order, 'funds_received'); + if (!cost) { + const priceAverage = this.safeString(order, 'price_avg'); + const priceToCalculate = this.safeString(order, 'price', priceAverage); + cost = _ccxt_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(priceToCalculate, amount); + } + const side = this.safeStringLower(order, 'side'); + let feeCurrency = this.safeStringUpper(market, 'quoteId'); + if (side === 'buy') { + feeCurrency = this.safeStringUpper(market, 'baseId'); + } + return this.safeOrder({ + 'id': this.safeString(order, 'id'), + 'info': order, + 'clientOrderId': this.safeString(order, 'client_order_id'), + 'timestamp': timestamp, + 'datetime': this.iso8601(timestamp), + 'lastTradeTimestamp': undefined, + 'status': this.parseOrderStatus(this.safeString(order, 'state')), + 'symbol': this.safeString(market, 'symbol'), + 'type': this.safeString(order, 'type'), + 'timeInForce': this.safeString(order, 'time_in_force'), + 'postOnly': this.safeBool(order, 'post_only'), + 'reduceOnly': undefined, + 'side': side, + 'price': this.parseNumber(price), + 'triggerPrice': this.safeNumber(order, 'stop_price'), + 'takeProfitPrice': undefined, + 'stopLossPrice': undefined, + 'cost': this.parseNumber(cost), + 'average': this.safeNumber(order, 'price_avg'), + 'amount': this.parseNumber(amount), + 'filled': this.parseNumber(filled), + 'remaining': this.parseNumber(remaining), + 'trades': undefined, + 'fee': { + 'currency': feeCurrency, + 'cost': this.safeNumber(order, 'fee_paid'), + }, + }); + } + parseDepositAddress(depositAddress, currency = undefined) { + const network = this.safeDict(depositAddress, 'network'); + const networkId = this.safeString(network, 'code'); + const currencyCode = this.safeCurrencyCode(undefined, currency); + const unifiedNetwork = this.networkIdToCode(networkId, currencyCode); + return { + 'address': this.safeString(depositAddress, 'address'), + 'tag': this.safeString(depositAddress, 'tag'), + 'currency': currencyCode, + 'network': unifiedNetwork, + 'info': depositAddress, + }; + } + parseTransactionStatus(status) { + const statuses = { + // BOTH + 'SUBMITTING': 'pending', + 'SUBMITTED': 'pending', + 'REJECTED': 'failed', + // DEPOSIT-SPECIFIC + 'CANCELLED': 'canceled', + 'ACCEPTED': 'ok', + 'WARNING': 'pending', + 'UNBLOCKED': 'pending', + 'BLOCKED': 'pending', + // WITHDRAWAL-SPECIFIC + 'PROCESSING': 'pending', + 'CANCELED': 'canceled', + 'FAILED': 'failed', + 'DONE': 'ok', + }; + return this.safeString(statuses, status, status); + } + parseTransaction(transaction, currency = undefined, since = undefined, limit = undefined) { + const cryptoDetails = this.safeDict(transaction, 'details_crypto'); + const address = this.safeString2(cryptoDetails, 'receiving_address', 'destination_address'); + const sn = this.safeString(transaction, 'sn'); + let type = 'withdrawal'; + if (sn !== undefined && sn[0] === 'D') { + type = 'deposit'; + } + const fee = this.safeString(transaction, 'fee', '0'); + const amount = this.safeString(transaction, 'amount'); + const currencySymbol = this.safeString(transaction, 'currency_symbol'); + let actualAmount = amount; + const currencyCode = this.safeCurrencyCode(currencySymbol); + const status = this.parseTransactionStatus(this.safeString(transaction, 'state')); + const created_at = this.safeString(transaction, 'created_at'); + const timestamp = this.parseDate(created_at); + const datetime = this.iso8601(timestamp); + if (fee !== undefined && amount !== undefined) { + // actualAmount = amount - fee; + actualAmount = _ccxt_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringSub(amount, fee); + } + const feeRate = _ccxt_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(fee, actualAmount); + const feeObj = { + 'cost': this.parseNumber(fee), + 'currency': currencyCode, + 'rate': this.parseNumber(feeRate), + }; + return { + 'info': transaction, + 'id': this.safeString(transaction, 'sn'), + 'txid': this.safeString(cryptoDetails, 'transaction_id'), + 'timestamp': timestamp, + 'datetime': datetime, + 'network': this.safeString(transaction, 'network_code'), + 'address': address, + 'addressTo': address, + 'addressFrom': undefined, + 'tag': this.safeString(transaction, 'destination_tag'), + 'tagTo': this.safeString(transaction, 'destination_tag'), + 'tagFrom': undefined, + 'type': type, + 'amount': this.parseNumber(amount), + 'currency': currencyCode, + 'status': status, + 'updated': undefined, + 'fee': feeObj, + 'comment': undefined, + 'internal': undefined, + }; + } + parseLedgerEntryType(type) { + const types = { + 'DEPOSITING': 'transaction', + 'WITHDRAWING': 'transaction', + 'TRADING': 'trade', + 'INTERNAL_TRANSFERING': 'transfer', + 'OTHERS': 'transaction', + }; + return this.safeString(types, type, type); + } + parseLedgerEntry(item, currency = undefined) { + // { + // "uuid": "f8e9f2d6-3c1e-4f2d-8f8e-9f2d6c1e4f2d", + // "amount": "0.0001", + // "balance": "0.0002", + // "created_at": "2021-07-01T12:00:00Z", + // "currency_symbol": "btc", + // "fee": "0.0001", + // "locked": "0.0001", + // "locked_amount": "0.0001", + // "reason_type": "DEPOSITING" + // } + const id = this.safeString(item, 'uuid'); + const createdAt = this.safeString(item, 'created_at'); + const timestamp = this.parse8601(createdAt); + const reasonType = this.safeString(item, 'reason_type'); + const type = this.parseLedgerEntryType(reasonType); + const exchangeSymbol = this.safeString(item, 'currency_symbol'); + const currencySymbol = this.safeCurrencyCode(exchangeSymbol); + let direction = 'in'; + const amount = this.safeNumber(item, 'amount'); + let realAmount = amount; + const balance = this.safeNumber(item, 'balance'); + const fee = { + 'cost': this.safeNumber(item, 'fee'), + 'currency': currencySymbol, + }; + if (amount < 0) { + direction = 'out'; + realAmount = amount * -1; + } + return { + 'id': id, + 'info': item, + 'timestamp': timestamp, + 'datetime': this.iso8601(timestamp), + 'direction': direction, + 'account': undefined, + 'referenceId': undefined, + 'referenceAccount': undefined, + 'type': type, + 'currency': currencySymbol, + 'amount': realAmount, + 'before': balance - amount, + 'after': balance, + 'status': 'ok', + 'fee': fee, + }; + } + sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) { + const version = api[0]; + let urlPath = api[1]; + let fullPath = '/rest/' + version + '/' + this.implodeParams(path, params); + if (version === 'status') { + fullPath = '/status'; + urlPath = 'status'; + } + let url = this.urls['api'][urlPath] + fullPath; + params = this.omit(params, this.extractParams(path)); + const timestamp = this.milliseconds(); + let query = ''; + let signatureQuery = ''; + if (method === 'GET') { + const paramKeys = Object.keys(params); + const paramKeysLength = paramKeys.length; + if (paramKeysLength > 0) { + query = this.urlencode(params); + url += '?' + query; + } + for (let i = 0; i < paramKeys.length; i++) { + const key = paramKeys[i]; + const value = this.safeString(params, key); + if (value !== undefined) { + signatureQuery += key + '=' + value; + } + if (i < paramKeysLength - 1) { + signatureQuery += '&'; + } + } + } + if (method === 'POST' || method === 'PUT') { + body = this.json(params); + } + let bodyToSignature = ''; + if (body !== undefined) { + bodyToSignature = body; + } + headers = { + 'Content-Type': 'application/json', + }; + if (urlPath === 'private') { + this.checkRequiredCredentials(); + const preHash = this.numberToString(timestamp) + method + fullPath + signatureQuery + bodyToSignature; + const signature = this.hmac(this.encode(preHash), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .s, 'hex'); + headers['X-FB-ACCESS-KEY'] = this.apiKey; + headers['X-FB-ACCESS-TIMESTAMP'] = this.numberToString(timestamp); + headers['X-FB-ACCESS-SIGNATURE'] = signature; + } + return { 'url': url, 'method': method, 'body': body, 'headers': headers }; + } + handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) { + if (response === undefined) { + return undefined; + } + const error = this.safeDict(response, 'error'); + const code = this.safeString(error, 'code'); + const details = this.safeList(error, 'details'); + const message = this.safeString(error, 'message'); + let detailsString = ''; + if (details) { + for (let i = 0; i < details.length; i++) { + detailsString = detailsString + details[i] + ' '; + } + } + if (error !== undefined) { + const feedback = this.id + ' ' + message + ' details: ' + detailsString; + this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback); + this.throwBroadlyMatchedException(this.exceptions['broad'], detailsString, feedback); + this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback); + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(feedback); + } + return undefined; + } +} + + /***/ }), /***/ 9403: @@ -167062,7 +169482,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] request['from'] = start; request['to'] = this.sum(start, 30 * 24 * 60 * 60); } - [request, params] = this.handleUntilOption('to', request, params); + [request, params] = this.handleUntilOption('to', request, params, 0.001); const response = await this.privateWalletGetDeposits(this.extend(request, params)); return this.parseTransactions(response, currency); } @@ -173472,11 +175892,15 @@ class hashkey extends _abstract_hashkey_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'future': false, 'option': false, 'addMargin': false, + 'borrowCrossMargin': false, + 'borrowIsolatedMargin': false, + 'borrowMargin': false, 'cancelAllOrders': true, 'cancelAllOrdersAfter': false, 'cancelOrder': true, 'cancelOrders': true, 'cancelWithdraw': false, + 'closeAllPositions': false, 'closePosition': false, 'createConvertTrade': false, 'createDepositAddress': false, @@ -173496,7 +175920,14 @@ class hashkey extends _abstract_hashkey_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'createTrailingPercentOrder': false, 'createTriggerOrder': true, 'fetchAccounts': true, + 'fetchAllGreeks': false, 'fetchBalance': true, + 'fetchBorrowInterest': false, + 'fetchBorrowRate': false, + 'fetchBorrowRateHistories': false, + 'fetchBorrowRateHistory': false, + 'fetchBorrowRates': false, + 'fetchBorrowRatesPerSymbol': false, 'fetchCanceledAndClosedOrders': true, 'fetchCanceledOrders': true, 'fetchClosedOrder': true, @@ -173505,6 +175936,8 @@ class hashkey extends _abstract_hashkey_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchConvertQuote': false, 'fetchConvertTrade': false, 'fetchConvertTradeHistory': false, + 'fetchCrossBorrowRate': false, + 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': true, 'fetchDepositAddresses': false, @@ -173512,23 +175945,42 @@ class hashkey extends _abstract_hashkey_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchDeposits': true, 'fetchDepositsWithdrawals': false, 'fetchFundingHistory': false, + 'fetchFundingInterval': false, + 'fetchFundingIntervals': false, 'fetchFundingRate': true, 'fetchFundingRateHistory': true, 'fetchFundingRates': true, + 'fetchGreeks': false, 'fetchIndexOHLCV': false, + 'fetchIsolatedBorrowRate': false, + 'fetchIsolatedBorrowRates': false, + 'fetchIsolatedPositions': false, 'fetchLedger': true, 'fetchLeverage': true, + 'fetchLeverages': false, 'fetchLeverageTiers': true, + 'fetchLiquidations': false, + 'fetchLongShortRatio': false, + 'fetchLongShortRatioHistory': false, 'fetchMarginAdjustmentHistory': false, 'fetchMarginMode': false, + 'fetchMarginModes': false, 'fetchMarketLeverageTiers': 'emulated', 'fetchMarkets': true, 'fetchMarkOHLCV': false, + 'fetchMarkPrice': false, + 'fetchMarkPrices': false, + 'fetchMyLiquidations': false, + 'fetchMySettlementHistory': false, 'fetchMyTrades': true, 'fetchOHLCV': true, + 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, + 'fetchOpenInterests': false, 'fetchOpenOrder': false, 'fetchOpenOrders': true, + 'fetchOption': false, + 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': false, @@ -173539,7 +175991,9 @@ class hashkey extends _abstract_hashkey_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchPositions': true, 'fetchPositionsForSymbol': true, 'fetchPositionsHistory': false, + 'fetchPositionsRisk': false, 'fetchPremiumIndexOHLCV': false, + 'fetchSettlementHistory': false, 'fetchStatus': true, 'fetchTicker': true, 'fetchTickers': true, @@ -173549,11 +176003,16 @@ class hashkey extends _abstract_hashkey_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchTradingFees': true, 'fetchTransactions': false, 'fetchTransfers': false, + 'fetchUnderlyingAssets': false, + 'fetchVolatilityHistory': false, 'fetchWithdrawals': true, 'reduceMargin': false, + 'repayCrossMargin': false, + 'repayIsolatedMargin': false, 'sandbox': false, 'setLeverage': true, 'setMargin': false, + 'setMarginMode': false, 'setPositionMode': false, 'transfer': true, 'withdraw': true, @@ -190793,13 +193252,19 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ let paginate = false; [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate'); if (paginate) { - return await this.fetchPaginatedCallCursor('fetchFundingRateHistory', symbol, since, limit, params, 'page_index', 'current_page', 1, 50); + return await this.fetchPaginatedCallCursor('fetchFundingRateHistory', symbol, since, limit, params, 'current_page', 'page_index', 1, 50); } await this.loadMarkets(); const market = this.market(symbol); const request = { 'contract_code': market['id'], }; + if (limit !== undefined) { + request['page_size'] = limit; + } + else { + request['page_size'] = 50; // max + } let response = undefined; if (market['inverse']) { response = await this.contractPublicGetSwapApiV1SwapHistoricalFundingRate(this.extend(request, params)); @@ -193544,6 +196009,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'orderStatus': 2, 'spotClearinghouseState': 2, 'exchangeStatus': 2, + 'candleSnapshot': 4, }, }, }, @@ -193722,6 +196188,9 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @returns {object} an associative dictionary of currencies */ async fetchCurrencies(params = {}) { + if (this.checkRequiredCredentials(false)) { + await this.handleBuilderFeeApproval(); + } const request = { 'type': 'meta', }; @@ -194002,6 +196471,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'quote': quote, 'settle': undefined, 'baseId': baseId, + 'baseName': baseName, 'quoteId': quoteId, 'settleId': undefined, 'type': 'spot', @@ -194109,6 +196579,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'quote': quote, 'settle': settle, 'baseId': baseId, + 'baseName': baseName, 'quoteId': quoteId, 'settleId': settleId, 'type': 'swap', @@ -194164,6 +196635,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} [params.user] user address, will default to this.walletAddress if not provided * @param {string} [params.type] wallet type, ['spot', 'swap'], defaults to swap * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure} */ async fetchBalance(params = {}) { @@ -194174,9 +196646,8 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ let marginMode = undefined; [marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params); const isSpot = (type === 'spot'); - const reqType = (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState'; const request = { - 'type': reqType, + 'type': (isSpot) ? 'spotClearinghouseState' : 'clearinghouseState', 'user': userAddress, }; const response = await this.publicPostInfo(this.extend(request, params)); @@ -194264,7 +196735,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ const market = this.market(symbol); const request = { 'type': 'l2Book', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], }; const response = await this.publicPostInfo(this.extend(request, params)); // @@ -194502,7 +196973,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ const request = { 'type': 'candleSnapshot', 'req': { - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], 'interval': this.safeString(this.timeframes, timeframe, timeframe), 'startTime': since, 'endTime': until, @@ -194564,6 +197035,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [params.until] timestamp in ms of the latest trade * @param {string} [params.address] wallet address that made trades * @param {string} [params.user] wallet address that made trades + * @param {string} [params.subAccountAddress] sub account user address * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} */ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) { @@ -194748,6 +197220,71 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ }; return this.signUserSignedAction(messageTypes, message); } + buildApproveBuilderFeeSig(message) { + const messageTypes = { + 'HyperliquidTransaction:ApproveBuilderFee': [ + { 'name': 'hyperliquidChain', 'type': 'string' }, + { 'name': 'maxFeeRate', 'type': 'string' }, + { 'name': 'builder', 'type': 'address' }, + { 'name': 'nonce', 'type': 'uint64' }, + ], + }; + return this.signUserSignedAction(messageTypes, message); + } + async approveBuilderFee(builder, maxFeeRate) { + const nonce = this.milliseconds(); + const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false); + const payload = { + 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet', + 'maxFeeRate': maxFeeRate, + 'builder': builder, + 'nonce': nonce, + }; + const sig = this.buildApproveBuilderFeeSig(payload); + const action = { + 'hyperliquidChain': payload['hyperliquidChain'], + 'signatureChainId': '0x66eee', + 'maxFeeRate': payload['maxFeeRate'], + 'builder': payload['builder'], + 'nonce': nonce, + 'type': 'approveBuilderFee', + }; + const request = { + 'action': action, + 'nonce': nonce, + 'signature': sig, + 'vaultAddress': undefined, + }; + // + // { + // "status": "ok", + // "response": { + // "type": "default" + // } + // } + // + return await this.privatePostExchange(request); + } + async handleBuilderFeeApproval() { + const buildFee = this.safeBool(this.options, 'builderFee', true); + if (!buildFee) { + return false; // skip if builder fee is not enabled + } + const approvedBuilderFee = this.safeBool(this.options, 'approvedBuilderFee', false); + if (approvedBuilderFee) { + return true; // skip if builder fee is already approved + } + try { + const builder = this.safeString(this.options, 'builder', '0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6'); + const maxFeeRate = this.safeString(this.options, 'feeRate', '0.01%'); + await this.approveBuilderFee(builder, maxFeeRate); + this.options['approvedBuilderFee'] = true; + } + catch (e) { + this.options['builderFee'] = false; // disable builder fee if an error occurs + } + return true; + } /** * @method * @name hyperliquid#createOrder @@ -194766,6 +197303,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.slippage] the slippage for market order * @param {string} [params.vaultAddress] the vault address for order + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ async createOrder(symbol, type, side, amount, price = undefined, params = {}) { @@ -194785,6 +197323,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ */ async createOrders(orders, params = {}) { await this.loadMarkets(); + await this.handleBuilderFeeApproval(); const request = this.createOrdersRequest(orders, params); const response = await this.privatePostExchange(request); // @@ -194970,10 +197509,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'type': 'order', 'orders': orderReq, 'grouping': grouping, - // 'brokerCode': 1, // cant }; - if (vaultAddress === undefined) { - orderAction['brokerCode'] = 1; + if (this.safeBool(this.options, 'approvedBuilderFee', false)) { + const wallet = this.safeStringLower(this.options, 'builder', '0x6530512A6c89C7cfCEbC3BA7fcD9aDa5f30827a6'); + orderAction['builder'] = { 'b': wallet, 'f': this.safeInteger(this.options, 'feeInt', 10) }; } const signature = this.signL1Action(orderAction, nonce, vaultAddress); const request = { @@ -194999,6 +197538,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.vaultAddress] the vault address for order + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ async cancelOrder(id, symbol = undefined, params = {}) { @@ -195016,6 +197556,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ async cancelOrders(ids, symbol = undefined, params = {}) { @@ -195061,7 +197602,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ } cancelAction['cancels'] = cancelReq; let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelOrders', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrders', 'vaultAddress', 'subAccountAddress'); vaultAddress = this.formatVaultAddress(vaultAddress); const signature = this.signL1Action(cancelAction, nonce, vaultAddress); request['action'] = cancelAction; @@ -195106,6 +197647,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}] * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ async cancelOrdersForSymbols(orders, params = {}) { @@ -195147,7 +197689,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ cancelAction['type'] = cancelByCloid ? 'cancelByCloid' : 'cancel'; cancelAction['cancels'] = cancelReq; let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelOrdersForSymbols', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelOrdersForSymbols', 'vaultAddress', 'subAccountAddress'); vaultAddress = this.formatVaultAddress(vaultAddress); const signature = this.signL1Action(cancelAction, nonce, vaultAddress); request['action'] = cancelAction; @@ -195170,7 +197712,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ // } // } // - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -195179,6 +197721,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {number} timeout time in milliseconds, 0 represents cancel the timer * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} the api result */ async cancelAllOrdersAfter(timeout, params = {}) { @@ -195195,7 +197738,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'time': nonce + timeout, }; let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'cancelAllOrdersAfter', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'cancelAllOrdersAfter', 'vaultAddress', 'subAccountAddress'); vaultAddress = this.formatVaultAddress(vaultAddress); const signature = this.signL1Action(cancelAction, nonce, vaultAddress); request['action'] = cancelAction; @@ -195354,6 +197897,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) * @param {string} [params.vaultAddress] the vault address for order + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) { @@ -195478,7 +198022,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ const market = this.market(symbol); const request = { 'type': 'fundingHistory', - 'coin': market['base'], + 'coin': market['baseName'], }; if (since !== undefined) { request['startTime'] = since; @@ -195529,6 +198073,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided * @param {string} [params.method] 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders' + * @param {string} [params.subAccountAddress] sub account user address * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -195627,6 +198172,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [limit] the maximum number of open orders structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -195663,6 +198209,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} symbol unified symbol of the market the order was made in * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ async fetchOrder(id, symbol = undefined, params = {}) { @@ -195895,6 +198442,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [limit] the maximum number of trades structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] timestamp in ms of the latest trade + * @param {string} [params.subAccountAddress] sub account user address * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure} */ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -196020,6 +198568,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string[]} [symbols] list of unified market symbols * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} */ async fetchPositions(symbols = undefined, params = {}) { @@ -196164,6 +198713,8 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} symbol unified market symbol of the market the position is held in, default is undefined * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.leverage] the rate of leverage, is required if setting trade mode (symbol) + * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} response from the exchange */ async setMarginMode(marginMode, symbol = undefined, params = {}) { @@ -196187,7 +198738,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'leverage': leverage, }; let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'setMarginMode', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'setMarginMode', 'vaultAddress', 'subAccountAddress'); if (vaultAddress !== undefined) { if (vaultAddress.startsWith('0x')) { vaultAddress = vaultAddress.replace('0x', ''); @@ -196242,7 +198793,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'leverage': leverage, }; let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'setLeverage', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'setLeverage', 'vaultAddress', 'subAccountAddress'); vaultAddress = this.formatVaultAddress(vaultAddress); const signature = this.signL1Action(updateAction, nonce, vaultAddress); const request = { @@ -196274,6 +198825,8 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} symbol unified market symbol * @param {float} amount amount of margin to add * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure} */ async addMargin(symbol, amount, params = {}) { @@ -196287,6 +198840,8 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} symbol unified market symbol * @param {float} amount the amount of margin to remove * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.vaultAddress] the vault address + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure} */ async reduceMargin(symbol, amount, params = {}) { @@ -196308,7 +198863,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ 'ntli': sz, }; let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'modifyMargin', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'modifyMargin', 'vaultAddress', 'subAccountAddress'); vaultAddress = this.formatVaultAddress(vaultAddress); const signature = this.signL1Action(updateAction, nonce, vaultAddress); const request = { @@ -196408,30 +198963,36 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ const transferResponse = await this.privatePostExchange(transferRequest); return transferResponse; } - // handle sub-account/different account transfer - this.checkAddress(toAccount); + // transfer between main account and subaccount if (code !== undefined) { code = code.toUpperCase(); if (code !== 'USDC') { throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' transfer() only support USDC'); } } - const payload = { - 'hyperliquidChain': isSandboxMode ? 'Testnet' : 'Mainnet', - 'destination': toAccount, - 'amount': this.numberToString(amount), - 'time': nonce, + let isDeposit = false; + let subAccountAddress = undefined; + if (fromAccount === 'main') { + subAccountAddress = toAccount; + isDeposit = true; + } + else if (toAccount === 'main') { + subAccountAddress = fromAccount; + } + else { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' transfer() only support main <> subaccount transfer'); + } + this.checkAddress(subAccountAddress); + const usd = this.parseToInt(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(this.numberToString(amount), '1000000')); + const action = { + 'type': 'subAccountTransfer', + 'subAccountUser': subAccountAddress, + 'isDeposit': isDeposit, + 'usd': usd, }; - const sig = this.buildUsdSendSig(payload); + const sig = this.signL1Action(action, nonce); const request = { - 'action': { - 'hyperliquidChain': payload['hyperliquidChain'], - 'signatureChainId': '0x66eee', - 'destination': toAccount, - 'amount': amount.toString(), - 'time': nonce, - 'type': 'usdSend', - }, + 'action': action, 'nonce': nonce, 'signature': sig, }; @@ -196583,6 +199144,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.user] user address, will default to this.walletAddress if not provided + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure} */ async fetchTradingFee(symbol, params = {}) { @@ -196691,6 +199253,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [limit] max number of ledger entries to return * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] timestamp in ms of the latest ledger entry + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger} */ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) { @@ -196783,6 +199346,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [limit] the maximum number of deposits structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] the latest time in ms to fetch withdrawals for + * @param {string} [params.subAccountAddress] sub account user address * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) { @@ -196828,6 +199392,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [limit] the maximum number of withdrawals structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {int} [params.until] the latest time in ms to fetch withdrawals for + * @param {string} [params.subAccountAddress] sub account user address * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure} */ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) { @@ -196934,6 +199499,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ * @param {int} [since] the earliest time in ms to fetch funding history for * @param {int} [limit] the maximum number of funding history structures to retrieve * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {string} [params.subAccountAddress] sub account user address * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure} */ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) { @@ -197031,7 +199597,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ } handlePublicAddress(methodName, params) { let userAux = undefined; - [userAux, params] = this.handleOptionAndParams(params, methodName, 'user'); + [userAux, params] = this.handleOptionAndParams2(params, methodName, 'user', 'subAccountAddress'); let user = userAux; [user, params] = this.handleOptionAndParams(params, methodName, 'address', userAux); if ((user !== undefined) && (user !== '')) { @@ -197046,7 +199612,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ if (coin.indexOf('/') > -1 || coin.indexOf('@') > -1) { return coin; // spot } - return coin + '/USDC:USDC'; + return this.safeCurrencyCode(coin) + '/USDC:USDC'; } handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) { if (!response) { @@ -197110,7 +199676,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/ parseCreateEditOrderArgs(id, symbol, type, side, amount, price = undefined, params = {}) { const market = this.market(symbol); let vaultAddress = undefined; - [vaultAddress, params] = this.handleOptionAndParams(params, 'createOrder', 'vaultAddress'); + [vaultAddress, params] = this.handleOptionAndParams2(params, 'createOrder', 'vaultAddress', 'subAccountAddress'); vaultAddress = this.formatVaultAddress(vaultAddress); symbol = market['symbol']; const order = { @@ -208777,7 +211343,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul async cancelAllOrders(symbol = undefined, params = {}) { await this.loadMarkets(); const request = {}; - const trigger = this.safeBool(params, 'stop', false); + const trigger = this.safeBool2(params, 'trigger', 'stop', false); let hf = undefined; [hf, params] = this.handleHfAndParams(params); params = this.omit(params, 'stop'); @@ -208806,7 +211372,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul else { response = await this.privateDeleteOrders(this.extend(request, query)); } - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -213013,7 +215579,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_ // }, // } // - return this.safeValue(response, 'data'); + return this.safeOrder({ 'info': response }); } /** * @method @@ -213112,7 +215678,8 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_ // }, // } // - return this.safeValue(response, 'data'); + const data = this.safeDict(response, 'data'); + return [this.safeOrder({ 'info': data })]; } /** * @method @@ -226905,11 +229472,14 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // "network": "TRX", // "status": "5", // "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh", - // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0", // "insertTime": "1664805021000", // "unlockConfirm": "200", // "confirmTimes": "203", - // "memo": "xxyy1122" + // "memo": "xxyy1122", + // "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "updateTime": "1664805621000", + // "netWork: "TRX" // } // ] // @@ -226954,7 +229524,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // [ // { // "id": "adcd1c8322154de691b815eedcd10c42", - // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0", // "coin": "USDC-MATIC", // "network": "MATIC", // "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62", @@ -226965,7 +229535,11 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // "confirmNo": null, // "applyTime": "1664882739000", // "remark": '', - // "memo": null + // "memo": null, + // "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "updateTime": "1664882799000", + // "netWork: "MATIC" // } // ] // @@ -226981,18 +229555,21 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // "network": "TRX", // "status": "5", // "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh", - // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0", // "insertTime": "1664805021000", // "unlockConfirm": "200", // "confirmTimes": "203", - // "memo": "xxyy1122" + // "memo": "xxyy1122", + // "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b", + // "updateTime": "1664805621000", + // "netWork: "TRX" // } // // fetchWithdrawals // // { // "id": "adcd1c8322154de691b815eedcd10c42", - // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0", // "coin": "USDC-MATIC", // "network": "MATIC", // "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62", @@ -227002,8 +229579,12 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // "transactionFee": "1", // "confirmNo": null, // "applyTime": "1664882739000", - // "remark": '', - // "memo": null + // "remark": "", + // "memo": null, + // "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0", + // "updateTime": "1664882799000", + // "netWork: "MATIC" // } // // withdraw @@ -227015,6 +229596,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] const id = this.safeString(transaction, 'id'); const type = (id === undefined) ? 'deposit' : 'withdrawal'; const timestamp = this.safeInteger2(transaction, 'insertTime', 'applyTime'); + const updated = this.safeInteger(transaction, 'updateTime'); let currencyId = undefined; const currencyWithNetwork = this.safeString(transaction, 'coin'); if (currencyWithNetwork !== undefined) { @@ -227029,7 +229611,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] const status = this.parseTransactionStatusByType(this.safeString(transaction, 'status'), type); let amountString = this.safeString(transaction, 'amount'); const address = this.safeString(transaction, 'address'); - const txid = this.safeString(transaction, 'txId'); + const txid = this.safeString2(transaction, 'transHash', 'txId'); let fee = undefined; const feeCostString = this.safeString(transaction, 'transactionFee'); if (feeCostString !== undefined) { @@ -227059,8 +229641,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] 'amount': this.parseNumber(amountString), 'currency': code, 'status': status, - 'updated': undefined, - 'comment': undefined, + 'updated': updated, + 'comment': this.safeString(transaction, 'remark'), 'internal': undefined, 'fee': fee, }; @@ -228000,7 +230582,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] // // { success: true, code: '0' } // - return this.parseLeverage(response, market); + return this.parseLeverage(response, market); // tmp revert type } nonce() { return this.milliseconds() - this.safeInteger(this.options, 'timeDifference', 0); @@ -228153,7 +230735,7 @@ class modetrade extends _abstract_modetrade_js__WEBPACK_IMPORTED_MODULE_0__/* [" 'countries': ['KY'], 'rateLimit': 100, 'version': 'v1', - 'certified': true, + 'certified': false, 'pro': true, 'dex': true, 'hostname': 'trade.mode.network', @@ -229939,9 +232521,9 @@ class modetrade extends _abstract_modetrade_js__WEBPACK_IMPORTED_MODULE_0__/* [" // } // return [ - { + this.safeOrder({ 'info': response, - }, + }), ]; } /** @@ -238144,7 +240726,7 @@ class okcoin extends _abstract_okcoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul const advanced = this.safeValue(params, 'advanced'); if (trigger || advanced) { const orderInner = await this.cancelOrders([id], symbol, params); - return this.safeValue(orderInner, 0); + return this.safeDict(orderInner, 0); } const market = this.market(symbol); const request = { @@ -240789,7 +243371,9 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ }, 'createOrder': 'privatePostTradeBatchOrders', 'createMarketBuyOrderRequiresPrice': false, - 'fetchMarkets': ['spot', 'future', 'swap', 'option'], + 'fetchMarkets': { + 'types': ['spot', 'future', 'swap', 'option'], // spot, future, swap, option + }, 'timeDifference': 0, 'adjustForTimeDifference': false, 'defaultType': 'spot', @@ -241186,7 +243770,14 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference(); } - const types = this.safeList(this.options, 'fetchMarkets', []); + let types = ['spot', 'future', 'swap', 'option']; + const fetchMarketsOption = this.safeDict(this.options, 'fetchMarkets'); + if (fetchMarketsOption !== undefined) { + types = this.safeList(fetchMarketsOption, 'types', types); + } + else { + types = this.safeList(this.options, 'fetchMarkets', types); // backward-support + } let promises = []; let result = []; for (let i = 0; i < types.length; i++) { @@ -242243,12 +244834,12 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // it may be incorrect to use total, free and used for swap accounts const eq = this.safeString(balance, 'eq'); const availEq = this.safeString(balance, 'availEq'); - if ((eq === undefined) || (availEq === undefined)) { + account['total'] = eq; + if (availEq === undefined) { account['free'] = this.safeString(balance, 'availBal'); account['used'] = this.safeString(balance, 'frozenBal'); } else { - account['total'] = eq; account['free'] = availEq; } result[code] = account; @@ -242520,7 +245111,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ } createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) { const market = this.market(symbol); - const request = { + let request = { 'instId': market['id'], // 'ccy': currency['id'], // only applicable to cross MARGIN orders in single-currency margin // 'clOrdId': clientOrderId, // up to 32 characters, must be unique @@ -242685,7 +245276,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (stopLossTriggerPrice === undefined) { throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"], or params["stopLoss"]["stopPrice"], or params["stopLoss"]["slTriggerPx"] for a stop loss order'); } - request['slTriggerPx'] = this.priceToPrecision(symbol, stopLossTriggerPrice); + const slTriggerPx = this.priceToPrecision(symbol, stopLossTriggerPrice); + request['slTriggerPx'] = slTriggerPx; const stopLossLimitPrice = this.safeValueN(stopLoss, ['price', 'stopLossPrice', 'slOrdPx']); const stopLossOrderType = this.safeString(stopLoss, 'type'); if (stopLossOrderType !== undefined) { @@ -242777,6 +245369,14 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (twoWayCondition) { request['ordType'] = 'oco'; } + if (side === 'sell') { + request = this.omit(request, 'tgtCcy'); + } + if (this.safeString(request, 'tdMode') === 'cash') { + // for some reason tdMode = cash throws + // {"code":"1","data":[{"algoClOrdId":"","algoId":"","clOrdId":"","sCode":"51000","sMsg":"Parameter tdMode error ","tag":""}],"msg":""} + request['tdMode'] = marginMode; + } if (takeProfitPrice !== undefined) { request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitPrice); let tpOrdPxReq = '-1'; @@ -243110,7 +245710,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const trailing = this.safeBool(params, 'trailing', false); if (trigger || trailing) { const orderInner = await this.cancelOrders([id], symbol, params); - return this.safeValue(orderInner, 0); + return this.safeDict(orderInner, 0); } await this.loadMarkets(); const market = this.market(symbol); @@ -250034,7 +252634,7 @@ class onetrading extends _abstract_onetrading_js__WEBPACK_IMPORTED_MODULE_0__/* // "a10e9bd1-8f72-4cfe-9f1b-7f1c8a9bd8ee" // ] // - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -253081,7 +255681,8 @@ class oxfun extends _abstract_oxfun_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" // "data": { "notice": "No working orders found" } // } // - return await this.privateDeleteV3OrdersCancelAll(this.extend(request, params)); + const response = await this.privateDeleteV3OrdersCancelAll(this.extend(request, params)); + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -254747,6 +257348,7 @@ class paradex extends _abstract_paradex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'createTriggerOrder': true, 'editOrder': false, 'fetchAccounts': false, + 'fetchAllGreeks': true, 'fetchBalance': true, 'fetchBorrowInterest': false, 'fetchBorrowRateHistories': false, @@ -254766,7 +257368,6 @@ class paradex extends _abstract_paradex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa 'fetchFundingRateHistory': false, 'fetchFundingRates': false, 'fetchGreeks': true, - 'fetchAllGreeks': true, 'fetchIndexOHLCV': false, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, @@ -255954,7 +258555,7 @@ class paradex extends _abstract_paradex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa const cancelReason = this.safeString(order, 'cancel_reason'); let status = this.safeString(order, 'status'); if (cancelReason !== undefined) { - if (cancelReason === 'NOT_ENOUGH_MARGIN') { + if (cancelReason === 'NOT_ENOUGH_MARGIN' || cancelReason === 'ORDER_EXCEEDS_POSITION_LIMIT') { status = 'rejected'; } else { @@ -256257,7 +258858,7 @@ class paradex extends _abstract_paradex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa // // if success, no response... // - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -260721,10 +263322,10 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul let triggerDirection = undefined; [triggerDirection, params] = this.handleParamString(params, 'triggerDirection'); if (triggerDirection === undefined) { - throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + " createOrder() also requires a 'triggerDirection' parameter with either 'up' or 'down' value"); + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + " createOrder() also requires a 'triggerDirection' parameter with either 'ascending' or 'descending' value"); } // the flow defined per https://phemex-docs.github.io/#more-order-type-examples - if (triggerDirection === 'up') { + if (triggerDirection === 'ascending' || triggerDirection === 'up') { if (side === 'sell') { request['ordType'] = (type === 'Market') ? 'MarketIfTouched' : 'LimitIfTouched'; } @@ -260732,7 +263333,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul request['ordType'] = (type === 'Market') ? 'Stop' : 'StopLimit'; } } - else if (triggerDirection === 'down') { + else if (triggerDirection === 'descending' || triggerDirection === 'down') { if (side === 'sell') { request['ordType'] = (type === 'Market') ? 'Stop' : 'StopLimit'; } @@ -274243,7 +276844,9 @@ class binancecoinm extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default" 'doc': 'https://developers.binance.com/en', }, 'options': { - 'fetchMarkets': ['inverse'], + 'fetchMarkets': { + 'types': ['inverse'], + }, 'defaultSubType': 'inverse', }, }); @@ -274300,7 +276903,9 @@ class binanceus extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] * 'fetchCurrencies': false, 'quoteOrderQty': false, 'defaultType': 'spot', - 'fetchMarkets': ['spot'], + 'fetchMarkets': { + 'types': ['spot'], + }, }, }); } @@ -274331,7 +276936,9 @@ class binanceusdm extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] 'doc': 'https://developers.binance.com/en', }, 'options': { - 'fetchMarkets': ['linear'], + 'fetchMarkets': { + 'types': ['linear'], + }, 'defaultSubType': 'linear', }, // https://binance-docs.github.io/apidocs/futures/en/#error-codes @@ -312160,7 +314767,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau 'method': 'subscribe', 'subscription': { 'type': 'l2Book', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], }, }; const message = this.extend(request, params); @@ -312189,7 +314796,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau 'method': 'unsubscribe', 'subscription': { 'type': 'l2Book', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], }, }; const message = this.extend(request, params); @@ -312497,7 +315104,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau 'method': 'subscribe', 'subscription': { 'type': 'trades', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], }, }; const message = this.extend(request, params); @@ -312527,7 +315134,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau 'method': 'unsubscribe', 'subscription': { 'type': 'trades', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], }, }; const message = this.extend(request, params); @@ -312654,7 +315261,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau 'method': 'subscribe', 'subscription': { 'type': 'candle', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], 'interval': timeframe, }, }; @@ -312685,7 +315292,7 @@ class hyperliquid extends _hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau 'method': 'unsubscribe', 'subscription': { 'type': 'candle', - 'coin': market['swap'] ? market['base'] : market['id'], + 'coin': market['swap'] ? market['baseName'] : market['id'], 'interval': timeframe, }, }; @@ -314112,18 +316719,16 @@ class kraken extends _kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols */ async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) { - const request = {}; + const requiredParams = {}; if (limit !== undefined) { if (this.inArray(limit, [10, 25, 100, 500, 1000])) { - request['params'] = { - 'depth': limit, // default 10, valid options 10, 25, 100, 500, 1000 - }; + requiredParams['depth'] = limit; // default 10, valid options 10, 25, 100, 500, 1000 } else { throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' watchOrderBook accepts limit values of 10, 25, 100, 500 and 1000 only'); } } - const orderbook = await this.watchMultiHelper('orderbook', 'book', symbols, { 'limit': limit }, this.extend(request, params)); + const orderbook = await this.watchMultiHelper('orderbook', 'book', symbols, { 'limit': limit }, this.extend(requiredParams, params)); return orderbook.limit(); } /** @@ -315043,20 +317648,22 @@ class kraken extends _kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A // const errorMessage = this.safeString2(message, 'errorMessage', 'error'); if (errorMessage !== undefined) { - const requestId = this.safeValue2(message, 'reqid', 'req_id'); - if (requestId !== undefined) { - const broad = this.exceptions['ws']['broad']; - const broadKey = this.findBroadlyMatchedKey(broad, errorMessage); - let exception = undefined; - if (broadKey === undefined) { - exception = new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(errorMessage); // c# requirement to convert the errorMessage to string - } - else { - exception = new broad[broadKey](errorMessage); - } - client.reject(exception, requestId); - return false; + // const requestId = this.safeValue2 (message, 'reqid', 'req_id'); + const broad = this.exceptions['ws']['broad']; + const broadKey = this.findBroadlyMatchedKey(broad, errorMessage); + let exception = undefined; + if (broadKey === undefined) { + exception = new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(errorMessage); // c# requirement to convert the errorMessage to string + } + else { + exception = new broad[broadKey](errorMessage); } + // if (requestId !== undefined) { + // client.reject (exception, requestId); + // } else { + client.reject(exception); + // } + return false; } return true; } @@ -322138,7 +324745,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { } url = this.urls['api']['ws']['spot']; params['unsubscribed'] = true; - this.watchSpotPublic(channel, messageHash, params); + await this.watchSpotPublic(channel, messageHash, params); } else { channel = 'unsub.ticker'; @@ -322146,7 +324753,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { 'symbol': market['id'], }; url = this.urls['api']['ws']['swap']; - this.watchSwapPublic(channel, messageHash, requestParams, params); + await this.watchSwapPublic(channel, messageHash, requestParams, params); } const client = this.client(url); this.handleUnsubscriptions(client, [messageHash]); @@ -322210,7 +324817,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { messageHashes.push('unsubscribe:ticker'); } const client = this.client(url); - this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes); + await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes); this.handleUnsubscriptions(client, messageHashes); return undefined; } @@ -322250,7 +324857,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { 'params': topics, }; const client = this.client(url); - this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes); + await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes); this.handleUnsubscriptions(client, messageHashes); return undefined; } @@ -322276,7 +324883,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { url = this.urls['api']['ws']['spot']; const channel = 'spot@public.kline.v3.api@' + market['id'] + '@' + timeframeId; params['unsubscribed'] = true; - this.watchSpotPublic(channel, messageHash, params); + await this.watchSpotPublic(channel, messageHash, params); } else { url = this.urls['api']['ws']['swap']; @@ -322285,7 +324892,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { 'symbol': market['id'], 'interval': timeframeId, }; - this.watchSwapPublic(channel, messageHash, requestParams, params); + await this.watchSwapPublic(channel, messageHash, requestParams, params); } const client = this.client(url); this.handleUnsubscriptions(client, [messageHash]); @@ -322309,7 +324916,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { url = this.urls['api']['ws']['spot']; const channel = 'spot@public.increase.depth.v3.api@' + market['id']; params['unsubscribed'] = true; - this.watchSpotPublic(channel, messageHash, params); + await this.watchSpotPublic(channel, messageHash, params); } else { url = this.urls['api']['ws']['swap']; @@ -322317,7 +324924,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { const requestParams = { 'symbol': market['id'], }; - this.watchSwapPublic(channel, messageHash, requestParams, params); + await this.watchSwapPublic(channel, messageHash, requestParams, params); } const client = this.client(url); this.handleUnsubscriptions(client, [messageHash]); @@ -322342,7 +324949,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { url = this.urls['api']['ws']['spot']; const channel = 'spot@public.deals.v3.api@' + market['id']; params['unsubscribed'] = true; - this.watchSpotPublic(channel, messageHash, params); + await this.watchSpotPublic(channel, messageHash, params); } else { url = this.urls['api']['ws']['swap']; @@ -322350,7 +324957,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A { const requestParams = { 'symbol': market['id'], }; - this.watchSwapPublic(channel, messageHash, requestParams, params); + await this.watchSwapPublic(channel, messageHash, requestParams, params); } const client = this.client(url); this.handleUnsubscriptions(client, [messageHash]); @@ -373529,7 +376136,7 @@ class vertex extends _abstract_vertex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul // } // } - return response; + return [this.safeOrder({ 'info': response })]; } /** * @method @@ -373543,7 +376150,8 @@ class vertex extends _abstract_vertex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure} */ async cancelOrder(id, symbol = undefined, params = {}) { - return await this.cancelOrders([id], symbol, params); + const order = await this.cancelOrders([id], symbol, params); + return this.safeOrder({ 'info': order }); } /** * @method @@ -376581,13 +379189,26 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_ const order1 = this.safeValue(data, 'order1'); const order2 = this.safeValue(data, 'order2'); let order = undefined; - // order2 arrived after order1 + // at first, detect if response is from `fetch_my_trades` if (this.safeString(order1, 'senderPublicKey') === this.apiKey) { order = order1; } - else { + else if (this.safeString(order2, 'senderPublicKey') === this.apiKey) { order = order2; } + else { + // response is from `fetch_trades`, so find only taker order + const date1 = this.safeString(order1, 'timestamp'); + const date2 = this.safeString(order2, 'timestamp'); + const ts1 = this.parse8601(date1); + const ts2 = this.parse8601(date2); + if (ts1 > ts2) { + order = order1; + } + else { + order = order2; + } + } let symbol = undefined; const assetPair = this.safeValue(order, 'assetPair'); if (assetPair !== undefined) { @@ -380553,7 +383174,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'fetchTickers': false, 'fetchTime': true, 'fetchTrades': true, - 'fetchTradingFee': false, + 'fetchTradingFee': true, 'fetchTradingFees': true, 'fetchTransactions': 'emulated', 'fetchTransfers': true, @@ -380689,19 +383310,56 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'v3': { 'public': { 'get': { - 'insuranceFund': 3, + 'systemInfo': 1, + 'instruments': 1, + 'token': 1, + 'tokenNetwork': 1, + 'tokenInfo': 1, + 'marketTrades': 1, + 'marketTradesHistory': 1, + 'orderbook': 1, + 'kline': 1, + 'klineHistory': 1, + 'futures': 1, + 'fundingRate': 1, + 'fundingRateHistory': 1, + 'insuranceFund': 1, // 10/1s }, }, 'private': { 'get': { + 'trade/order': 2, + 'trade/orders': 1, + 'trade/algoOrder': 1, + 'trade/algoOrders': 1, + 'trade/transaction': 1, + 'trade/transactionHistory': 5, + 'trade/tradingFee': 5, + 'account/info': 60, + 'account/tokenConfig': 1, + 'account/symbolConfig': 1, + 'account/subAccounts/all': 60, + 'account/referral/summary': 60, + 'account/referral/rewardHistory': 60, + 'account/credentials': 60, + 'asset/balances': 1, + 'asset/token/history': 60, + 'asset/transfer/history': 30, + 'asset/wallet/history': 60, + 'asset/wallet/deposit': 60, + 'asset/staking/yieldHistory': 60, + 'futures/positions': 3.33, + 'futures/leverage': 60, + 'futures/defaultMarginMode': 60, + 'futures/fundingFee/history': 30, + 'spotMargin/interestRate': 60, + 'spotMargin/interestHistory': 60, + 'spotMargin/maxMargin': 60, 'algo/order/{oid}': 1, 'algo/orders': 1, 'balances': 1, - 'accountinfo': 60, 'positions': 3.33, 'buypower': 1, - 'referrals': 60, - 'referral_rewards': 60, 'convert/exchangeInfo': 1, 'convert/assetInfo': 1, 'convert/rfq': 60, @@ -380709,16 +383367,34 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'convert/trades': 1, }, 'post': { + 'trade/order': 2, + 'trade/algoOrder': 5, + 'trade/cancelAllAfter': 1, + 'account/tradingMode': 120, + 'account/listenKey': 20, + 'asset/transfer': 30, + 'asset/wallet/withdraw': 60, + 'spotMargin/leverage': 120, + 'spotMargin/interestRepay': 60, 'algo/order': 5, 'convert/rft': 60, }, 'put': { + 'trade/order': 2, + 'trade/algoOrder': 2, + 'futures/leverage': 60, + 'futures/positionMode': 120, 'order/{oid}': 2, 'order/client/{client_order_id}': 2, 'algo/order/{oid}': 2, 'algo/order/client/{client_order_id}': 2, }, 'delete': { + 'trade/order': 1, + 'trade/orders': 1, + 'trade/algoOrder': 1, + 'trade/algoOrders': 1, + 'trade/allOrders': 1, 'algo/order/{order_id}': 1, 'algo/orders/pending': 1, 'algo/orders/pending/{symbol}': 1, @@ -380897,20 +383573,21 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchStatus * @description the latest known information on the availability of the exchange API - * @see https://docs.woox.io/#get-system-maintenance-status-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure} */ async fetchStatus(params = {}) { - const response = await this.v1PublicGetSystemInfo(params); + const response = await this.v3PublicGetSystemInfo(params); // // { // "success": true, // "data": { - // "status": "0", - // "msg": "System is functioning properly." + // "status": 0, + // "msg": "System is functioning properly.", + // "estimatedEndTime": 1749963600362 // }, - // "timestamp": "1709274106602" + // "timestamp": 1751442989564 // } // const data = this.safeDict(response, 'data', {}); @@ -380936,20 +383613,21 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchTime * @description fetches the current integer timestamp in milliseconds from the exchange server - * @see https://docs.woox.io/#get-system-maintenance-status-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/systemInfo * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the exchange server */ async fetchTime(params = {}) { - const response = await this.v1PublicGetSystemInfo(params); + const response = await this.v3PublicGetSystemInfo(params); // // { // "success": true, // "data": { - // "status": "0", - // "msg": "System is functioning properly." + // "status": 0, + // "msg": "System is functioning properly.", + // "estimatedEndTime": 1749963600362 // }, - // "timestamp": "1709274106602" + // "timestamp": 1751442989564 // } // return this.safeInteger(response, 'timestamp'); @@ -380958,7 +383636,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchMarkets * @description retrieves data on all markets for woo - * @see https://docs.woox.io/#exchange-information + * @see https://developer.woox.io/api-reference/endpoint/public_data/instruments * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} an array of objects representing market data */ @@ -380966,30 +383644,42 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference(); } - const response = await this.v1PublicGetInfo(params); + const response = await this.v3PublicGetInstruments(params); // - // { - // "rows": [ - // { - // "symbol": "SPOT_AAVE_USDT", - // "quote_min": 0, - // "quote_max": 100000, - // "quote_tick": 0.01, - // "base_min": 0.01, - // "base_max": 7284, - // "base_tick": 0.0001, - // "min_notional": 10, - // "price_range": 0.1, - // "created_time": "0", - // "updated_time": "1639107647.988", - // "is_stable": 0 + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "SPOT_AAVE_USDT", + // "status": "TRADING", + // "baseAsset": "AAVE", + // "baseAssetMultiplier": 1, + // "quoteAsset": "USDT", + // "quoteMin": "0", + // "quoteMax": "100000", + // "quoteTick": "0.01", + // "baseMin": "0.005", + // "baseMax": "5000", + // "baseTick": "0.0001", + // "minNotional": "1", + // "bidCapRatio": "1.1", + // "bidFloorRatio": null, + // "askCapRatio": null, + // "askFloorRatio": "0.9", + // "orderMode": "NORMAL", + // "impactNotional": null, + // "isAllowedRpi": false, + // "tickGranularity": null + // } + // ] // }, - // ... - // "success": true - // } + // "timestamp": 1751512951338 + // } // - const data = this.safeList(response, 'rows', []); - return this.parseMarkets(data); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); + return this.parseMarkets(rows); } parseMarket(market) { const marketId = this.safeString(market, 'symbol'); @@ -381027,7 +383717,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ linear = true; inverse = false; } - const active = this.safeString(market, 'is_trading') === '1'; + const active = this.safeString(market, 'status') === 'TRADING'; return { 'id': marketId, 'symbol': symbol, @@ -381053,8 +383743,8 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'strike': undefined, 'optionType': undefined, 'precision': { - 'amount': this.safeNumber(market, 'base_tick'), - 'price': this.safeNumber(market, 'quote_tick'), + 'amount': this.safeNumber(market, 'baseTick'), + 'price': this.safeNumber(market, 'quoteTick'), }, 'limits': { 'leverage': { @@ -381062,19 +383752,19 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'max': undefined, }, 'amount': { - 'min': this.safeNumber(market, 'base_min'), - 'max': this.safeNumber(market, 'base_max'), + 'min': this.safeNumber(market, 'baseMin'), + 'max': this.safeNumber(market, 'baseMax'), }, 'price': { - 'min': this.safeNumber(market, 'quote_min'), - 'max': this.safeNumber(market, 'quote_max'), + 'min': this.safeNumber(market, 'quoteMin'), + 'max': this.safeNumber(market, 'quoteMax'), }, 'cost': { - 'min': this.safeNumber(market, 'min_notional'), + 'min': this.safeNumber(market, 'minNotional'), 'max': undefined, }, }, - 'created': this.safeTimestamp(market, 'created_time'), + 'created': undefined, 'info': market, }; } @@ -381082,7 +383772,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchTrades * @description get the list of most recent trades for a particular symbol - * @see https://docs.woox.io/#market-trades-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/marketTrades * @param {string} symbol unified symbol of the market to fetch trades for * @param {int} [since] timestamp in ms of the earliest trade to fetch * @param {int} [limit] the maximum amount of trades to fetch @@ -381098,38 +383788,28 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (limit !== undefined) { request['limit'] = limit; } - const response = await this.v1PublicGetMarketTrades(this.extend(request, params)); + const response = await this.v3PublicGetMarketTrades(this.extend(request, params)); // - // { - // "success": true, - // "rows": [ - // { - // "symbol": "SPOT_BTC_USDT", - // "side": "SELL", - // "executed_price": 46222.35, - // "executed_quantity": 0.0012, - // "executed_timestamp": "1641241162.329" - // }, - // { - // "symbol": "SPOT_BTC_USDT", - // "side": "SELL", - // "executed_price": 46222.35, - // "executed_quantity": 0.0012, - // "executed_timestamp": "1641241162.329" - // }, - // { - // "symbol": "SPOT_BTC_USDT", - // "side": "BUY", - // "executed_price": 46224.32, - // "executed_quantity": 0.00039, - // "executed_timestamp": "1641241162.287" + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "SPOT_BTC_USDT", + // "side": "SELL", + // "source": 0, + // "executedPrice": "108741.01", + // "executedQuantity": "0.02477", + // "executedTimestamp": 1751513940144 + // } + // ] // }, - // ... - // ] - // } + // "timestamp": 1751513988543 + // } // - const resultResponse = this.safeList(response, 'rows', []); - return this.parseTrades(resultResponse, market, since, limit); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); + return this.parseTrades(rows, market, since, limit); } parseTrade(trade, market = undefined) { // @@ -381138,36 +383818,47 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // { // "symbol": "SPOT_BTC_USDT", // "side": "SELL", - // "executed_price": 46222.35, - // "executed_quantity": 0.0012, - // "executed_timestamp": "1641241162.329" + // "source": 0, + // "executedPrice": "108741.01", + // "executedQuantity": "0.02477", + // "executedTimestamp": 1751513940144 // } // // fetchOrderTrades, fetchOrder // // { - // "id": "99119876", - // "symbol": "SPOT_WOO_USDT", - // "fee": "0.0024", + // "id": 1734947821, + // "symbol": "SPOT_LTC_USDT", + // "orderId": 60780383217, + // "executedPrice": 87.86, + // "executedQuantity": 0.1, + // "fee": 0.0001, + // "realizedPnl": null, + // "feeAsset": "LTC", + // "orderTag": "default", // "side": "BUY", - // "executed_timestamp": "1641481113.084", - // "order_id": "87001234", - // "order_tag": "default", <-- this param only in "fetchOrderTrades" - // "executed_price": "1", - // "executed_quantity": "12", - // "fee_asset": "WOO", - // "is_maker": "1" + // "executedTimestamp": "1752055173.630", + // "isMaker": 0 // } // const isFromFetchOrder = ('id' in trade); - const timestamp = this.safeTimestamp(trade, 'executed_timestamp'); + const timestampString = this.safeString2(trade, 'executed_timestamp', 'executedTimestamp'); + let timestamp = undefined; + if (timestampString !== undefined) { + if (timestampString.indexOf('.') > -1) { + timestamp = this.safeTimestamp2(trade, 'executed_timestamp', 'executedTimestamp'); + } + else { + timestamp = this.safeInteger(trade, 'executedTimestamp'); + } + } const marketId = this.safeString(trade, 'symbol'); market = this.safeMarket(marketId, market); const symbol = market['symbol']; - const price = this.safeString(trade, 'executed_price'); - const amount = this.safeString(trade, 'executed_quantity'); - const order_id = this.safeString(trade, 'order_id'); - const fee = this.parseTokenAndFeeTemp(trade, 'fee_asset', 'fee'); + const price = this.safeString2(trade, 'executed_price', 'executedPrice'); + const amount = this.safeString2(trade, 'executed_quantity', 'executedQuantity'); + const order_id = this.safeString2(trade, 'order_id', 'orderId'); + const fee = this.parseTokenAndFeeTemp(trade, ['fee_asset', 'feeAsset'], ['fee']); const feeCost = this.safeString(fee, 'cost'); if (feeCost !== undefined) { fee['cost'] = feeCost; @@ -381177,7 +383868,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const id = this.safeString(trade, 'id'); let takerOrMaker = undefined; if (isFromFetchOrder) { - const isMaker = this.safeString(trade, 'is_maker') === '1'; + const isMaker = this.safeString2(trade, 'is_maker', 'isMaker') === '1'; takerOrMaker = isMaker ? 'maker' : 'taker'; } return this.safeTrade({ @@ -381196,11 +383887,11 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'info': trade, }, market); } - parseTokenAndFeeTemp(item, feeTokenKey, feeAmountKey) { - const feeCost = this.safeString(item, feeAmountKey); + parseTokenAndFeeTemp(item, feeTokenKeys, feeAmountKeys) { + const feeCost = this.safeStringN(item, feeAmountKeys); let fee = undefined; if (feeCost !== undefined) { - const feeCurrencyId = this.safeString(item, feeTokenKey); + const feeCurrencyId = this.safeStringN(item, feeTokenKeys); const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId); fee = { 'cost': feeCost, @@ -381209,43 +383900,90 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ } return fee; } + parseTradingFee(fee, market = undefined) { + const marketId = this.safeString(fee, 'symbol'); + const symbol = this.safeSymbol(marketId, market); + return { + 'info': fee, + 'symbol': symbol, + 'maker': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(this.safeString(fee, 'makerFee'), '100')), + 'taker': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringDiv(this.safeString(fee, 'takerFee'), '100')), + 'percentage': undefined, + 'tierBased': undefined, + }; + } + /** + * @method + * @name woo#fetchTradingFee + * @description fetch the trading fees for a market + * @see https://developer.woox.io/api-reference/endpoint/trading/get_tradingFee + * @param {string} symbol unified market symbol + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account + * @param {string} [params.subType] "linear" or "inverse" + * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure} + */ + async fetchTradingFee(symbol, params = {}) { + await this.loadMarkets(); + const market = this.market(symbol); + const request = { + 'symbol': market['id'], + }; + const response = await this.v3PrivateGetTradeTradingFee(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "symbol": "SPOT_BTC_USDT", + // "takerFee": "10", + // "makerFee": "8" + // }, + // "timestamp": 1751858977368 + // } + // + const data = this.safeDict(response, 'data', {}); + return this.parseTradingFee(data, market); + } /** * @method * @name woo#fetchTradingFees * @description fetch the trading fees for multiple markets - * @see https://docs.woox.io/#get-account-information-new + * @see https://developer.woox.io/api-reference/endpoint/account/get_account_info * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols */ async fetchTradingFees(params = {}) { await this.loadMarkets(); - const response = await this.v3PrivateGetAccountinfo(params); + const response = await this.v3PrivateGetAccountInfo(params); // // { // "success": true, // "data": { - // "applicationId": "dsa", - // "account": "dsa", - // "alias": "haha", - // "accountMode": "MARGIN", - // "leverage": 1, - // "takerFeeRate": 1, - // "makerFeeRate": 1, - // "interestRate": 1, - // "futuresTakerFeeRate": 1, - // "futuresMakerFeeRate": 1, + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "account": "carlos_jose_lima@yahoo.com", + // "alias": "carlos_jose_lima@yahoo.com", // "otpauth": true, - // "marginRatio": 1, - // "openMarginRatio": 1, - // "initialMarginRatio": 1, - // "maintenanceMarginRatio": 1, - // "totalCollateral": 1, - // "freeCollateral": 1, - // "totalAccountValue": 1, - // "totalVaultValue": 1, - // "totalStakingValue": 1 + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "makerFeeRate": 0, + // "takerFeeRate": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.55629469", + // "freeCollateral": "165.55629469", + // "totalAccountValue": "167.32418611", + // "totalTradingValue": "167.32418611", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" // }, - // "timestamp": 1673323685109 + // "timestamp": 1752062807915 // } // const data = this.safeDict(response, 'data', {}); @@ -381509,8 +384247,8 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#createOrder * @description create a trade order - * @see https://docs.woox.io/#send-order - * @see https://docs.woox.io/#send-algo-order + * @see https://developer.woox.io/api-reference/endpoint/trading/post_order + * @see https://developer.woox.io/api-reference/endpoint/trading/post_algo_order * @param {string} symbol unified symbol of the market to create an order in * @param {string} type 'market' or 'limit' * @param {string} side 'buy' or 'sell' @@ -381545,7 +384283,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ let marginMode = undefined; [marginMode, params] = this.handleMarginModeAndParams('createOrder', params); if (marginMode !== undefined) { - request['margin_mode'] = this.encodeMarginMode(marginMode); + request['marginMode'] = this.encodeMarginMode(marginMode); } const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice'); const stopLoss = this.safeValue(params, 'stopLoss'); @@ -381561,33 +384299,29 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const isMarket = orderType === 'MARKET'; const timeInForce = this.safeStringLower(params, 'timeInForce'); const postOnly = this.isPostOnly(isMarket, undefined, params); - const reduceOnlyKey = isConditional ? 'reduceOnly' : 'reduce_only'; - const clientOrderIdKey = isConditional ? 'clientOrderId' : 'client_order_id'; - const orderQtyKey = isConditional ? 'quantity' : 'order_quantity'; - const priceKey = isConditional ? 'price' : 'order_price'; - const typeKey = isConditional ? 'type' : 'order_type'; - request[typeKey] = orderType; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID + const clientOrderIdKey = isConditional ? 'clientAlgoOrderId' : 'clientOrderId'; + request['type'] = orderType; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID if (!isConditional) { if (postOnly) { - request['order_type'] = 'POST_ONLY'; + request['type'] = 'POST_ONLY'; } else if (timeInForce === 'fok') { - request['order_type'] = 'FOK'; + request['type'] = 'FOK'; } else if (timeInForce === 'ioc') { - request['order_type'] = 'IOC'; + request['type'] = 'IOC'; } } if (reduceOnly) { - request[reduceOnlyKey] = reduceOnly; + request['reduceOnly'] = reduceOnly; } if (!isMarket && price !== undefined) { - request[priceKey] = this.priceToPrecision(symbol, price); + request['price'] = this.priceToPrecision(symbol, price); } if (isMarket && !isConditional) { // for market buy it requires the amount of quote currency to spend - const cost = this.safeString2(params, 'cost', 'order_amount'); - params = this.omit(params, ['cost', 'order_amount']); + const cost = this.safeStringN(params, ['cost', 'order_amount', 'orderAmount']); + params = this.omit(params, ['cost', 'order_amount', 'orderAmount']); const isPriceProvided = price !== undefined; if (market['spot'] && (isPriceProvided || (cost !== undefined))) { let quoteAmount = undefined; @@ -381600,14 +384334,14 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const costRequest = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(amountString, priceString); quoteAmount = this.costToPrecision(symbol, costRequest); } - request['order_amount'] = quoteAmount; + request['amount'] = quoteAmount; } else { - request['order_quantity'] = this.amountToPrecision(symbol, amount); + request['quantity'] = this.amountToPrecision(symbol, amount); } } else if (algoType !== 'POSITIONAL_TP_SL') { - request[orderQtyKey] = this.amountToPrecision(symbol, amount); + request['quantity'] = this.amountToPrecision(symbol, amount); } const clientOrderId = this.safeStringN(params, ['clOrdID', 'clientOrderId', 'client_order_id']); if (clientOrderId !== undefined) { @@ -381670,44 +384404,46 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']); let response = undefined; if (isConditional) { - response = await this.v3PrivatePostAlgoOrder(this.extend(request, params)); + response = await this.v3PrivatePostTradeAlgoOrder(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "orderId": "1578938", + // "clientOrderId": "0", + // "algoType": "STOP_LOSS", + // "quantity": "0.1" + // } + // ] + // }, + // "timestamp": "1686149372216" + // } + // } else { - response = await this.v1PrivatePostOrder(this.extend(request, params)); - } - // { - // "success": true, - // "timestamp": "1641383206.489", - // "order_id": "86980774", - // "order_type": "LIMIT", - // "order_price": "1", // null for "MARKET" order - // "order_quantity": "12", // null for "MARKET" order - // "order_amount": null, // NOT-null for "MARKET" order - // "client_order_id": "0" - // } - // stop orders - // { - // "success": true, - // "data": { - // "rows": [ - // { - // "orderId": "1578938", - // "clientOrderId": "0", - // "algoType": "STOP_LOSS", - // "quantity": "0.1" - // } - // ] - // }, - // "timestamp": "1686149372216" - // } - const data = this.safeDict(response, 'data'); - if (data !== undefined) { - const rows = this.safeList(data, 'rows', []); - return this.parseOrder(rows[0], market); + response = await this.v3PrivatePostTradeOrder(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "orderId": 60667653330, + // "clientOrderId": 0, + // "type": "LIMIT", + // "price": 60, + // "quantity": 0.1, + // "amount": null, + // "bidAskLevel": null + // }, + // "timestamp": 1751871779855 + // } + // } - const order = this.parseOrder(response, market); - order['type'] = type; - return order; + let data = this.safeDict(response, 'data', {}); + data = this.safeDict(this.safeList(data, 'rows'), 0, data); + data['timestamp'] = this.safeString(response, 'timestamp'); + return this.parseOrder(data, market); } encodeMarginMode(mode) { const modes = { @@ -381816,9 +384552,8 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ /** * @method * @name woo#cancelOrder - * @see https://docs.woox.io/#cancel-algo-order - * @see https://docs.woox.io/#cancel-order - * @see https://docs.woox.io/#cancel-order-by-client_order_id + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_order + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_algo_order * @description cancels an open order * @param {string} id order id * @param {string} symbol unified symbol of the market the order was made in @@ -381840,42 +384575,52 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const request = {}; const clientOrderIdUnified = this.safeString2(params, 'clOrdID', 'clientOrderId'); const clientOrderIdExchangeSpecific = this.safeString(params, 'client_order_id', clientOrderIdUnified); + params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id']); const isByClientOrder = clientOrderIdExchangeSpecific !== undefined; let response = undefined; if (isTrigger) { - request['order_id'] = id; - response = await this.v3PrivateDeleteAlgoOrderOrderId(this.extend(request, params)); + if (isByClientOrder) { + request['clientAlgoOrderId'] = clientOrderIdExchangeSpecific; + } + else { + request['algoOrderId'] = id; + } + response = await this.v3PrivateDeleteTradeAlgoOrder(this.extend(request, params)); } else { request['symbol'] = market['id']; if (isByClientOrder) { - request['client_order_id'] = clientOrderIdExchangeSpecific; - params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id']); - response = await this.v1PrivateDeleteClientOrder(this.extend(request, params)); + request['clientOrderId'] = clientOrderIdExchangeSpecific; } else { - request['order_id'] = id; - response = await this.v1PrivateDeleteOrder(this.extend(request, params)); + request['orderId'] = id; } + response = await this.v3PrivateDeleteTradeOrder(this.extend(request, params)); } // - // { success: true, status: "CANCEL_SENT" } + // { + // "success": true, + // "data": { + // "status": "CANCEL_SENT" + // }, + // "timestamp": 1751940315838 + // } // - const extendParams = { 'symbol': symbol }; + const data = this.safeDict(response, 'data', {}); + data['timestamp'] = this.safeString(response, 'timestamp'); if (isByClientOrder) { - extendParams['client_order_id'] = clientOrderIdExchangeSpecific; + data['clientOrderId'] = clientOrderIdExchangeSpecific; } else { - extendParams['id'] = id; + data['orderId'] = id; } - return this.extend(this.parseOrder(response), extendParams); + return this.parseOrder(data, market); } /** * @method * @name woo#cancelAllOrders - * @see https://docs.woox.io/#cancel-all-pending-orders - * @see https://docs.woox.io/#cancel-orders - * @see https://docs.woox.io/#cancel-all-pending-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_all_order + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_algo_orders * @description cancel all open orders in a market * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint @@ -381886,32 +384631,35 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ await this.loadMarkets(); const trigger = this.safeBool2(params, 'stop', 'trigger'); params = this.omit(params, ['stop', 'trigger']); + const request = {}; + if (symbol !== undefined) { + const market = this.market(symbol); + request['symbol'] = market['id']; + } + let response = undefined; if (trigger) { - return await this.v3PrivateDeleteAlgoOrdersPending(params); + response = await this.v3PrivateDeleteTradeAlgoOrders(params); } - if (symbol === undefined) { - throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument'); + else { + response = await this.v3PrivateDeleteTradeOrders(this.extend(request, params)); } - const market = this.market(symbol); - const request = { - 'symbol': market['id'], - }; - const response = await this.v1PrivateDeleteOrders(this.extend(request, params)); // // { - // "success":true, - // "status":"CANCEL_ALL_SENT" + // "success": true, + // "data": { + // "status": "CANCEL_ALL_SENT" + // }, + // "timestamp": 1751941988134 // } // - return [ - this.safeOrder(response), - ]; + const data = this.safeDict(response, 'data', {}); + return [this.safeOrder({ 'info': data })]; } /** * @method * @name woo#cancelAllOrdersAfter * @description dead man's switch, cancel all orders after the given timeout - * @see https://docs.woox.io/#cancel-all-after + * @see https://developer.woox.io/api-reference/endpoint/trading/cancel_all_after * @param {number} timeout time in milliseconds, 0 represents cancel the timer * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} the api result @@ -381919,27 +384667,25 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ async cancelAllOrdersAfter(timeout, params = {}) { await this.loadMarkets(); const request = { - 'trigger_after': (timeout > 0) ? timeout : 0, + 'triggerAfter': (timeout > 0) ? Math.min(timeout, 900000) : 0, }; - const response = await this.v1PrivatePostOrderCancelAllAfter(this.extend(request, params)); + const response = await this.v3PrivatePostTradeCancelAllAfter(this.extend(request, params)); // - // { - // "success": true, - // "data": { - // "expected_trigger_time": 1711534302938 - // }, - // "timestamp": 1711534302943 + // { + // "success": true, + // "timestamp": 123, + // "data": { + // "expectedTriggerTime": 123 // } + // } // - return [ - this.safeOrder(response), - ]; + return response; } /** * @method * @name woo#fetchOrder - * @see https://docs.woox.io/#get-algo-order - * @see https://docs.woox.io/#get-order + * @see https://developer.woox.io/api-reference/endpoint/trading/get_order + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_order * @description fetches information on an order made by the user * @param {string} id the order id * @param {string} symbol unified symbol of the market the order was made in @@ -381949,68 +384695,109 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ */ async fetchOrder(id, symbol = undefined, params = {}) { await this.loadMarkets(); - const market = (symbol !== undefined) ? this.market(symbol) : undefined; + let market = undefined; + if (symbol !== undefined) { + market = this.market(symbol); + } const trigger = this.safeBool2(params, 'stop', 'trigger'); params = this.omit(params, ['stop', 'trigger']); const request = {}; const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId'); let response = undefined; if (trigger) { - request['oid'] = id; - response = await this.v3PrivateGetAlgoOrderOid(this.extend(request, params)); - } - else if (clientOrderId) { - request['client_order_id'] = clientOrderId; - response = await this.v1PrivateGetClientOrderClientOrderId(this.extend(request, params)); + if (clientOrderId !== undefined) { + request['clientAlgoOrderId'] = id; + } + else { + request['algoOrderId'] = id; + } + response = await this.v3PrivateGetTradeAlgoOrder(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "algoOrderId": 10399260, + // "clientAlgoOrderId": 0, + // "rootAlgoOrderId": 10399260, + // "parentAlgoOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "algoOrderTag": "default", + // "algoType": "TAKE_PROFIT", + // "side": "BUY", + // "quantity": 0.1, + // "isTriggered": false, + // "triggerPrice": 65, + // "triggerStatus": "USELESS", + // "type": "LIMIT", + // "rootAlgoStatus": "NEW", + // "algoStatus": "NEW", + // "triggerPriceType": "MARKET_PRICE", + // "price": 60, + // "triggerTime": "0", + // "totalExecutedQuantity": 0, + // "visibleQuantity": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "", + // "totalRebate": 0, + // "rebateAsset": "", + // "reduceOnly": false, + // "createdTime": "1752049747.732", + // "updatedTime": "1752049747.732", + // "positionSide": "BOTH" + // }, + // "timestamp": 1752049767550 + // } + // } else { - request['oid'] = id; - response = await this.v1PrivateGetOrderOid(this.extend(request, params)); + if (clientOrderId !== undefined) { + request['clientOrderId'] = clientOrderId; + } + else { + request['orderId'] = id; + } + response = await this.v3PrivateGetTradeOrder(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "orderId": 60780315704, + // "clientOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "orderTag": "default", + // "side": "BUY", + // "quantity": 0.1, + // "amount": null, + // "type": "LIMIT", + // "status": "NEW", + // "price": 60, + // "executed": 0, + // "visible": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "LTC", + // "totalRebate": 0, + // "rebateAsset": "USDT", + // "reduceOnly": false, + // "createdTime": "1752049062.496", + // "realizedPnl": null, + // "positionSide": "BOTH", + // "bidAskLevel": null + // }, + // "timestamp": 1752049393466 + // } + // } - // - // { - // "success": true, - // "symbol": "SPOT_WOO_USDT", - // "status": "FILLED", // FILLED, NEW - // "side": "BUY", - // "created_time": "1641480933.000", - // "order_id": "87541111", - // "order_tag": "default", - // "price": "1", - // "type": "LIMIT", - // "quantity": "12", - // "amount": null, - // "visible": "12", - // "executed": "12", // or any partial amount - // "total_fee": "0.0024", - // "fee_asset": "WOO", - // "client_order_id": null, - // "average_executed_price": "1", - // "Transactions": [ - // { - // "id": "99111647", - // "symbol": "SPOT_WOO_USDT", - // "fee": "0.0024", - // "side": "BUY", - // "executed_timestamp": "1641482113.084", - // "order_id": "87541111", - // "executed_price": "1", - // "executed_quantity": "12", - // "fee_asset": "WOO", - // "is_maker": "1" - // } - // ] - // } - // - const orders = this.safeDict(response, 'data', response); - return this.parseOrder(orders, market); + const data = this.safeDict(response, 'data', {}); + return this.parseOrder(data, market); } /** * @method * @name woo#fetchOrders * @description fetches information on multiple orders made by the user - * @see https://docs.woox.io/#get-orders - * @see https://docs.woox.io/#get-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve @@ -382018,7 +384805,6 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @param {boolean} [params.trigger] whether the order is a trigger/algo order * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default) * @param {string} [params.side] 'buy' or 'sell' - * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure} */ @@ -382032,80 +384818,124 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const request = {}; let market = undefined; const trigger = this.safeBool2(params, 'stop', 'trigger'); - const trailing = this.safeBool(params, 'trailing', false); - params = this.omit(params, ['stop', 'trailing', 'trigger']); + params = this.omit(params, ['stop', 'trigger']); if (symbol !== undefined) { market = this.market(symbol); request['symbol'] = market['id']; } if (since !== undefined) { - if (trigger || trailing) { - request['createdTimeStart'] = since; - } - else { - request['start_t'] = since; - } - } - if (limit !== undefined) { - request['size'] = limit; - } - else { - request['size'] = trailing ? 50 : 500; + request['startTime'] = since; } - if (trigger) { - request['algoType'] = 'stop'; + const until = this.safeInteger(params, 'until'); // unified in milliseconds + params = this.omit(params, ['until']); + if (until !== undefined) { + request['endTime'] = until; } - else if (trailing) { - request['algoType'] = 'TRAILING_STOP'; + if (limit !== undefined) { + request['size'] = Math.min(limit, 500); } let response = undefined; - if (trigger || trailing) { - response = await this.v3PrivateGetAlgoOrders(this.extend(request, params)); + if (trigger) { + response = await this.v3PrivateGetTradeAlgoOrders(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "algoOrderId": 10399260, + // "clientAlgoOrderId": 0, + // "rootAlgoOrderId": 10399260, + // "parentAlgoOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "algoOrderTag": "default", + // "algoType": "TAKE_PROFIT", + // "side": "BUY", + // "quantity": 0.1, + // "isTriggered": false, + // "triggerPrice": 65, + // "triggerStatus": "USELESS", + // "type": "LIMIT", + // "rootAlgoStatus": "NEW", + // "algoStatus": "NEW", + // "triggerPriceType": "MARKET_PRICE", + // "price": 60, + // "triggerTime": "0", + // "totalExecutedQuantity": 0, + // "visibleQuantity": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "", + // "totalRebate": 0, + // "rebateAsset": "", + // "reduceOnly": false, + // "createdTime": "1752049747.730", + // "updatedTime": "1752049747.730", + // "positionSide": "BOTH" + // } + // ], + // "meta": { + // "total": 7, + // "recordsPerPage": 1, + // "currentPage": 1 + // } + // }, + // "timestamp": 1752053127448 + // } + // } else { - response = await this.v1PrivateGetOrders(this.extend(request, params)); + response = await this.v3PrivateGetTradeOrders(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "orderId": 60780315704, + // "clientOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "orderTag": "default", + // "side": "BUY", + // "quantity": 0.1, + // "amount": null, + // "type": "LIMIT", + // "status": "NEW", + // "price": 60, + // "executed": 0, + // "visible": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "LTC", + // "totalRebate": 0, + // "rebateAsset": "USDT", + // "reduceOnly": false, + // "createdTime": "1752049062.496", + // "realizedPnl": null, + // "positionSide": "BOTH", + // "bidAskLevel": null + // } + // ], + // "meta": { + // "total": 11, + // "recordsPerPage": 1, + // "currentPage": 1 + // } + // }, + // "timestamp": 1752053061236 + // } + // } - // - // { - // "success":true, - // "meta":{ - // "total":1, - // "records_per_page":100, - // "current_page":1 - // }, - // "rows":[ - // { - // "symbol":"PERP_BTC_USDT", - // "status":"FILLED", - // "side":"SELL", - // "created_time":"1611617776.000", - // "updated_time":"1611617776.000", - // "order_id":52121167, - // "order_tag":"default", - // "price":null, - // "type":"MARKET", - // "quantity":0.002, - // "amount":null, - // "visible":0, - // "executed":0.002, - // "total_fee":0.01732885, - // "fee_asset":"USDT", - // "client_order_id":null, - // "average_executed_price":28881.41 - // } - // ] - // } - // - const data = this.safeValue(response, 'data', response); - const orders = this.safeList(data, 'rows'); + const data = this.safeValue(response, 'data', {}); + const orders = this.safeList(data, 'rows', []); return this.parseOrders(orders, market, since, limit); } /** * @method * @name woo#fetchOpenOrders * @description fetches information on multiple orders made by the user - * @see https://docs.woox.io/#get-orders - * @see https://docs.woox.io/#get-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve @@ -382126,8 +384956,8 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchClosedOrders * @description fetches information on multiple orders made by the user - * @see https://docs.woox.io/#get-orders - * @see https://docs.woox.io/#get-algo-orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_orders + * @see https://developer.woox.io/api-reference/endpoint/trading/get_algo_orders * @param {string} symbol unified market symbol of the market orders were made in * @param {int} [since] the earliest time in ms to fetch orders for * @param {int} [limit] the maximum number of order structures to retrieve @@ -382154,83 +384984,108 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ } parseOrder(order, market = undefined) { // - // Possible input functions: - // * createOrder - // * cancelOrder - // * fetchOrder - // * fetchOrders - // const isFromFetchOrder = ('order_tag' in order); TO_DO + // createOrder + // { + // "orderId": 60667653330, + // "clientOrderId": 0, + // "type": "LIMIT", + // "price": 60, + // "quantity": 0.1, + // "amount": null, + // "bidAskLevel": null, + // "timestamp": 1751871779855 + // } // - // stop order after creating it: - // { - // "orderId": "1578938", - // "clientOrderId": "0", - // "algoType": "STOP_LOSS", - // "quantity": "0.1" - // } - // stop order after fetching it: - // { - // "algoOrderId": "1578958", - // "clientOrderId": "0", - // "rootAlgoOrderId": "1578958", - // "parentAlgoOrderId": "0", - // "symbol": "SPOT_LTC_USDT", - // "orderTag": "default", - // "algoType": "STOP_LOSS", - // "side": "BUY", - // "quantity": "0.1", - // "isTriggered": false, - // "triggerPrice": "100", - // "triggerStatus": "USELESS", - // "type": "LIMIT", - // "rootAlgoStatus": "CANCELLED", - // "algoStatus": "CANCELLED", - // "triggerPriceType": "MARKET_PRICE", - // "price": "75", - // "triggerTime": "0", - // "totalExecutedQuantity": "0", - // "averageExecutedPrice": "0", - // "totalFee": "0", - // "feeAsset": '', - // "reduceOnly": false, - // "createdTime": "1686149609.744", - // "updatedTime": "1686149903.362" - // } + // createOrder - algo + // { + // "orderId": "1578938", + // "clientOrderId": "0", + // "algoType": "STOP_LOSS", + // "quantity": "0.1", + // "timestamp": "1686149372216" + // } // - const timestamp = this.safeTimestampN(order, ['timestamp', 'created_time', 'createdTime']); - const orderId = this.safeStringN(order, ['order_id', 'orderId', 'algoOrderId']); - const clientOrderId = this.omitZero(this.safeString2(order, 'client_order_id', 'clientOrderId')); // Somehow, this always returns 0 for limit order + // fetchOrder + // { + // "orderId": 60780315704, + // "clientOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "orderTag": "default", + // "side": "BUY", + // "quantity": 0.1, + // "amount": null, + // "type": "LIMIT", + // "status": "NEW", + // "price": 60, + // "executed": 0, + // "visible": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "LTC", + // "totalRebate": 0, + // "rebateAsset": "USDT", + // "reduceOnly": false, + // "createdTime": "1752049062.496", + // "realizedPnl": null, + // "positionSide": "BOTH", + // "bidAskLevel": null + // } + // + // fetchOrder - algo + // { + // "algoOrderId": 10399260, + // "clientAlgoOrderId": 0, + // "rootAlgoOrderId": 10399260, + // "parentAlgoOrderId": 0, + // "symbol": "SPOT_LTC_USDT", + // "algoOrderTag": "default", + // "algoType": "TAKE_PROFIT", + // "side": "BUY", + // "quantity": 0.1, + // "isTriggered": false, + // "triggerPrice": 65, + // "triggerStatus": "USELESS", + // "type": "LIMIT", + // "rootAlgoStatus": "NEW", + // "algoStatus": "NEW", + // "triggerPriceType": "MARKET_PRICE", + // "price": 60, + // "triggerTime": "0", + // "totalExecutedQuantity": 0, + // "visibleQuantity": 0.1, + // "averageExecutedPrice": 0, + // "totalFee": 0, + // "feeAsset": "", + // "totalRebate": 0, + // "rebateAsset": "", + // "reduceOnly": false, + // "createdTime": "1752049747.732", + // "updatedTime": "1752049747.732", + // "positionSide": "BOTH" + // } + // + let timestamp = this.safeTimestamp(order, 'createdTime'); + if (timestamp === undefined) { + timestamp = this.safeInteger(order, 'timestamp'); + } + const orderId = this.safeString2(order, 'orderId', 'algoOrderId'); + const clientOrderId = this.omitZero(this.safeString2(order, 'clientOrderId', 'clientAlgoOrderId')); // Somehow, this always returns 0 for limit order const marketId = this.safeString(order, 'symbol'); market = this.safeMarket(marketId, market); const symbol = market['symbol']; - const price = this.safeString2(order, 'order_price', 'price'); - const amount = this.safeString2(order, 'order_quantity', 'quantity'); // This is base amount - const cost = this.safeString2(order, 'order_amount', 'amount'); // This is quote amount - const orderType = this.safeStringLower2(order, 'order_type', 'type'); + const price = this.safeString(order, 'price'); + const amount = this.safeString(order, 'quantity'); // This is base amount + const cost = this.safeString(order, 'amount'); // This is quote amount + const orderType = this.safeStringLower(order, 'type'); const status = this.safeValue2(order, 'status', 'algoStatus'); const side = this.safeStringLower(order, 'side'); const filled = this.omitZero(this.safeValue2(order, 'executed', 'totalExecutedQuantity')); - const average = this.omitZero(this.safeString2(order, 'average_executed_price', 'averageExecutedPrice')); + const average = this.omitZero(this.safeString(order, 'averageExecutedPrice')); // const remaining = Precise.stringSub (cost, filled); - const fee = this.safeNumber2(order, 'total_fee', 'totalFee'); - const feeCurrency = this.safeString2(order, 'fee_asset', 'feeAsset'); - const transactions = this.safeValue(order, 'Transactions'); + const fee = this.safeNumber(order, 'totalFee'); + const feeCurrency = this.safeString(order, 'feeAsset'); const triggerPrice = this.safeNumber(order, 'triggerPrice'); - let takeProfitPrice = undefined; - let stopLossPrice = undefined; - const childOrders = this.safeValue(order, 'childOrders'); - if (childOrders !== undefined) { - const first = this.safeValue(childOrders, 0); - const innerChildOrders = this.safeValue(first, 'childOrders', []); - const innerChildOrdersLength = innerChildOrders.length; - if (innerChildOrdersLength > 0) { - const takeProfitOrder = this.safeValue(innerChildOrders, 0); - const stopLossOrder = this.safeValue(innerChildOrders, 1); - takeProfitPrice = this.safeNumber(takeProfitOrder, 'triggerPrice'); - stopLossPrice = this.safeNumber(stopLossOrder, 'triggerPrice'); - } - } - const lastUpdateTimestamp = this.safeTimestamp2(order, 'updatedTime', 'updated_time'); + const lastUpdateTimestamp = this.safeTimestamp(order, 'updatedTime'); return this.safeOrder({ 'id': orderId, 'clientOrderId': clientOrderId, @@ -382243,18 +385098,18 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'type': orderType, 'timeInForce': this.parseTimeInForce(orderType), 'postOnly': undefined, - 'reduceOnly': this.safeBool(order, 'reduce_only'), + 'reduceOnly': this.safeBool(order, 'reduceOnly'), 'side': side, 'price': price, 'triggerPrice': triggerPrice, - 'takeProfitPrice': takeProfitPrice, - 'stopLossPrice': stopLossPrice, + 'takeProfitPrice': undefined, + 'stopLossPrice': undefined, 'average': average, 'amount': amount, 'filled': filled, 'remaining': undefined, 'cost': cost, - 'trades': transactions, + 'trades': undefined, 'fee': { 'cost': fee, 'currency': feeCurrency, @@ -382283,7 +385138,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchOrderBook * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data - * @see https://docs.woox.io/#orderbook-snapshot-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/orderbook * @param {string} symbol unified symbol of the market to fetch the order book for * @param {int} [limit] the maximum amount of order book entries to return * @param {object} [params] extra parameters specific to the exchange API endpoint @@ -382296,40 +385151,45 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'symbol': market['id'], }; if (limit !== undefined) { - limit = Math.min(limit, 1000); - request['max_level'] = limit; + request['maxLevel'] = limit; } - const response = await this.v1PublicGetOrderbookSymbol(this.extend(request, params)); + const response = await this.v3PublicGetOrderbook(this.extend(request, params)); // - // { - // "success": true, - // "timestamp": "1641562961192", - // "asks": [ - // { price: '0.921', quantity: "76.01" }, - // { price: '0.933', quantity: "477.10" }, - // ... - // ], - // "bids": [ - // { price: '0.940', quantity: "13502.47" }, - // { price: '0.932', quantity: "43.91" }, - // ... - // ] // } + // { + // "success": true, + // "timestamp": 1751620923344, + // "data": { + // "asks": [ + // { + // "price": "108924.86", + // "quantity": "0.032126" + // } + // ], + // "bids": [ + // { + // "price": "108924.85", + // "quantity": "1.714147" + // } + // ] + // } + // } // + const data = this.safeDict(response, 'data', {}); const timestamp = this.safeInteger(response, 'timestamp'); - return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks', 'price', 'quantity'); + return this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks', 'price', 'quantity'); } /** * @method * @name woo#fetchOHLCV - * @see https://docs.woox.io/#kline-public - * @see https://docs.woox.io/#kline-historical-data-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/klineHistory * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market * @param {string} symbol unified symbol of the market to fetch OHLCV data for * @param {string} timeframe the length of time each candle represents * @param {int} [since] timestamp in ms of the earliest candle to fetch * @param {int} [limit] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms))) * @param {object} [params] extra parameters specific to the exchange API endpoint + * @param {int} [params.until] the latest time in ms to fetch entries for * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume */ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) { @@ -382339,75 +385199,47 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'symbol': market['id'], 'type': this.safeString(this.timeframes, timeframe, timeframe), }; - let useHistEndpoint = since !== undefined; - if ((limit !== undefined) && (since !== undefined)) { - const oneThousandCandles = this.parseTimeframe(timeframe) * 1000 * 999; // 999 because there will be delay between this and the request, causing the latest candle to be excluded sometimes - const startWithLimit = this.milliseconds() - oneThousandCandles; - useHistEndpoint = since < startWithLimit; - } - if (useHistEndpoint) { - request['start_time'] = since; - } - else if (limit !== undefined) { // the hist endpoint does not accept limit + if (limit !== undefined) { request['limit'] = Math.min(limit, 1000); } - let response = undefined; - if (!useHistEndpoint) { - response = await this.v1PublicGetKline(this.extend(request, params)); - // - // { - // "success": true, - // "rows": [ - // { - // "open": "0.94238", - // "close": "0.94271", - // "low": "0.94238", - // "high": "0.94296", - // "volume": "73.55", - // "amount": "69.32040520", - // "symbol": "SPOT_WOO_USDT", - // "type": "1m", - // "start_timestamp": "1641584700000", - // "end_timestamp": "1641584760000" - // }, - // ... - // ] - // } - // + if (since !== undefined) { + request['after'] = since; } - else { - response = await this.v1PubGetHistKline(this.extend(request, params)); - response = this.safeDict(response, 'data'); - // - // { - // "success": true, - // "data": { - // "rows": [ - // { - // "symbol": "SPOT_BTC_USDT", - // "open": 44181.40000000, - // "close": 44174.29000000, - // "high": 44193.44000000, - // "low": 44148.34000000, - // "volume": 110.11930100, - // "amount": 4863796.24318878, - // "type": "1m", - // "start_timestamp": 1704153600000, - // "end_timestamp": 1704153660000 - // }, - // ... - // ] - // } - // } - // + const until = this.safeInteger(params, 'until'); + params = this.omit(params, 'until'); + if (until !== undefined) { + request['before'] = until; } - const rows = this.safeList(response, 'rows', []); + const response = await this.v3PublicGetKlineHistory(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "SPOT_BTC_USDT", + // "open": "108994.16", + // "close": "108994.16", + // "high": "108994.16", + // "low": "108994.16", + // "volume": "0", + // "amount": "0", + // "type": "1m", + // "startTimestamp": 1751622120000, + // "endTimestamp": 1751622180000 + // } + // ] + // }, + // "timestamp": 1751622205410 + // } + // + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); return this.parseOHLCVs(rows, market, timeframe, since, limit); } parseOHLCV(ohlcv, market = undefined) { - // example response in fetchOHLCV return [ - this.safeInteger(ohlcv, 'start_timestamp'), + this.safeInteger(ohlcv, 'startTimestamp'), this.safeNumber(ohlcv, 'open'), this.safeNumber(ohlcv, 'high'), this.safeNumber(ohlcv, 'low'), @@ -382462,7 +385294,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchMyTrades * @description fetch all trades made by the user - * @see https://docs.woox.io/#get-trade-history + * @see https://developer.woox.io/api-reference/endpoint/trading/get_transactions * @param {string} symbol unified market symbol * @param {int} [since] the earliest time in ms to fetch trades for * @param {int} [limit] the maximum number of trades structures to retrieve @@ -382477,93 +385309,159 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (paginate) { return await this.fetchPaginatedCallIncremental('fetchMyTrades', symbol, since, limit, params, 'page', 500); } - let request = {}; + const request = {}; let market = undefined; if (symbol !== undefined) { market = this.market(symbol); request['symbol'] = market['id']; } if (since !== undefined) { - request['start_t'] = since; + request['startTime'] = since; } - [request, params] = this.handleUntilOption('end_t', request, params); - if (limit !== undefined) { - request['size'] = limit; + const until = this.safeInteger(params, 'until'); // unified in milliseconds + params = this.omit(params, ['until']); + if (until !== undefined) { + request['endTime'] = until; } - else { - request['size'] = 500; + if (limit !== undefined) { + request['limit'] = limit; } - const response = await this.v1PrivateGetClientTrades(this.extend(request, params)); - // { - // "success": true, - // "meta": { - // "records_per_page": 25, - // "current_page": 1 - // }, - // "rows": [ - // { - // "id": 5, - // "symbol": "SPOT_BTC_USDT", - // "order_id": 211, - // "order_tag": "default", - // "executed_price": 10892.84, - // "executed_quantity": 0.002, - // "is_maker": 0, - // "side": "SELL", - // "fee": 0, - // "fee_asset": "USDT", - // "executed_timestamp": "1566264290.250" + const response = await this.v3PrivateGetTradeTransactionHistory(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "id": 1734947821, + // "symbol": "SPOT_LTC_USDT", + // "orderId": 60780383217, + // "executedPrice": 87.86, + // "executedQuantity": 0.1, + // "fee": 0.0001, + // "realizedPnl": null, + // "feeAsset": "LTC", + // "orderTag": "default", + // "side": "BUY", + // "executedTimestamp": "1752055173.630", + // "isMaker": 0 + // } + // ], + // "meta": { + // "total": 1, + // "recordsPerPage": 100, + // "currentPage": 1 + // } // }, - // ... - // ] - // } - const trades = this.safeList(response, 'rows', []); + // "timestamp": 1752055545121 + // } + // + const data = this.safeDict(response, 'data', {}); + const trades = this.safeList(data, 'rows', []); return this.parseTrades(trades, market, since, limit, params); } /** * @method * @name woo#fetchAccounts * @description fetch all the accounts associated with a profile - * @see https://docs.woox.io/#get-assets-of-subaccounts + * @see https://developer.woox.io/api-reference/endpoint/account/get_account_info + * @see https://developer.woox.io/api-reference/endpoint/account/sub_accounts * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type */ async fetchAccounts(params = {}) { - const response = await this.v1PrivateGetSubAccountAssets(params); + const mainAccountPromise = this.v3PrivateGetAccountInfo(params); // // { - // "rows": [{ - // "application_id": "13e4fc34-e2ff-4cb7-b1e4-4c22fee7d365", - // "account": "Main", - // "usdt_balance": "4.0" - // }, - // { - // "application_id": "432952aa-a401-4e26-aff6-972920aebba3", - // "account": "subaccount", - // "usdt_balance": "1.0" - // } - // ], - // "success": true + // "success": true, + // "data": { + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "account": "carlos_jose_lima@yahoo.com", + // "alias": "carlos_jose_lima@yahoo.com", + // "otpauth": true, + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.55629469", + // "freeCollateral": "165.55629469", + // "totalAccountValue": "167.32418611", + // "totalTradingValue": "167.32418611", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" + // }, + // "timestamp": 1752062807915 // } // - const rows = this.safeList(response, 'rows', []); + const subAccountPromise = this.v3PrivateGetAccountSubAccountsAll(params); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "applicationId": "6b43de5c-0955-4887-9862-d84e4689f9fe", + // "name": "sub_account_2", + // "createdTime": "1606897264.994" + // }, + // ] + // }, + // "timestamp": 1721295317627 + // } + // + const [mainAccountResponse, subAccountResponse] = await Promise.all([mainAccountPromise, subAccountPromise]); + const mainData = this.safeDict(mainAccountResponse, 'data', {}); + const mainRows = [mainData]; + const subData = this.safeDict(subAccountResponse, 'data', {}); + const subRows = this.safeList(subData, 'rows', []); + const rows = this.arrayConcat(mainRows, subRows); return this.parseAccounts(rows, params); } parseAccount(account) { // // { - // "application_id": "336952aa-a401-4e26-aff6-972920aebba3", - // "account": "subaccount", - // "usdt_balance": "1.0", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "account": "carlos_jose_lima@yahoo.com", + // "alias": "carlos_jose_lima@yahoo.com", + // "otpauth": true, + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.55629469", + // "freeCollateral": "165.55629469", + // "totalAccountValue": "167.32418611", + // "totalTradingValue": "167.32418611", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" + // } + // + // { + // "applicationId": "6b43de5c-0955-4887-9862-d84e4689f9fe", + // "name": "sub_account_2", + // "createdTime": "1606897264.994" // } // - const accountId = this.safeString(account, 'account'); return { 'info': account, - 'id': this.safeString(account, 'application_id'), - 'name': accountId, + 'id': this.safeString(account, 'applicationId'), + 'name': this.safeStringN(account, ['name', 'account', 'alias']), 'code': undefined, - 'type': accountId === 'Main' ? 'main' : 'subaccount', + 'type': this.safeStringLower(account, 'accountType', 'subaccount'), }; } /** @@ -382622,7 +385520,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchDepositAddress * @description fetch the deposit address for a currency associated with this account - * @see https://docs.woox.io/#get-token-deposit-address + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_deposit * @param {string} code unified currency code * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure} @@ -382631,18 +385529,25 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // this method is TODO because of networks unification await this.loadMarkets(); const currency = this.currency(code); - let specialNetworkId = undefined; - [specialNetworkId, params] = this.getDedicatedNetworkId(currency, params); + let networkCode = undefined; + [networkCode, params] = this.handleNetworkCodeAndParams(params); const request = { - 'token': specialNetworkId, + 'token': currency['id'], + 'network': this.networkCodeToId(networkCode), }; - const response = await this.v1PrivateGetAssetDeposit(this.extend(request, params)); - // { - // "success": true, - // "address": "3Jmtjx5544T4smrit9Eroe4PCrRkpDeKjP", - // "extra": '' - // } - return this.parseDepositAddress(response, currency); + const response = await this.v3PrivateGetAssetWalletDeposit(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "address": "0x31d64B3230f8baDD91dE1710A65DF536aF8f7cDa", + // "extra": "" + // }, + // "timestamp": 1721300689532 + // } + // + const data = this.safeDict(response, 'data', {}); + return this.parseDepositAddress(data, currency); } getDedicatedNetworkId(currency, params) { let networkCode = undefined; @@ -382673,61 +385578,68 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ let currency = undefined; if (code !== undefined) { currency = this.currency(code); - request['balance_token'] = currency['id']; + request['token'] = currency['id']; + } + let networkCode = undefined; + [networkCode, params] = this.handleNetworkCodeAndParams(params); + if (networkCode !== undefined) { + request['network'] = this.networkCodeToId(networkCode); } if (since !== undefined) { - request['start_t'] = since; + request['startTime'] = since; } if (limit !== undefined) { - request['pageSize'] = limit; + request['size'] = Math.min(limit, 1000); } const transactionType = this.safeString(params, 'type'); params = this.omit(params, 'type'); if (transactionType !== undefined) { request['type'] = transactionType; } - const response = await this.v1PrivateGetAssetHistory(this.extend(request, params)); - // { - // "rows": [ - // { - // "id": "22010508193900165", - // "token": "TRON_USDT", - // "extra": '', - // "amount": "13.75848500", - // "status": "COMPLETED", - // "account": null, - // "description": null, - // "user_id": "42222", - // "application_id": "6ad2b303-f354-45c0-8105-9f5f19d0e335", - // "external_id": "220105081900134", - // "target_address": "TXnyFSnAYad3YCaqtwMw9jvXKkeU39NLnK", - // "source_address": "TYDzsYUEpvnYmQk4zGP9sWWcTEd2MiAtW6", - // "type": "BALANCE", - // "token_side": "DEPOSIT", - // "tx_id": "35b0004022f6b3ad07f39a0b7af199f6b258c2c3e2c7cdc93c67efa74fd625ee", - // "fee_token": '', - // "fee_amount": "0.00000000", - // "created_time": "1641370779.442", - // "updated_time": "1641370779.465", - // "is_new_target_address": null, - // "confirmed_number": "29", - // "confirming_threshold": "27", - // "audit_tag": "1", - // "audit_result": "0", - // "balance_token": null, // TODO -write to support, that this seems broken. here should be the token id - // "network_name": null // TODO -write to support, that this seems broken. here should be the network id - // } - // ], - // "meta": { total: '1', records_per_page: "25", current_page: "1" }, - // "success": true - // } - return [currency, this.safeList(response, 'rows', [])]; + const response = await this.v3PrivateGetAssetWalletHistory(this.extend(request, params)); + // + // { + // "success": true, + // "data": { + // "rows": [ + // { + // "createdTime": "1734964440.523", + // "updatedTime": "1734964614.081", + // "id": "24122314340000585", + // "externalId": "241223143600621", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "token": "ARB_USDCNATIVE", + // "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635", + // "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4", + // "extra": "", + // "type": "BALANCE", + // "tokenSide": "WITHDRAW", + // "amount": "10.00000000", + // "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6", + // "feeToken": "USDC", + // "feeAmount": "2", + // "status": "COMPLETED", + // "confirmingThreshold": null, + // "confirmedNumber": null + // } + // ], + // "meta": { + // "total": 1, + // "records_per_page": 25, + // "current_page": 1 + // } + // }, + // "timestamp": 1752485344719 + // } + // + const data = this.safeDict(response, 'data', {}); + return [currency, this.safeList(data, 'rows', [])]; } /** * @method * @name woo#fetchLedger * @description fetch the history of changes, actions done by the user or operations that altered balance of the user - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} [code] unified currency code, default is undefined * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined * @param {int} [limit] max number of ledger entries to return, default is undefined @@ -382741,22 +385653,43 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ return this.parseLedger(rows, currency, since, limit, params); } parseLedgerEntry(item, currency = undefined) { + // + // { + // "createdTime": "1734964440.523", + // "updatedTime": "1734964614.081", + // "id": "24122314340000585", + // "externalId": "241223143600621", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "token": "ARB_USDCNATIVE", + // "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635", + // "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4", + // "extra": "", + // "type": "BALANCE", + // "tokenSide": "WITHDRAW", + // "amount": "10.00000000", + // "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6", + // "feeToken": "USDC", + // "feeAmount": "2", + // "status": "COMPLETED", + // "confirmingThreshold": null, + // "confirmedNumber": null + // } + // const networkizedCode = this.safeString(item, 'token'); - const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency); - const code = currencyDefined['code']; + const code = this.safeCurrencyCode(networkizedCode, currency); currency = this.safeCurrency(code, currency); const amount = this.safeNumber(item, 'amount'); - const side = this.safeString(item, 'token_side'); + const side = this.safeString(item, 'tokenSide'); const direction = (side === 'DEPOSIT') ? 'in' : 'out'; - const timestamp = this.safeTimestamp(item, 'created_time'); - const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount'); + const timestamp = this.safeTimestamp(item, 'createdTime'); + const fee = this.parseTokenAndFeeTemp(item, ['feeToken'], ['feeAmount']); return this.safeLedgerEntry({ 'info': item, 'id': this.safeString(item, 'id'), 'currency': code, 'account': this.safeString(item, 'account'), 'referenceAccount': undefined, - 'referenceId': this.safeString(item, 'tx_id'), + 'referenceId': this.safeString(item, 'txId'), 'status': this.parseTransactionStatus(this.safeString(item, 'status')), 'amount': amount, 'before': undefined, @@ -382795,7 +385728,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchDeposits * @description fetch all deposits made to an account - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} code unified currency code * @param {int} [since] the earliest time in ms to fetch deposits for * @param {int} [limit] the maximum number of deposits structures to retrieve @@ -382804,7 +385737,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ */ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) { const request = { - 'token_side': 'DEPOSIT', + 'tokenSide': 'DEPOSIT', }; return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params)); } @@ -382812,7 +385745,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchWithdrawals * @description fetch all withdrawals made from an account - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} code unified currency code * @param {int} [since] the earliest time in ms to fetch withdrawals for * @param {int} [limit] the maximum number of withdrawals structures to retrieve @@ -382821,7 +385754,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ */ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) { const request = { - 'token_side': 'WITHDRAW', + 'tokenSide': 'WITHDRAW', }; return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params)); } @@ -382829,7 +385762,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchDepositsWithdrawals * @description fetch history of deposits and withdrawals - * @see https://docs.woox.io/#get-asset-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_wallet_history * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined @@ -382843,36 +385776,46 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const currencyRows = await this.getAssetHistoryRows(code, since, limit, this.extend(request, params)); const currency = this.safeValue(currencyRows, 0); const rows = this.safeList(currencyRows, 1); + return this.parseTransactions(rows, currency, since, limit, params); + } + parseTransaction(transaction, currency = undefined) { // // { - // "rows":[], - // "meta":{ - // "total":0, - // "records_per_page":25, - // "current_page":1 - // }, - // "success":true + // "createdTime": "1734964440.523", + // "updatedTime": "1734964614.081", + // "id": "24122314340000585", + // "externalId": "241223143600621", + // "applicationId": "251bf5c4-f3c8-4544-bb8b-80001007c3c0", + // "token": "ARB_USDCNATIVE", + // "targetAddress": "0x4d6802d2736daa85e6242ef0dc0f00aa0e68f635", + // "sourceAddress": "0x63DFE4e34A3bFC00eB0220786238a7C6cEF8Ffc4", + // "extra": "", + // "type": "BALANCE", + // "tokenSide": "WITHDRAW", + // "amount": "10.00000000", + // "txId": "0x891ade0a47fd55466bb9d06702bea4edcb75ed9367d9afbc47b93a84f496d2e6", + // "feeToken": "USDC", + // "feeAmount": "2", + // "status": "COMPLETED", + // "confirmingThreshold": null, + // "confirmedNumber": null // } // - return this.parseTransactions(rows, currency, since, limit, params); - } - parseTransaction(transaction, currency = undefined) { - // example in fetchLedger const networkizedCode = this.safeString(transaction, 'token'); const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency); const code = currencyDefined['code']; - let movementDirection = this.safeStringLower(transaction, 'token_side'); + let movementDirection = this.safeStringLower2(transaction, 'token_side', 'tokenSide'); if (movementDirection === 'withdraw') { movementDirection = 'withdrawal'; } - const fee = this.parseTokenAndFeeTemp(transaction, 'fee_token', 'fee_amount'); - const addressTo = this.safeString(transaction, 'target_address'); - const addressFrom = this.safeString(transaction, 'source_address'); - const timestamp = this.safeTimestamp(transaction, 'created_time'); + const fee = this.parseTokenAndFeeTemp(transaction, ['fee_token', 'feeToken'], ['fee_amount', 'feeAmount']); + const addressTo = this.safeString2(transaction, 'target_address', 'targetAddress'); + const addressFrom = this.safeString2(transaction, 'source_address', 'sourceAddress'); + const timestamp = this.safeTimestamp2(transaction, 'created_time', 'createdTime'); return { 'info': transaction, - 'id': this.safeString2(transaction, 'id', 'withdraw_id'), - 'txid': this.safeString(transaction, 'tx_id'), + 'id': this.safeStringN(transaction, ['id', 'withdraw_id', 'withdrawId']), + 'txid': this.safeString2(transaction, 'tx_id', 'txId'), 'timestamp': timestamp, 'datetime': this.iso8601(timestamp), 'address': undefined, @@ -382885,7 +385828,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'amount': this.safeNumber(transaction, 'amount'), 'currency': code, 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')), - 'updated': this.safeTimestamp(transaction, 'updated_time'), + 'updated': this.safeTimestamp2(transaction, 'updated_time', 'updatedTime'), 'comment': undefined, 'internal': undefined, 'fee': fee, @@ -382944,7 +385887,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchTransfers * @description fetch a history of internal transfers made on an account - * @see https://docs.woox.io/#get-transfer-history + * @see https://developer.woox.io/api-reference/endpoint/assets/get_transfer_history * @param {string} code unified currency code of the currency transferred * @param {int} [since] the earliest time in ms to fetch transfers for * @param {int} [limit] the maximum number of transfers structures to retrieve @@ -382954,44 +385897,56 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ */ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) { const request = {}; + let currency = undefined; + if (code !== undefined) { + currency = this.currency(code); + } if (limit !== undefined) { request['size'] = limit; } if (since !== undefined) { - request['start_t'] = since; + request['startTime'] = since; } const until = this.safeInteger(params, 'until'); // unified in milliseconds params = this.omit(params, ['until']); if (until !== undefined) { - request['end_t'] = until; + request['endTime'] = until; } - const response = await this.v1PrivateGetAssetMainSubTransferHistory(this.extend(request, params)); + const response = await this.v3PrivateGetAssetTransferHistory(this.extend(request, params)); // // { - // "rows": [ - // { - // "id": 46704, - // "token": "USDT", - // "amount": 30000.00000000, - // "status": "COMPLETED", - // "from_application_id": "0f1bd3cd-dba2-4563-b8bb-0adb1bfb83a3", - // "to_application_id": "c01e6940-a735-4022-9b6c-9d3971cdfdfa", - // "from_user": "LeverageLow", - // "to_user": "dev", - // "created_time": "1709022325.427", - // "updated_time": "1709022325.542" + // "success": true, + // "data": { + // "rows": [ + // { + // "id": 225, + // "token": "USDT", + // "amount": "1000000", + // "status": "COMPLETED", + // "from": { + // "applicationId": "046b5c5c-5b44-4d27-9593-ddc32c0a08ae", + // "accountName": "Main" + // }, + // "to": { + // "applicationId": "082ae5ae-e26a-4fb1-be5b-03e5b4867663", + // "accountName": "sub001" + // }, + // "createdTime": "1642660941.534", + // "updatedTime": "1642660941.950" + // } + // ], + // "meta": { + // "total": 46, + // "recordsPerPage": 1, + // "currentPage": 1 // } - // ], - // "meta": { - // "total": 50, - // "records_per_page": 25, - // "current_page": 1 // }, - // "success": true + // "timestamp": 1721295317627 // } // - const data = this.safeList(response, 'rows', []); - return this.parseTransfers(data, undefined, since, limit, params); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); + return this.parseTransfers(rows, currency, since, limit, params); } parseTransfer(transfer, currency = undefined) { // @@ -383008,6 +385963,22 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // "created_time": "1709022325.427", // "updated_time": "1709022325.542" // } + // { + // "id": 225, + // "token": "USDT", + // "amount": "1000000", + // "status": "COMPLETED", + // "from": { + // "applicationId": "046b5c5c-5b44-4d27-9593-ddc32c0a08ae", + // "accountName": "Main" + // }, + // "to": { + // "applicationId": "082ae5ae-e26a-4fb1-be5b-03e5b4867663", + // "accountName": "sub001" + // }, + // "createdTime": "1642660941.534", + // "updatedTime": "1642660941.950" + // } // // transfer // { @@ -383015,23 +385986,23 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // "id": 200 // } // - const networkizedCode = this.safeString(transfer, 'token'); - const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency); - const code = currencyDefined['code']; - const timestamp = this.safeTimestamp(transfer, 'created_time'); + const code = this.safeCurrencyCode(this.safeString(transfer, 'token'), currency); + const timestamp = this.safeTimestamp(transfer, 'createdTime'); const success = this.safeBool(transfer, 'success'); let status = undefined; if (success !== undefined) { status = success ? 'ok' : 'failed'; } + const fromAccount = this.safeDict(transfer, 'from', {}); + const toAccount = this.safeDict(transfer, 'to', {}); return { 'id': this.safeString(transfer, 'id'), 'timestamp': timestamp, 'datetime': this.iso8601(timestamp), 'currency': code, 'amount': this.safeNumber(transfer, 'amount'), - 'fromAccount': this.safeString(transfer, 'from_application_id'), - 'toAccount': this.safeString(transfer, 'to_application_id'), + 'fromAccount': this.safeString(fromAccount, 'applicationId'), + 'toAccount': this.safeString(toAccount, 'applicationId'), 'status': this.parseTransferStatus(this.safeString(transfer, 'status', status)), 'info': transfer, }; @@ -383158,7 +386129,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ } else { this.checkRequiredCredentials(); - if (method === 'POST' && (path === 'algo/order' || path === 'order')) { + if (method === 'POST' && (path === 'trade/algoOrder' || path === 'trade/order')) { const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false); if (!isSandboxMode) { const applicationId = 'bc830de7-50f3-460b-9ee0-f430f83f9dad'; @@ -383182,9 +386153,10 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ }; if (version === 'v3') { auth = ts + method + '/' + version + '/' + pathWithParams; - if (method === 'POST' || method === 'PUT' || method === 'DELETE') { + if (method === 'POST' || method === 'PUT') { body = this.json(params); auth += body; + headers['content-type'] = 'application/json'; } else { if (Object.keys(params).length) { @@ -383193,7 +386165,6 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ auth += '?' + query; } } - headers['content-type'] = 'application/json'; } else { auth = this.urlencode(params); @@ -383232,25 +386203,26 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ parseIncome(income, market = undefined) { // // { - // "id":666666, - // "symbol":"PERP_BTC_USDT", - // "funding_rate":0.00001198, - // "mark_price":28941.04000000, - // "funding_fee":0.00069343, - // "payment_type":"Pay", - // "status":"COMPLETED", - // "created_time":"1653616000.666", - // "updated_time":"1653616000.605" + // "id": 1286360, + // "symbol": "PERP_BTC_USDT", + // "fundingRate": -0.00001445, + // "markPrice": "26930.60000000", + // "fundingFee": "9.56021744", + // "fundingIntervalHours": 8, + // "paymentType": "Pay", + // "status": "COMPLETED", + // "createdTime": 1696060873259, + // "updatedTime": 1696060873286 // } // const marketId = this.safeString(income, 'symbol'); const symbol = this.safeSymbol(marketId, market); - let amount = this.safeString(income, 'funding_fee'); + let amount = this.safeString(income, 'fundingFee'); const code = this.safeCurrencyCode('USD'); const id = this.safeString(income, 'id'); - const timestamp = this.safeTimestamp(income, 'updated_time'); - const rate = this.safeNumber(income, 'funding_rate'); - const paymentType = this.safeString(income, 'payment_type'); + const timestamp = this.safeInteger(income, 'updatedTime'); + const rate = this.safeNumber(income, 'fundingRate'); + const paymentType = this.safeString(income, 'paymentType'); amount = (paymentType === 'Pay') ? _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringNeg(amount) : amount; return { 'info': income, @@ -383267,7 +386239,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchFundingHistory * @description fetch the history of funding payments paid and received on this account - * @see https://docs.woox.io/#get-funding-fee-history + * @see https://developer.woox.io/api-reference/endpoint/futures/get_fundingFee_history * @param {string} [symbol] unified market symbol * @param {int} [since] the earliest time in ms to fetch funding history for * @param {int} [limit] the maximum number of funding history structures to retrieve @@ -383280,7 +386252,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ let paginate = false; [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate'); if (paginate) { - return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'page', 'page', 1, 500); + return await this.fetchPaginatedCallIncremental('fetchFundingHistory', symbol, since, limit, params, 'page', 500); } const request = {}; let market = undefined; @@ -383289,70 +386261,67 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ request['symbol'] = market['id']; } if (since !== undefined) { - request['start_t'] = since; + request['startTime'] = since; } - if (limit !== undefined) { - request['size'] = limit; + const until = this.safeInteger(params, 'until'); // unified in milliseconds + params = this.omit(params, ['until']); + if (until !== undefined) { + request['endTime'] = until; } - else { - request['size'] = 5000; + if (limit !== undefined) { + request['size'] = Math.min(limit, 500); } - const response = await this.v1PrivateGetFundingFeeHistory(this.extend(request, params)); + const response = await this.v3PrivateGetFuturesFundingFeeHistory(this.extend(request, params)); // // { - // "rows":[ - // { - // "id":666666, - // "symbol":"PERP_BTC_USDT", - // "funding_rate":0.00001198, - // "mark_price":28941.04000000, - // "funding_fee":0.00069343, - // "payment_type":"Pay", - // "status":"COMPLETED", - // "created_time":"1653616000.666", - // "updated_time":"1653616000.605" - // } - // ], - // "meta":{ - // "total":235, - // "records_per_page":25, - // "current_page":1 + // "success": true, + // "data": { + // "meta": { + // "total": 670, + // "recordsPerPage": 25, + // "currentPage": 1 + // }, + // "rows": [ + // { + // "id": 1286360, + // "symbol": "PERP_BTC_USDT", + // "fundingRate": -0.00001445, + // "markPrice": "26930.60000000", + // "fundingFee": "9.56021744", + // "fundingIntervalHours": 8, + // "paymentType": "Pay", + // "status": "COMPLETED", + // "createdTime": 1696060873259, + // "updatedTime": 1696060873286 + // } + // ] // }, - // "success":true + // "timestamp": 1721351502594 // } // - const meta = this.safeDict(response, 'meta', {}); - const cursor = this.safeInteger(meta, 'current_page'); - const result = this.safeList(response, 'rows', []); - const resultLength = result.length; - if (resultLength > 0) { - const lastItem = result[resultLength - 1]; - lastItem['page'] = cursor; - result[resultLength - 1] = lastItem; - } - return this.parseIncomes(result, market, since, limit); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); + return this.parseIncomes(rows, market, since, limit); } parseFundingRate(fundingRate, market = undefined) { // // { - // "success": true, - // "timestamp": 1727427915529, // "symbol": "PERP_BTC_USDT", - // "est_funding_rate": -0.00092719, - // "est_funding_rate_timestamp": 1727427899060, - // "last_funding_rate": -0.00092610, - // "last_funding_rate_timestamp": 1727424000000, - // "next_funding_time": 1727452800000, - // "last_funding_rate_interval": 8, - // "est_funding_rate_interval": 8 + // "estFundingRate": "-0.00000441", + // "estFundingRateTimestamp": 1751623979022, + // "lastFundingRate": "-0.00004953", + // "lastFundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "lastFundingIntervalHours": 8, + // "estFundingIntervalHours": 8 // } // const symbol = this.safeString(fundingRate, 'symbol'); market = this.market(symbol); - const nextFundingTimestamp = this.safeInteger(fundingRate, 'next_funding_time'); - const estFundingRateTimestamp = this.safeInteger(fundingRate, 'est_funding_rate_timestamp'); - const lastFundingRateTimestamp = this.safeInteger(fundingRate, 'last_funding_rate_timestamp'); - const intervalString = this.safeString(fundingRate, 'est_funding_rate_interval'); + const nextFundingTimestamp = this.safeInteger(fundingRate, 'nextFundingTime'); + const estFundingRateTimestamp = this.safeInteger(fundingRate, 'estFundingRateTimestamp'); + const lastFundingRateTimestamp = this.safeInteger(fundingRate, 'lastFundingRateTimestamp'); + const intervalString = this.safeString(fundingRate, 'estFundingIntervalHours'); return { 'info': fundingRate, 'symbol': market['symbol'], @@ -383362,13 +386331,13 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ 'estimatedSettlePrice': undefined, 'timestamp': estFundingRateTimestamp, 'datetime': this.iso8601(estFundingRateTimestamp), - 'fundingRate': this.safeNumber(fundingRate, 'est_funding_rate'), + 'fundingRate': this.safeNumber(fundingRate, 'estFundingRate'), 'fundingTimestamp': nextFundingTimestamp, 'fundingDatetime': this.iso8601(nextFundingTimestamp), 'nextFundingRate': undefined, 'nextFundingTimestamp': undefined, 'nextFundingDatetime': undefined, - 'previousFundingRate': this.safeNumber(fundingRate, 'last_funding_rate'), + 'previousFundingRate': this.safeNumber(fundingRate, 'lastFundingRate'), 'previousFundingTimestamp': lastFundingRateTimestamp, 'previousFundingDatetime': this.iso8601(lastFundingRateTimestamp), 'interval': intervalString + 'h', @@ -383378,7 +386347,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchFundingInterval * @description fetch the current funding rate interval - * @see https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure} @@ -383390,7 +386359,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchFundingRate * @description fetch the current funding rate - * @see https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure} @@ -383401,28 +386370,37 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const request = { 'symbol': market['id'], }; - const response = await this.v1PublicGetFundingRateSymbol(this.extend(request, params)); + const response = await this.v3PublicGetFundingRate(this.extend(request, params)); // // { // "success": true, - // "timestamp": 1727428037877, - // "symbol": "PERP_BTC_USDT", - // "est_funding_rate": -0.00092674, - // "est_funding_rate_timestamp": 1727428019064, - // "last_funding_rate": -0.00092610, - // "last_funding_rate_timestamp": 1727424000000, - // "next_funding_time": 1727452800000, - // "last_funding_rate_interval": 8, - // "est_funding_rate_interval": 8 + // "data": { + // "rows": [ + // { + // "symbol": "PERP_BTC_USDT", + // "estFundingRate": "-0.00000441", + // "estFundingRateTimestamp": 1751623979022, + // "lastFundingRate": "-0.00004953", + // "lastFundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "lastFundingIntervalHours": 8, + // "estFundingIntervalHours": 8 + // } + // ] + // }, + // "timestamp": 1751624037798 // } // - return this.parseFundingRate(response, market); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); + const first = this.safeDict(rows, 0, {}); + return this.parseFundingRate(first, market); } /** * @method * @name woo#fetchFundingRates * @description fetch the funding rate for multiple markets - * @see https://docs.woox.io/#get-predicted-funding-rate-for-all-markets-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRate * @param {string[]|undefined} symbols list of unified market symbols * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols @@ -383430,31 +386408,36 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ async fetchFundingRates(symbols = undefined, params = {}) { await this.loadMarkets(); symbols = this.marketSymbols(symbols); - const response = await this.v1PublicGetFundingRates(params); + const response = await this.v3PublicGetFundingRate(params); // // { - // "success":true, - // "rows":[ - // { - // "symbol":"PERP_AAVE_USDT", - // "est_funding_rate":-0.00003447, - // "est_funding_rate_timestamp":1653633959001, - // "last_funding_rate":-0.00002094, - // "last_funding_rate_timestamp":1653631200000, - // "next_funding_time":1653634800000 - // } - // ], - // "timestamp":1653633985646 + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "PERP_BTC_USDT", + // "estFundingRate": "-0.00000441", + // "estFundingRateTimestamp": 1751623979022, + // "lastFundingRate": "-0.00004953", + // "lastFundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "lastFundingIntervalHours": 8, + // "estFundingIntervalHours": 8 + // } + // ] + // }, + // "timestamp": 1751624037798 // } // - const rows = this.safeList(response, 'rows', []); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); return this.parseFundingRates(rows, symbols); } /** * @method * @name woo#fetchFundingRateHistory * @description fetches historical funding rate prices - * @see https://docs.woox.io/#get-funding-rate-history-for-one-market-public + * @see https://developer.woox.io/api-reference/endpoint/public_data/fundingRateHistory * @param {string} symbol unified symbol of the market to fetch the funding rate history for * @param {int} [since] timestamp in ms of the earliest funding rate to fetch * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch @@ -383470,46 +386453,52 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ if (paginate) { return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'page', 25); } - let request = {}; - if (symbol !== undefined) { - const market = this.market(symbol); - symbol = market['symbol']; - request['symbol'] = market['id']; + if (symbol === undefined) { + throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument'); } + const market = this.market(symbol); + symbol = market['symbol']; + let request = { + 'symbol': market['id'], + }; if (since !== undefined) { - request['start_t'] = this.parseToInt(since / 1000); + request['startTime'] = since; } - [request, params] = this.handleUntilOption('end_t', request, params, 0.001); - const response = await this.v1PublicGetFundingRateHistory(this.extend(request, params)); + [request, params] = this.handleUntilOption('endTime', request, params); + const response = await this.v3PublicGetFundingRateHistory(this.extend(request, params)); // // { - // "success":true, - // "meta":{ - // "total":2464, - // "records_per_page":25, - // "current_page":1 - // }, - // "rows":[ - // { - // "symbol":"PERP_BTC_USDT", - // "funding_rate":0.00000629, - // "funding_rate_timestamp":1653638400000, - // "next_funding_time":1653642000000 + // "success": true, + // "data": { + // "rows": [ + // { + // "symbol": "PERP_BTC_USDT", + // "fundingRate": "-0.00004953", + // "fundingRateTimestamp": 1751616000000, + // "nextFundingTime": 1751644800000, + // "markPrice": "108708" + // } + // ], + // "meta": { + // "total": 11690, + // "recordsPerPage": 25, + // "currentPage": 1 // } - // ], - // "timestamp":1653640814885 + // }, + // "timestamp": 1751632390031 // } // - const result = this.safeList(response, 'rows'); + const data = this.safeDict(response, 'data', {}); + const rows = this.safeList(data, 'rows', []); const rates = []; - for (let i = 0; i < result.length; i++) { - const entry = result[i]; + for (let i = 0; i < rows.length; i++) { + const entry = rows[i]; const marketId = this.safeString(entry, 'symbol'); - const timestamp = this.safeInteger(entry, 'funding_rate_timestamp'); + const timestamp = this.safeInteger(entry, 'fundingRateTimestamp'); rates.push({ 'info': entry, 'symbol': this.safeSymbol(marketId), - 'fundingRate': this.safeNumber(entry, 'funding_rate'), + 'fundingRate': this.safeNumber(entry, 'fundingRate'), 'timestamp': timestamp, 'datetime': this.iso8601(timestamp), }); @@ -383521,7 +386510,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#setPositionMode * @description set hedged to true or false for a market - * @see https://docs.woox.io/#update-position-mode + * @see https://developer.woox.io/api-reference/endpoint/futures/position_mode * @param {bool} hedged set to true to use HEDGE_MODE, false for ONE_WAY * @param {string} symbol not used by woo setPositionMode * @param {object} [params] extra parameters specific to the exchange API endpoint @@ -383536,14 +386525,13 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ hedgeMode = 'ONE_WAY'; } const request = { - 'position_mode': hedgeMode, + 'positionMode': hedgeMode, }; - const response = await this.v1PrivatePostClientPositionMode(this.extend(request, params)); + const response = await this.v3PrivatePutFuturesPositionMode(this.extend(request, params)); // // { // "success": true, - // "data": {}, - // "timestamp": "1709195608551" + // "timestamp": 1752550492845 // } // return response; @@ -383552,11 +386540,12 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#fetchLeverage * @description fetch the set leverage for a market - * @see https://docs.woox.io/#get-account-information-new + * @see https://developer.woox.io/api-reference/endpoint/account/get_account_info + * @see https://developer.woox.io/api-reference/endpoint/futures/get_leverage * @param {string} symbol unified market symbol * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated' - * @param {string} [params.position_mode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' + * @param {string} [params.positionMode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure} */ async fetchLeverage(symbol, params = {}) { @@ -383564,7 +386553,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ const market = this.market(symbol); let response = undefined; if (market['spot']) { - response = await this.v3PrivateGetAccountinfo(params); + response = await this.v3PrivateGetAccountInfo(params); // // { // "success": true, @@ -383572,25 +386561,26 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // "applicationId": "dsa", // "account": "dsa", // "alias": "haha", - // "accountMode": "MARGIN", - // "leverage": 1, - // "takerFeeRate": 1, - // "makerFeeRate": 1, - // "interestRate": 1, - // "futuresTakerFeeRate": 1, - // "futuresMakerFeeRate": 1, // "otpauth": true, - // "marginRatio": 1, - // "openMarginRatio": 1, - // "initialMarginRatio": 1, - // "maintenanceMarginRatio": 1, - // "totalCollateral": 1, - // "freeCollateral": 1, - // "totalAccountValue": 1, - // "totalVaultValue": 1, - // "totalStakingValue": 1 + // "accountMode": "FUTURES", + // "positionMode": "ONE_WAY", + // "leverage": 0, + // "marginRatio": "10", + // "openMarginRatio": "10", + // "initialMarginRatio": "10", + // "maintenanceMarginRatio": "0.03", + // "totalCollateral": "165.6115334", + // "freeCollateral": "165.6115334", + // "totalAccountValue": "167.52723093", + // "totalTradingValue": "167.52723093", + // "totalVaultValue": "0", + // "totalStakingValue": "0", + // "totalLaunchpadValue": "0", + // "totalEarnValue": "0", + // "referrerID": null, + // "accountType": "Main" // }, - // "timestamp": 1673323685109 + // "timestamp": 1752645129054 // } // } @@ -383600,8 +386590,8 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ }; let marginMode = undefined; [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross'); - request['margin_mode'] = this.encodeMarginMode(marginMode); - response = await this.v1PrivateGetClientFuturesLeverage(this.extend(request, params)); + request['marginMode'] = this.encodeMarginMode(marginMode); + response = await this.v3PrivateGetFuturesLeverage(this.extend(request, params)); // // HEDGE_MODE // { @@ -383609,15 +386599,15 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // "data": // { // "symbol": "PERP_ETH_USDT", - // "default_margin_mode": "CROSS", - // "position_mode": "HEDGE_MODE", + // "marginMode": "CROSS", + // "positionMode": "HEDGE_MODE", // "details": [ // { - // "position_side": "LONG", + // "positionSide": "LONG", // "leverage": 10 // }, // { - // "position_side": "SHORT", + // "positionSide": "SHORT", // "leverage": 10 // } // ] @@ -383630,11 +386620,11 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // "success": true, // "data": { // "symbol": "PERP_ETH_USDT", - // "default_margin_mode": "ISOLATED", - // "position_mode": "ONE_WAY", + // "marginMode": "ISOLATED", + // "positionMode": "ONE_WAY", // "details": [ // { - // "position_side": "BOTH", + // "positionSide": "BOTH", // "leverage": 10 // } // ] @@ -383652,15 +386642,18 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ parseLeverage(leverage, market = undefined) { const marketId = this.safeString(leverage, 'symbol'); market = this.safeMarket(marketId, market); - const marginMode = this.safeStringLower(leverage, 'default_margin_mode'); - const spotLeverage = this.safeInteger(leverage, 'leverage'); + const marginMode = this.safeStringLower(leverage, 'marginMode'); + let spotLeverage = this.safeInteger(leverage, 'leverage'); + if (spotLeverage === 0) { + spotLeverage = null; + } let longLeverage = spotLeverage; let shortLeverage = spotLeverage; const details = this.safeList(leverage, 'details', []); for (let i = 0; i < details.length; i++) { const position = this.safeDict(details, i, {}); const positionLeverage = this.safeInteger(position, 'leverage'); - const side = this.safeString(position, 'position_side'); + const side = this.safeString(position, 'positionSide'); if (side === 'BOTH') { longLeverage = positionLeverage; shortLeverage = positionLeverage; @@ -383684,13 +386677,13 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ * @method * @name woo#setLeverage * @description set the level of leverage for a market - * @see https://docs.woox.io/#update-leverage-setting - * @see https://docs.woox.io/#update-futures-leverage-setting + * @see https://developer.woox.io/api-reference/endpoint/spot_margin/set_leverage + * @see https://developer.woox.io/api-reference/endpoint/futures/set_leverage * @param {float} leverage the rate of leverage (1, 2, 3, 4 or 5 for spot markets, 1, 2, 3, 4, 5, 10, 15, 20 for swap markets) * @param {string} [symbol] unified market symbol (is mandatory for swap markets) * @param {object} [params] extra parameters specific to the exchange API endpoint * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated' - * @param {string} [params.position_side] *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode. + * @param {string} [params.positionMode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE' * @returns {object} response from the exchange */ async setLeverage(leverage, symbol = undefined, params = {}) { @@ -383703,14 +386696,14 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ market = this.market(symbol); } if ((symbol === undefined) || market['spot']) { - return await this.v1PrivatePostClientLeverage(this.extend(request, params)); + return await this.v3PrivatePostSpotMarginLeverage(this.extend(request, params)); } else if (market['swap']) { request['symbol'] = market['id']; let marginMode = undefined; [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross'); - request['margin_mode'] = this.encodeMarginMode(marginMode); - return await this.v1PrivatePostClientFuturesLeverage(this.extend(request, params)); + request['marginMode'] = this.encodeMarginMode(marginMode); + return await this.v3PrivatePutFuturesLeverage(this.extend(request, params)); } else { throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets'); @@ -383755,93 +386748,99 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ }; return await this.v1PrivatePostClientIsolatedMargin(this.extend(request, params)); } + /** + * @method + * @name woo#fetchPosition + * @description fetch data on an open position + * @see https://developer.woox.io/api-reference/endpoint/futures/get_positions + * @param {string} symbol unified market symbol of the market the position is held in + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} + */ async fetchPosition(symbol, params = {}) { await this.loadMarkets(); const market = this.market(symbol); const request = { 'symbol': market['id'], }; - const response = await this.v1PrivateGetPositionSymbol(this.extend(request, params)); + const response = await this.v3PrivateGetFuturesPositions(this.extend(request, params)); // // { - // "symbol": "PERP_ETH_USDT", - // "position_side": "BOTH", - // "leverage": 10, - // "margin_mode": "CROSS", - // "average_open_price": 3139.9, - // "isolated_margin_amount": 0.0, - // "isolated_margin_token": "", - // "opening_time": "1720627963.094", - // "mark_price": 3155.19169891, - // "pending_short_qty": 0.0, - // "pending_long_qty": 0.0, - // "holding": -0.7, - // "pnl_24_h": 0.0, - // "est_liq_price": 9107.40055552, - // "settle_price": 3151.0319904, // "success": true, - // "fee_24_h": 0.0, - // "isolated_frozen_long": 0.0, - // "isolated_frozen_short": 0.0, - // "timestamp": "1720867502.544" + // "data": { + // "positions": [ + // { + // "symbol": "PERP_LTC_USDT", + // "holding": "0.1", + // "pendingLongQty": "0", + // "pendingShortQty": "0", + // "settlePrice": "96.87", + // "averageOpenPrice": "96.87", + // "pnl24H": "0", + // "fee24H": "0.0048435", + // "markPrice": "96.83793449", + // "estLiqPrice": "0", + // "timestamp": 1752500555823, + // "adlQuantile": 2, + // "positionSide": "BOTH", + // "marginMode": "CROSS", + // "isolatedMarginToken": "", + // "isolatedMarginAmount": "0", + // "isolatedFrozenLong": "0", + // "isolatedFrozenShort": "0", + // "leverage": 10 + // } + // ] + // }, + // "timestamp": 1752500579848 // } // - return this.parsePosition(response, market); + const result = this.safeDict(response, 'data', {}); + const positions = this.safeList(result, 'positions', []); + const first = this.safeDict(positions, 0, {}); + return this.parsePosition(first, market); } + /** + * @method + * @name woo#fetchPositions + * @description fetch all open positions + * @see https://developer.woox.io/api-reference/endpoint/futures/get_positions + * @param {string[]} [symbols] list of unified market symbols + * @param {object} [params] extra parameters specific to the exchange API endpoint + * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} + */ async fetchPositions(symbols = undefined, params = {}) { await this.loadMarkets(); - const response = await this.v3PrivateGetPositions(params); + const response = await this.v3PrivateGetFuturesPositions(params); // // { // "success": true, - // "data": - // { + // "data": { // "positions": [ // { - // "symbol": "PERP_ETH_USDT", - // "holding": -1.0, - // "pendingLongQty": 0.0, - // "pendingShortQty": 0.0, - // "settlePrice": 3143.2, - // "averageOpenPrice": 3143.2, - // "pnl24H": 0.0, - // "fee24H": 1.5716, - // "markPrice": 3134.97984158, - // "estLiqPrice": 3436.176349, - // "timestamp": 1720628031.463, - // "adlQuantile": 5, - // "positionSide": "BOTH", - // "marginMode": "ISOLATED", - // "isolatedMarginToken": "USDT", - // "isolatedMarginAmount": 314.62426, - // "isolatedFrozenLong": 0.0, - // "isolatedFrozenShort": 0.0, - // "leverage": 10 - // }, - // { - // "symbol": "PERP_SOL_USDT", - // "holding": -1.0, - // "pendingLongQty": 0.0, - // "pendingShortQty": 0.0, - // "settlePrice": 141.89933923, - // "averageOpenPrice": 171.38, - // "pnl24H": 0.0, - // "fee24H": 0.0, - // "markPrice": 141.65155427, - // "estLiqPrice": 4242.73548551, - // "timestamp": 1720616702.68, - // "adlQuantile": 5, + // "symbol": "PERP_LTC_USDT", + // "holding": "0.1", + // "pendingLongQty": "0", + // "pendingShortQty": "0", + // "settlePrice": "96.87", + // "averageOpenPrice": "96.87", + // "pnl24H": "0", + // "fee24H": "0.0048435", + // "markPrice": "96.83793449", + // "estLiqPrice": "0", + // "timestamp": 1752500555823, + // "adlQuantile": 2, // "positionSide": "BOTH", // "marginMode": "CROSS", // "isolatedMarginToken": "", - // "isolatedMarginAmount": 0.0, - // "isolatedFrozenLong": 0.0, - // "isolatedFrozenShort": 0.0, + // "isolatedMarginAmount": "0", + // "isolatedFrozenLong": "0", + // "isolatedFrozenShort": "0", // "leverage": 10 // } // ] // }, - // "timestamp": 1720628675078 + // "timestamp": 1752500579848 // } // const result = this.safeDict(response, 'data', {}); @@ -383876,24 +386875,24 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ // // v3PrivateGetPositions // { - // "symbol": "PERP_ETH_USDT", - // "holding": -1.0, - // "pendingLongQty": 0.0, // todo: check - // "pendingShortQty": 0.0, // todo: check - // "settlePrice": 3143.2, - // "averageOpenPrice": 3143.2, - // "pnl24H": 0.0, // todo: check - // "fee24H": 1.5716, // todo: check - // "markPrice": 3134.97984158, - // "estLiqPrice": 3436.176349, - // "timestamp": 1720628031.463, - // "adlQuantile": 5, + // "symbol": "PERP_LTC_USDT", + // "holding": "0.1", + // "pendingLongQty": "0", + // "pendingShortQty": "0", + // "settlePrice": "96.87", + // "averageOpenPrice": "96.87", + // "pnl24H": "0", + // "fee24H": "0.0048435", + // "markPrice": "96.83793449", + // "estLiqPrice": "0", + // "timestamp": 1752500555823, + // "adlQuantile": 2, // "positionSide": "BOTH", - // "marginMode": "ISOLATED", - // "isolatedMarginToken": "USDT", // todo: check - // "isolatedMarginAmount": 314.62426, // todo: check - // "isolatedFrozenLong": 0.0, // todo: check - // "isolatedFrozenShort": 0.0, // todo: check + // "marginMode": "CROSS", + // "isolatedMarginToken": "", + // "isolatedMarginAmount": "0", + // "isolatedFrozenLong": "0", + // "isolatedFrozenShort": "0", // "leverage": 10 // } // @@ -383909,7 +386908,16 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ } const contractSize = this.safeString(market, 'contractSize'); const markPrice = this.safeString2(position, 'markPrice', 'mark_price'); - const timestamp = this.safeTimestamp(position, 'timestamp'); + const timestampString = this.safeString(position, 'timestamp'); + let timestamp = undefined; + if (timestampString !== undefined) { + if (timestampString.indexOf('.') > -1) { + timestamp = this.safeTimestamp(position, 'timestamp'); + } + else { + timestamp = this.safeInteger(position, 'timestamp'); + } + } const entryPrice = this.safeString2(position, 'averageOpenPrice', 'average_open_price'); const priceDifference = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringSub(markPrice, entryPrice); const unrealisedPnl = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .Y.stringMul(priceDifference, size); @@ -386077,9 +389085,9 @@ class woofipro extends _abstract_woofipro_js__WEBPACK_IMPORTED_MODULE_0__/* ["de // } // return [ - { + this.safeOrder({ 'info': response, - }, + }), ]; } /** @@ -405425,48 +408433,48 @@ async function __wbg_init(input) { var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ AccountNotEnabled: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.AccountNotEnabled), -/* harmony export */ AccountSuspended: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.AccountSuspended), -/* harmony export */ AddressPending: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.AddressPending), -/* harmony export */ ArgumentsRequired: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ArgumentsRequired), -/* harmony export */ AuthenticationError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.AuthenticationError), -/* harmony export */ BadRequest: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.BadRequest), -/* harmony export */ BadResponse: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.BadResponse), -/* harmony export */ BadSymbol: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.BadSymbol), -/* harmony export */ BaseError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.BaseError), -/* harmony export */ CancelPending: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.CancelPending), -/* harmony export */ ChecksumError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ChecksumError), -/* harmony export */ ContractUnavailable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ContractUnavailable), -/* harmony export */ DDoSProtection: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.DDoSProtection), -/* harmony export */ DuplicateOrderId: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.DuplicateOrderId), +/* harmony export */ AccountNotEnabled: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.AccountNotEnabled), +/* harmony export */ AccountSuspended: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.AccountSuspended), +/* harmony export */ AddressPending: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.AddressPending), +/* harmony export */ ArgumentsRequired: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ArgumentsRequired), +/* harmony export */ AuthenticationError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.AuthenticationError), +/* harmony export */ BadRequest: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.BadRequest), +/* harmony export */ BadResponse: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.BadResponse), +/* harmony export */ BadSymbol: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.BadSymbol), +/* harmony export */ BaseError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.BaseError), +/* harmony export */ CancelPending: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.CancelPending), +/* harmony export */ ChecksumError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ChecksumError), +/* harmony export */ ContractUnavailable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ContractUnavailable), +/* harmony export */ DDoSProtection: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.DDoSProtection), +/* harmony export */ DuplicateOrderId: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.DuplicateOrderId), /* harmony export */ Exchange: () => (/* reexport safe */ ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_.k), -/* harmony export */ ExchangeClosedByUser: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ExchangeClosedByUser), -/* harmony export */ ExchangeError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ExchangeError), -/* harmony export */ ExchangeNotAvailable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ExchangeNotAvailable), -/* harmony export */ InsufficientFunds: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.InsufficientFunds), -/* harmony export */ InvalidAddress: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.InvalidAddress), -/* harmony export */ InvalidNonce: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.InvalidNonce), -/* harmony export */ InvalidOrder: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.InvalidOrder), -/* harmony export */ InvalidProxySettings: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.InvalidProxySettings), -/* harmony export */ ManualInteractionNeeded: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.ManualInteractionNeeded), -/* harmony export */ MarginModeAlreadySet: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.MarginModeAlreadySet), -/* harmony export */ MarketClosed: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.MarketClosed), -/* harmony export */ NetworkError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.NetworkError), -/* harmony export */ NoChange: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.NoChange), -/* harmony export */ NotSupported: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.NotSupported), -/* harmony export */ NullResponse: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.NullResponse), -/* harmony export */ OnMaintenance: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OnMaintenance), -/* harmony export */ OperationFailed: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OperationFailed), -/* harmony export */ OperationRejected: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OperationRejected), -/* harmony export */ OrderImmediatelyFillable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OrderImmediatelyFillable), -/* harmony export */ OrderNotCached: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OrderNotCached), -/* harmony export */ OrderNotFillable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OrderNotFillable), -/* harmony export */ OrderNotFound: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.OrderNotFound), -/* harmony export */ PermissionDenied: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.PermissionDenied), -/* harmony export */ Precise: () => (/* reexport safe */ ccxt_src_base_Precise_js_WEBPACK_IMPORTED_MODULE_179_.Y), -/* harmony export */ RateLimitExceeded: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.RateLimitExceeded), -/* harmony export */ RequestTimeout: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.RequestTimeout), -/* harmony export */ UnsubscribeError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_.UnsubscribeError), +/* harmony export */ ExchangeClosedByUser: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ExchangeClosedByUser), +/* harmony export */ ExchangeError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ExchangeError), +/* harmony export */ ExchangeNotAvailable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ExchangeNotAvailable), +/* harmony export */ InsufficientFunds: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.InsufficientFunds), +/* harmony export */ InvalidAddress: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.InvalidAddress), +/* harmony export */ InvalidNonce: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.InvalidNonce), +/* harmony export */ InvalidOrder: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.InvalidOrder), +/* harmony export */ InvalidProxySettings: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.InvalidProxySettings), +/* harmony export */ ManualInteractionNeeded: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.ManualInteractionNeeded), +/* harmony export */ MarginModeAlreadySet: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.MarginModeAlreadySet), +/* harmony export */ MarketClosed: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.MarketClosed), +/* harmony export */ NetworkError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.NetworkError), +/* harmony export */ NoChange: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.NoChange), +/* harmony export */ NotSupported: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.NotSupported), +/* harmony export */ NullResponse: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.NullResponse), +/* harmony export */ OnMaintenance: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OnMaintenance), +/* harmony export */ OperationFailed: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OperationFailed), +/* harmony export */ OperationRejected: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OperationRejected), +/* harmony export */ OrderImmediatelyFillable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OrderImmediatelyFillable), +/* harmony export */ OrderNotCached: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OrderNotCached), +/* harmony export */ OrderNotFillable: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OrderNotFillable), +/* harmony export */ OrderNotFound: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.OrderNotFound), +/* harmony export */ PermissionDenied: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.PermissionDenied), +/* harmony export */ Precise: () => (/* reexport safe */ ccxt_src_base_Precise_js_WEBPACK_IMPORTED_MODULE_180_.Y), +/* harmony export */ RateLimitExceeded: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.RateLimitExceeded), +/* harmony export */ RequestTimeout: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.RequestTimeout), +/* harmony export */ UnsubscribeError: () => (/* reexport safe */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_.UnsubscribeError), /* harmony export */ alpaca: () => (/* reexport safe */ ccxt_src_alpaca_js_WEBPACK_IMPORTED_MODULE_1_.A), /* harmony export */ apex: () => (/* reexport safe */ ccxt_src_apex_js_WEBPACK_IMPORTED_MODULE_2_.A), /* harmony export */ ascendex: () => (/* reexport safe */ ccxt_src_ascendex_js_WEBPACK_IMPORTED_MODULE_3_.A), @@ -405522,67 +408530,68 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ derive: () => (/* reexport safe */ ccxt_src_derive_js_WEBPACK_IMPORTED_MODULE_52_.A), /* harmony export */ digifinex: () => (/* reexport safe */ ccxt_src_digifinex_js_WEBPACK_IMPORTED_MODULE_53_.A), /* harmony export */ ellipx: () => (/* reexport safe */ ccxt_src_ellipx_js_WEBPACK_IMPORTED_MODULE_54_.A), -/* harmony export */ errors: () => (/* reexport module object */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_), +/* harmony export */ errors: () => (/* reexport module object */ ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_), /* harmony export */ exchanges: () => (/* binding */ ccxt_exchanges), /* harmony export */ exmo: () => (/* reexport safe */ ccxt_src_exmo_js_WEBPACK_IMPORTED_MODULE_55_.A), /* harmony export */ fmfwio: () => (/* reexport safe */ ccxt_src_fmfwio_js_WEBPACK_IMPORTED_MODULE_56_.A), -/* harmony export */ functions: () => (/* reexport module object */ ccxt_src_base_functions_js_WEBPACK_IMPORTED_MODULE_180_), -/* harmony export */ gate: () => (/* reexport safe */ ccxt_src_gate_js_WEBPACK_IMPORTED_MODULE_57_.A), -/* harmony export */ gateio: () => (/* reexport safe */ ccxt_src_gateio_js_WEBPACK_IMPORTED_MODULE_58_.A), -/* harmony export */ gemini: () => (/* reexport safe */ ccxt_src_gemini_js_WEBPACK_IMPORTED_MODULE_59_.A), -/* harmony export */ hashkey: () => (/* reexport safe */ ccxt_src_hashkey_js_WEBPACK_IMPORTED_MODULE_60_.A), -/* harmony export */ hitbtc: () => (/* reexport safe */ ccxt_src_hitbtc_js_WEBPACK_IMPORTED_MODULE_61_.A), -/* harmony export */ hollaex: () => (/* reexport safe */ ccxt_src_hollaex_js_WEBPACK_IMPORTED_MODULE_62_.A), -/* harmony export */ htx: () => (/* reexport safe */ ccxt_src_htx_js_WEBPACK_IMPORTED_MODULE_63_.A), -/* harmony export */ huobi: () => (/* reexport safe */ ccxt_src_huobi_js_WEBPACK_IMPORTED_MODULE_64_.A), -/* harmony export */ hyperliquid: () => (/* reexport safe */ ccxt_src_hyperliquid_js_WEBPACK_IMPORTED_MODULE_65_.A), -/* harmony export */ independentreserve: () => (/* reexport safe */ ccxt_src_independentreserve_js_WEBPACK_IMPORTED_MODULE_66_.A), -/* harmony export */ indodax: () => (/* reexport safe */ ccxt_src_indodax_js_WEBPACK_IMPORTED_MODULE_67_.A), -/* harmony export */ kraken: () => (/* reexport safe */ ccxt_src_kraken_js_WEBPACK_IMPORTED_MODULE_68_.A), -/* harmony export */ krakenfutures: () => (/* reexport safe */ ccxt_src_krakenfutures_js_WEBPACK_IMPORTED_MODULE_69_.A), -/* harmony export */ kucoin: () => (/* reexport safe */ ccxt_src_kucoin_js_WEBPACK_IMPORTED_MODULE_70_.A), -/* harmony export */ kucoinfutures: () => (/* reexport safe */ ccxt_src_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_71_.A), -/* harmony export */ latoken: () => (/* reexport safe */ ccxt_src_latoken_js_WEBPACK_IMPORTED_MODULE_72_.A), -/* harmony export */ lbank: () => (/* reexport safe */ ccxt_src_lbank_js_WEBPACK_IMPORTED_MODULE_73_.A), -/* harmony export */ luno: () => (/* reexport safe */ ccxt_src_luno_js_WEBPACK_IMPORTED_MODULE_74_.A), -/* harmony export */ mercado: () => (/* reexport safe */ ccxt_src_mercado_js_WEBPACK_IMPORTED_MODULE_75_.A), -/* harmony export */ mexc: () => (/* reexport safe */ ccxt_src_mexc_js_WEBPACK_IMPORTED_MODULE_76_.A), -/* harmony export */ modetrade: () => (/* reexport safe */ ccxt_src_modetrade_js_WEBPACK_IMPORTED_MODULE_77_.A), -/* harmony export */ myokx: () => (/* reexport safe */ ccxt_src_myokx_js_WEBPACK_IMPORTED_MODULE_78_.A), -/* harmony export */ ndax: () => (/* reexport safe */ ccxt_src_ndax_js_WEBPACK_IMPORTED_MODULE_79_.A), -/* harmony export */ novadax: () => (/* reexport safe */ ccxt_src_novadax_js_WEBPACK_IMPORTED_MODULE_80_.A), -/* harmony export */ oceanex: () => (/* reexport safe */ ccxt_src_oceanex_js_WEBPACK_IMPORTED_MODULE_81_.A), -/* harmony export */ okcoin: () => (/* reexport safe */ ccxt_src_okcoin_js_WEBPACK_IMPORTED_MODULE_82_.A), -/* harmony export */ okx: () => (/* reexport safe */ ccxt_src_okx_js_WEBPACK_IMPORTED_MODULE_83_.A), -/* harmony export */ okxus: () => (/* reexport safe */ ccxt_src_okxus_js_WEBPACK_IMPORTED_MODULE_84_.A), -/* harmony export */ onetrading: () => (/* reexport safe */ ccxt_src_onetrading_js_WEBPACK_IMPORTED_MODULE_85_.A), -/* harmony export */ oxfun: () => (/* reexport safe */ ccxt_src_oxfun_js_WEBPACK_IMPORTED_MODULE_86_.A), -/* harmony export */ p2b: () => (/* reexport safe */ ccxt_src_p2b_js_WEBPACK_IMPORTED_MODULE_87_.A), -/* harmony export */ paradex: () => (/* reexport safe */ ccxt_src_paradex_js_WEBPACK_IMPORTED_MODULE_88_.A), -/* harmony export */ paymium: () => (/* reexport safe */ ccxt_src_paymium_js_WEBPACK_IMPORTED_MODULE_89_.A), -/* harmony export */ phemex: () => (/* reexport safe */ ccxt_src_phemex_js_WEBPACK_IMPORTED_MODULE_90_.A), -/* harmony export */ poloniex: () => (/* reexport safe */ ccxt_src_poloniex_js_WEBPACK_IMPORTED_MODULE_91_.A), +/* harmony export */ foxbit: () => (/* reexport safe */ ccxt_src_foxbit_js_WEBPACK_IMPORTED_MODULE_57_.A), +/* harmony export */ functions: () => (/* reexport module object */ ccxt_src_base_functions_js_WEBPACK_IMPORTED_MODULE_181_), +/* harmony export */ gate: () => (/* reexport safe */ ccxt_src_gate_js_WEBPACK_IMPORTED_MODULE_58_.A), +/* harmony export */ gateio: () => (/* reexport safe */ ccxt_src_gateio_js_WEBPACK_IMPORTED_MODULE_59_.A), +/* harmony export */ gemini: () => (/* reexport safe */ ccxt_src_gemini_js_WEBPACK_IMPORTED_MODULE_60_.A), +/* harmony export */ hashkey: () => (/* reexport safe */ ccxt_src_hashkey_js_WEBPACK_IMPORTED_MODULE_61_.A), +/* harmony export */ hitbtc: () => (/* reexport safe */ ccxt_src_hitbtc_js_WEBPACK_IMPORTED_MODULE_62_.A), +/* harmony export */ hollaex: () => (/* reexport safe */ ccxt_src_hollaex_js_WEBPACK_IMPORTED_MODULE_63_.A), +/* harmony export */ htx: () => (/* reexport safe */ ccxt_src_htx_js_WEBPACK_IMPORTED_MODULE_64_.A), +/* harmony export */ huobi: () => (/* reexport safe */ ccxt_src_huobi_js_WEBPACK_IMPORTED_MODULE_65_.A), +/* harmony export */ hyperliquid: () => (/* reexport safe */ ccxt_src_hyperliquid_js_WEBPACK_IMPORTED_MODULE_66_.A), +/* harmony export */ independentreserve: () => (/* reexport safe */ ccxt_src_independentreserve_js_WEBPACK_IMPORTED_MODULE_67_.A), +/* harmony export */ indodax: () => (/* reexport safe */ ccxt_src_indodax_js_WEBPACK_IMPORTED_MODULE_68_.A), +/* harmony export */ kraken: () => (/* reexport safe */ ccxt_src_kraken_js_WEBPACK_IMPORTED_MODULE_69_.A), +/* harmony export */ krakenfutures: () => (/* reexport safe */ ccxt_src_krakenfutures_js_WEBPACK_IMPORTED_MODULE_70_.A), +/* harmony export */ kucoin: () => (/* reexport safe */ ccxt_src_kucoin_js_WEBPACK_IMPORTED_MODULE_71_.A), +/* harmony export */ kucoinfutures: () => (/* reexport safe */ ccxt_src_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_72_.A), +/* harmony export */ latoken: () => (/* reexport safe */ ccxt_src_latoken_js_WEBPACK_IMPORTED_MODULE_73_.A), +/* harmony export */ lbank: () => (/* reexport safe */ ccxt_src_lbank_js_WEBPACK_IMPORTED_MODULE_74_.A), +/* harmony export */ luno: () => (/* reexport safe */ ccxt_src_luno_js_WEBPACK_IMPORTED_MODULE_75_.A), +/* harmony export */ mercado: () => (/* reexport safe */ ccxt_src_mercado_js_WEBPACK_IMPORTED_MODULE_76_.A), +/* harmony export */ mexc: () => (/* reexport safe */ ccxt_src_mexc_js_WEBPACK_IMPORTED_MODULE_77_.A), +/* harmony export */ modetrade: () => (/* reexport safe */ ccxt_src_modetrade_js_WEBPACK_IMPORTED_MODULE_78_.A), +/* harmony export */ myokx: () => (/* reexport safe */ ccxt_src_myokx_js_WEBPACK_IMPORTED_MODULE_79_.A), +/* harmony export */ ndax: () => (/* reexport safe */ ccxt_src_ndax_js_WEBPACK_IMPORTED_MODULE_80_.A), +/* harmony export */ novadax: () => (/* reexport safe */ ccxt_src_novadax_js_WEBPACK_IMPORTED_MODULE_81_.A), +/* harmony export */ oceanex: () => (/* reexport safe */ ccxt_src_oceanex_js_WEBPACK_IMPORTED_MODULE_82_.A), +/* harmony export */ okcoin: () => (/* reexport safe */ ccxt_src_okcoin_js_WEBPACK_IMPORTED_MODULE_83_.A), +/* harmony export */ okx: () => (/* reexport safe */ ccxt_src_okx_js_WEBPACK_IMPORTED_MODULE_84_.A), +/* harmony export */ okxus: () => (/* reexport safe */ ccxt_src_okxus_js_WEBPACK_IMPORTED_MODULE_85_.A), +/* harmony export */ onetrading: () => (/* reexport safe */ ccxt_src_onetrading_js_WEBPACK_IMPORTED_MODULE_86_.A), +/* harmony export */ oxfun: () => (/* reexport safe */ ccxt_src_oxfun_js_WEBPACK_IMPORTED_MODULE_87_.A), +/* harmony export */ p2b: () => (/* reexport safe */ ccxt_src_p2b_js_WEBPACK_IMPORTED_MODULE_88_.A), +/* harmony export */ paradex: () => (/* reexport safe */ ccxt_src_paradex_js_WEBPACK_IMPORTED_MODULE_89_.A), +/* harmony export */ paymium: () => (/* reexport safe */ ccxt_src_paymium_js_WEBPACK_IMPORTED_MODULE_90_.A), +/* harmony export */ phemex: () => (/* reexport safe */ ccxt_src_phemex_js_WEBPACK_IMPORTED_MODULE_91_.A), +/* harmony export */ poloniex: () => (/* reexport safe */ ccxt_src_poloniex_js_WEBPACK_IMPORTED_MODULE_92_.A), /* harmony export */ pro: () => (/* binding */ ccxt_pro), -/* harmony export */ probit: () => (/* reexport safe */ ccxt_src_probit_js_WEBPACK_IMPORTED_MODULE_92_.A), -/* harmony export */ timex: () => (/* reexport safe */ ccxt_src_timex_js_WEBPACK_IMPORTED_MODULE_93_.A), -/* harmony export */ tokocrypto: () => (/* reexport safe */ ccxt_src_tokocrypto_js_WEBPACK_IMPORTED_MODULE_94_.A), -/* harmony export */ tradeogre: () => (/* reexport safe */ ccxt_src_tradeogre_js_WEBPACK_IMPORTED_MODULE_95_.A), -/* harmony export */ upbit: () => (/* reexport safe */ ccxt_src_upbit_js_WEBPACK_IMPORTED_MODULE_96_.A), +/* harmony export */ probit: () => (/* reexport safe */ ccxt_src_probit_js_WEBPACK_IMPORTED_MODULE_93_.A), +/* harmony export */ timex: () => (/* reexport safe */ ccxt_src_timex_js_WEBPACK_IMPORTED_MODULE_94_.A), +/* harmony export */ tokocrypto: () => (/* reexport safe */ ccxt_src_tokocrypto_js_WEBPACK_IMPORTED_MODULE_95_.A), +/* harmony export */ tradeogre: () => (/* reexport safe */ ccxt_src_tradeogre_js_WEBPACK_IMPORTED_MODULE_96_.A), +/* harmony export */ upbit: () => (/* reexport safe */ ccxt_src_upbit_js_WEBPACK_IMPORTED_MODULE_97_.A), /* harmony export */ version: () => (/* binding */ ccxt_version), -/* harmony export */ vertex: () => (/* reexport safe */ ccxt_src_vertex_js_WEBPACK_IMPORTED_MODULE_97_.A), -/* harmony export */ wavesexchange: () => (/* reexport safe */ ccxt_src_wavesexchange_js_WEBPACK_IMPORTED_MODULE_98_.A), -/* harmony export */ whitebit: () => (/* reexport safe */ ccxt_src_whitebit_js_WEBPACK_IMPORTED_MODULE_99_.A), -/* harmony export */ woo: () => (/* reexport safe */ ccxt_src_woo_js_WEBPACK_IMPORTED_MODULE_100_.A), -/* harmony export */ woofipro: () => (/* reexport safe */ ccxt_src_woofipro_js_WEBPACK_IMPORTED_MODULE_101_.A), -/* harmony export */ xt: () => (/* reexport safe */ ccxt_src_xt_js_WEBPACK_IMPORTED_MODULE_102_.A), -/* harmony export */ yobit: () => (/* reexport safe */ ccxt_src_yobit_js_WEBPACK_IMPORTED_MODULE_103_.A), -/* harmony export */ zaif: () => (/* reexport safe */ ccxt_src_zaif_js_WEBPACK_IMPORTED_MODULE_104_.A), -/* harmony export */ zonda: () => (/* reexport safe */ ccxt_src_zonda_js_WEBPACK_IMPORTED_MODULE_105_.A) +/* harmony export */ vertex: () => (/* reexport safe */ ccxt_src_vertex_js_WEBPACK_IMPORTED_MODULE_98_.A), +/* harmony export */ wavesexchange: () => (/* reexport safe */ ccxt_src_wavesexchange_js_WEBPACK_IMPORTED_MODULE_99_.A), +/* harmony export */ whitebit: () => (/* reexport safe */ ccxt_src_whitebit_js_WEBPACK_IMPORTED_MODULE_100_.A), +/* harmony export */ woo: () => (/* reexport safe */ ccxt_src_woo_js_WEBPACK_IMPORTED_MODULE_101_.A), +/* harmony export */ woofipro: () => (/* reexport safe */ ccxt_src_woofipro_js_WEBPACK_IMPORTED_MODULE_102_.A), +/* harmony export */ xt: () => (/* reexport safe */ ccxt_src_xt_js_WEBPACK_IMPORTED_MODULE_103_.A), +/* harmony export */ yobit: () => (/* reexport safe */ ccxt_src_yobit_js_WEBPACK_IMPORTED_MODULE_104_.A), +/* harmony export */ zaif: () => (/* reexport safe */ ccxt_src_zaif_js_WEBPACK_IMPORTED_MODULE_105_.A), +/* harmony export */ zonda: () => (/* reexport safe */ ccxt_src_zonda_js_WEBPACK_IMPORTED_MODULE_106_.A) /* harmony export */ }); /* harmony import */ var ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(2961); -/* harmony import */ var ccxt_src_base_Precise_js_WEBPACK_IMPORTED_MODULE_179_ = __webpack_require__(5147); -/* harmony import */ var ccxt_src_base_functions_js_WEBPACK_IMPORTED_MODULE_180_ = __webpack_require__(5095); -/* harmony import */ var ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_ = __webpack_require__(2079); +/* harmony import */ var ccxt_src_base_Precise_js_WEBPACK_IMPORTED_MODULE_180_ = __webpack_require__(5147); +/* harmony import */ var ccxt_src_base_functions_js_WEBPACK_IMPORTED_MODULE_181_ = __webpack_require__(5095); +/* harmony import */ var ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_ = __webpack_require__(2079); /* harmony import */ var ccxt_src_alpaca_js_WEBPACK_IMPORTED_MODULE_1_ = __webpack_require__(7930); /* harmony import */ var ccxt_src_apex_js_WEBPACK_IMPORTED_MODULE_2_ = __webpack_require__(4920); /* harmony import */ var ccxt_src_ascendex_js_WEBPACK_IMPORTED_MODULE_3_ = __webpack_require__(1411); @@ -405639,128 +408648,129 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var ccxt_src_ellipx_js_WEBPACK_IMPORTED_MODULE_54_ = __webpack_require__(1962); /* harmony import */ var ccxt_src_exmo_js_WEBPACK_IMPORTED_MODULE_55_ = __webpack_require__(7057); /* harmony import */ var ccxt_src_fmfwio_js_WEBPACK_IMPORTED_MODULE_56_ = __webpack_require__(3042); -/* harmony import */ var ccxt_src_gate_js_WEBPACK_IMPORTED_MODULE_57_ = __webpack_require__(9403); -/* harmony import */ var ccxt_src_gateio_js_WEBPACK_IMPORTED_MODULE_58_ = __webpack_require__(784); -/* harmony import */ var ccxt_src_gemini_js_WEBPACK_IMPORTED_MODULE_59_ = __webpack_require__(8823); -/* harmony import */ var ccxt_src_hashkey_js_WEBPACK_IMPORTED_MODULE_60_ = __webpack_require__(2937); -/* harmony import */ var ccxt_src_hitbtc_js_WEBPACK_IMPORTED_MODULE_61_ = __webpack_require__(7996); -/* harmony import */ var ccxt_src_hollaex_js_WEBPACK_IMPORTED_MODULE_62_ = __webpack_require__(4455); -/* harmony import */ var ccxt_src_htx_js_WEBPACK_IMPORTED_MODULE_63_ = __webpack_require__(9946); -/* harmony import */ var ccxt_src_huobi_js_WEBPACK_IMPORTED_MODULE_64_ = __webpack_require__(63); -/* harmony import */ var ccxt_src_hyperliquid_js_WEBPACK_IMPORTED_MODULE_65_ = __webpack_require__(1936); -/* harmony import */ var ccxt_src_independentreserve_js_WEBPACK_IMPORTED_MODULE_66_ = __webpack_require__(4162); -/* harmony import */ var ccxt_src_indodax_js_WEBPACK_IMPORTED_MODULE_67_ = __webpack_require__(7325); -/* harmony import */ var ccxt_src_kraken_js_WEBPACK_IMPORTED_MODULE_68_ = __webpack_require__(8042); -/* harmony import */ var ccxt_src_krakenfutures_js_WEBPACK_IMPORTED_MODULE_69_ = __webpack_require__(2300); -/* harmony import */ var ccxt_src_kucoin_js_WEBPACK_IMPORTED_MODULE_70_ = __webpack_require__(1397); -/* harmony import */ var ccxt_src_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_71_ = __webpack_require__(6217); -/* harmony import */ var ccxt_src_latoken_js_WEBPACK_IMPORTED_MODULE_72_ = __webpack_require__(8146); -/* harmony import */ var ccxt_src_lbank_js_WEBPACK_IMPORTED_MODULE_73_ = __webpack_require__(3144); -/* harmony import */ var ccxt_src_luno_js_WEBPACK_IMPORTED_MODULE_74_ = __webpack_require__(9248); -/* harmony import */ var ccxt_src_mercado_js_WEBPACK_IMPORTED_MODULE_75_ = __webpack_require__(6419); -/* harmony import */ var ccxt_src_mexc_js_WEBPACK_IMPORTED_MODULE_76_ = __webpack_require__(2403); -/* harmony import */ var ccxt_src_modetrade_js_WEBPACK_IMPORTED_MODULE_77_ = __webpack_require__(5345); -/* harmony import */ var ccxt_src_myokx_js_WEBPACK_IMPORTED_MODULE_78_ = __webpack_require__(8982); -/* harmony import */ var ccxt_src_ndax_js_WEBPACK_IMPORTED_MODULE_79_ = __webpack_require__(4460); -/* harmony import */ var ccxt_src_novadax_js_WEBPACK_IMPORTED_MODULE_80_ = __webpack_require__(8473); -/* harmony import */ var ccxt_src_oceanex_js_WEBPACK_IMPORTED_MODULE_81_ = __webpack_require__(3805); -/* harmony import */ var ccxt_src_okcoin_js_WEBPACK_IMPORTED_MODULE_82_ = __webpack_require__(7915); -/* harmony import */ var ccxt_src_okx_js_WEBPACK_IMPORTED_MODULE_83_ = __webpack_require__(3660); -/* harmony import */ var ccxt_src_okxus_js_WEBPACK_IMPORTED_MODULE_84_ = __webpack_require__(3536); -/* harmony import */ var ccxt_src_onetrading_js_WEBPACK_IMPORTED_MODULE_85_ = __webpack_require__(3573); -/* harmony import */ var ccxt_src_oxfun_js_WEBPACK_IMPORTED_MODULE_86_ = __webpack_require__(6358); -/* harmony import */ var ccxt_src_p2b_js_WEBPACK_IMPORTED_MODULE_87_ = __webpack_require__(4998); -/* harmony import */ var ccxt_src_paradex_js_WEBPACK_IMPORTED_MODULE_88_ = __webpack_require__(6993); -/* harmony import */ var ccxt_src_paymium_js_WEBPACK_IMPORTED_MODULE_89_ = __webpack_require__(3280); -/* harmony import */ var ccxt_src_phemex_js_WEBPACK_IMPORTED_MODULE_90_ = __webpack_require__(9075); -/* harmony import */ var ccxt_src_poloniex_js_WEBPACK_IMPORTED_MODULE_91_ = __webpack_require__(288); -/* harmony import */ var ccxt_src_probit_js_WEBPACK_IMPORTED_MODULE_92_ = __webpack_require__(5037); -/* harmony import */ var ccxt_src_timex_js_WEBPACK_IMPORTED_MODULE_93_ = __webpack_require__(6213); -/* harmony import */ var ccxt_src_tokocrypto_js_WEBPACK_IMPORTED_MODULE_94_ = __webpack_require__(2490); -/* harmony import */ var ccxt_src_tradeogre_js_WEBPACK_IMPORTED_MODULE_95_ = __webpack_require__(5887); -/* harmony import */ var ccxt_src_upbit_js_WEBPACK_IMPORTED_MODULE_96_ = __webpack_require__(930); -/* harmony import */ var ccxt_src_vertex_js_WEBPACK_IMPORTED_MODULE_97_ = __webpack_require__(4910); -/* harmony import */ var ccxt_src_wavesexchange_js_WEBPACK_IMPORTED_MODULE_98_ = __webpack_require__(7073); -/* harmony import */ var ccxt_src_whitebit_js_WEBPACK_IMPORTED_MODULE_99_ = __webpack_require__(5336); -/* harmony import */ var ccxt_src_woo_js_WEBPACK_IMPORTED_MODULE_100_ = __webpack_require__(669); -/* harmony import */ var ccxt_src_woofipro_js_WEBPACK_IMPORTED_MODULE_101_ = __webpack_require__(9641); -/* harmony import */ var ccxt_src_xt_js_WEBPACK_IMPORTED_MODULE_102_ = __webpack_require__(5344); -/* harmony import */ var ccxt_src_yobit_js_WEBPACK_IMPORTED_MODULE_103_ = __webpack_require__(7469); -/* harmony import */ var ccxt_src_zaif_js_WEBPACK_IMPORTED_MODULE_104_ = __webpack_require__(1530); -/* harmony import */ var ccxt_src_zonda_js_WEBPACK_IMPORTED_MODULE_105_ = __webpack_require__(6022); -/* harmony import */ var ccxt_src_pro_alpaca_js_WEBPACK_IMPORTED_MODULE_106_ = __webpack_require__(6810); -/* harmony import */ var ccxt_src_pro_apex_js_WEBPACK_IMPORTED_MODULE_107_ = __webpack_require__(136); -/* harmony import */ var ccxt_src_pro_ascendex_js_WEBPACK_IMPORTED_MODULE_108_ = __webpack_require__(1657); -/* harmony import */ var ccxt_src_pro_bequant_js_WEBPACK_IMPORTED_MODULE_109_ = __webpack_require__(9338); -/* harmony import */ var ccxt_src_pro_binance_js_WEBPACK_IMPORTED_MODULE_110_ = __webpack_require__(9544); -/* harmony import */ var ccxt_src_pro_binancecoinm_js_WEBPACK_IMPORTED_MODULE_111_ = __webpack_require__(902); -/* harmony import */ var ccxt_src_pro_binanceus_js_WEBPACK_IMPORTED_MODULE_112_ = __webpack_require__(8788); -/* harmony import */ var ccxt_src_pro_binanceusdm_js_WEBPACK_IMPORTED_MODULE_113_ = __webpack_require__(8251); -/* harmony import */ var ccxt_src_pro_bingx_js_WEBPACK_IMPORTED_MODULE_114_ = __webpack_require__(9456); -/* harmony import */ var ccxt_src_pro_bitfinex_js_WEBPACK_IMPORTED_MODULE_115_ = __webpack_require__(1038); -/* harmony import */ var ccxt_src_pro_bitget_js_WEBPACK_IMPORTED_MODULE_116_ = __webpack_require__(205); -/* harmony import */ var ccxt_src_pro_bithumb_js_WEBPACK_IMPORTED_MODULE_117_ = __webpack_require__(6181); -/* harmony import */ var ccxt_src_pro_bitmart_js_WEBPACK_IMPORTED_MODULE_118_ = __webpack_require__(3069); -/* harmony import */ var ccxt_src_pro_bitmex_js_WEBPACK_IMPORTED_MODULE_119_ = __webpack_require__(3731); -/* harmony import */ var ccxt_src_pro_bitopro_js_WEBPACK_IMPORTED_MODULE_120_ = __webpack_require__(4401); -/* harmony import */ var ccxt_src_pro_bitrue_js_WEBPACK_IMPORTED_MODULE_121_ = __webpack_require__(3333); -/* harmony import */ var ccxt_src_pro_bitstamp_js_WEBPACK_IMPORTED_MODULE_122_ = __webpack_require__(3326); -/* harmony import */ var ccxt_src_pro_bittrade_js_WEBPACK_IMPORTED_MODULE_123_ = __webpack_require__(2391); -/* harmony import */ var ccxt_src_pro_bitvavo_js_WEBPACK_IMPORTED_MODULE_124_ = __webpack_require__(1327); -/* harmony import */ var ccxt_src_pro_blockchaincom_js_WEBPACK_IMPORTED_MODULE_125_ = __webpack_require__(8693); -/* harmony import */ var ccxt_src_pro_blofin_js_WEBPACK_IMPORTED_MODULE_126_ = __webpack_require__(1672); -/* harmony import */ var ccxt_src_pro_bybit_js_WEBPACK_IMPORTED_MODULE_127_ = __webpack_require__(8518); -/* harmony import */ var ccxt_src_pro_cex_js_WEBPACK_IMPORTED_MODULE_128_ = __webpack_require__(3774); -/* harmony import */ var ccxt_src_pro_coinbase_js_WEBPACK_IMPORTED_MODULE_129_ = __webpack_require__(8160); -/* harmony import */ var ccxt_src_pro_coinbaseadvanced_js_WEBPACK_IMPORTED_MODULE_130_ = __webpack_require__(5918); -/* harmony import */ var ccxt_src_pro_coinbaseexchange_js_WEBPACK_IMPORTED_MODULE_131_ = __webpack_require__(1925); -/* harmony import */ var ccxt_src_pro_coinbaseinternational_js_WEBPACK_IMPORTED_MODULE_132_ = __webpack_require__(998); -/* harmony import */ var ccxt_src_pro_coincatch_js_WEBPACK_IMPORTED_MODULE_133_ = __webpack_require__(3242); -/* harmony import */ var ccxt_src_pro_coincheck_js_WEBPACK_IMPORTED_MODULE_134_ = __webpack_require__(5317); -/* harmony import */ var ccxt_src_pro_coinex_js_WEBPACK_IMPORTED_MODULE_135_ = __webpack_require__(9088); -/* harmony import */ var ccxt_src_pro_coinone_js_WEBPACK_IMPORTED_MODULE_136_ = __webpack_require__(8673); -/* harmony import */ var ccxt_src_pro_cryptocom_js_WEBPACK_IMPORTED_MODULE_137_ = __webpack_require__(6292); -/* harmony import */ var ccxt_src_pro_defx_js_WEBPACK_IMPORTED_MODULE_138_ = __webpack_require__(8717); -/* harmony import */ var ccxt_src_pro_deribit_js_WEBPACK_IMPORTED_MODULE_139_ = __webpack_require__(7791); -/* harmony import */ var ccxt_src_pro_derive_js_WEBPACK_IMPORTED_MODULE_140_ = __webpack_require__(2127); -/* harmony import */ var ccxt_src_pro_exmo_js_WEBPACK_IMPORTED_MODULE_141_ = __webpack_require__(5233); -/* harmony import */ var ccxt_src_pro_gate_js_WEBPACK_IMPORTED_MODULE_142_ = __webpack_require__(9195); -/* harmony import */ var ccxt_src_pro_gateio_js_WEBPACK_IMPORTED_MODULE_143_ = __webpack_require__(5843); -/* harmony import */ var ccxt_src_pro_gemini_js_WEBPACK_IMPORTED_MODULE_144_ = __webpack_require__(375); -/* harmony import */ var ccxt_src_pro_hashkey_js_WEBPACK_IMPORTED_MODULE_145_ = __webpack_require__(1481); -/* harmony import */ var ccxt_src_pro_hitbtc_js_WEBPACK_IMPORTED_MODULE_146_ = __webpack_require__(4524); -/* harmony import */ var ccxt_src_pro_hollaex_js_WEBPACK_IMPORTED_MODULE_147_ = __webpack_require__(8247); -/* harmony import */ var ccxt_src_pro_htx_js_WEBPACK_IMPORTED_MODULE_148_ = __webpack_require__(3898); -/* harmony import */ var ccxt_src_pro_huobi_js_WEBPACK_IMPORTED_MODULE_149_ = __webpack_require__(6335); -/* harmony import */ var ccxt_src_pro_hyperliquid_js_WEBPACK_IMPORTED_MODULE_150_ = __webpack_require__(3984); -/* harmony import */ var ccxt_src_pro_independentreserve_js_WEBPACK_IMPORTED_MODULE_151_ = __webpack_require__(98); -/* harmony import */ var ccxt_src_pro_kraken_js_WEBPACK_IMPORTED_MODULE_152_ = __webpack_require__(9050); -/* harmony import */ var ccxt_src_pro_krakenfutures_js_WEBPACK_IMPORTED_MODULE_153_ = __webpack_require__(6396); -/* harmony import */ var ccxt_src_pro_kucoin_js_WEBPACK_IMPORTED_MODULE_154_ = __webpack_require__(4965); -/* harmony import */ var ccxt_src_pro_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_155_ = __webpack_require__(905); -/* harmony import */ var ccxt_src_pro_lbank_js_WEBPACK_IMPORTED_MODULE_156_ = __webpack_require__(1736); -/* harmony import */ var ccxt_src_pro_luno_js_WEBPACK_IMPORTED_MODULE_157_ = __webpack_require__(2208); -/* harmony import */ var ccxt_src_pro_mexc_js_WEBPACK_IMPORTED_MODULE_158_ = __webpack_require__(9219); -/* harmony import */ var ccxt_src_pro_modetrade_js_WEBPACK_IMPORTED_MODULE_159_ = __webpack_require__(49); -/* harmony import */ var ccxt_src_pro_myokx_js_WEBPACK_IMPORTED_MODULE_160_ = __webpack_require__(3062); -/* harmony import */ var ccxt_src_pro_ndax_js_WEBPACK_IMPORTED_MODULE_161_ = __webpack_require__(3887); -/* harmony import */ var ccxt_src_pro_okcoin_js_WEBPACK_IMPORTED_MODULE_162_ = __webpack_require__(6187); -/* harmony import */ var ccxt_src_pro_okx_js_WEBPACK_IMPORTED_MODULE_163_ = __webpack_require__(8588); -/* harmony import */ var ccxt_src_pro_okxus_js_WEBPACK_IMPORTED_MODULE_164_ = __webpack_require__(3296); -/* harmony import */ var ccxt_src_pro_onetrading_js_WEBPACK_IMPORTED_MODULE_165_ = __webpack_require__(4357); -/* harmony import */ var ccxt_src_pro_oxfun_js_WEBPACK_IMPORTED_MODULE_166_ = __webpack_require__(550); -/* harmony import */ var ccxt_src_pro_p2b_js_WEBPACK_IMPORTED_MODULE_167_ = __webpack_require__(4934); -/* harmony import */ var ccxt_src_pro_paradex_js_WEBPACK_IMPORTED_MODULE_168_ = __webpack_require__(1057); -/* harmony import */ var ccxt_src_pro_phemex_js_WEBPACK_IMPORTED_MODULE_169_ = __webpack_require__(1619); -/* harmony import */ var ccxt_src_pro_poloniex_js_WEBPACK_IMPORTED_MODULE_170_ = __webpack_require__(3456); -/* harmony import */ var ccxt_src_pro_probit_js_WEBPACK_IMPORTED_MODULE_171_ = __webpack_require__(5738); -/* harmony import */ var ccxt_src_pro_tradeogre_js_WEBPACK_IMPORTED_MODULE_172_ = __webpack_require__(8719); -/* harmony import */ var ccxt_src_pro_upbit_js_WEBPACK_IMPORTED_MODULE_173_ = __webpack_require__(5794); -/* harmony import */ var ccxt_src_pro_vertex_js_WEBPACK_IMPORTED_MODULE_174_ = __webpack_require__(910); -/* harmony import */ var ccxt_src_pro_whitebit_js_WEBPACK_IMPORTED_MODULE_175_ = __webpack_require__(4712); -/* harmony import */ var ccxt_src_pro_woo_js_WEBPACK_IMPORTED_MODULE_176_ = __webpack_require__(5869); -/* harmony import */ var ccxt_src_pro_woofipro_js_WEBPACK_IMPORTED_MODULE_177_ = __webpack_require__(8713); -/* harmony import */ var ccxt_src_pro_xt_js_WEBPACK_IMPORTED_MODULE_178_ = __webpack_require__(2368); +/* harmony import */ var ccxt_src_foxbit_js_WEBPACK_IMPORTED_MODULE_57_ = __webpack_require__(448); +/* harmony import */ var ccxt_src_gate_js_WEBPACK_IMPORTED_MODULE_58_ = __webpack_require__(9403); +/* harmony import */ var ccxt_src_gateio_js_WEBPACK_IMPORTED_MODULE_59_ = __webpack_require__(784); +/* harmony import */ var ccxt_src_gemini_js_WEBPACK_IMPORTED_MODULE_60_ = __webpack_require__(8823); +/* harmony import */ var ccxt_src_hashkey_js_WEBPACK_IMPORTED_MODULE_61_ = __webpack_require__(2937); +/* harmony import */ var ccxt_src_hitbtc_js_WEBPACK_IMPORTED_MODULE_62_ = __webpack_require__(7996); +/* harmony import */ var ccxt_src_hollaex_js_WEBPACK_IMPORTED_MODULE_63_ = __webpack_require__(4455); +/* harmony import */ var ccxt_src_htx_js_WEBPACK_IMPORTED_MODULE_64_ = __webpack_require__(9946); +/* harmony import */ var ccxt_src_huobi_js_WEBPACK_IMPORTED_MODULE_65_ = __webpack_require__(63); +/* harmony import */ var ccxt_src_hyperliquid_js_WEBPACK_IMPORTED_MODULE_66_ = __webpack_require__(1936); +/* harmony import */ var ccxt_src_independentreserve_js_WEBPACK_IMPORTED_MODULE_67_ = __webpack_require__(4162); +/* harmony import */ var ccxt_src_indodax_js_WEBPACK_IMPORTED_MODULE_68_ = __webpack_require__(7325); +/* harmony import */ var ccxt_src_kraken_js_WEBPACK_IMPORTED_MODULE_69_ = __webpack_require__(8042); +/* harmony import */ var ccxt_src_krakenfutures_js_WEBPACK_IMPORTED_MODULE_70_ = __webpack_require__(2300); +/* harmony import */ var ccxt_src_kucoin_js_WEBPACK_IMPORTED_MODULE_71_ = __webpack_require__(1397); +/* harmony import */ var ccxt_src_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_72_ = __webpack_require__(6217); +/* harmony import */ var ccxt_src_latoken_js_WEBPACK_IMPORTED_MODULE_73_ = __webpack_require__(8146); +/* harmony import */ var ccxt_src_lbank_js_WEBPACK_IMPORTED_MODULE_74_ = __webpack_require__(3144); +/* harmony import */ var ccxt_src_luno_js_WEBPACK_IMPORTED_MODULE_75_ = __webpack_require__(9248); +/* harmony import */ var ccxt_src_mercado_js_WEBPACK_IMPORTED_MODULE_76_ = __webpack_require__(6419); +/* harmony import */ var ccxt_src_mexc_js_WEBPACK_IMPORTED_MODULE_77_ = __webpack_require__(2403); +/* harmony import */ var ccxt_src_modetrade_js_WEBPACK_IMPORTED_MODULE_78_ = __webpack_require__(5345); +/* harmony import */ var ccxt_src_myokx_js_WEBPACK_IMPORTED_MODULE_79_ = __webpack_require__(8982); +/* harmony import */ var ccxt_src_ndax_js_WEBPACK_IMPORTED_MODULE_80_ = __webpack_require__(4460); +/* harmony import */ var ccxt_src_novadax_js_WEBPACK_IMPORTED_MODULE_81_ = __webpack_require__(8473); +/* harmony import */ var ccxt_src_oceanex_js_WEBPACK_IMPORTED_MODULE_82_ = __webpack_require__(3805); +/* harmony import */ var ccxt_src_okcoin_js_WEBPACK_IMPORTED_MODULE_83_ = __webpack_require__(7915); +/* harmony import */ var ccxt_src_okx_js_WEBPACK_IMPORTED_MODULE_84_ = __webpack_require__(3660); +/* harmony import */ var ccxt_src_okxus_js_WEBPACK_IMPORTED_MODULE_85_ = __webpack_require__(3536); +/* harmony import */ var ccxt_src_onetrading_js_WEBPACK_IMPORTED_MODULE_86_ = __webpack_require__(3573); +/* harmony import */ var ccxt_src_oxfun_js_WEBPACK_IMPORTED_MODULE_87_ = __webpack_require__(6358); +/* harmony import */ var ccxt_src_p2b_js_WEBPACK_IMPORTED_MODULE_88_ = __webpack_require__(4998); +/* harmony import */ var ccxt_src_paradex_js_WEBPACK_IMPORTED_MODULE_89_ = __webpack_require__(6993); +/* harmony import */ var ccxt_src_paymium_js_WEBPACK_IMPORTED_MODULE_90_ = __webpack_require__(3280); +/* harmony import */ var ccxt_src_phemex_js_WEBPACK_IMPORTED_MODULE_91_ = __webpack_require__(9075); +/* harmony import */ var ccxt_src_poloniex_js_WEBPACK_IMPORTED_MODULE_92_ = __webpack_require__(288); +/* harmony import */ var ccxt_src_probit_js_WEBPACK_IMPORTED_MODULE_93_ = __webpack_require__(5037); +/* harmony import */ var ccxt_src_timex_js_WEBPACK_IMPORTED_MODULE_94_ = __webpack_require__(6213); +/* harmony import */ var ccxt_src_tokocrypto_js_WEBPACK_IMPORTED_MODULE_95_ = __webpack_require__(2490); +/* harmony import */ var ccxt_src_tradeogre_js_WEBPACK_IMPORTED_MODULE_96_ = __webpack_require__(5887); +/* harmony import */ var ccxt_src_upbit_js_WEBPACK_IMPORTED_MODULE_97_ = __webpack_require__(930); +/* harmony import */ var ccxt_src_vertex_js_WEBPACK_IMPORTED_MODULE_98_ = __webpack_require__(4910); +/* harmony import */ var ccxt_src_wavesexchange_js_WEBPACK_IMPORTED_MODULE_99_ = __webpack_require__(7073); +/* harmony import */ var ccxt_src_whitebit_js_WEBPACK_IMPORTED_MODULE_100_ = __webpack_require__(5336); +/* harmony import */ var ccxt_src_woo_js_WEBPACK_IMPORTED_MODULE_101_ = __webpack_require__(669); +/* harmony import */ var ccxt_src_woofipro_js_WEBPACK_IMPORTED_MODULE_102_ = __webpack_require__(9641); +/* harmony import */ var ccxt_src_xt_js_WEBPACK_IMPORTED_MODULE_103_ = __webpack_require__(5344); +/* harmony import */ var ccxt_src_yobit_js_WEBPACK_IMPORTED_MODULE_104_ = __webpack_require__(7469); +/* harmony import */ var ccxt_src_zaif_js_WEBPACK_IMPORTED_MODULE_105_ = __webpack_require__(1530); +/* harmony import */ var ccxt_src_zonda_js_WEBPACK_IMPORTED_MODULE_106_ = __webpack_require__(6022); +/* harmony import */ var ccxt_src_pro_alpaca_js_WEBPACK_IMPORTED_MODULE_107_ = __webpack_require__(6810); +/* harmony import */ var ccxt_src_pro_apex_js_WEBPACK_IMPORTED_MODULE_108_ = __webpack_require__(136); +/* harmony import */ var ccxt_src_pro_ascendex_js_WEBPACK_IMPORTED_MODULE_109_ = __webpack_require__(1657); +/* harmony import */ var ccxt_src_pro_bequant_js_WEBPACK_IMPORTED_MODULE_110_ = __webpack_require__(9338); +/* harmony import */ var ccxt_src_pro_binance_js_WEBPACK_IMPORTED_MODULE_111_ = __webpack_require__(9544); +/* harmony import */ var ccxt_src_pro_binancecoinm_js_WEBPACK_IMPORTED_MODULE_112_ = __webpack_require__(902); +/* harmony import */ var ccxt_src_pro_binanceus_js_WEBPACK_IMPORTED_MODULE_113_ = __webpack_require__(8788); +/* harmony import */ var ccxt_src_pro_binanceusdm_js_WEBPACK_IMPORTED_MODULE_114_ = __webpack_require__(8251); +/* harmony import */ var ccxt_src_pro_bingx_js_WEBPACK_IMPORTED_MODULE_115_ = __webpack_require__(9456); +/* harmony import */ var ccxt_src_pro_bitfinex_js_WEBPACK_IMPORTED_MODULE_116_ = __webpack_require__(1038); +/* harmony import */ var ccxt_src_pro_bitget_js_WEBPACK_IMPORTED_MODULE_117_ = __webpack_require__(205); +/* harmony import */ var ccxt_src_pro_bithumb_js_WEBPACK_IMPORTED_MODULE_118_ = __webpack_require__(6181); +/* harmony import */ var ccxt_src_pro_bitmart_js_WEBPACK_IMPORTED_MODULE_119_ = __webpack_require__(3069); +/* harmony import */ var ccxt_src_pro_bitmex_js_WEBPACK_IMPORTED_MODULE_120_ = __webpack_require__(3731); +/* harmony import */ var ccxt_src_pro_bitopro_js_WEBPACK_IMPORTED_MODULE_121_ = __webpack_require__(4401); +/* harmony import */ var ccxt_src_pro_bitrue_js_WEBPACK_IMPORTED_MODULE_122_ = __webpack_require__(3333); +/* harmony import */ var ccxt_src_pro_bitstamp_js_WEBPACK_IMPORTED_MODULE_123_ = __webpack_require__(3326); +/* harmony import */ var ccxt_src_pro_bittrade_js_WEBPACK_IMPORTED_MODULE_124_ = __webpack_require__(2391); +/* harmony import */ var ccxt_src_pro_bitvavo_js_WEBPACK_IMPORTED_MODULE_125_ = __webpack_require__(1327); +/* harmony import */ var ccxt_src_pro_blockchaincom_js_WEBPACK_IMPORTED_MODULE_126_ = __webpack_require__(8693); +/* harmony import */ var ccxt_src_pro_blofin_js_WEBPACK_IMPORTED_MODULE_127_ = __webpack_require__(1672); +/* harmony import */ var ccxt_src_pro_bybit_js_WEBPACK_IMPORTED_MODULE_128_ = __webpack_require__(8518); +/* harmony import */ var ccxt_src_pro_cex_js_WEBPACK_IMPORTED_MODULE_129_ = __webpack_require__(3774); +/* harmony import */ var ccxt_src_pro_coinbase_js_WEBPACK_IMPORTED_MODULE_130_ = __webpack_require__(8160); +/* harmony import */ var ccxt_src_pro_coinbaseadvanced_js_WEBPACK_IMPORTED_MODULE_131_ = __webpack_require__(5918); +/* harmony import */ var ccxt_src_pro_coinbaseexchange_js_WEBPACK_IMPORTED_MODULE_132_ = __webpack_require__(1925); +/* harmony import */ var ccxt_src_pro_coinbaseinternational_js_WEBPACK_IMPORTED_MODULE_133_ = __webpack_require__(998); +/* harmony import */ var ccxt_src_pro_coincatch_js_WEBPACK_IMPORTED_MODULE_134_ = __webpack_require__(3242); +/* harmony import */ var ccxt_src_pro_coincheck_js_WEBPACK_IMPORTED_MODULE_135_ = __webpack_require__(5317); +/* harmony import */ var ccxt_src_pro_coinex_js_WEBPACK_IMPORTED_MODULE_136_ = __webpack_require__(9088); +/* harmony import */ var ccxt_src_pro_coinone_js_WEBPACK_IMPORTED_MODULE_137_ = __webpack_require__(8673); +/* harmony import */ var ccxt_src_pro_cryptocom_js_WEBPACK_IMPORTED_MODULE_138_ = __webpack_require__(6292); +/* harmony import */ var ccxt_src_pro_defx_js_WEBPACK_IMPORTED_MODULE_139_ = __webpack_require__(8717); +/* harmony import */ var ccxt_src_pro_deribit_js_WEBPACK_IMPORTED_MODULE_140_ = __webpack_require__(7791); +/* harmony import */ var ccxt_src_pro_derive_js_WEBPACK_IMPORTED_MODULE_141_ = __webpack_require__(2127); +/* harmony import */ var ccxt_src_pro_exmo_js_WEBPACK_IMPORTED_MODULE_142_ = __webpack_require__(5233); +/* harmony import */ var ccxt_src_pro_gate_js_WEBPACK_IMPORTED_MODULE_143_ = __webpack_require__(9195); +/* harmony import */ var ccxt_src_pro_gateio_js_WEBPACK_IMPORTED_MODULE_144_ = __webpack_require__(5843); +/* harmony import */ var ccxt_src_pro_gemini_js_WEBPACK_IMPORTED_MODULE_145_ = __webpack_require__(375); +/* harmony import */ var ccxt_src_pro_hashkey_js_WEBPACK_IMPORTED_MODULE_146_ = __webpack_require__(1481); +/* harmony import */ var ccxt_src_pro_hitbtc_js_WEBPACK_IMPORTED_MODULE_147_ = __webpack_require__(4524); +/* harmony import */ var ccxt_src_pro_hollaex_js_WEBPACK_IMPORTED_MODULE_148_ = __webpack_require__(8247); +/* harmony import */ var ccxt_src_pro_htx_js_WEBPACK_IMPORTED_MODULE_149_ = __webpack_require__(3898); +/* harmony import */ var ccxt_src_pro_huobi_js_WEBPACK_IMPORTED_MODULE_150_ = __webpack_require__(6335); +/* harmony import */ var ccxt_src_pro_hyperliquid_js_WEBPACK_IMPORTED_MODULE_151_ = __webpack_require__(3984); +/* harmony import */ var ccxt_src_pro_independentreserve_js_WEBPACK_IMPORTED_MODULE_152_ = __webpack_require__(98); +/* harmony import */ var ccxt_src_pro_kraken_js_WEBPACK_IMPORTED_MODULE_153_ = __webpack_require__(9050); +/* harmony import */ var ccxt_src_pro_krakenfutures_js_WEBPACK_IMPORTED_MODULE_154_ = __webpack_require__(6396); +/* harmony import */ var ccxt_src_pro_kucoin_js_WEBPACK_IMPORTED_MODULE_155_ = __webpack_require__(4965); +/* harmony import */ var ccxt_src_pro_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_156_ = __webpack_require__(905); +/* harmony import */ var ccxt_src_pro_lbank_js_WEBPACK_IMPORTED_MODULE_157_ = __webpack_require__(1736); +/* harmony import */ var ccxt_src_pro_luno_js_WEBPACK_IMPORTED_MODULE_158_ = __webpack_require__(2208); +/* harmony import */ var ccxt_src_pro_mexc_js_WEBPACK_IMPORTED_MODULE_159_ = __webpack_require__(9219); +/* harmony import */ var ccxt_src_pro_modetrade_js_WEBPACK_IMPORTED_MODULE_160_ = __webpack_require__(49); +/* harmony import */ var ccxt_src_pro_myokx_js_WEBPACK_IMPORTED_MODULE_161_ = __webpack_require__(3062); +/* harmony import */ var ccxt_src_pro_ndax_js_WEBPACK_IMPORTED_MODULE_162_ = __webpack_require__(3887); +/* harmony import */ var ccxt_src_pro_okcoin_js_WEBPACK_IMPORTED_MODULE_163_ = __webpack_require__(6187); +/* harmony import */ var ccxt_src_pro_okx_js_WEBPACK_IMPORTED_MODULE_164_ = __webpack_require__(8588); +/* harmony import */ var ccxt_src_pro_okxus_js_WEBPACK_IMPORTED_MODULE_165_ = __webpack_require__(3296); +/* harmony import */ var ccxt_src_pro_onetrading_js_WEBPACK_IMPORTED_MODULE_166_ = __webpack_require__(4357); +/* harmony import */ var ccxt_src_pro_oxfun_js_WEBPACK_IMPORTED_MODULE_167_ = __webpack_require__(550); +/* harmony import */ var ccxt_src_pro_p2b_js_WEBPACK_IMPORTED_MODULE_168_ = __webpack_require__(4934); +/* harmony import */ var ccxt_src_pro_paradex_js_WEBPACK_IMPORTED_MODULE_169_ = __webpack_require__(1057); +/* harmony import */ var ccxt_src_pro_phemex_js_WEBPACK_IMPORTED_MODULE_170_ = __webpack_require__(1619); +/* harmony import */ var ccxt_src_pro_poloniex_js_WEBPACK_IMPORTED_MODULE_171_ = __webpack_require__(3456); +/* harmony import */ var ccxt_src_pro_probit_js_WEBPACK_IMPORTED_MODULE_172_ = __webpack_require__(5738); +/* harmony import */ var ccxt_src_pro_tradeogre_js_WEBPACK_IMPORTED_MODULE_173_ = __webpack_require__(8719); +/* harmony import */ var ccxt_src_pro_upbit_js_WEBPACK_IMPORTED_MODULE_174_ = __webpack_require__(5794); +/* harmony import */ var ccxt_src_pro_vertex_js_WEBPACK_IMPORTED_MODULE_175_ = __webpack_require__(910); +/* harmony import */ var ccxt_src_pro_whitebit_js_WEBPACK_IMPORTED_MODULE_176_ = __webpack_require__(4712); +/* harmony import */ var ccxt_src_pro_woo_js_WEBPACK_IMPORTED_MODULE_177_ = __webpack_require__(5869); +/* harmony import */ var ccxt_src_pro_woofipro_js_WEBPACK_IMPORTED_MODULE_178_ = __webpack_require__(8713); +/* harmony import */ var ccxt_src_pro_xt_js_WEBPACK_IMPORTED_MODULE_179_ = __webpack_require__(2368); /* MIT License @@ -405795,7 +408805,7 @@ SOFTWARE. //----------------------------------------------------------------------------- // this is updated by vss.js when building -const ccxt_version = '4.4.92'; +const ccxt_version = '4.4.96'; ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_/* .Exchange */ .k.ccxtVersion = ccxt_version; //----------------------------------------------------------------------------- @@ -405901,6 +408911,7 @@ ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_/* .Exchange */ .k.ccxtVersi + // pro exchanges @@ -406034,130 +409045,131 @@ const ccxt_exchanges = { 'ellipx': ccxt_src_ellipx_js_WEBPACK_IMPORTED_MODULE_54_/* ["default"] */ .A, 'exmo': ccxt_src_exmo_js_WEBPACK_IMPORTED_MODULE_55_/* ["default"] */ .A, 'fmfwio': ccxt_src_fmfwio_js_WEBPACK_IMPORTED_MODULE_56_/* ["default"] */ .A, - 'gate': ccxt_src_gate_js_WEBPACK_IMPORTED_MODULE_57_/* ["default"] */ .A, - 'gateio': ccxt_src_gateio_js_WEBPACK_IMPORTED_MODULE_58_/* ["default"] */ .A, - 'gemini': ccxt_src_gemini_js_WEBPACK_IMPORTED_MODULE_59_/* ["default"] */ .A, - 'hashkey': ccxt_src_hashkey_js_WEBPACK_IMPORTED_MODULE_60_/* ["default"] */ .A, - 'hitbtc': ccxt_src_hitbtc_js_WEBPACK_IMPORTED_MODULE_61_/* ["default"] */ .A, - 'hollaex': ccxt_src_hollaex_js_WEBPACK_IMPORTED_MODULE_62_/* ["default"] */ .A, - 'htx': ccxt_src_htx_js_WEBPACK_IMPORTED_MODULE_63_/* ["default"] */ .A, - 'huobi': ccxt_src_huobi_js_WEBPACK_IMPORTED_MODULE_64_/* ["default"] */ .A, - 'hyperliquid': ccxt_src_hyperliquid_js_WEBPACK_IMPORTED_MODULE_65_/* ["default"] */ .A, - 'independentreserve': ccxt_src_independentreserve_js_WEBPACK_IMPORTED_MODULE_66_/* ["default"] */ .A, - 'indodax': ccxt_src_indodax_js_WEBPACK_IMPORTED_MODULE_67_/* ["default"] */ .A, - 'kraken': ccxt_src_kraken_js_WEBPACK_IMPORTED_MODULE_68_/* ["default"] */ .A, - 'krakenfutures': ccxt_src_krakenfutures_js_WEBPACK_IMPORTED_MODULE_69_/* ["default"] */ .A, - 'kucoin': ccxt_src_kucoin_js_WEBPACK_IMPORTED_MODULE_70_/* ["default"] */ .A, - 'kucoinfutures': ccxt_src_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_71_/* ["default"] */ .A, - 'latoken': ccxt_src_latoken_js_WEBPACK_IMPORTED_MODULE_72_/* ["default"] */ .A, - 'lbank': ccxt_src_lbank_js_WEBPACK_IMPORTED_MODULE_73_/* ["default"] */ .A, - 'luno': ccxt_src_luno_js_WEBPACK_IMPORTED_MODULE_74_/* ["default"] */ .A, - 'mercado': ccxt_src_mercado_js_WEBPACK_IMPORTED_MODULE_75_/* ["default"] */ .A, - 'mexc': ccxt_src_mexc_js_WEBPACK_IMPORTED_MODULE_76_/* ["default"] */ .A, - 'modetrade': ccxt_src_modetrade_js_WEBPACK_IMPORTED_MODULE_77_/* ["default"] */ .A, - 'myokx': ccxt_src_myokx_js_WEBPACK_IMPORTED_MODULE_78_/* ["default"] */ .A, - 'ndax': ccxt_src_ndax_js_WEBPACK_IMPORTED_MODULE_79_/* ["default"] */ .A, - 'novadax': ccxt_src_novadax_js_WEBPACK_IMPORTED_MODULE_80_/* ["default"] */ .A, - 'oceanex': ccxt_src_oceanex_js_WEBPACK_IMPORTED_MODULE_81_/* ["default"] */ .A, - 'okcoin': ccxt_src_okcoin_js_WEBPACK_IMPORTED_MODULE_82_/* ["default"] */ .A, - 'okx': ccxt_src_okx_js_WEBPACK_IMPORTED_MODULE_83_/* ["default"] */ .A, - 'okxus': ccxt_src_okxus_js_WEBPACK_IMPORTED_MODULE_84_/* ["default"] */ .A, - 'onetrading': ccxt_src_onetrading_js_WEBPACK_IMPORTED_MODULE_85_/* ["default"] */ .A, - 'oxfun': ccxt_src_oxfun_js_WEBPACK_IMPORTED_MODULE_86_/* ["default"] */ .A, - 'p2b': ccxt_src_p2b_js_WEBPACK_IMPORTED_MODULE_87_/* ["default"] */ .A, - 'paradex': ccxt_src_paradex_js_WEBPACK_IMPORTED_MODULE_88_/* ["default"] */ .A, - 'paymium': ccxt_src_paymium_js_WEBPACK_IMPORTED_MODULE_89_/* ["default"] */ .A, - 'phemex': ccxt_src_phemex_js_WEBPACK_IMPORTED_MODULE_90_/* ["default"] */ .A, - 'poloniex': ccxt_src_poloniex_js_WEBPACK_IMPORTED_MODULE_91_/* ["default"] */ .A, - 'probit': ccxt_src_probit_js_WEBPACK_IMPORTED_MODULE_92_/* ["default"] */ .A, - 'timex': ccxt_src_timex_js_WEBPACK_IMPORTED_MODULE_93_/* ["default"] */ .A, - 'tokocrypto': ccxt_src_tokocrypto_js_WEBPACK_IMPORTED_MODULE_94_/* ["default"] */ .A, - 'tradeogre': ccxt_src_tradeogre_js_WEBPACK_IMPORTED_MODULE_95_/* ["default"] */ .A, - 'upbit': ccxt_src_upbit_js_WEBPACK_IMPORTED_MODULE_96_/* ["default"] */ .A, - 'vertex': ccxt_src_vertex_js_WEBPACK_IMPORTED_MODULE_97_/* ["default"] */ .A, - 'wavesexchange': ccxt_src_wavesexchange_js_WEBPACK_IMPORTED_MODULE_98_/* ["default"] */ .A, - 'whitebit': ccxt_src_whitebit_js_WEBPACK_IMPORTED_MODULE_99_/* ["default"] */ .A, - 'woo': ccxt_src_woo_js_WEBPACK_IMPORTED_MODULE_100_/* ["default"] */ .A, - 'woofipro': ccxt_src_woofipro_js_WEBPACK_IMPORTED_MODULE_101_/* ["default"] */ .A, - 'xt': ccxt_src_xt_js_WEBPACK_IMPORTED_MODULE_102_/* ["default"] */ .A, - 'yobit': ccxt_src_yobit_js_WEBPACK_IMPORTED_MODULE_103_/* ["default"] */ .A, - 'zaif': ccxt_src_zaif_js_WEBPACK_IMPORTED_MODULE_104_/* ["default"] */ .A, - 'zonda': ccxt_src_zonda_js_WEBPACK_IMPORTED_MODULE_105_/* ["default"] */ .A, + 'foxbit': ccxt_src_foxbit_js_WEBPACK_IMPORTED_MODULE_57_/* ["default"] */ .A, + 'gate': ccxt_src_gate_js_WEBPACK_IMPORTED_MODULE_58_/* ["default"] */ .A, + 'gateio': ccxt_src_gateio_js_WEBPACK_IMPORTED_MODULE_59_/* ["default"] */ .A, + 'gemini': ccxt_src_gemini_js_WEBPACK_IMPORTED_MODULE_60_/* ["default"] */ .A, + 'hashkey': ccxt_src_hashkey_js_WEBPACK_IMPORTED_MODULE_61_/* ["default"] */ .A, + 'hitbtc': ccxt_src_hitbtc_js_WEBPACK_IMPORTED_MODULE_62_/* ["default"] */ .A, + 'hollaex': ccxt_src_hollaex_js_WEBPACK_IMPORTED_MODULE_63_/* ["default"] */ .A, + 'htx': ccxt_src_htx_js_WEBPACK_IMPORTED_MODULE_64_/* ["default"] */ .A, + 'huobi': ccxt_src_huobi_js_WEBPACK_IMPORTED_MODULE_65_/* ["default"] */ .A, + 'hyperliquid': ccxt_src_hyperliquid_js_WEBPACK_IMPORTED_MODULE_66_/* ["default"] */ .A, + 'independentreserve': ccxt_src_independentreserve_js_WEBPACK_IMPORTED_MODULE_67_/* ["default"] */ .A, + 'indodax': ccxt_src_indodax_js_WEBPACK_IMPORTED_MODULE_68_/* ["default"] */ .A, + 'kraken': ccxt_src_kraken_js_WEBPACK_IMPORTED_MODULE_69_/* ["default"] */ .A, + 'krakenfutures': ccxt_src_krakenfutures_js_WEBPACK_IMPORTED_MODULE_70_/* ["default"] */ .A, + 'kucoin': ccxt_src_kucoin_js_WEBPACK_IMPORTED_MODULE_71_/* ["default"] */ .A, + 'kucoinfutures': ccxt_src_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_72_/* ["default"] */ .A, + 'latoken': ccxt_src_latoken_js_WEBPACK_IMPORTED_MODULE_73_/* ["default"] */ .A, + 'lbank': ccxt_src_lbank_js_WEBPACK_IMPORTED_MODULE_74_/* ["default"] */ .A, + 'luno': ccxt_src_luno_js_WEBPACK_IMPORTED_MODULE_75_/* ["default"] */ .A, + 'mercado': ccxt_src_mercado_js_WEBPACK_IMPORTED_MODULE_76_/* ["default"] */ .A, + 'mexc': ccxt_src_mexc_js_WEBPACK_IMPORTED_MODULE_77_/* ["default"] */ .A, + 'modetrade': ccxt_src_modetrade_js_WEBPACK_IMPORTED_MODULE_78_/* ["default"] */ .A, + 'myokx': ccxt_src_myokx_js_WEBPACK_IMPORTED_MODULE_79_/* ["default"] */ .A, + 'ndax': ccxt_src_ndax_js_WEBPACK_IMPORTED_MODULE_80_/* ["default"] */ .A, + 'novadax': ccxt_src_novadax_js_WEBPACK_IMPORTED_MODULE_81_/* ["default"] */ .A, + 'oceanex': ccxt_src_oceanex_js_WEBPACK_IMPORTED_MODULE_82_/* ["default"] */ .A, + 'okcoin': ccxt_src_okcoin_js_WEBPACK_IMPORTED_MODULE_83_/* ["default"] */ .A, + 'okx': ccxt_src_okx_js_WEBPACK_IMPORTED_MODULE_84_/* ["default"] */ .A, + 'okxus': ccxt_src_okxus_js_WEBPACK_IMPORTED_MODULE_85_/* ["default"] */ .A, + 'onetrading': ccxt_src_onetrading_js_WEBPACK_IMPORTED_MODULE_86_/* ["default"] */ .A, + 'oxfun': ccxt_src_oxfun_js_WEBPACK_IMPORTED_MODULE_87_/* ["default"] */ .A, + 'p2b': ccxt_src_p2b_js_WEBPACK_IMPORTED_MODULE_88_/* ["default"] */ .A, + 'paradex': ccxt_src_paradex_js_WEBPACK_IMPORTED_MODULE_89_/* ["default"] */ .A, + 'paymium': ccxt_src_paymium_js_WEBPACK_IMPORTED_MODULE_90_/* ["default"] */ .A, + 'phemex': ccxt_src_phemex_js_WEBPACK_IMPORTED_MODULE_91_/* ["default"] */ .A, + 'poloniex': ccxt_src_poloniex_js_WEBPACK_IMPORTED_MODULE_92_/* ["default"] */ .A, + 'probit': ccxt_src_probit_js_WEBPACK_IMPORTED_MODULE_93_/* ["default"] */ .A, + 'timex': ccxt_src_timex_js_WEBPACK_IMPORTED_MODULE_94_/* ["default"] */ .A, + 'tokocrypto': ccxt_src_tokocrypto_js_WEBPACK_IMPORTED_MODULE_95_/* ["default"] */ .A, + 'tradeogre': ccxt_src_tradeogre_js_WEBPACK_IMPORTED_MODULE_96_/* ["default"] */ .A, + 'upbit': ccxt_src_upbit_js_WEBPACK_IMPORTED_MODULE_97_/* ["default"] */ .A, + 'vertex': ccxt_src_vertex_js_WEBPACK_IMPORTED_MODULE_98_/* ["default"] */ .A, + 'wavesexchange': ccxt_src_wavesexchange_js_WEBPACK_IMPORTED_MODULE_99_/* ["default"] */ .A, + 'whitebit': ccxt_src_whitebit_js_WEBPACK_IMPORTED_MODULE_100_/* ["default"] */ .A, + 'woo': ccxt_src_woo_js_WEBPACK_IMPORTED_MODULE_101_/* ["default"] */ .A, + 'woofipro': ccxt_src_woofipro_js_WEBPACK_IMPORTED_MODULE_102_/* ["default"] */ .A, + 'xt': ccxt_src_xt_js_WEBPACK_IMPORTED_MODULE_103_/* ["default"] */ .A, + 'yobit': ccxt_src_yobit_js_WEBPACK_IMPORTED_MODULE_104_/* ["default"] */ .A, + 'zaif': ccxt_src_zaif_js_WEBPACK_IMPORTED_MODULE_105_/* ["default"] */ .A, + 'zonda': ccxt_src_zonda_js_WEBPACK_IMPORTED_MODULE_106_/* ["default"] */ .A, }; const ccxt_pro = { - 'alpaca': ccxt_src_pro_alpaca_js_WEBPACK_IMPORTED_MODULE_106_/* ["default"] */ .A, - 'apex': ccxt_src_pro_apex_js_WEBPACK_IMPORTED_MODULE_107_/* ["default"] */ .A, - 'ascendex': ccxt_src_pro_ascendex_js_WEBPACK_IMPORTED_MODULE_108_/* ["default"] */ .A, - 'bequant': ccxt_src_pro_bequant_js_WEBPACK_IMPORTED_MODULE_109_/* ["default"] */ .A, - 'binance': ccxt_src_pro_binance_js_WEBPACK_IMPORTED_MODULE_110_/* ["default"] */ .A, - 'binancecoinm': ccxt_src_pro_binancecoinm_js_WEBPACK_IMPORTED_MODULE_111_/* ["default"] */ .A, - 'binanceus': ccxt_src_pro_binanceus_js_WEBPACK_IMPORTED_MODULE_112_/* ["default"] */ .A, - 'binanceusdm': ccxt_src_pro_binanceusdm_js_WEBPACK_IMPORTED_MODULE_113_/* ["default"] */ .A, - 'bingx': ccxt_src_pro_bingx_js_WEBPACK_IMPORTED_MODULE_114_/* ["default"] */ .A, - 'bitfinex': ccxt_src_pro_bitfinex_js_WEBPACK_IMPORTED_MODULE_115_/* ["default"] */ .A, - 'bitget': ccxt_src_pro_bitget_js_WEBPACK_IMPORTED_MODULE_116_/* ["default"] */ .A, - 'bithumb': ccxt_src_pro_bithumb_js_WEBPACK_IMPORTED_MODULE_117_/* ["default"] */ .A, - 'bitmart': ccxt_src_pro_bitmart_js_WEBPACK_IMPORTED_MODULE_118_/* ["default"] */ .A, - 'bitmex': ccxt_src_pro_bitmex_js_WEBPACK_IMPORTED_MODULE_119_/* ["default"] */ .A, - 'bitopro': ccxt_src_pro_bitopro_js_WEBPACK_IMPORTED_MODULE_120_/* ["default"] */ .A, - 'bitrue': ccxt_src_pro_bitrue_js_WEBPACK_IMPORTED_MODULE_121_/* ["default"] */ .A, - 'bitstamp': ccxt_src_pro_bitstamp_js_WEBPACK_IMPORTED_MODULE_122_/* ["default"] */ .A, - 'bittrade': ccxt_src_pro_bittrade_js_WEBPACK_IMPORTED_MODULE_123_/* ["default"] */ .A, - 'bitvavo': ccxt_src_pro_bitvavo_js_WEBPACK_IMPORTED_MODULE_124_/* ["default"] */ .A, - 'blockchaincom': ccxt_src_pro_blockchaincom_js_WEBPACK_IMPORTED_MODULE_125_/* ["default"] */ .A, - 'blofin': ccxt_src_pro_blofin_js_WEBPACK_IMPORTED_MODULE_126_/* ["default"] */ .A, - 'bybit': ccxt_src_pro_bybit_js_WEBPACK_IMPORTED_MODULE_127_/* ["default"] */ .A, - 'cex': ccxt_src_pro_cex_js_WEBPACK_IMPORTED_MODULE_128_/* ["default"] */ .A, - 'coinbase': ccxt_src_pro_coinbase_js_WEBPACK_IMPORTED_MODULE_129_/* ["default"] */ .A, - 'coinbaseadvanced': ccxt_src_pro_coinbaseadvanced_js_WEBPACK_IMPORTED_MODULE_130_/* ["default"] */ .A, - 'coinbaseexchange': ccxt_src_pro_coinbaseexchange_js_WEBPACK_IMPORTED_MODULE_131_/* ["default"] */ .A, - 'coinbaseinternational': ccxt_src_pro_coinbaseinternational_js_WEBPACK_IMPORTED_MODULE_132_/* ["default"] */ .A, - 'coincatch': ccxt_src_pro_coincatch_js_WEBPACK_IMPORTED_MODULE_133_/* ["default"] */ .A, - 'coincheck': ccxt_src_pro_coincheck_js_WEBPACK_IMPORTED_MODULE_134_/* ["default"] */ .A, - 'coinex': ccxt_src_pro_coinex_js_WEBPACK_IMPORTED_MODULE_135_/* ["default"] */ .A, - 'coinone': ccxt_src_pro_coinone_js_WEBPACK_IMPORTED_MODULE_136_/* ["default"] */ .A, - 'cryptocom': ccxt_src_pro_cryptocom_js_WEBPACK_IMPORTED_MODULE_137_/* ["default"] */ .A, - 'defx': ccxt_src_pro_defx_js_WEBPACK_IMPORTED_MODULE_138_/* ["default"] */ .A, - 'deribit': ccxt_src_pro_deribit_js_WEBPACK_IMPORTED_MODULE_139_/* ["default"] */ .A, - 'derive': ccxt_src_pro_derive_js_WEBPACK_IMPORTED_MODULE_140_/* ["default"] */ .A, - 'exmo': ccxt_src_pro_exmo_js_WEBPACK_IMPORTED_MODULE_141_/* ["default"] */ .A, - 'gate': ccxt_src_pro_gate_js_WEBPACK_IMPORTED_MODULE_142_/* ["default"] */ .A, - 'gateio': ccxt_src_pro_gateio_js_WEBPACK_IMPORTED_MODULE_143_/* ["default"] */ .A, - 'gemini': ccxt_src_pro_gemini_js_WEBPACK_IMPORTED_MODULE_144_/* ["default"] */ .A, - 'hashkey': ccxt_src_pro_hashkey_js_WEBPACK_IMPORTED_MODULE_145_/* ["default"] */ .A, - 'hitbtc': ccxt_src_pro_hitbtc_js_WEBPACK_IMPORTED_MODULE_146_/* ["default"] */ .A, - 'hollaex': ccxt_src_pro_hollaex_js_WEBPACK_IMPORTED_MODULE_147_/* ["default"] */ .A, - 'htx': ccxt_src_pro_htx_js_WEBPACK_IMPORTED_MODULE_148_/* ["default"] */ .A, - 'huobi': ccxt_src_pro_huobi_js_WEBPACK_IMPORTED_MODULE_149_/* ["default"] */ .A, - 'hyperliquid': ccxt_src_pro_hyperliquid_js_WEBPACK_IMPORTED_MODULE_150_/* ["default"] */ .A, - 'independentreserve': ccxt_src_pro_independentreserve_js_WEBPACK_IMPORTED_MODULE_151_/* ["default"] */ .A, - 'kraken': ccxt_src_pro_kraken_js_WEBPACK_IMPORTED_MODULE_152_/* ["default"] */ .A, - 'krakenfutures': ccxt_src_pro_krakenfutures_js_WEBPACK_IMPORTED_MODULE_153_/* ["default"] */ .A, - 'kucoin': ccxt_src_pro_kucoin_js_WEBPACK_IMPORTED_MODULE_154_/* ["default"] */ .A, - 'kucoinfutures': ccxt_src_pro_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_155_/* ["default"] */ .A, - 'lbank': ccxt_src_pro_lbank_js_WEBPACK_IMPORTED_MODULE_156_/* ["default"] */ .A, - 'luno': ccxt_src_pro_luno_js_WEBPACK_IMPORTED_MODULE_157_/* ["default"] */ .A, - 'mexc': ccxt_src_pro_mexc_js_WEBPACK_IMPORTED_MODULE_158_/* ["default"] */ .A, - 'modetrade': ccxt_src_pro_modetrade_js_WEBPACK_IMPORTED_MODULE_159_/* ["default"] */ .A, - 'myokx': ccxt_src_pro_myokx_js_WEBPACK_IMPORTED_MODULE_160_/* ["default"] */ .A, - 'ndax': ccxt_src_pro_ndax_js_WEBPACK_IMPORTED_MODULE_161_/* ["default"] */ .A, - 'okcoin': ccxt_src_pro_okcoin_js_WEBPACK_IMPORTED_MODULE_162_/* ["default"] */ .A, - 'okx': ccxt_src_pro_okx_js_WEBPACK_IMPORTED_MODULE_163_/* ["default"] */ .A, - 'okxus': ccxt_src_pro_okxus_js_WEBPACK_IMPORTED_MODULE_164_/* ["default"] */ .A, - 'onetrading': ccxt_src_pro_onetrading_js_WEBPACK_IMPORTED_MODULE_165_/* ["default"] */ .A, - 'oxfun': ccxt_src_pro_oxfun_js_WEBPACK_IMPORTED_MODULE_166_/* ["default"] */ .A, - 'p2b': ccxt_src_pro_p2b_js_WEBPACK_IMPORTED_MODULE_167_/* ["default"] */ .A, - 'paradex': ccxt_src_pro_paradex_js_WEBPACK_IMPORTED_MODULE_168_/* ["default"] */ .A, - 'phemex': ccxt_src_pro_phemex_js_WEBPACK_IMPORTED_MODULE_169_/* ["default"] */ .A, - 'poloniex': ccxt_src_pro_poloniex_js_WEBPACK_IMPORTED_MODULE_170_/* ["default"] */ .A, - 'probit': ccxt_src_pro_probit_js_WEBPACK_IMPORTED_MODULE_171_/* ["default"] */ .A, - 'tradeogre': ccxt_src_pro_tradeogre_js_WEBPACK_IMPORTED_MODULE_172_/* ["default"] */ .A, - 'upbit': ccxt_src_pro_upbit_js_WEBPACK_IMPORTED_MODULE_173_/* ["default"] */ .A, - 'vertex': ccxt_src_pro_vertex_js_WEBPACK_IMPORTED_MODULE_174_/* ["default"] */ .A, - 'whitebit': ccxt_src_pro_whitebit_js_WEBPACK_IMPORTED_MODULE_175_/* ["default"] */ .A, - 'woo': ccxt_src_pro_woo_js_WEBPACK_IMPORTED_MODULE_176_/* ["default"] */ .A, - 'woofipro': ccxt_src_pro_woofipro_js_WEBPACK_IMPORTED_MODULE_177_/* ["default"] */ .A, - 'xt': ccxt_src_pro_xt_js_WEBPACK_IMPORTED_MODULE_178_/* ["default"] */ .A, + 'alpaca': ccxt_src_pro_alpaca_js_WEBPACK_IMPORTED_MODULE_107_/* ["default"] */ .A, + 'apex': ccxt_src_pro_apex_js_WEBPACK_IMPORTED_MODULE_108_/* ["default"] */ .A, + 'ascendex': ccxt_src_pro_ascendex_js_WEBPACK_IMPORTED_MODULE_109_/* ["default"] */ .A, + 'bequant': ccxt_src_pro_bequant_js_WEBPACK_IMPORTED_MODULE_110_/* ["default"] */ .A, + 'binance': ccxt_src_pro_binance_js_WEBPACK_IMPORTED_MODULE_111_/* ["default"] */ .A, + 'binancecoinm': ccxt_src_pro_binancecoinm_js_WEBPACK_IMPORTED_MODULE_112_/* ["default"] */ .A, + 'binanceus': ccxt_src_pro_binanceus_js_WEBPACK_IMPORTED_MODULE_113_/* ["default"] */ .A, + 'binanceusdm': ccxt_src_pro_binanceusdm_js_WEBPACK_IMPORTED_MODULE_114_/* ["default"] */ .A, + 'bingx': ccxt_src_pro_bingx_js_WEBPACK_IMPORTED_MODULE_115_/* ["default"] */ .A, + 'bitfinex': ccxt_src_pro_bitfinex_js_WEBPACK_IMPORTED_MODULE_116_/* ["default"] */ .A, + 'bitget': ccxt_src_pro_bitget_js_WEBPACK_IMPORTED_MODULE_117_/* ["default"] */ .A, + 'bithumb': ccxt_src_pro_bithumb_js_WEBPACK_IMPORTED_MODULE_118_/* ["default"] */ .A, + 'bitmart': ccxt_src_pro_bitmart_js_WEBPACK_IMPORTED_MODULE_119_/* ["default"] */ .A, + 'bitmex': ccxt_src_pro_bitmex_js_WEBPACK_IMPORTED_MODULE_120_/* ["default"] */ .A, + 'bitopro': ccxt_src_pro_bitopro_js_WEBPACK_IMPORTED_MODULE_121_/* ["default"] */ .A, + 'bitrue': ccxt_src_pro_bitrue_js_WEBPACK_IMPORTED_MODULE_122_/* ["default"] */ .A, + 'bitstamp': ccxt_src_pro_bitstamp_js_WEBPACK_IMPORTED_MODULE_123_/* ["default"] */ .A, + 'bittrade': ccxt_src_pro_bittrade_js_WEBPACK_IMPORTED_MODULE_124_/* ["default"] */ .A, + 'bitvavo': ccxt_src_pro_bitvavo_js_WEBPACK_IMPORTED_MODULE_125_/* ["default"] */ .A, + 'blockchaincom': ccxt_src_pro_blockchaincom_js_WEBPACK_IMPORTED_MODULE_126_/* ["default"] */ .A, + 'blofin': ccxt_src_pro_blofin_js_WEBPACK_IMPORTED_MODULE_127_/* ["default"] */ .A, + 'bybit': ccxt_src_pro_bybit_js_WEBPACK_IMPORTED_MODULE_128_/* ["default"] */ .A, + 'cex': ccxt_src_pro_cex_js_WEBPACK_IMPORTED_MODULE_129_/* ["default"] */ .A, + 'coinbase': ccxt_src_pro_coinbase_js_WEBPACK_IMPORTED_MODULE_130_/* ["default"] */ .A, + 'coinbaseadvanced': ccxt_src_pro_coinbaseadvanced_js_WEBPACK_IMPORTED_MODULE_131_/* ["default"] */ .A, + 'coinbaseexchange': ccxt_src_pro_coinbaseexchange_js_WEBPACK_IMPORTED_MODULE_132_/* ["default"] */ .A, + 'coinbaseinternational': ccxt_src_pro_coinbaseinternational_js_WEBPACK_IMPORTED_MODULE_133_/* ["default"] */ .A, + 'coincatch': ccxt_src_pro_coincatch_js_WEBPACK_IMPORTED_MODULE_134_/* ["default"] */ .A, + 'coincheck': ccxt_src_pro_coincheck_js_WEBPACK_IMPORTED_MODULE_135_/* ["default"] */ .A, + 'coinex': ccxt_src_pro_coinex_js_WEBPACK_IMPORTED_MODULE_136_/* ["default"] */ .A, + 'coinone': ccxt_src_pro_coinone_js_WEBPACK_IMPORTED_MODULE_137_/* ["default"] */ .A, + 'cryptocom': ccxt_src_pro_cryptocom_js_WEBPACK_IMPORTED_MODULE_138_/* ["default"] */ .A, + 'defx': ccxt_src_pro_defx_js_WEBPACK_IMPORTED_MODULE_139_/* ["default"] */ .A, + 'deribit': ccxt_src_pro_deribit_js_WEBPACK_IMPORTED_MODULE_140_/* ["default"] */ .A, + 'derive': ccxt_src_pro_derive_js_WEBPACK_IMPORTED_MODULE_141_/* ["default"] */ .A, + 'exmo': ccxt_src_pro_exmo_js_WEBPACK_IMPORTED_MODULE_142_/* ["default"] */ .A, + 'gate': ccxt_src_pro_gate_js_WEBPACK_IMPORTED_MODULE_143_/* ["default"] */ .A, + 'gateio': ccxt_src_pro_gateio_js_WEBPACK_IMPORTED_MODULE_144_/* ["default"] */ .A, + 'gemini': ccxt_src_pro_gemini_js_WEBPACK_IMPORTED_MODULE_145_/* ["default"] */ .A, + 'hashkey': ccxt_src_pro_hashkey_js_WEBPACK_IMPORTED_MODULE_146_/* ["default"] */ .A, + 'hitbtc': ccxt_src_pro_hitbtc_js_WEBPACK_IMPORTED_MODULE_147_/* ["default"] */ .A, + 'hollaex': ccxt_src_pro_hollaex_js_WEBPACK_IMPORTED_MODULE_148_/* ["default"] */ .A, + 'htx': ccxt_src_pro_htx_js_WEBPACK_IMPORTED_MODULE_149_/* ["default"] */ .A, + 'huobi': ccxt_src_pro_huobi_js_WEBPACK_IMPORTED_MODULE_150_/* ["default"] */ .A, + 'hyperliquid': ccxt_src_pro_hyperliquid_js_WEBPACK_IMPORTED_MODULE_151_/* ["default"] */ .A, + 'independentreserve': ccxt_src_pro_independentreserve_js_WEBPACK_IMPORTED_MODULE_152_/* ["default"] */ .A, + 'kraken': ccxt_src_pro_kraken_js_WEBPACK_IMPORTED_MODULE_153_/* ["default"] */ .A, + 'krakenfutures': ccxt_src_pro_krakenfutures_js_WEBPACK_IMPORTED_MODULE_154_/* ["default"] */ .A, + 'kucoin': ccxt_src_pro_kucoin_js_WEBPACK_IMPORTED_MODULE_155_/* ["default"] */ .A, + 'kucoinfutures': ccxt_src_pro_kucoinfutures_js_WEBPACK_IMPORTED_MODULE_156_/* ["default"] */ .A, + 'lbank': ccxt_src_pro_lbank_js_WEBPACK_IMPORTED_MODULE_157_/* ["default"] */ .A, + 'luno': ccxt_src_pro_luno_js_WEBPACK_IMPORTED_MODULE_158_/* ["default"] */ .A, + 'mexc': ccxt_src_pro_mexc_js_WEBPACK_IMPORTED_MODULE_159_/* ["default"] */ .A, + 'modetrade': ccxt_src_pro_modetrade_js_WEBPACK_IMPORTED_MODULE_160_/* ["default"] */ .A, + 'myokx': ccxt_src_pro_myokx_js_WEBPACK_IMPORTED_MODULE_161_/* ["default"] */ .A, + 'ndax': ccxt_src_pro_ndax_js_WEBPACK_IMPORTED_MODULE_162_/* ["default"] */ .A, + 'okcoin': ccxt_src_pro_okcoin_js_WEBPACK_IMPORTED_MODULE_163_/* ["default"] */ .A, + 'okx': ccxt_src_pro_okx_js_WEBPACK_IMPORTED_MODULE_164_/* ["default"] */ .A, + 'okxus': ccxt_src_pro_okxus_js_WEBPACK_IMPORTED_MODULE_165_/* ["default"] */ .A, + 'onetrading': ccxt_src_pro_onetrading_js_WEBPACK_IMPORTED_MODULE_166_/* ["default"] */ .A, + 'oxfun': ccxt_src_pro_oxfun_js_WEBPACK_IMPORTED_MODULE_167_/* ["default"] */ .A, + 'p2b': ccxt_src_pro_p2b_js_WEBPACK_IMPORTED_MODULE_168_/* ["default"] */ .A, + 'paradex': ccxt_src_pro_paradex_js_WEBPACK_IMPORTED_MODULE_169_/* ["default"] */ .A, + 'phemex': ccxt_src_pro_phemex_js_WEBPACK_IMPORTED_MODULE_170_/* ["default"] */ .A, + 'poloniex': ccxt_src_pro_poloniex_js_WEBPACK_IMPORTED_MODULE_171_/* ["default"] */ .A, + 'probit': ccxt_src_pro_probit_js_WEBPACK_IMPORTED_MODULE_172_/* ["default"] */ .A, + 'tradeogre': ccxt_src_pro_tradeogre_js_WEBPACK_IMPORTED_MODULE_173_/* ["default"] */ .A, + 'upbit': ccxt_src_pro_upbit_js_WEBPACK_IMPORTED_MODULE_174_/* ["default"] */ .A, + 'vertex': ccxt_src_pro_vertex_js_WEBPACK_IMPORTED_MODULE_175_/* ["default"] */ .A, + 'whitebit': ccxt_src_pro_whitebit_js_WEBPACK_IMPORTED_MODULE_176_/* ["default"] */ .A, + 'woo': ccxt_src_pro_woo_js_WEBPACK_IMPORTED_MODULE_177_/* ["default"] */ .A, + 'woofipro': ccxt_src_pro_woofipro_js_WEBPACK_IMPORTED_MODULE_178_/* ["default"] */ .A, + 'xt': ccxt_src_pro_xt_js_WEBPACK_IMPORTED_MODULE_179_/* ["default"] */ .A, }; for (const exchange in ccxt_pro) { // const ccxtExchange = exchanges[exchange] @@ -406170,7 +409182,7 @@ for (const exchange in ccxt_pro) { ccxt_pro.exchanges = Object.keys(ccxt_pro); ccxt_pro['Exchange'] = ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_/* .Exchange */ .k; // now the same for rest and ts //----------------------------------------------------------------------------- -const ccxt_ccxt = Object.assign({ version: ccxt_version, Exchange: ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_/* .Exchange */ .k, Precise: ccxt_src_base_Precise_js_WEBPACK_IMPORTED_MODULE_179_/* .Precise */ .Y, 'exchanges': Object.keys(ccxt_exchanges), 'pro': ccxt_pro }, ccxt_exchanges, ccxt_src_base_functions_js_WEBPACK_IMPORTED_MODULE_180_, ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_181_); +const ccxt_ccxt = Object.assign({ version: ccxt_version, Exchange: ccxt_src_base_Exchange_js_WEBPACK_IMPORTED_MODULE_0_/* .Exchange */ .k, Precise: ccxt_src_base_Precise_js_WEBPACK_IMPORTED_MODULE_180_/* .Precise */ .Y, 'exchanges': Object.keys(ccxt_exchanges), 'pro': ccxt_pro }, ccxt_exchanges, ccxt_src_base_functions_js_WEBPACK_IMPORTED_MODULE_181_, ccxt_src_base_errors_js_WEBPACK_IMPORTED_MODULE_182_); /* harmony default export */ const ts_ccxt = (ccxt_ccxt); //----------------------------------------------------------------------------- diff --git a/dist/ccxt.browser.min.js b/dist/ccxt.browser.min.js index e288ea6a1043e..338ce5dfd4d82 100644 --- a/dist/ccxt.browser.min.js +++ b/dist/ccxt.browser.min.js @@ -1,10 +1,10 @@ -(()=>{"use strict";var e={4523:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1185:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},566:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3971:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},335:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4619:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3885:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2308:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5625:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9332:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1578:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9152:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3974:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1466:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8186:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7202:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8800:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9656:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5223:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8535:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7754:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8716:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5254:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1769:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9644:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3829:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2317:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8430:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1293:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5465:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5661:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1552:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2609:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5769:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2938:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5277:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8109:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1671:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6658:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4935:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9360:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4295:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3037:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9872:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7227:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4012:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},970:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9420:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6351:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1352:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7418:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3434:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9722:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},706:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1180:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8617:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9023:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},359:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4558:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2459:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1359:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3548:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3942:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(1397);class r extends s.A{}const a=r},121:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},575:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7533:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6928:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9174:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5362:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3414:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},1426:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7774:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9886:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5531:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3800:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},9401:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7849:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},2134:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8563:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4158:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7733:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},995:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},334:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7999:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},4352:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},6405:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8139:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7698:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3965:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7246:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5308:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3521:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},3578:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},8291:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},5517:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(2961);class r extends s.k{}const a=r},7930:(e,t,i)=>{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,h="active"===this.safeString(e,"status"),c=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:h,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:c,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"),h={symbols:o,loc:n};let c;if(s=this.omit(s,["loc","method"]),"marketPublicGetV1beta3CryptoLocTrades"===d){void 0!==t&&(h.start=this.iso8601(t)),void 0!==i&&(h.limit=i);const e=await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(h,s)),r=this.safeDict(e,"trades",{});c=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(h,s)),t=this.safeDict(e,"trades",{});c=this.safeDict(t,o,{}),c=[c]}}return this.parseTrades(c,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,{}),h=this.parse8601(this.safeString(d,"t"));return this.parseOrderBook(d,s.symbol,h,"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"),h=this.safeString(r,"method","marketPublicGetV1beta3CryptoLocBars"),c={symbols:n,loc:d};let l;if(r=this.omit(r,["loc","method"]),"marketPublicGetV1beta3CryptoLocBars"===h){void 0!==s&&(c.limit=s),void 0!==i&&(c.start=this.yyyymmdd(i)),c.timeframe=this.safeString(this.timeframes,t,t);const e=await this.marketPublicGetV1beta3CryptoLocBars(this.extend(c,r)),a=this.safeDict(e,"bars",{});l=this.safeList(a,n,[])}else{if("marketPublicGetV1beta3CryptoLocLatestBars"!==h)throw new a.NotSupported(this.id+" fetchOHLCV() does not support "+h+", marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported");{const e=await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(c,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,h),d.type=i}t.indexOf("limit")>=0&&(d.limit_price=this.priceToPrecision(e,r));const c=this.safeString(o,"cost");void 0!==c?(o=this.omit(o,"cost"),d.notional=this.costToPrecision(e,c)):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 h=this.safeStringN(o,["triggerPrice","stop_price"]);let c;void 0!==h&&(n.stop_price=this.priceToPrecision(t,h),o=this.omit(o,"triggerPrice")),void 0!==a&&(n.limit_price=this.priceToPrecision(t,a)),[c,o]=this.handleOptionAndParams2(o,"editOrder","timeInForce","defaultTimeInForce"),void 0!==c&&(n.time_in_force=c),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 h=this.safeString(e,"submitted_at"),c=this.parse8601(h);return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:this.safeString(e,"client_order_id"),timestamp:c,datetime:h,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"),h=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:h,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{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,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,fetchBalance:!0,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!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,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,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,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 h=this.market(e),c=t.toUpperCase(),l=i.toUpperCase(),u=this.amountToPrecision(e,r);let f="0";void 0!==o&&(f=this.priceToPrecision(e,o));const p=this.safeDict(this.fees,"swap",{}),m=this.safeNumber(p,"taker",5e-4),g=this.safeNumber(p,"maker",2e-4),v=this.decimalToPrecision(s.Y.stringAdd(s.Y.stringMul(s.Y.stringMul(f,u),m.toString()),h.precision.price.toString()),a.R3,h.precision.price,this.precisionMode,this.paddingMode),y=this.milliseconds(),w="MARKET"===c;if(w&&void 0===o)throw new n.ArgumentsRequired(this.id+" createOrder() requires a price argument for market orders");let b=this.safeStringUpper(d,"timeInForce");const k=this.isPostOnly(w,void 0,d);void 0===b&&(b="GOOD_TIL_CANCEL"),w||(k?b="POST_ONLY":"ioc"===b&&(b="IMMEDIATE_OR_CANCEL")),d=this.omit(d,"timeInForce"),d=this.omit(d,"postOnly");let S=this.safeStringN(d,["clientId","clientOrderId","client_order_id"]);const O=await this.getAccountId();void 0===S&&(S=this.generateRandomClientIdOmni(O)),d=this.omit(d,["clientId","clientOrderId","client_order_id"]);const T={accountId:O,slotId:S,nonce:S,pairId:h.quoteId,size:u,price:f,direction:l,makerFeeRate:g.toString(),takerFeeRate:m.toString()},P=await this.getZKContractSignatureObj(this.remove0xPrefix(this.getSeeds()),T),I={symbol:h.id,side:l,type:c,size:u,price:f,limitFee:v,expiration:Math.floor(y/1e3+2592e3),timeInForce:b,clientId:S,brokerId:this.safeString(this.options,"brokerId","6956")};I.signature=P;const M=await this.privatePostV3Order(this.extend(I,d)),x=this.safeDict(M,"data",{});return this.parseOrder(x,h)}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",{}),h=this.safeList(d,"assets",[]),c=this.safeDict(n,"spotConfig",{}),l=this.safeList(c,"assets",[]),u=this.safeDict(c,"global",{}),f=this.safeString(u,"contractAssetPoolEthAddress",""),p=this.safeString(u,"contractAssetPoolZkAccountId",""),m=this.safeString(u,"contractAssetPoolSubAccount",""),g=this.safeString(u,"contractAssetPoolAccountId",""),v=await this.privateGetV3Account(a),y=this.safeDict(v,"data",{}),w=this.safeDict(y,"spotAccount",{}),b=this.safeString(w,"zkAccountId",""),k=this.safeString(w,"defaultSubAccountId","0"),S=this.safeList(w,"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()?h:l;for(let t=0;t{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,fetchBalance:!0,fetchClosedOrders:!0,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,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=h[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,f=this.safeString2(i,"underlying","symbol").split("/"),p=this.safeString(f,0),m=this.safeString(f,1),g=this.safeCurrencyCode(p),v=this.safeCurrencyCode(m),y=this.safeNumber(i,"commissionReserveRate"),w=this.safeBool(i,"marginTradable",!1);l.push({id:t,symbol:g+"/"+v,base:g,baseId:p,quote:v,quoteId:m,settle:void 0,settleId:void 0,type:"spot",spot:!0,margin:w,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(h,"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)}c=this.safeDict(e,a,{})}else c=this.safeDict(h,0,{});const l=this.parseDepositAddress(c,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 h=this.safeString(e,"commission");d=a.Y.stringSub(d,h);const c=this.safeCurrencyCode(n,t);return{info:e,id:this.safeString(e,"requestId"),txid:this.safeString(e,"networkTransactionId"),type:this.safeString(e,"transactionType"),currency:c,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:c,cost:this.parseNumber(h),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&&(c+="?"+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&&(c+="?"+this.urlencode(s)):(r["Content-Type"]="application/json",a=this.json(s))}return c=this.urls.api.rest+c,{url:c,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.safeString(n,"code"),l=this.safeString(n,"message");if(void 0!==c&&"0"!==c||void 0!==l){const e=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,c,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwBroadlyMatchedException(this.exceptions.broad,l,e),new r.ExchangeError(e)}}}},2961:(e,t,i)=>{i.d(t,{k:()=>St});var s=i(5095),r=i(7437),a=i(6238),o=i(2079),n=i(5147),d=i(7288),h=i(3206),c=i(3828),l=i(8283),u=i(8995),f=i(5897),p=i(4380),m=i(447),g=i(3187),v=i(7661),y=i(6907),w=i(9793),b=i(9491),k=i(1878),S=i(4852);const{isNode:O,selfIsDefined:T,deepExtend:P,extend:I,clone:M,flatten:x,unique:_,indexBy:A,sortBy:C,sortBy2:B,safeFloat2:E,groupBy:N,aggregate:R,uuid:L,unCamelCase:D,precisionFromString:q,Throttler:V,capitalize:F,now:G,decimalToPrecision:H,safeValue:U,safeValue2:W,safeString:j,safeString2:K,seconds:z,milliseconds:Y,binaryToBase16:X,numberToBE:Q,base16ToBinary:Z,iso8601:$,omit:J,isJsonEncodedObject:ee,safeInteger:te,sum:ie,omitZero:se,implodeParams:re,extractParams:ae,json:oe,merge:ne,binaryConcat:de,hash:he,ecdsa:ce,arrayConcat:le,encode:ue,urlencode:fe,hmac:pe,numberToString:me,roundTimeframe:ge,parseTimeframe:ve,safeInteger2:ye,safeStringLower:we,parse8601:be,yyyymmdd:ke,safeStringUpper:Se,safeTimestamp:Oe,binaryConcatArray:Te,uuidv1:Pe,numberToLE:Ie,ymdhms:Me,stringToBase64:xe,decode:_e,uuid22:Ae,safeIntegerProduct2:Ce,safeIntegerProduct:Be,safeStringLower2:Ee,yymmdd:Ne,base58ToBinary:Re,binaryToBase58:Le,safeTimestamp2:De,rawencode:qe,keysort:Ve,sort:Fe,inArray:Ge,isEmpty:He,ordered:Ue,filterBy:We,uuid16:je,safeFloat:Ke,base64ToBinary:ze,safeStringUpper2:Ye,urlencodeWithArrayRepeat:Xe,microseconds:Qe,binaryToBase64:Ze,strip:$e,toArray:Je,safeFloatN:et,safeIntegerN:tt,safeIntegerProductN:it,safeTimestampN:st,safeValueN:rt,safeStringN:at,safeStringLowerN:ot,safeStringUpperN:nt,urlencodeNested:dt,urlencodeBase64:ht,parseDate:ct,ymd:lt,base64ToString:ut,crc32:ft,packb:pt,TRUNCATE:mt,ROUND:gt,DECIMAL_PLACES:vt,NO_PADDING:yt,TICK_SIZE:wt,SIGNIFICANT_DIGITS:bt,sleep:kt}=s;class St{constructor(e={}){this.isSandboxModeEnabled=!1,this.throttleProp=void 0,this.sleep=kt,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.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.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.clients={},this.newUpdates=!0,this.streaming={},this.alias=!1,this.deepExtend=P,this.deepExtendSafe=P,this.isNode=O,this.keys=r.HP,this.values=r.zu,this.extend=I,this.clone=M,this.flatten=x,this.unique=_,this.indexBy=A,this.indexBySafe=A,this.roundTimeframe=ge,this.sortBy=C,this.sortBy2=B,this.groupBy=N,this.aggregate=R,this.uuid=L,this.unCamelCase=D,this.precisionFromString=q,this.capitalize=F,this.now=G,this.decimalToPrecision=H,this.safeValue=U,this.safeValue2=W,this.safeString=j,this.safeString2=K,this.safeFloat=Ke,this.safeFloat2=E,this.seconds=z,this.milliseconds=Y,this.binaryToBase16=X,this.numberToBE=Q,this.base16ToBinary=Z,this.iso8601=$,this.omit=J,this.isJsonEncodedObject=ee,this.safeInteger=te,this.sum=ie,this.omitZero=se,this.implodeParams=re,this.extractParams=ae,this.json=oe,this.vwap=a.ru,this.merge=ne,this.binaryConcat=de,this.hash=he,this.arrayConcat=le,this.encode=ue,this.urlencode=fe,this.hmac=pe,this.numberToString=me,this.parseTimeframe=ve,this.safeInteger2=ye,this.safeStringLower=we,this.parse8601=be,this.yyyymmdd=ke,this.safeStringUpper=Se,this.safeTimestamp=Oe,this.binaryConcatArray=Te,this.uuidv1=Pe,this.numberToLE=Ie,this.ymdhms=Me,this.yymmdd=Ne,this.stringToBase64=xe,this.decode=_e,this.uuid22=Ae,this.safeIntegerProduct2=Ce,this.safeIntegerProduct=Be,this.binaryToBase58=Le,this.base58ToBinary=Re,this.base64ToBinary=ze,this.safeTimestamp2=De,this.rawencode=qe,this.keysort=Ve,this.sort=Fe,this.inArray=Ge,this.safeStringLower2=Ee,this.safeStringUpper2=Ye,this.isEmpty=He,this.ordered=Ue,this.filterBy=We,this.uuid16=je,this.urlencodeWithArrayRepeat=Xe,this.microseconds=Qe,this.binaryToBase64=Ze,this.strip=$e,this.toArray=Je,this.safeFloatN=et,this.safeIntegerN=tt,this.safeIntegerProductN=it,this.safeTimestampN=st,this.safeValueN=rt,this.safeStringN=at,this.safeStringLowerN=ot,this.safeStringUpperN=nt,this.urlencodeNested=dt,this.parseDate=ct,this.ymd=lt,this.base64ToString=ut,this.crc32=ft,this.packb=pt,this.urlencodeBase64=ht,this.httpProxyAgentModule=void 0,this.httpsProxyAgentModule=void 0,this.socksProxyAgentModule=void 0,this.socksProxyAgentModuleChecked=!1,this.proxyDictionaries={},this.proxiesModulesLoading=void 0,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.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;ef&&(i=!1),c===f&&(l>p||l===p&&u>m)&&(i=!1),!i){if(t)throw new o.NotSupported("Your current version of CCXT is "+St.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 V(this.tokenBucket)}defineRestApiEndpoint(e,t,i,s,r,a,o={}){const n=r.split(/[^a-zA-Z0-9]/),d=n.map(this.capitalize).join(""),h=n.map((e=>e.trim().toLowerCase())).filter((e=>e.length>0)).join("_"),c=[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=c+s+this.capitalize(d),f=l+"_"+i+"_"+h,p=a.length>1?a:a[0],m=async(i={},s={})=>this[e](r,p,t,i,void 0,void 0,o,s);this[u]=m,this[f]=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(!O&&(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(O&&"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}}async fetch(e,t="GET",i=void 0,s=void 0){if(O&&!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&&(O&&(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,h]=this.checkProxySettings(e,t,i,s);this.checkConflictingProxies(n||d||h,r),O&&await this.loadProxyModules();const c=this.setProxyAgents(n,d,h),l=void 0!==this.userAgent?this.userAgent:this.user_agent;if(l&&O&&("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(O){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=T()?self.fetch:fetch,this.AbortError=DOMException,this.FetchError=TypeError;const u=this.fetchImplementation,f={method:t,headers:i,body:s,timeout:this.timeout};this.agent&&(f.agent=this.agent),a?f.agent=a:c&&(f.agent=c);const p=new AbortController;f.signal=p.signal;const m=setTimeout((()=>{p.abort()}),this.timeout);try{const r=await u(e,f);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||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(me(parseFloat(i)));const s=this.number(i);return 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,h.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 c.Mi(e,t)}indexedOrderBook(e={},t=Number.MAX_SAFE_INTEGER){return new c.nS(e,t)}countedOrderBook(e={},t=Number.MAX_SAFE_INTEGER){return new c.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,h]=this.checkWsProxySettings(),c=this.setProxyAgents(o,n,h),l=this.getHttpAgentIfNeeded(e),u=c||(l||this.agent),f=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 V(this.tokenBucket),options:{agent:u}},a);this.clients[e]=new d.A(e,t,i,s,r,f)}return this.clients[e]}watchMultiple(e,t,i=void 0,s=void 0,r=void 0){const a=this.client(e),o=h.K.race(t.map((e=>a.future(e))));let 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(){const e=Object.values(this.clients||{}),t=[];for(let i=0;i=0)return d.reset(o),this.handleDeltas(d,a.slice(h)),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]}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}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(f.Ay.encode(e,t).slice(2))}ethEncodeStructuredData(e,t,i){return this.base16ToBinary(p.z.encode(e,t,i).slice(-132))}retrieveStarkAccount(e,t,i){const s=(0,g.b)(e),r=(0,g.$u)(s),a=y.fP.compile({implementation:t,selector:w.BK("initialize"),calldata:y.fP.compile({signer:r,guardian:"0"})});return{privateKey:s,publicKey:r,address:b.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 k.E(a,s)}starknetSign(e,t){const i=(0,g._S)(e.replace("0x",""),t.slice(-64));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")),S.s,"hex"))).toString(),s=BigInt("0x"+this.remove0xPrefix(this.hash(this.encode(this.safeString(t,"nonce")),S.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,v.Ay)();const h=v.$s({});await h.initZklinkSigner(e);let c=new v.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=v.JF(c);l?.sign(h?.getZkLinkSigner());const u=l.jsValue(),f=u?.signature?.signature;return f}async getZKTransferSignatureObj(e,t={}){await(0,v.Ay)();const i=v.$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),S.s,"hex"))).toString();s=n.Y.stringMod(t,e)}let r=new v.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=v.qj(r);a?.sign(i?.getZkLinkSigner());const o=a.jsValue(),d=o?.signature?.signature;return d}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 m.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 h=this.valueIsDefined(this.httpProxy),c=this.valueIsDefined(this.http_proxy);(h||c)&&(r.push("httpProxy"),a=h?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 f=this.valueIsDefined(this.httpsProxy),p=this.valueIsDefined(this.https_proxy);(f||p)&&(r.push("httpsProxy"),n=f?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 w=this.valueIsDefined(this.socksProxyCallback),b=this.valueIsDefined(this.socks_proxy_callback);(w||b)&&(r.push("socksProxyCallback"),d=w?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 h=this.valueIsDefined(this.wsSocksProxy),c=this.valueIsDefined(this.ws_socks_proxy);(h||c)&&(e.push("wsSocksProxy"),s=h?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),h=this.toArray(e);let c=h;if(n||d){c=[];for(let e=0;e=s)&&c.push(r)}}return o&&void 0!==r?this.arraySlice(c,-r):this.filterByLimit(c,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}}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 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,maxCapacity:1e3,refillRate:e},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;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 o=this.keysort(this.currencies);return this.codes=Object.keys(o),this.markets}getDescribeForExtendedWsExchange(e,t,i){const s=this.deepExtend(t.describe(),e.describe());return this.deepExtend(s,i)}safeBalance(e){const t=this.omit(e,["info","timestamp","datetime","free","used","total"]),i=Object.keys(t);e.free={},e.used={},e.total={};const s={};for(let t=0;t0){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),f&&(r="0"),p&&(a="0");for(let e=0;e=this.sum(a[d][0],r)?a.push([n,s.price,s.price,s.price,s.price,s.amount,1]):(a[d][2]=Math.max(a[d][2],s.price),a[d][3]=Math.min(a[d][3],s.price),a[d][4]=s.price,a[d][5]=this.sum(a[d][5],s.amount),a[d][6]=this.sum(a[d][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 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.safeNumber(e,t),a=this.safeNumber(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){const r=this.safeMarketStructure({symbol:e,marketId:e});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 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 h=this.safeString(d,"takeProfitType"),c=this.safeString(d,"takeProfitPriceType"),l=this.safeString(d,"takeProfitLimitPrice"),u=this.safeString(d,"takeProfitAmount"),f=this.safeString(d,"stopLossType"),p=this.safeString(d,"stopLossPriceType"),m=this.safeString(d,"stopLossLimitPrice"),g=this.safeString(d,"stopLossAmount");return void 0!==h&&(d.takeProfit.type=h),void 0!==c&&(d.takeProfit.priceType=c),void 0!==l&&(d.takeProfit.price=this.parseToNumeric(l)),void 0!==u&&(d.takeProfit.amount=this.parseToNumeric(u)),void 0!==f&&(d.stopLoss.type=f),void 0!==p&&(d.stopLoss.priceType=p),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 cancelOrderWs(e,t=void 0,i={}){throw new o.NotSupported(this.id+" cancelOrderWs() is not supported yet")}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 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(void 0===this.currencies)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>h)throw e}}let v=p;u&&(v=this.removeRepeatedElementsFromArray(p));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 h=this.milliseconds(),c=[],l=1e3*this.parseTimeframe(r)*n;let u=h-d*l-1;u=void 0!==i?Math.max(u,i):Math.max(u,1241440531e3);const f=this.safeInteger2(a,"until","till");if(void 0!==f){const e=Math.ceil((f-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=f)&&!(u>=h);i++)c.push(this.safeDeterministicCall(e,t,u,n,r,a)),u=this.sum(u,l)-1;const p=await Promise.all(c);let m=[];for(let e=0;ec)throw e}u+=1}const g=this.sortCursorPaginatedResult(p),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 h=0,c=0,l=[];for(;hd)throw e}h+=1}const u=this.sortCursorPaginatedResult(l),f="fetchOHLCV"===e?0:"timestamp";return this.filterBySinceLimit(u,i,s,f)}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{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)=>{i.r(t),i.d(t,{AccountNotEnabled:()=>n,AccountSuspended:()=>d,AddressPending:()=>w,ArgumentsRequired:()=>h,AuthenticationError:()=>a,BadRequest:()=>c,BadResponse:()=>V,BadSymbol:()=>l,BaseError:()=>s,CancelPending:()=>G,ChecksumError:()=>D,ContractUnavailable:()=>I,DDoSProtection:()=>B,DuplicateOrderId:()=>P,ExchangeClosedByUser:()=>_,ExchangeError:()=>r,ExchangeNotAvailable:()=>N,InsufficientFunds:()=>v,InvalidAddress:()=>y,InvalidNonce:()=>L,InvalidOrder:()=>b,InvalidProxySettings:()=>x,ManualInteractionNeeded:()=>g,MarginModeAlreadySet:()=>p,MarketClosed:()=>m,NetworkError:()=>C,NoChange:()=>f,NotSupported:()=>M,NullResponse:()=>F,OnMaintenance:()=>R,OperationFailed:()=>A,OperationRejected:()=>u,OrderImmediatelyFillable:()=>O,OrderNotCached:()=>S,OrderNotFillable:()=>T,OrderNotFound:()=>k,PermissionDenied:()=>o,RateLimitExceeded:()=>E,RequestTimeout:()=>q,UnsubscribeError:()=>H,default:()=>U});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 h extends r{constructor(e){super(e),this.name="ArgumentsRequired"}}class c extends r{constructor(e){super(e),this.name="BadRequest"}}class l extends c{constructor(e){super(e),this.name="BadSymbol"}}class u extends r{constructor(e){super(e),this.name="OperationRejected"}}class f extends u{constructor(e){super(e),this.name="NoChange"}}class p extends f{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 r{constructor(e){super(e),this.name="InsufficientFunds"}}class y extends r{constructor(e){super(e),this.name="InvalidAddress"}}class w extends y{constructor(e){super(e),this.name="AddressPending"}}class b extends r{constructor(e){super(e),this.name="InvalidOrder"}}class k extends b{constructor(e){super(e),this.name="OrderNotFound"}}class S extends b{constructor(e){super(e),this.name="OrderNotCached"}}class O extends b{constructor(e){super(e),this.name="OrderImmediatelyFillable"}}class T extends b{constructor(e){super(e),this.name="OrderNotFillable"}}class P extends b{constructor(e){super(e),this.name="DuplicateOrderId"}}class I extends b{constructor(e){super(e),this.name="ContractUnavailable"}}class M 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 A extends s{constructor(e){super(e),this.name="OperationFailed"}}class C extends A{constructor(e){super(e),this.name="NetworkError"}}class B extends C{constructor(e){super(e),this.name="DDoSProtection"}}class E extends C{constructor(e){super(e),this.name="RateLimitExceeded"}}class N extends C{constructor(e){super(e),this.name="ExchangeNotAvailable"}}class R extends N{constructor(e){super(e),this.name="OnMaintenance"}}class L extends C{constructor(e){super(e),this.name="InvalidNonce"}}class D extends L{constructor(e){super(e),this.name="ChecksumError"}}class q extends C{constructor(e){super(e),this.name="RequestTimeout"}}class V extends A{constructor(e){super(e),this.name="BadResponse"}}class F extends V{constructor(e){super(e),this.name="NullResponse"}}class G extends A{constructor(e){super(e),this.name="CancelPending"}}class H extends s{constructor(e){super(e),this.name="UnsubscribeError"}}const U={BaseError:s,ExchangeError:r,AuthenticationError:a,PermissionDenied:o,AccountNotEnabled:n,AccountSuspended:d,ArgumentsRequired:h,BadRequest:c,BadSymbol:l,OperationRejected:u,NoChange:f,MarginModeAlreadySet:p,MarketClosed:m,ManualInteractionNeeded:g,InsufficientFunds:v,InvalidAddress:y,AddressPending:w,InvalidOrder:b,OrderNotFound:k,OrderNotCached:S,OrderImmediatelyFillable:O,OrderNotFillable:T,DuplicateOrderId:P,ContractUnavailable:I,NotSupported:M,InvalidProxySettings:x,ExchangeClosedByUser:_,OperationFailed:A,NetworkError:C,DDoSProtection:B,RateLimitExceeded:E,ExchangeNotAvailable:N,OnMaintenance:R,InvalidNonce:L,ChecksumError:D,RequestTimeout:q,BadResponse:V,NullResponse:F,CancelPending:G,UnsubscribeError:H}},5095:(e,t,i)=>{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:()=>c.GA,aggregate:()=>u.QD,arrayConcat:()=>r.ax,asFloat:()=>o.Pf,asInteger:()=>o.JU,axolotl:()=>h.Sw,base16ToBinary:()=>d.FF,base58ToBinary:()=>d.Ry,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:()=>h.QR,decimalToPrecision:()=>n.fq,decode:()=>d.D4,deepExtend:()=>r.zw,ecdsa:()=>h.h1,eddsa:()=>h.q4,encode:()=>d.lF,extend:()=>r.X$,extractParams:()=>u.um,filterBy:()=>r.WP,flatten:()=>r.Bq,groupBy:()=>r.$z,hasProps:()=>o.dl,hash:()=>h.tW,hmac:()=>h.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:()=>c.LC,json:()=>d.Pq,keys:()=>r.HP,keysort:()=>r.CA,mdy:()=>c.rE,merge:()=>r.h1,microseconds:()=>c.EZ,milliseconds:()=>c.Rz,now:()=>c.tB,numberToBE:()=>d.qE,numberToLE:()=>d.aN,numberToString:()=>n.um,omit:()=>r.cJ,omitZero:()=>n.Ye,ordered:()=>r.Sj,packb:()=>d.Am,parse8601:()=>c.Dj,parseDate:()=>c._U,parseTimeframe:()=>u.ce,pluck:()=>r.Ey,precisionConstants:()=>n.S2,precisionFromString:()=>n.Iu,prop:()=>o._w,rawencode:()=>d.rO,rfc2616:()=>c.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:()=>c.YA,selfIsDefined:()=>u.Se,setTimeout_safe:()=>c.k4,sleep:()=>c.yy,sort:()=>r.di,sortBy:()=>r.Ul,sortBy2:()=>r.sy,stringToBase64:()=>d.q3,stringToBinary:()=>d.wN,strip:()=>a.bB,sum:()=>r.cz,timeout:()=>c.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:()=>c.nm,values:()=>r.zu,vwap:()=>u.ru,ymd:()=>c.Th,ymdhms:()=>c.RR,yymmdd:()=>c.x_,yyyymmdd:()=>c.Rn});var s=i(7597),r=i(7437),a=i(3503),o=i(6834),n=i(1579),d=i(9560),h=i(8283),c=i(8403),l=i(7618),u=i(6238)},8283:(e,t,i)=>{i.d(t,{QR:()=>v,Sw:()=>m,h1:()=>p,q4:()=>g,tW:()=>u,w8:()=>f});var s=i(712),r=i(4710),a=i(5268),o=i(890),n=i(987),d=i(8342),h=i(191);const c={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 c[i](s)},f=(e,t,i,r="hex")=>{const a=(0,s.w)(i,t,e);return c[r](a)};function p(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)<c||n.r<=d||n.s<=d);)n=i.sign(e,t,{lowS:!0,extraEntropy:(0,h.z)(BigInt(f),32)}),f+=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)=>{i.d(t,{Am:()=>C,D4:()=>M,Dy:()=>O,FF:()=>g,LI:()=>x,Pq:()=>d,QM:()=>f,Ry:()=>y,Vw:()=>k,aN:()=>_,bj:()=>w,cg:()=>p,ev:()=>T,kn:()=>c,lF:()=>I,mC:()=>h,mu:()=>S,q3:()=>u,qE:()=>A,qo:()=>b,rO:()=>P,sQ:()=>m,t7:()=>v,wN:()=>l});var s=i(4710),r=i(191),a=i(917),o=i(4580),n=i.n(o);const d=(e,t=void 0)=>JSON.stringify(e),h=e=>"string"==typeof e&&e.length>=2&&("{"===e[0]||"["===e[0]),c=s.As.encode,l=s.As.decode,u=e=>s.K3.encode(s.As.decode(e)),f=e=>s.As.encode(s.K3.decode(e)),p=s.K3.decode,m=s.K3.encode,g=s.xn.decode,v=s.xn.encode,y=s.tw.decode,w=s.tw.encode,b=r.Id,k=e=>(0,r.Id)(...e),S=(e,t=!1)=>n().stringify(e),O=e=>n().stringify(e),T=e=>n().stringify(e,{arrayFormat:"repeat"}),P=(e,t=!1)=>n().stringify(e,{encode:!1}),I=s.As.decode,M=s.As.encode,x=e=>("string"==typeof e?u(e):m(e)).replace(/[=]+$/,"").replace(/\+/g,"-").replace(/\//g,"_"),_=(e,t)=>(0,r.z)(BigInt(e),t),A=(e,t)=>(0,r.lq)(BigInt(e),t);function C(e){return(0,a.l)(e)}},7437:(e,t,i)=>{i.d(t,{$r:()=>f,$z:()=>v,Am:()=>c,Bq:()=>S,CA:()=>m,Ey:()=>O,HP:()=>r,Im:()=>p,Pe:()=>o,RV:()=>u,Sj:()=>h,Ul:()=>b,WP:()=>w,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),h=e=>e,c=e=>Array.from(o(e)),l=(e,t)=>e.concat(t),u=(e,t)=>t.includes(e),f=e=>Object.values(e),p=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},w=(e,t,i=void 0,s=[])=>{for(const r of a(e))r[t]===i&&s.push(r);return s},b=(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{i.d(t,{Hp:()=>h,QD:()=>l,Se:()=>u,ce:()=>o,jG:()=>n,ru:()=>c,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},h=(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)=>{i.d(t,{D_:()=>r,Iu:()=>v,NZ:()=>m,R3:()=>s,S2:()=>u,Tz:()=>a,Ye:()=>b,_g:()=>o,ex:()=>l,fq:()=>y,fv:()=>n,kb:()=>h,um:()=>f,v:()=>d,w1:()=>c,xv:()=>g});const s=0,r=1,a=2,o=3,n=2,d=3,h=4,c=5,l=6,u={ROUND:r,TRUNCATE:s,ROUND_UP:a,ROUND_DOWN:o,DECIMAL_PLACES:n,SIGNIFICANT_DIGITS:d,TICK_SIZE:h,NO_PADDING:c,PAD_WITH_ZERO:l};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 p=[],m=(e,t=0)=>{if(e=f(e),t>0){const i=p[t]||(p[t]=new RegExp("([-]*\\d+\\.\\d{"+t+"})(\\d)")),[,s]=e.toString().match(i)||[null,e];return s.toString()}return parseInt(e).toString()},g=(e,t=0)=>parseFloat(m(e,t));function v(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 y=(e,t,i,s=n,r=c)=>w(e,t,i,s,r),w=(e,t,i,a=n,o=c)=>{if(a===h&&("string"==typeof i&&(i=parseFloat(i)),i<=0))throw new Error("TICK_SIZE cant be used with negative or zero numPrecisionDigits");if(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===h){const a=v(w(i,r,22,n,c));let d=e%i;d=Number(w(d,r,8,n,c));return 0!==v(w(d/i,r,Math.max(a,8),n,c))&&(t===r?e>0?d>=i/2?e=e-d+i:e-=d:e=d>=i/2?Number(e)-d:Number(e)-d-i:t===s&&(e-=d)),w(e,r,a,n,o)}const l=f(e),u="-"===l[0],p=u?1:0,m=l.length;for(var g=0;g57)throw new Error(`${l}: invalid number (contains an illegal character '${l[P-1]}')`);k[P]=e,e!==b&&O<0&&(O=P)}}O<0&&(O=1);let M=a===n?S:O,x=M+i;T=-1;let _=!0,A=u;for(let e=k.length-1,s=0;e>=0;e--){let a=k[e];if(0!==e){if(a+=s,e>=M+i){a=t===r&&a>=53&&!(53===a&&s)?58:b}a>57?(a=b,s=1):s=0}else s&&(a=49);k[e]=a,a!==b&&(_=!1,O=e,T=T<0?e+1:T)}a===d&&(M=O,x=M+i),_&&(A=!1);const C=O>=S||_?S-1:O,B=T{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)=>{i.d(t,{a:()=>h,n:()=>d});var s=i(5944),r=i(4710),a=i(9560),o=i(8283),n=i(8342);function d(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 c=(s?"RS":"HS")+8*i.outputLen;h.alg&&(c=h.alg.toUpperCase());const l=Object.assign({alg:c,typ:"JWT"},h);void 0!==l.iat&&(e.iat=l.iat,delete l.iat);const u=[(0,a.LI)(JSON.stringify(l)),(0,a.LI)(JSON.stringify(e))].join("."),f=c.slice(0,2);let p;if("HS"===f)p=(0,a.LI)((0,o.w8)(u,t,i,"binary"));else if(s||"RS"===f)p=(0,a.LI)((0,a.cg)(d(u,r.As.encode(t),i)));else if("ES"===f){const e=(0,o.h1)(u,r.As.encode(t),n.Qj,i),s=e.r.padStart(64,"0"),d=e.s.padStart(64,"0");p=(0,a.LI)((0,a.FF)(s+d))}return[u,p].join(".")}},3503:(e,t,i)=>{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)=>{i.d(t,{x:()=>r});var s=i(8403);class r{constructor(e){this.config={refillRate:1,delay:.001,capacity:1,maxCapacity:2e3,tokens:0,cost:1},Object.assign(this.config,e),this.queue=[],this.running=!1}async loop(){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)}}}throttle(e=void 0){let t;const i=new Promise(((e,i)=>{t=e}));if(this.queue.length>this.config.maxCapacity)throw new Error("throttle queue is over maxCapacity ("+this.config.maxCapacity.toString()+"), see https://github.com/ccxt/ccxt/issues/11645#issuecomment-1195695526");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)=>{i.d(t,{D9:()=>p,Dj:()=>u,EZ:()=>r,GA:()=>c,LC:()=>l,RR:()=>w,Rn:()=>y,Rz:()=>a,Th:()=>g,YA:()=>o,_U:()=>f,k4:()=>h,nm:()=>n,rE:()=>m,tB:()=>s,wR:()=>k,x_:()=>v,yy:()=>b});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,h=(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=h(e,t,i,r):e()}),t);return function(){o&&(o=!1,clearTimeout(n)),a()}};class c extends Error{constructor(){const e="timed out";super(e),this.constructor=c,this.__proto__=c.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}},f=e=>{if("string"==typeof e&&e){if(e.indexOf("GMT")>=0)try{return Date.parse(e)}catch(e){return}return u(e)}},p=(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),w=(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},b=e=>new Promise((t=>h(t,e))),k=async(e,t)=>{let i=()=>{};const s=new Promise((t=>i=h(t,e)));try{return await Promise.race([t,s.then((()=>{throw new c}))])}finally{i()}}},8995:(e,t,i)=>{i.d(t,{A:()=>n,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"),h=t(d.substring(d.length-1));let c=(t(d.substr(2*h,8))&t("7fffffff"))+"";return c.substring(c.length-6,c.length)}const n=o},6834:(e,t,i)=>{i.d(t,{At:()=>E,Cw:()=>T,DR:()=>L,Dj:()=>x,Et:()=>s,F7:()=>C,Fq:()=>r,Gv:()=>d,Hf:()=>h,I9:()=>q,J0:()=>I,JU:()=>m,KL:()=>c,Kg:()=>n,Pf:()=>p,Q7:()=>B,RH:()=>O,Rc:()=>D,Y2:()=>v,Y_:()=>R,_w:()=>l,cy:()=>a,d0:()=>_,dl:()=>o,fu:()=>V,gw:()=>S,hO:()=>N,lu:()=>y,mU:()=>P,nr:()=>k,pI:()=>b,q0:()=>w,uS:()=>A,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,h=e=>d(e)&&Object.getPrototypeOf(e)===Object.prototype&&!a(e)&&!(e=>e instanceof RegExp)(e),c=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,f=(e,t)=>d(e)?e[t.find((t=>void 0!==l(e,t)))]:void 0,p=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=p(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=p(l(e,t));return s(a)?parseInt(a*i):r},w=(e,t,i)=>{const r=p(l(e,t));return s(r)?parseInt(1e3*r):i},b=(e,t,i)=>{const s=l(e,t);return o(s)?s:i},k=(e,t,i)=>{const s=l(e,t);return c(s)?String(s):i},S=(e,t,i)=>{const s=l(e,t);return c(s)?String(s).toLowerCase():c(i)?String(i).toLowerCase():i},O=(e,t,i)=>{const s=l(e,t);return c(s)?String(s).toUpperCase():c(i)?String(i).toUpperCase():i},T=(e,t,i,r)=>{const a=p(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=p(u(e,t,i));return s(o)?parseInt(o*r):a},M=(e,t,i,r)=>{const a=p(u(e,t,i));return s(a)?parseInt(1e3*a):r},x=(e,t,i,s)=>{const r=u(e,t,i);return o(r)?r:s},_=(e,t,i,s)=>{const r=u(e,t,i);return c(r)?String(r):s},A=(e,t,i,s)=>{const r=u(e,t,i);return c(r)?String(r).toLowerCase():c(s)?String(s).toLowerCase():s},C=(e,t,i,s)=>{const r=u(e,t,i);return c(r)?String(r).toUpperCase():c(s)?String(s).toUpperCase():s},B=(e,t,i)=>{const r=p(f(e,t));return s(r)?r:i},E=(e,t,i)=>{if(void 0===e)return i;const r=m(f(e,t));return s(r)?r:i},N=(e,t,i,r)=>{const a=p(f(e,t));return s(a)?parseInt(a*i):r},R=(e,t,i)=>{const r=p(f(e,t));return s(r)?parseInt(1e3*r):i},L=(e,t,i)=>{if(void 0===e)return i;const s=f(e,t);return o(s)?s:i},D=(e,t,i)=>{if(void 0===e)return i;const s=f(e,t);return c(s)?String(s):i},q=(e,t,i)=>{const s=f(e,t);return c(s)?String(s).toLowerCase():c(i)?String(i).toLowerCase():i},V=(e,t,i)=>{const s=f(e,t);return c(s)?String(s).toUpperCase():c(i)?String(i).toUpperCase():i}},2931:(e,t,i)=>{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)=>{i.d(t,{A:()=>l});var s=i(2079),r=i(4350),a=i(3206),o=i(7437),n=i(8403),d=i(7597),h=i(9560),c=i(4710);class l{constructor(e,t,i,s,r,n={}){this.verbose=!1;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)()}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.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")}onPong(){this.lastPong=(0,n.Rz)(),this.verbose&&this.log(new Date,"onPong")}onError(e){this.verbose&&this.log(new Date,"onError",e.message),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.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")}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=c.As.encode(t)):i=i.toString());try{(0,h.mC)(i)&&(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)}try{this.onMessageCallback(this,i)}catch(e){this.reject(e)}}}},3206:(e,t,i)=>{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(){setTimeout((()=>{e.apply(this,arguments)}))},i.reject=function(){setTimeout((()=>{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)=>{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{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:()=>h,eB:()=>f,f_:()=>c,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{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),h=i(3206);const c=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(),o.Ll?this.connection=new c(this.url,this.protocols,this.options):this.connection=new c(this.url,this.protocols),this.connection.onopen=this.onOpen.bind(this),this.connection.onmessage=this.onMessage.bind(this),this.connection.onerror=this.onError.bind(this),this.connection.onclose=this.onClose.bind(this),o.Ll&&this.connection.on("ping",this.onPing.bind(this)).on("pong",this.onPong.bind(this)).on("upgrade",this.onUpgrade.bind(this))}connect(e=0){return this.startedConnecting||(this.startedConnecting=!0,e?(0,d.yy)(e).then(this.createConnection.bind(this)):this.createConnection()),this.connected}isOpen(){return this.connection.readyState===c.OPEN}close(){return this.connection instanceof c&&(void 0===this.disconnected&&(this.disconnected=(0,h.K)()),this.connection.close()),this.disconnected}}},9002:(e,t,i)=>{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)=>{i.d(t,{A:()=>h});var s=i(3971),r=i(2079),a=i(1579),o=i(5354),n=i(4852),d=i(5147);class h 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:void 0,future:void 0,option:!1,cancelAllOrders:!0,cancelOrder:!0,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!0,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchMarkets:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFees:!1,fetchWithdrawals:!0,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{i.d(t,{A:()=>l});var s=i(335),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(5354),h=i(8283),c=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"},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"},www:"https://www.binance.com",referral:{url:"https://accounts.binance.com/en/register?ref=D7YA7CLY",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,"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,"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]]},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}},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},post:{batchOrders:5,"positionSide/dual":1,positionMargin:1,marginType:1,order:4,leverage:1,listenKey:1,countdownCancelAll:10,multiAssetsMargin:1,"apiReferral/customization":1,"apiReferral/userCustomization":1,feeBurn:1,"convert/getQuote":200,"convert/acceptQuote":20},put:{listenKey:1,order:1,batchOrders:5},delete:{batchOrders:1,order:1,allOpenOrders:1,listenKey: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},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,"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}}},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:["spot","linear","inverse"],loadAllOptions:!1,fetchCurrencies:!0,defaultTimeInForce:"GTC",defaultType:"spot",defaultSubType:void 0,hasAlreadyAuthenticatedSuccessfully:!1,warnOnFetchOpenOrdersWithoutSymbol:!0,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,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}}})}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),h=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(h),expiryDatetime:h,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){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)}currencyToPrecision(e,t,i=void 0){return void 0!==this.safeValue(this.currencies[e],"precision")?this.decimalToPrecision(t,o.R3,this.currencies[e].precision,this.precisionMode,this.paddingMode):this.numberToString(t)}nonce(){return this.milliseconds()-this.options.timeDifference}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;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();h.endTime=Math.min(a,r)}let l;void 0!==d&&(h.endTime=d),l=o.option?await this.eapiPublicGetKlines(this.extend(h,r)):"mark"===n?o.inverse?await this.dapiPublicGetMarkPriceKlines(this.extend(h,r)):await this.fapiPublicGetMarkPriceKlines(this.extend(h,r)):"index"===n?o.inverse?await this.dapiPublicGetIndexPriceKlines(this.extend(h,r)):await this.fapiPublicGetIndexPriceKlines(this.extend(h,r)):"premiumIndex"===n?o.inverse?await this.dapiPublicGetPremiumIndexKlines(this.extend(h,r)):await this.fapiPublicGetPremiumIndexKlines(this.extend(h,r)):o.linear?await this.fapiPublicGetKlines(this.extend(h,r)):o.inverse?await this.dapiPublicGetKlines(this.extend(h,r)):await this.publicGetKlines(this.extend(h,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 h=this.safeBool2(e,"m","isBuyerMaker");let c,l;if(void 0!==h?d=h?"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&&(c=e.isMaker?"maker":"taker"),"maker"in e&&(c=e.maker?"maker":"taker"),"optionSide"in e||t.option){const t=this.safeCurrencyCode(this.safeString(e,"quoteAsset","USDT"));c=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:c,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 h=this.editSpotOrderRequest(e,t,i,s,a,o,n),c=await this.privatePostOrderCancelReplace(h),l=this.safeDict(c,"newOrderResponse");return this.parseOrder(l,d)}editSpotOrderRequest(e,t,i,s,n,d=void 0,h={}){const c=this.market(t),l=this.safeStringN(h,["newClientOrderId","clientOrderId","origClientOrderId"]),u={symbol:c.id,side:s.toUpperCase()},f=i.toUpperCase();let p=f;this.isPostOnly("MARKET"===f,"LIMIT_MAKER"===f,h)&&(p="LIMIT_MAKER");const m=this.safeNumber2(h,"stopPrice","triggerPrice");void 0!==m&&("MARKET"===p?p="STOP_LOSS":"LIMIT"===p&&(p="STOP_LOSS_LIMIT")),u.type=p;const g=this.safeList(c.info,"orderTypes");if(!this.inArray(p,g))throw f!==p?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,w=!1,b=!1;if("MARKET"===p){if(this.safeBool(this.options,"quoteOrderQty",!0)){const e=this.safeValue2(h,"quoteOrderQty","cost"),t=c.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 b=!0}else b=!0}else"LIMIT"===p?(y=!0,v=!0,b=!0):"STOP_LOSS"===p||"TAKE_PROFIT"===p?(w=!0,b=!0):"STOP_LOSS_LIMIT"===p||"TAKE_PROFIT_LIMIT"===p?(b=!0,w=!0,y=!0,v=!0):"LIMIT_MAKER"===p&&(y=!0,b=!0);if(b&&(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(h,"timeInForce")&&(u.timeInForce=this.options.defaultTimeInForce),w){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(h,"cancelNewClientOrderId","cancelOrigClientOrderId")&&(u.cancelOrderId=e),"PO"===this.safeString(h,"timeInForce")&&(h=this.omit(h,["timeInForce"])),h=this.omit(h,["quoteOrderQty","cost","stopPrice","newClientOrderId","clientOrderId","postOnly"]),this.extend(u,h)}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 h={symbol:d.id,side:s.toUpperCase(),orderId:e,quantity:this.amountToPrecision(t,a)},c=this.safeStringN(n,["newClientOrderId","clientOrderId","origClientOrderId"]);return void 0!==o&&(h.price=this.priceToPrecision(t,o)),void 0!==c&&(h.origClientOrderId=c),n=this.omit(n,["clientOrderId","newClientOrderId"]),h}async editContractOrder(e,t,i,s,a,o=void 0,n={}){await this.loadMarkets();const d=this.market(t);let h;if([h,n]=this.handleOptionAndParams2(n,"editContractOrder","papi","portfolioMargin",!1),(d.linear||h)&&void 0===o&&!("priceMatch"in n))throw new r.ArgumentsRequired(this.id+" editOrder() requires a price argument for portfolio margin and linear orders");const c=this.editContractOrderRequest(e,t,i,s,a,o,n);let l;return d.linear?l=h?await this.papiPutUmOrder(this.extend(c,n)):await this.fapiPrivatePutOrder(this.extend(c,n)):d.inverse&&(l=h?await this.papiPutCmOrder(this.extend(c,n)):await this.dapiPrivatePutOrder(this.extend(c,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)c=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;[h,s]=this.handleMarginModeAndParams("fetchMyTrades",s),[t,s]=this.handleOptionAndParams2(s,"fetchMyTrades","papi","portfolioMargin",!1),"spot"===d||"margin"===d?t?c=await this.papiGetMarginMyTrades(this.extend(o,s)):"margin"===d||void 0!==h?("isolated"===h&&(o.isIsolated=!0),c=await this.sapiGetMarginMyTrades(this.extend(o,s))):c=await this.privateGetMyTrades(this.extend(o,s)):n.linear?c=t?await this.papiGetUmUserTrades(this.extend(o,s)):await this.fapiPrivateGetUserTrades(this.extend(o,s)):n.inverse&&(c=t?await this.papiGetCmUserTrades(this.extend(o,s)):await this.dapiPrivateGetUserTrades(this.extend(o,s)))}return this.parseTrades(c,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),h=[];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 h=this.safeInteger2(e,"successTime","updateTime");let c=this.safeString(e,"type");if(void 0===c){const t=this.safeString(e,"transactionType");void 0!==t&&(c="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"),c),u=this.safeNumber(e,"amount"),f=this.safeNumber2(e,"transactionFee","totalFee");let p;void 0!==f&&(p={currency:d,cost:f});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:c,amount:u,currency:d,status:l,updated:h,internal:g,comment:void 0,fee:p}}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 h=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(h,n,n),d=this.safeString(h,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 c=this.safeInteger2(e,"timestamp","transactionTime"),l=this.parseTransferStatus(this.safeString(e,"status"));return{info:e,id:i,timestamp:c,datetime:this.iso8601(c),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(),h=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"===h&&void 0===e)throw new r.ArgumentsRequired(this.id+' transfer () requires params["symbol"] when toAccount is '+s);const c=this.safeDict(this.options,"accountsById",{}),l=!(d in c),u=!(h in c);if(l&&void 0===t&&(o=d),u&&void 0===t&&(o=h),l||u){const e="MAIN"===d,t="MAIN"===h;if((l||u)&&("UMFUTURE"===d||"CMFUTURE"===d||("UMFUTURE"===h||"CMFUTURE"===h)||("FUNDING"===d||"FUNDING"===h)||("OPTION"===d||"OPTION"===h)))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?(h="ISOLATED_MARGIN",n.toSymbol=o):l&&u?(n.fromSymbol=d,n.toSymbol=h,d="ISOLATEDMARGIN",h="ISOLATEDMARGIN"):(l&&(n.fromSymbol=o,d="ISOLATEDMARGIN"),u&&(n.toSymbol=o,h="ISOLATEDMARGIN")),n.type=d+"_"+h}else n.type=d+"_"+h}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 h="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",{}),c=this.safeString(n,t),l=this.safeString(n,a);if(void 0===o){if(void 0===c){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=c+"_"+l}d.type=o,h="size"}void 0!==i&&(d[h]=i),void 0!==t&&(d.startTime=t);const c=this.safeInteger(s,"until");let l;void 0!==c&&(s=this.omit(s,"until"),d.endTime=c),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 h,c;void 0!==e&&(h=this.market(e),e=h.symbol,a.symbol=h.id),[c,s]=this.handleSubTypeAndParams("fetchFundingRateHistory",h,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 f;if(s=this.omit(s,["endTime","until"]),void 0!==u&&(a.endTime=u),void 0!==i&&(a.limit=i),this.isLinear(d,c))f=await this.fapiPublicGetFundingRate(this.extend(a,s));else{if(!this.isInverse(d,c))throw new r.NotSupported(this.id+" fetchFundingRateHistory() is not supported for "+d+" markets");f=await this.dapiPublicGetFundingRate(this.extend(a,s))}return this.parseFundingRateHistories(f,h,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"),h=this.safeNumber(e,"lastFundingRate"),c=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:h,fundingTimestamp:c,fundingDatetime:this.iso8601(c),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={}){const s=this.safeString(this.options,"defaultType","future"),a=this.safeString(i,"type",s);let o,n,d;i=this.omit(i,["type"]),[o,i]=this.handleSubTypeAndParams("setPositionMode",void 0,i),[n,i]=this.handleOptionAndParams2(i,"setPositionMode","papi","portfolioMargin",!1),d=e?"true":"false";const h={dualSidePosition:d};let c;if(this.isInverse(a,o))c=n?await this.papiPostCmPositionSideDual(this.extend(h,i)):await this.dapiPrivatePostPositionSideDual(this.extend(h,i));else{if(!this.isLinear(a,o))throw new r.BadRequest(this.id+" setPositionMode() supports linear and inverse contracts only");c=n?await this.papiPostUmPositionSideDual(this.extend(h,i)):await this.fapiPrivatePostPositionSideDual(this.extend(h,i))}return c}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 h=this.safeInteger(e,"leverage");return void 0===o||"both"===o?(n=h,d=h):"long"===o?n=h:"short"===o&&(d=h),{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)),h=this.parseSettlements(d,a),c=this.sortBy(h,"timestamp");return this.filterBySymbolSinceLimit(c,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)),h=this.parseSettlements(d,a),c=this.sortBy(h,"timestamp");return this.filterBySymbolSinceLimit(c,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||"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 r;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.safeList(f,"origclientorderidlist",[]);f=this.omit(f,["orderidlist","origclientorderidlist"]),r=this.rawencode(f);const i=e.length,s=t.length;i>0&&(r=r+"&orderidlist=%5B"+e.join("%2C")+"%5D"),s>0&&(r=r+"&origclientorderidlist=%5B"+t.join("%2C")+"%5D")}else r=this.rawencode(f);else r=this.urlencode(f);let m;m=this.secret.indexOf("PRIVATE KEY")>-1?this.secret.length>120?this.encodeURIComponent((0,d.n)(r,this.secret,n.s)):this.encodeURIComponent((0,h.q4)(this.encode(r),this.secret,c.ev)):this.hmac(this.encode(r),this.encode(this.secret),n.s),r+="&signature="+m,a={"X-MBX-APIKEY":this.apiKey},"GET"===i||"DELETE"===i?l+="?"+r:(o=r,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://testnet.binance.vision")?i="spot":e.startsWith("https://dapi."+s+"/")||e.startsWith("https://testnet.binancefuture.com/dapi")?i="inverse":e.startsWith("https://fapi."+s+"/")||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,h,c){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 f=this.safeString(d,"code");if(void 0!==f){if("200"===f||a.Y.stringEquals(f,"0"))return;if("-2015"===f&&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"),f,e),this.throwExactlyMatchedException(this.exceptions.exact,f,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 h=this.safeList(n,"rows"),c=this.parseBorrowInterests(h,o);return this.filterByCurrencySinceLimit(c,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 h=this.safeInteger(a,"until"),c=this.safeInteger(a,"endTime",h);if(a=this.omit(a,["endTime","until"]),c)d.endTime=c;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",c="list",h=await this.sapiGetConvertTradeFlow(this.extend(a,s))}const f=this.safeList(h,c,[]);return this.parseConversions(f,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,h={period:t};if([h,a]=this.handleUntilOption("endTime",h,a),void 0!==i&&(h.startTime=i),void 0!==s&&(h.limit=s),[n,a]=this.handleSubTypeAndParams("fetchLongShortRatioHistory",o,a),"linear"===n)h.symbol=o.id,d=await this.fapiDataGetGlobalLongShortAccountRatio(this.extend(h,a));else{if("inverse"!==n)throw new r.BadRequest(this.id+" fetchLongShortRatioHistory() supports linear and inverse subTypes only");h.pair=o.info.pair,d=await this.dapiDataGetGlobalLongShortAccountRatio(this.extend(h,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)=>{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:["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)=>{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:["spot"],defaultType:"spot",fetchMargins:!1,quoteOrderQty:!1},has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:void 0,option:!1,addMargin:!1,closeAllPositions:!1,closePosition:!1,createReduceOnlyOrder:!1,fetchBorrowInterest:!1,fetchBorrowRate:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchBorrowRates:!1,fetchBorrowRatesPerSymbol:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedPositions:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarketLeverageTiers:!1,fetchMarkOHLCV:!1,fetchOpenInterestHistory:!1,fetchPosition:!1,fetchPositions:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,reduceMargin:!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)=>{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:["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)=>{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,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,fetchBalance:!0,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDeposits:!0,fetchDepositWithdrawFee:"emulated",fetchDepositWithdrawFees:!0,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchLeverage:!0,fetchLiquidations:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!0,fetchMarkets:!0,fetchMarkOHLCV:!0,fetchMarkPrice:!0,fetchMarkPrices:!0,fetchMyLiquidations:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterest:!0,fetchOpenOrders:!0,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,fetchWithdrawals:!0,reduceMargin:!0,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:{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"},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:{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},post:{"trade/order":2,"trade/cancel":2,"trade/batchOrders":5,"trade/order/cancelReplace":5,"trade/cancelOrders":5,"trade/cancelOpenOrders":5,"trade/cancelAllAfter":5}}},v2:{public:{get:{"market/depth":1,"market/kline":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}},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/cancelReplace":2,"positionSide/dual":5,"trade/batchCancelReplace":5,"trade/closePosition":2,"trade/getVst":5,"twap/order":5,"twap/cancelOrder":5,"trade/assetMode":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/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}}}},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},post:{"swap/trace/closeTrackOrder":2,"swap/trace/setTPSL":2,"spot/trader/sellOrder":10}}}},api:{v3:{private:{get:{"asset/transfer":1,"capital/deposit/hisrec":1,"capital/withdraw/history":1},post:{"post/asset/transfer":1}}}}},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",swap:"PFUTURES",future:"SFUTURES"},accountsById:{FUND:"funding",SPOT:"spot",PFUTURES:"swap",SFUTURES:"future"},recvWindow:5e3,broker:"CCXT",defaultNetworks:{ETH:"ETH",USDT:"ERC20",USDC:"ERC20",BTC:"BTC",LTC:"LTC"},networks:{ARB:"ARBITRUM",MATIC:"POLYGON"}},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",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),h=await this.swapV2PrivatePostTradeBatchOrders(d)}else{this.safeBool(t,"sync",!1)&&(d.sync=!0),d.data=this.json(i),h=await this.spotV1PrivatePostTradeBatchOrders(d)}"string"==typeof h&&(h=this.fixStringifiedJsonMembers(h),h=this.parseJson(h));const c=this.safeDict(h,"data",{}),l=this.safeList(c,"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"]),h=this.safeInteger2(e,"updateTime","T"),c=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 f,p=this.safeValue(e,"stopLoss");void 0!==p&&""!==p&&(f=this.omitZero(this.safeString(p,"stopLoss"))),void 0!==p&&"number"!=typeof p&&""!==p&&("string"==typeof p&&(p=this.parseJson(p)),f=this.omitZero(this.safeString(p,"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 w=y;return void 0!==y&&(v.indexOf("stop")>-1&&void 0===f&&(f=y,w=void 0),v.indexOf("take")>-1&&void 0===m&&(m=y,w=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:h,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:w,stopLossPrice:f,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(c),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,h;i=this.omit(i,["clientOrderId"]),void 0!==n?s.clientOrderID=n:s.orderId=e,[d,i]=this.handleMarketTypeAndParams("cancelOrder",o,i),[h,i]=this.handleSubTypeAndParams("cancelOrder",o,i),a="spot"===d?await this.spotV1PrivatePostTradeCancel(this.extend(s,i)):"inverse"===h?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 h=[];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)),h=this.safeDict(d,"data",{}),c=this.safeList(h,"orders",[]);return this.parseOrders(c,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 h=this.safeDict(d,"data",{}),c=this.safeList2(h,"orders","list",[]);return this.parseOrders(c,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,h;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)h=await this.contractV1PrivateGetAllOrders(this.extend(a,s));else if("spot"===o)void 0!==i&&(a.pageSize=i),h=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,h=await this.swapV1PrivateGetTwapHistoryOrders(this.extend(a,s))}else h="inverse"===n?await this.cswapV1PrivateGetTradeOrderHistory(this.extend(a,s)):await this.swapV2PrivateGetTradeAllOrders(this.extend(a,s))}const c=this.safeDict(h,"data",{}),l=this.safeList2(c,"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",{}),n=this.safeString(o,i,i),d=this.safeString(o,s,s),h={asset:a.id,amount:this.currencyToPrecision(e,t),type:n+"_"+d},c=await this.spotV3PrivateGetGetAssetTransfer(this.extend(h,r));return{info:c,id:this.safeString(c,"tranId"),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={}){let a;await this.loadMarkets(),void 0!==e&&(a=this.currency(e));const o=this.safeDict(this.options,"accountsByType",{}),n=this.safeString(s,"fromAccount"),d=this.safeString(s,"toAccount"),h=this.safeString(o,n,n),c=this.safeString(o,d,d);if(void 0===h||void 0===c)throw new r.ExchangeError(this.id+" fromAccount & toAccount parameter are required");s=this.omit(s,["fromAccount","toAccount"]);let l=!1;if([l,s]=this.handleOptionAndParams(s,"fetchTransfers","paginate",!1),l)return await this.fetchPaginatedCallDynamic("fetchTransfers",void 0,t,i,s,100);let u={type:h+"_"+c};void 0!==t&&(u.startTime=t),void 0!==i&&(u.size=i),[u,s]=this.handleUntilOption("endTime",u,s);const f=await this.spotV3PrivateGetAssetTransfer(this.extend(u,s)),p=this.safeList(f,"rows",[]);return this.parseTransfers(p,a,t,i)}parseTransfer(e,t=void 0){const i=this.safeString(e,"tranId"),s=this.safeInteger(e,"timestamp"),r=this.safeCurrencyCode(void 0,t),a=this.safeString(e,"status"),o=this.safeDict(this.options,"accountsById",{}),n=this.safeString(e,"type").split("_"),d=this.safeString(n,0),h=this.safeString(n,1),c=this.safeString(o,d,d),l=this.safeString(o,h,h);return{info:e,id:i,timestamp:s,datetime:this.iso8601(s),currency:r,amount:this.safeNumber(e,"amount"),fromAccount:c,toAccount:l,status:this.parseTransferStatus(a)}}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.safeInteger(e,"insertTime"),d=this.iso8601(n);void 0===n&&(d=this.safeString(e,"applyTime"),n=this.parse8601(d));const h=this.safeString(e,"network"),c=this.safeString(e,"coin");let l=this.safeCurrencyCode(c,t);void 0!==l&&l!==h&&l.indexOf(h)>=0&&void 0!==h&&(l=l.replace(h,""));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(h),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,h;if([h,s]=this.handleSubTypeAndParams("fetchMyTrades",a,s),"inverse"===h){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.safeList(e,"networkList",[]),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;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),h=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(h),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",{}),h=this.safeList(d,"success",[]),c=[];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}sign(e,t="public",i="GET",s={},a=void 0,n=void 0){let d=t[0],h=t[1],c=t[2];if(this.safeBool(this.options,"sandboxMode",!1)&&"swap"!==d)throw new r.NotSupported(this.id+" does not have a testnet/sandbox URL for "+d+" endpoints");let l=this.implodeHostname(this.urls.api[d]);if(e=this.implodeParams(e,s),"transfer"===h&&(d="account/transfer",h=t[2],c=t[3]),"account/apiPermissions"!==e&&(l+="spot"===d&&"v3"===h?"/api":"/"+d),l+="/"+h+"/"+e,(s=this.omit(s,this.extractParams(e))).timestamp=this.nonce(),s=this.keysort(s),"public"===c)Object.keys(s).length&&(l+="?"+this.urlencode(s));else if("private"===c){this.checkRequiredCredentials();const e=("subAccount"===d||"account/transfer"===d)&&"POST"===i;let t,r;e?r=this.customEncode(s):(t=this.parseParams(s),r=this.rawencode(t,!0));const h=this.hmac(this.encode(r),this.encode(this.secret),o.s);if(a={"X-BX-APIKEY":this.apiKey,"X-SOURCE-KEY":this.safeString(this.options,"broker","CCXT")},e)a["Content-Type"]="application/json",s.signature=h,n=this.json(s);else{l+="?"+this.urlencode(t,!0)+"&signature="+h}}return{url:l,method:i,body:n,headers:a}}nonce(){return this.milliseconds()}setSandboxMode(e){super.setSandboxMode(e),this.options.sandboxMode=e}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.safeString(n,"code");let l=this.safeString(n,"msg");const u=this.safeString(n,"transferErrorMsg");if(void 0!==u||void 0!==c&&"0"!==c){void 0!==u&&(l=u);const e=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwExactlyMatchedException(this.exceptions.exact,c,e),this.throwBroadlyMatchedException(this.exceptions.broad,l,e),new r.ExchangeError(e)}}}},2342:(e,t,i)=>{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{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",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,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","tickers","tickers_jpy","{pair}/depth","{pair}/transactions","{pair}/transactions/{yyyymmdd}","{pair}/candlestick/{candletype}/{yyyymmdd}","{pair}/circuit_break_info"]},private:{get:["user/assets","user/spot/order","user/spot/active_orders","user/margin/positions","user/spot/trade_history","user/deposit_history","user/unconfirmed_deposits","user/deposit_originators","user/withdrawal_account","user/withdrawal_history","spot/status","spot/pairs"],post:["user/spot/order","user/spot/cancel_order","user/spot/cancel_orders","user/spot/orders_info","user/confirm_deposits","user/confirm_deposits_all","user/request_withdrawal"]},markets:{get:["spot/pairs"]}},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 h=this.safeString(e,"order_id"),c=this.safeString(e,"type"),l=this.safeString(e,"side");return this.safeTrade({timestamp:i,datetime:this.iso8601(i),symbol:t.symbol,id:a,order:h,type:c,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{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,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"),h=this.safeString(a,"trail_rate");a=this.omit(a,["triggerPrice","stopPrice","trail_rate","target_rate","t_rate"]);const c={side:i.toUpperCase(),symbol:o.uppercaseId,quantity:this.amountToPrecision(e,s)};let l="v2PostOrders";"limit"===t?c.rate=this.priceToPrecision(e,r):(l="v1PostPlaceMarketOrderQntySymbol",c.market=o.quoteId),void 0!==n&&(c.t_rate=this.priceToPrecision(e,n)),void 0!==d&&(c.target_rate=this.priceToPrecision(e,d)),void 0!==h&&(c.trail_rate=this.priceToPrecision(e,h));const u=await this[l](this.extend(c,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 h="USDT"===s.quoteId?"usdtcancel":"cancel";return h+=d,o.side=h,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"},h=await this.v2PostGetordersnew(this.extend(d,s)),c=this.safeList(h,"data",[]);return this.parseOrders(c,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 h;void 0!==d?o=a.Y.stringDiv(o,d):(o=this.safeString(e,"base_volume"),h=this.safeString(e,"quote_volume"));const c=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:c,id:i,order:i,type:void 0,side:n,takerOrMaker:void 0,price:r,amount:o,cost:h,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"),h=this.safeNumber(e,"fee");let c;return void 0!==h&&(c={currency:s,cost:h}),{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:c}}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 h=this.omit(s,this.extractParams(e)),c=this.nonce().toString();if("GET"===i)Object.keys(h).length&&(d+="?"+this.urlencode(h));else if("POST"===i){const e={timeStamp_nonce:c,body:o=Object.keys(h).length?this.json(h):"{}"},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,h){if(void 0===n)return;const c=this.safeString(n,"code"),l=this.safeString(n,"msg");if(void 0!==c&&"200"!==c&&"204"!==c||void 0!==l){const e=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions.exact,c,e),this.throwExactlyMatchedException(this.exceptions.exact,l,e),this.throwBroadlyMatchedException(this.exceptions.broad,l,e),new r.ExchangeError(e)}}}},8657:(e,t,i)=>{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,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,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,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",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}getCurrencyId(e){return"f"+e}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 h,c;if(i.indexOf(":")>=0){const e=i.split(":");h=e[0],c=e[1]}else h=i.slice(0,3),c=i.slice(3,6);let l=this.safeCurrencyCode(h),u=this.safeCurrencyCode(c);const f=l.split("F0"),p=u.split("F0");l=this.safeString(f,0),u=this.safeString(p,0);let m,g,v=l+"/"+u;h=this.getCurrencyId(h),c=this.getCurrencyId(c),a&&(m=u,g=u,v=v+":"+m);const y=this.safeString(s,3),w=this.safeString(s,4);let b=!1;r&&this.inArray(i,o)&&(b=!0),d.push({id:"t"+i,symbol:v,base:l,quote:u,settle:m,baseId:h,quoteId:c,settleId:g,type:r?"spot":"swap",spot:r,margin:b,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(w)},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 h=s?5:3,c=this.safeString(i,h);let l,u,f,p;"-"===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);p={cost:t,currency:this.safeCurrencyCode(s)};const a=i[6];f=this.safeString(this.options.exchangeTypes,a)}return this.safeTrade({id:a,timestamp:v,datetime:this.iso8601(v),symbol:m,order:l,side:n,type:f,takerOrMaker:u,price:c,amount:d,cost:void 0,fee:p,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)),h=this.sortBy(d,1),c=[];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),h=this.safeNumber(i,6),c=this.safeString(i,8);if(void 0!==c){const e=c.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:h,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.uppercaseId,o=await this.privatePostAuthRLedgersCurrencyHist(this.extend(n,s))):o=await this.privatePostAuthRLedgersHist(this.extend(n,s));const d=[];for(let e=0;e{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,cancelAllOrders:void 0,cancelOrder:!0,createOrder:!0,fetchBalance:!0,fetchClosedOrders:"emulated",fetchDeposits:!0,fetchFundingRate:!0,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMyTrades:!0,fetchOpenOrders:"emulated",fetchOrder:"emulated",fetchOrderBook:!0,fetchOrders:!0,fetchPositionMode:!1,fetchPositions:!0,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawals:!0,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{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:!1,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/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/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/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/open-count":2,"v2/mix/account/bill":2,"v2/mix/market/query-position-lever":2,"v2/mix/position/single-position":2,"v2/mix/position/all-position":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/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-leverage":4,"v2/mix/account/set-margin":4,"v2/mix/account/set-margin-mode":4,"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/place-tpsl-order":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/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/history-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/modify-order":2,"v3/trade/cancel-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,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,"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,43111:r.PermissionDenied},broad:{"invalid size, valid range":r.ExchangeError}},precisionMode:o.kb,commonCurrencies:{APX:"AstroPepeX",DEGEN:"DegenReborn",JADE:"Jade Protocol",OMNI:"omni",TONCOIN:"TON"},options:{uta:!1,timeDifference:0,adjustForTimeDifference:!1,timeframes:{spot:{"1m":"1min","5m":"5min","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"}},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,"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",BSC:"BEP20",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"]},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}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.safeString(t,"productType",s);if(void 0===a&&void 0!==e){const t=e.settle;a="USDT"===t?"USDT-FUTURES":"USDC"===t?"USDC-FUTURES":"SUSDT"===t?"SUSDT-FUTURES":"SUSDC"===t?"SUSDC-FUTURES":"SBTC"===t||"SETH"===t||"SEOS"===t?"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" or "SCOIN-FUTURES"');return[a,t=this.omit(t,"productType")]}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;ie*u&&(I=this.sum(P,e*u),l.endTime=I)}if(l.limit=s,d.spot)x=_?await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(l,r)):await this.publicSpotGetV2SpotMarketCandles(this.extend(l,r));else{let e,t;[e,r]=this.handleParamString(r,"price"),[t,r]=this.handleProductTypeAndParams(d,r),l.productType=t;const i=this.extend(l,r);x="mark"===e?await this.publicMixGetV2MixMarketHistoryMarkCandles(i):"index"===e?await this.publicMixGetV2MixMarketHistoryIndexCandles(i):_?await this.publicMixGetV2MixMarketHistoryCandles(i):await this.publicMixGetV2MixMarketCandles(i)}if(""===x)return[];const A=this.safeList(x,"data",x);return this.parseOHLCVs(A,d,t,i,s)}async fetchBalance(e={}){await this.loadMarkets();const t={};let i,s,a;if([i,e]=this.handleMarketTypeAndParams("fetchBalance",void 0,e),[s,e]=this.handleMarginModeAndParams("fetchBalance",e),"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.privateMarginGetMarginV1IsolatedAccountAssets(this.extend(t,e));else if("cross"===s)a=await this.privateMarginGetMarginV1CrossAccountAssets(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 o=this.safeValue(a,"data",[]);return this.parseBalance(o)}parseBalance(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 x=this.safeString2(n,"triggerPriceType","triggerType","mark_price"),_=this.safeBool(n,"reduceOnly",!1),A=this.safeString2(n,"clientOid","clientOrderId"),C=this.safeString2(n,"force","timeInForce");let B;[B,n]=this.handlePostOnly(u,"post_only"===C,n);const E=this.safeStringUpper(this.options,"defaultTimeInForce"),N=this.safeStringUpper(n,"timeInForce",E);if(B?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"===h||"future"===h){let t;if(l.marginCoin=d.settleId,l.size=this.amountToPrecision(e,s),[t,n]=this.handleProductTypeAndParams(d,n),l.productType=t,void 0!==A&&(l.clientOid=A),(y||O||M)&&(l.triggerType=x),M){if(!u)throw new r.BadRequest(this.id+" createOrder() bitget trailing orders must be market orders");if(void 0===P)throw new r.ArgumentsRequired(this.id+" createOrder() bitget trailing orders must have a trailingTriggerPrice param");l.planType="track_plan",l.triggerPrice=this.priceToPrecision(e,P),l.callbackRatio=I}else if(y){if(l.planType="normal_plan",l.triggerPrice=this.priceToPrecision(e,f),void 0!==o&&(l.executePrice=this.priceToPrecision(e,o)),k){const t=this.safeNumber2(g,"triggerPrice","stopPrice");l.stopLossTriggerPrice=this.priceToPrecision(e,t);const i=this.safeNumber(g,"price");l.stopLossExecutePrice=this.priceToPrecision(e,i);const s=this.safeString(g,"type","mark_price");l.stopLossTriggerType=s}if(S){const t=this.safeNumber2(v,"triggerPrice","stopPrice");l.stopSurplusTriggerPrice=this.priceToPrecision(e,t);const i=this.safeNumber(v,"price");l.stopSurplusExecutePrice=this.priceToPrecision(e,i);const s=this.safeString(v,"type","mark_price");l.stopSurplusTriggerType=s}}else if(O){if(!u)throw new r.ExchangeError(this.id+" createOrder() bitget stopLoss or takeProfit orders must be market orders");l.holdSide="buy"===i?"long":"short",w?(l.triggerPrice=this.priceToPrecision(e,p),l.planType="pos_loss"):b&&(l.triggerPrice=this.priceToPrecision(e,m),l.planType="pos_profit")}else{if(k){const t=this.safeValue2(g,"triggerPrice","stopPrice");l.presetStopLossPrice=this.priceToPrecision(e,t)}if(S){const t=this.safeValue2(v,"triggerPrice","stopPrice");l.presetStopSurplusPrice=this.priceToPrecision(e,t)}}if(!O){void 0===c&&(c="cross");const e="cross"===c?"crossed":"isolated";let t,s;l.marginMode=e,[t,n]=this.handleParamBool(n,"hedged",!1),[s,n]=this.handleParamBool(n,"oneWayMode"),void 0!==s&&(t=!s);let r=i;_?t?(r="buy"===i?"sell":"buy",l.tradeSide="Close"):l.reduceOnly="YES":t&&(l.tradeSide="Open"),l.side=r}}else{if("spot"!==h)throw new r.NotSupported(this.id+" createOrder() does not support "+h+" orders");{if(O||T)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 h=!0;if([h,n]=this.handleOptionAndParams(n,"createOrder","createMarketBuyOrderRequiresPrice",!0),u&&"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(h){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!==A&&(l.clientOid=A),void 0!==c?(l.loanType="normal",u&&"buy"===i?l.quoteSize=t:l.baseSize=t):(void 0!==t&&(l.size=t),void 0!==f&&(l.planType=d,l.triggerType=x,l.triggerPrice=this.priceToPrecision(e,f),void 0!==o&&(l.executePrice=this.priceToPrecision(e,o))))}}return this.extend(l,n)}async createOrders(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");const P=this.safeString2(d,"clientOid","clientOrderId");let I;if(void 0!==P&&(c.clientOid=P),d=this.omit(d,["stopPrice","triggerType","stopLossPrice","takeProfitPrice","stopLoss","takeProfit","clientOrderId","trailingTriggerPrice","trailingPercent"]),h.spot){if(void 0===u)throw new r.NotSupported(this.id+" editOrder() only supports plan/trigger spot orders");if(this.safeBool(this.options,"editMarketBuyOrderRequiresPrice",!0)&&l&&"buy"===s){if(void 0===n)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 set the editMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter");{const e=this.numberToString(o),i=this.numberToString(n),s=this.parseNumber(a.Y.stringMul(e,i));c.size=this.priceToPrecision(t,s)}}else c.size=this.amountToPrecision(t,o);c.orderType=i,c.triggerPrice=this.priceToPrecision(t,u),c.executePrice=this.priceToPrecision(t,n),I=await this.privateSpotPostV2SpotTradeModifyPlanOrder(this.extend(c,d))}else{if(!h.swap&&!h.future)throw new r.NotSupported(this.id+" editOrder() does not support "+h.type+" orders");let e;if(c.symbol=h.id,[e,d]=this.handleProductTypeAndParams(h,d),c.productType=e,v||m||(c.newSize=this.amountToPrecision(t,o),void 0===n||T||(c.newPrice=this.priceToPrecision(t,n))),T){if(!l)throw new r.BadRequest(this.id+" editOrder() bitget trailing orders must be market orders");void 0!==S&&(c.newTriggerPrice=this.priceToPrecision(t,S)),c.newCallbackRatio=O,I=await this.privateMixPostV2MixOrderModifyPlanOrder(this.extend(c,d))}else if(v||m)c.marginCoin=h.settleId,c.size=this.amountToPrecision(t,o),void 0!==n&&(c.executePrice=this.priceToPrecision(t,n)),m?c.triggerPrice=this.priceToPrecision(t,p):v&&(c.triggerPrice=this.priceToPrecision(t,g)),I=await this.privateMixPostV2MixOrderModifyTpslOrder(this.extend(c,d));else if(f){if(c.newTriggerPrice=this.priceToPrecision(t,u),b){const e=this.safeNumber2(y,"triggerPrice","stopPrice");c.newStopLossTriggerPrice=this.priceToPrecision(t,e);const i=this.safeNumber(y,"price");c.newStopLossExecutePrice=this.priceToPrecision(t,i);const s=this.safeString(y,"type","mark_price");c.newStopLossTriggerType=s}if(k){const e=this.safeNumber2(w,"triggerPrice","stopPrice");c.newSurplusTriggerPrice=this.priceToPrecision(t,e);const i=this.safeNumber(w,"price");c.newStopSurplusExecutePrice=this.priceToPrecision(t,i);const s=this.safeString(w,"type","mark_price");c.newStopSurplusTriggerType=s}I=await this.privateMixPostV2MixOrderModifyPlanOrder(this.extend(c,d))}else{const e=this.uuid(),i=this.safeString2(d,"newClientOid","newClientOrderId",e);if(d=this.omit(d,"newClientOrderId"),c.newClientOid=i,b){const e=this.safeValue2(y,"triggerPrice","stopPrice");c.newPresetStopLossPrice=this.priceToPrecision(t,e)}if(k){const e=this.safeValue2(w,"triggerPrice","stopPrice");c.newPresetStopSurplusPrice=this.priceToPrecision(t,e)}I=await this.privateMixPostV2MixOrderModifyOrder(this.extend(c,d))}}const M=this.safeDict(I,"data",{});return this.parseOrder(M,h)}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"),h=this.safeValue2(i,"stop","trigger");if(i=this.omit(i,["stop","trigger","trailing"]),s.spot&&h||(n.symbol=s.id),(s.swap||s.future)&&h||(n.orderId=e),s.swap||s.future){let t;if([t,i]=this.handleProductTypeAndParams(s,i),n.productType=t,h||d){const t=[],i={orderId:e};t.push(i),n.orderIdList=t}if(d){const e=this.safeString(i,"planType","track_plan");n.planType=e,o=await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(n,i))}else o=h?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=h?await this.privateSpotPostV2SpotTradeCancelPlanOrder(this.extend(n,i)):await this.privateSpotPostV2SpotTradeCancelOrder(this.extend(n,i))}const c=this.safeValue(o,"data",{});let l;if((s.swap||s.future)&&h){l=this.safeValue(c,"successList",[])[0]}else l=c;return this.parseOrder(l,s)}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);let a;[a,i]=this.handleMarginModeAndParams("cancelOrders",i);const o=this.safeValue2(i,"stop","trigger");i=this.omit(i,["stop","trigger"]);const n=[];for(let t=0;t=0&&(c="out"),this.safeLedgerEntry({info:e,id:this.safeString(e,"billId"),timestamp:r,datetime:this.iso8601(r),direction:c,account:void 0,referenceId:void 0,referenceAccount:void 0,type:this.parseLedgerType(this.safeString(e,"businessType")),currency:s,amount:h,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={}){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;[o,s]=this.handleMarginModeAndParams("fetchMyTrades",s);let n,d=!1;if([d,s]=this.handleOptionAndParams(s,"fetchMyTrades","paginate"),d){let r;return a.spot?void 0!==o&&(r="minId"):r="endId",await this.fetchPaginatedCallCursor("fetchMyTrades",e,t,i,s,r,"idLessThan")}let h={symbol:a.id};if([h,s]=this.handleUntilOption("endTime",h,s),void 0!==t&&(h.startTime=t),void 0!==i&&(h.limit=i),a.spot)void 0!==o?(void 0===t&&(h.startTime=this.milliseconds()-7776e6),"isolated"===o?n=await this.privateMarginGetV2MarginIsolatedFills(this.extend(h,s)):"cross"===o&&(n=await this.privateMarginGetV2MarginCrossedFills(this.extend(h,s)))):n=await this.privateSpotGetV2SpotTradeFills(this.extend(h,s));else{let e;[e,s]=this.handleProductTypeAndParams(a,s),h.productType=e,n=await this.privateMixGetV2MixOrderFills(this.extend(h,s))}const c=this.safeValue(n,"data");if(a.swap||a.future){const e=this.safeList(c,"fillList",[]);return this.parseTrades(e,a,t,i)}if(void 0!==o){const e=this.safeList(c,"fills",[]);return this.parseTrades(e,a,t,i)}return this.parseTrades(c,a,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,marginCoin:i.settleId,productType:s},a=await this.privateMixGetV2MixPositionSinglePosition(this.extend(r,t)),o=this.safeList(a,"data",[]),n=this.safeDict(o,0,{});return this.parsePosition(n,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);a=this.market(t)}[o,t]=this.handleProductTypeAndParams(a,t);const n={productType:o};let d,h=!1;if("privateMixGetV2MixPositionAllPosition"===i){let i=this.safeString(t,"marginCoin","USDT");if(void 0!==e)i=a.settleId;else if("USDT-FUTURES"===o)i="USDT";else if("USDC-FUTURES"===o)i="USDC";else if("SUSDT-FUTURES"===o)i="SUSDT";else if("SUSDC-FUTURES"===o)i="SUSDC";else if(("SCOIN-FUTURES"===o||"COIN-FUTURES"===o)&&void 0===i)throw new r.ArgumentsRequired(this.id+" fetchPositions() requires a marginCoin parameter that matches the productType");n.marginCoin=i,d=await this.privateMixGetV2MixPositionAllPosition(this.extend(n,t))}else h=!0,void 0!==a&&(n.symbol=a.id),d=await this.privateMixGetV2MixPositionHistoryPosition(this.extend(n,t));let c=[];if(h){const e=this.safeDict(d,"data",{});c=this.safeList(e,"list",[])}else c=this.safeList(d,"data",[]);const l=[];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,marginCoin:s.settleId,leverage:this.numberToString(e),productType:a};return await this.privateMixPostV2MixAccountSetLeverage(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.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";let r,a;void 0!==t&&(r=this.market(t)),[a,i]=this.handleProductTypeAndParams(r,i);const o={posMode:s,productType:a};return await this.privateMixPostV2MixAccountSetPositionMode(this.extend(o,i))}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,productType:s},o=await this.publicMixGetV2MixMarketOpenInterest(this.extend(a,t)),n=this.safeDict(o,"data",{});return this.parseOpenInterest(n,i)}parseOpenInterest(e,t=void 0){const i=this.safeValue(e,"openInterestList",[]),s=this.safeInteger(e,"ts"),r=this.safeString(i[0],"symbol");return this.safeOpenInterest({symbol:this.safeSymbol(r,t,void 0,"contract"),openInterestAmount:this.safeNumber(i[0],"size"),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 h={coin:d.id,fromType:a};void 0!==t&&(h.startTime=t),void 0!==i&&(h.limit=i),[h,s]=this.handleUntilOption("endTime",h,s);const c=await this.privateSpotGetV2SpotAccountTransferRecords(this.extend(h,s)),l=this.safeList(c,"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 h;r=this.omit(r,"symbol"),void 0!==d&&(h=this.market(d),n.symbol=h.id);const c=await this.privateSpotPostV2SpotWalletTransfer(this.extend(n,r)),l=this.safeValue(c,"data",{});return l.ts=this.safeInteger(c,"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"),h=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:h,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){const t=this.market(e[0]);a.symbol=t.id}}void 0!==t&&(a.startTime=t),void 0!==i&&(a.limit=i),void 0!==r&&(a.endTime=r);const o=await this.privateMixGetV2MixPositionHistoryPosition(this.extend(a,s)),n=this.safeDict(o,"data"),d=this.safeList(n,"list"),h=this.parsePositions(d,e,s);return this.filterBySinceLimit(h,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),h=this.safeString(o,"toCoin",t),c=this.currency(h);return this.parseConversion(o,d,c)}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},h=await this.privateConvertPostV2ConvertTrade(this.extend(d,a)),c=this.safeDict(h,"data",{}),l=this.safeString(c,"toCoin",i),u=this.currency(l);return this.parseConversion(c,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",{}),h=this.safeList(d,"dataList",[]);return this.parseConversions(h,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&&(c=c+"?"+this.urlencode(l))}if(o){this.checkRequiredCredentials();const e=this.nonce().toString();let t=e+i+h;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","$")),c+=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){void 0===r&&(r={});const e=this.safeString(s,"productType");"SCOIN-FUTURES"!==e&&"SUSDT-FUTURES"!==e&&"SUSDC-FUTURES"!==e&&(r.PAPTRADING="1")}return{url:c,method:i,body:a,headers:r}}}},357:(e,t,i)=>{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,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}}}}},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 h;const c=this.safeString(e,"fee");if(void 0!==c){const t=this.safeString(e,"fee_currency");h={cost:c,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:h},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 h="privatePostTradePlace";"limit"===t?(d.price=a,d.type="buy"===i?"bid":"ask"):h="privatePostTradeMarket"+this.capitalize(i);const c=await this[h](this.extend(d,o)),l=this.safeString(c,"order_id");if(void 0===l)throw new r.InvalidOrder(this.id+" createOrder() did not return an order id");return this.safeOrder({info:c,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 h,c=this.fixCommaNumber(this.safeString(e,"units_remaining"));void 0===c&&("closed"===r?c="0":"canceled"!==r&&(c=d));const l=this.safeString(e,"order_currency"),u=this.safeString(e,"payment_currency"),f=this.safeCurrencyCode(l),p=this.safeCurrencyCode(u);void 0!==f&&void 0!==p&&(h=f+"/"+p),void 0===h&&(h=(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:h,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:c,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 h=this.omit(s,this.extractParams(e));if("public"===t)Object.keys(h).length&&(d+="?"+this.urlencode(h));else{this.checkRequiredCredentials(),a=this.urlencode(this.extend({endpoint:o},h));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,h){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)=>{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,"you contract account available balance not enough":r.InsufficientFunds}},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 h,c;if(void 0!==d){2===this.safeInteger(d,"status")?h="ok":(h="maintenance",c=this.safeInteger(d,"end_time"))}return{status:h,updated:void 0,eta:c,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 h=this.safeDict(r,d);void 0===h&&(h={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 c=this.networkIdToCode(o),l=this.safeBool(t,"withdraw_enabled"),u=this.safeBool(t,"deposit_enabled");h.networks[c]={info:t,id:o,code:c,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]=h}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"),h=this.safeString(e,"fluctuation"),c=this.safeString2(e,"high_24h","high_price"),l=this.safeString2(e,"low_24h","low_price"),u=this.safeString2(e,"best_bid","bid_px"),f=this.safeString2(e,"best_bid_size","bid_sz"),p=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 w=this.safeString(i,0);void 0!==w&&(r=w,o=this.safeInteger(i,12),c=this.safeString(i,5),l=this.safeString(i,6),u=this.safeString(i,8),f=this.safeString(i,9),p=this.safeString(i,10),m=this.safeString(i,11),g=this.safeString(i,4),n=this.safeString(i,1),h=this.safeString(i,7),v=this.safeString(i,2),y=this.safeStringLower(i,3));const b=(t=this.safeMarket(r,t)).symbol;return void 0===o&&(o=this.safeIntegerProduct(e,"s_t",1e3)),void 0===d&&(d=a.Y.stringMul(h,"100")),void 0===y&&(void 0===v?y=this.safeString(e,"volume_24h",y):(y=v,v=void 0)),this.safeTicker({symbol:b,timestamp:o,datetime:this.iso8601(o),high:c,low:l,bid:u,bidVolume:f,ask:p,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{i.d(t,{A:()=>h});var s=i(8186),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(8995);class h 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")),h=this.convertToRealAmount(n,this.safeString(e,"unrealisedPnl")),c=this.parseNumber(o.Y.stringAbs(this.safeString(e,"currentQty"))),l=this.safeNumber(t,"contractSize");let u;const f=this.safeString(e,"homeNotional");return void 0!==f&&(u="-"===f[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:c,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:h,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 h={currency:a.id,amount:o,address:i,network:this.networkCodeToId(n,a.code)};void 0!==this.twofa&&(h.otpToken=(0,d.O)(this.twofa));const c=await this.privatePostUserRequestWithdrawal(this.extend(h,r));return this.parseTransaction(c,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,h=this.checkRequiredCredentials(!1);if("private"===t||"public"===t&&h){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)=>{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 c=this.id+" "+o,l=this.safeString(n,"error");throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,l,c),new r.ExchangeError(c)}}},9061:(e,t,i)=>{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:["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,h;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))),h=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)),h=this.safeList(d,"data",[])}}return this.parseOHLCVs(h,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"),h=this.safeInteger(e,"createdAt"),c=this.safeInteger(e,"updatedAt"),l="payAmount"in e||"ctime"in e?"withdrawal":"deposit",u=this.parseTransactionStatusByType(this.safeString(e,"status"),l),f=this.safeNumber(e,"amount");let p,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&&(p=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:h,datetime:this.iso8601(h),network:p,address:o,addressTo:o,addressFrom:n,tag:r,tagTo:r,tagFrom:a,type:l,amount:f,currency:g,status:u,updated:c,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)),h=this.safeDict(d,"data",{});return this.parseTransaction(h,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),h={coinSymbol:a.id,amount:this.currencyToPrecision(e,t),transferType:n+"_to_"+d},c=await this.fapiV2PrivatePostFuturesTransfer(this.extend(h,r)),l=this.safeDict(c,"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),h=this.safeString(t,2);let c;if(c="api"===o&&"kline"===d||"open"===o&&e.indexOf("listenKey")>=0?this.urls.api[o]:this.urls.api[o]+"/"+d,c=c+"/"+this.implodeParams(e,s),s=this.omit(s,this.extractParams(e)),"private"===h){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?c+="?"+e:(a=e,r["Content-Type"]="application/x-www-form-urlencoded")}else{const h=this.nonce().toString();let l;"fapi"===o?l="/fapi":"dapi"===o&&(l="/dapi"),l=l+"/"+d+"/"+e;let u=h+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":h},c+="?"+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":h}}}}else Object.keys(s).length&&(c+="?"+this.urlencode(s));return{url:c,method:i,body:a,headers:r}}handleErrors(e,t,i,s,o,n,d,h,c){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 f=this.safeString(d,"code");if(void 0!==f){if("200"===f||a.Y.stringEquals(f,"0"))return;if("-2015"===f&&this.options.hasAlreadyAuthenticatedSuccessfully)throw new r.DDoSProtection(this.id+" temporary banned: "+n);const e=this.id+" "+n;throw this.throwExactlyMatchedException(this.exceptions.exact,f,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{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,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 h=this.safeString(o,"amount"),c=this.safeString(o,"currency"),l=this.safeCurrencyCode(c,t);t=this.safeCurrency(c,t);const u=this.safeValue(e,"details",{});let f=this.safeString2(u,"fid","wid");if(void 0===f&&(f=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(h),currency:t}}const p=this.parse8601(this.safeString(e,"created_at"));return this.safeLedgerEntry({info:e,id:this.safeString(e,"eid"),direction:n,account:void 0,referenceId:f,referenceAccount:void 0,type:s,currency:l,amount:h,timestamp:p,datetime:this.iso8601(p),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{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},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 h,c=this.safeString(e,"cost");if(void 0===t){const i=Object.keys(e);for(let e=0;e=0&&(h=s,t=this.safeMarket(h,t,"_"))}}void 0===t&&(t=this.getMarketFromTrade(e));const l=this.safeString(e,"fee"),u=t.quote,f=void 0!==h?h:t.marketId;o=this.safeString(e,f,o),n=this.safeString(e,t.baseId,n),c=this.safeString(e,t.quoteId,c),s=t.symbol;const p=this.safeString2(e,"date","datetime");let m,g;if(void 0!==p&&(p.indexOf(" ")>=0?m=this.parse8601(p):(m=parseInt(p),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!==c&&(c=a.Y.stringAbs(c)),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:c,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)),h=this.safeValue(d,"data",{}),c=this.safeList(h,"ohlc",[]);return this.parseOHLCVs(c,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],c=e[1])}let f={currency:void 0,cost:void 0,rate:void 0};return void 0!==o&&(f={currency:n,cost:o,rate:void 0}),{info:e,id:this.safeString(e,"id"),txid:this.safeString(e,"transaction_id"),type:h,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:c,tagFrom:void 0,tagTo:c,updated:void 0,comment:void 0,internal:void 0,fee:f}}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")),h=this.safeString(e,"amount"),c=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:h,filled:void 0,remaining:void 0,trades:c,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 h=this.parseTransfer(d,o);return h.amount=t,h.fromAccount=i,h.toAccount=s,h}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(),h="v2";let c="";r={"X-Auth":e,"X-Auth-Nonce":t,"X-Auth-Timestamp":s,"X-Auth-Version":h},"POST"===i&&(Object.keys(d).length?(a=this.urlencode(d),c="application/x-www-form-urlencoded",r["Content-Type"]=c):(a=this.urlencode({foo:"bar"}),c="application/x-www-form-urlencoded",r["Content-Type"]=c));const l=a||"",u=e+i+o.replace("https://","")+c+t+s+h+l,f=this.hmac(this.encode(u),this.encode(this.secret),n.s);r["X-Auth-Signature"]=f}return{url:o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=this.safeString(n,"status"),l=this.safeValue(n,"error");if("error"===c||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{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"),h=this.safeString(e,"timeStart"),c=this.parse8601(h);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:c,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)=>{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 h=await this.privatePostDwWithdrawApiCreate(this.extend(o,r));return this.parseTransaction(h,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 h=this.urlencode(s);const c=[i,this.hostname,o,h].join("\n"),l=this.hmac(this.encode(c),this.encode(this.secret),n.s,"base64");h+="&"+this.urlencode({Signature:l}),o+="?"+h,"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,h){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)=>{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:!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:!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.v,commonCurrencies:{MIOTA:"IOTA"}})}amountToPrecision(e,t){return this.decimalToPrecision(t,a.R3,this.markets[e].precision.amount,a.fv)}priceToPrecision(e,t){return t=this.decimalToPrecision(t,a.D_,this.markets[e].precision.price,this.precisionMode),this.decimalToPrecision(t,a.R3,8,a.fv)}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=this.currencies,i=this.indexBy(t,"id"),s=[],r=this.fees;for(let t=0;t{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,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{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,h=this.safeString(e,"baseCurrency"),c=this.safeString(e,"quoteCurrency"),l=this.safeString(e,"quoteCurrency"),u=this.safeCurrencyCode(l),f=this.safeCurrencyCode(h),p=this.safeCurrencyCode(c);let m=f+"/"+p;o&&(m=m+":"+u);const g=void 0,v=this.safeString(e,"tickSize"),y=this.safeDict2(this.fees,i,"trading",{}),w=this.safeNumber(y,"taker"),b=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:f,quote:p,baseId:h,quoteId:c,settle:u,settleId:l,type:i,spot:s,option:n,margin:s&&a.Y.stringGt(k,"1"),swap:o,future:r,active:S,taker:w,maker:b,contract:d,linear:d?c===l:void 0,inverse:d?h===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"),h=this.safeString(e,"high24h"),c=this.safeString(e,"low24h");return this.safeTicker({symbol:r,timestamp:i,datetime:this.iso8601(i),high:h,low:c,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"),h=this.safeString(e,"orderId"),c=this.safeString(e,"fee");let l;return void 0!==c&&(l={cost:c,currency:t.settle}),this.safeTrade({info:e,timestamp:a,datetime:this.iso8601(a),symbol:r,id:i,order:h,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 h=this.safeList(n,"data",[]);return this.parseTrades(h,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 h;void 0!==d&&(n.after=d,r=this.omit(r,"until")),h=await this.publicGetMarketCandles(this.extend(n,r));const c=this.safeList(h,"data",[]);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();let a=!1;if([a,s]=this.handleOptionAndParams(s,"fetchFundingRateHistory","paginate"),a)return await this.fetchPaginatedCallDeterministic("fetchFundingRateHistory",e,t,i,"8h",s);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=await this.publicGetMarketFundingRateHistory(this.extend(n,s)),h=[],c=this.safeList(d,"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 h=this.omit(s,["method","stop","trigger","tpsl","TPSL"]);let c;c=n||"privateGetTradeOrdersTpslHistory"===d?await this.privateGetTradeOrdersTpslHistory(this.extend(a,h)):await this.privateGetTradeOrdersHistory(this.extend(a,h));const l=this.safeList(c,"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,h){if(void 0===n)return;const c=this.safeString(n,"code"),l=this.safeString(n,"msg"),u=this.id+" "+o;if(void 0!==c&&"0"!==c)throw this.throwExactlyMatchedException(this.exceptions.exact,l,u),this.throwExactlyMatchedException(this.exceptions.exact,c,u),this.throwBroadlyMatchedException(this.exceptions.broad,l,u),new r.ExchangeError(u);const f=this.safeList(n,"data"),p=this.safeDict(f,0),m=this.safeString(p,"msg"),g=this.safeString(p,"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 h=this.implodeHostname(this.urls.api.rest)+o;if("public"===t)this.isEmpty(d)||(h+="?"+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);h+=e,o+=e}}else this.isEmpty(d)||(t=a=this.json(d)),r["Content-Type"]="application/json";const s=o+i+e+e+t,c=this.stringToBase64(this.hmac(this.encode(s),this.encode(this.secret),n.s));r["ACCESS-SIGN"]=c}return{url:h,method:i,body:a,headers:r}}}},3413:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(9644),r=i(2079),a=i(5147),o=i(1579),n=i(4852);class d extends s.A{describe(){return this.deepExtend(super.describe(),{id:"btcalpha",name:"BTC-Alpha",countries:["US"],version:"v1",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,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://btc-alpha.com/api"},www:"https://btc-alpha.com",doc:"https://btc-alpha.github.io/api-docs",fees:"https://btc-alpha.com/fees/",referral:"https://btc-alpha.com/?r=123788"},api:{public:{get:["currencies/","pairs/","orderbook/{pair_name}","exchanges/","charts/{pair}/{type}/chart/","ticker/"]},private:{get:["wallets/","orders/own/","order/{id}/","exchanges/own/","deposits/","withdraws/"],post:["order/","order-cancel/"]}},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),h=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(h),max:this.safeNumber(e,"maximum_order_size")},price:{min:this.parseNumber(d),max:void 0},cost:{min:this.parseNumber(a.Y.stringMul(d,h)),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{i.d(t,{A:()=>h});var s=i(3829),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(4035);class h 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,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 h=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:h,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 c=this.safeValue(n,"result");if(void 0===c||!0===c)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)=>{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,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,h=this.safeString(a,"address");if(void 0!==h){const e=h.split("?dt=");e.length>1&&(h=e[0],d=e[1])}const c=h,l=d,u=this.safeString(e,"fee"),f=this.parseTransactionStatus(this.safeString(e,"status")),p=this.safeString(e,"assetName"),m=this.safeCurrencyCode(p);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:h,addressTo:c,addressFrom:undefined,tag:d,tagTo:l,tagFrom:undefined,type:r,amount:this.parseNumber(g),currency:m,status:f,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"))),h=this.safeNumber(e,"minOrderAmount"),c=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:h,max:c},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{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,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,h,c,l;for(let e=0;e{i.d(t,{A:()=>h});var s=i(1293),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(5354);class h 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,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/register?affiliate_id=35953"},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/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/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-record":10,"v5/asset/withdraw/withdrawable-amount":5,"v5/asset/withdraw/vasp/list":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-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/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/order":5,"v5/earn/position":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/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/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-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/ins-loan/association-uid":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,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:["spot","linear","inverse","option"],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"}},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",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),h=this.convertExpireDate(o),c=this.parse8601(h);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:c,expiryDatetime:h,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 h={symbol:n.id,orderId:e,category:d};let c;[c,i]=this.handleParamBool2(i,"trigger","stop",!1),c&&(h.orderFilter="StopOrder");const l=await this.privateGetV5OrderRealtime(this.extend(h,i)),u=this.safeDict(l,"result",{}),f=this.safeList(u,"list",[]);if(0===f.length){const t=c?"":' 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 p=this.safeDict(f,0,{});return this.parseOrder(p,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 h=this.safeBoolN(s,["trigger","stop"],!1);s=this.omit(s,["trigger","stop"]),h&&(o.orderFilter="StopOrder"),void 0!==i&&(o.limit=i),void 0!==t&&(o.startTime=t);const c=this.safeInteger(s,"until"),l=this.safeInteger(s,"endTime",c);s=this.omit(s,["endTime","until"]),void 0!==l&&(o.endTime=l);const u=await this.privateGetV5OrderHistory(this.extend(o,s)),f=this.addPaginationCursorToResult(u);return this.parseOrders(f,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 h=this.safeInteger(s,"until"),c=this.safeInteger(s,"endTime",h);s=this.omit(s,["endTime","until"]),void 0!==c&&(a.endTime=c);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 h=await this.privateGetV5OrderRealtime(this.extend(a,s)),c=this.addPaginationCursorToResult(h);return this.parseOrders(c,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)),h=this.addPaginationCursorToResult(d);return this.parseTrades(h,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 h=this.parseDepositAddresses(n,[i.code],!1,{currency:i.code});return this.indexBy(h,"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 h;void 0!==n&&(h={cost:n,currency:s});const c=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:c,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:h,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,h,c="coin";if(o[1]?(c="currency",void 0!==t&&(a.startTime=t)):void 0!==t&&(a.start_date=this.yyyymmdd(t)),void 0!==e&&(n=this.currency(e),a[c]=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);h="inverse"===d&&e<5?await this.privateGetV5AccountContractTransactionLog(this.extend(a,s)):await this.privateGetV5AccountTransactionLog(this.extend(a,s))}else h=await this.privateGetV5AccountContractTransactionLog(this.extend(a,s));const l=this.addPaginationCursorToResult(h);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,h,c;if(void 0!==a&&void 0!==r){const e="out"===n?r:o.Y.stringNeg(r);d=this.parseToNumeric(o.Y.stringAdd(a,e)),h=this.parseToNumeric(a),c=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:c,timestamp:l,datetime:this.iso8601(l),before:d,after:h,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),[a,r]=this.handleOptionAndParams(r,"withdraw","accountType","SPOT"),await this.loadMarkets(),this.checkAddress(i);const o=this.currency(e),n={coin:o.id,amount:this.numberToString(t),address:i,timestamp:this.milliseconds(),accountType:a};void 0!==s&&(n.tag=s);const[d,h]=this.handleNetworkCodeAndParams(r),c=this.networkCodeToId(d);void 0!==c&&(n.chain=c.toUpperCase());const l=await this.privatePostV5AssetWithdrawCreate(this.extend(n,h)),u=this.safeDict(l,"result",{});return this.parseTransaction(u,o)}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",[]),h=this.safeInteger(r,"time"),c=this.safeDict(d,0,{}),l=this.parsePosition(c,i);return l.timestamp=h,l.datetime=this.iso8601(h),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)),h=this.addPaginationCursorToResult(d),c=[];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 h=await this.privateGetV5PositionClosedPnl(this.extend(d,s)),c=this.safeDict(h,"result"),l=this.safeList(c,"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",{}),h=this.safeList(d,"coins",[]);for(let e=0;e=0,t=o.indexOf("unified/v3")>=0,h=o.indexOf("contract/v3")>=0,c=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||h||c){r={"Content-Type":"application/json","X-BAPI-API-KEY":this.apiKey,"X-BAPI-TIMESTAMP":l,"X-BAPI-RECV-WINDOW":this.options.recvWindow.toString()},(t||h)&&(r["X-BAPI-SIGN-TYPE"]="2");const e=this.extend({},s),c=this.rawencode(e),u=l.toString()+this.apiKey+this.options.recvWindow.toString();let f,p;"POST"===i?f=u+(a=this.json(e)):(f=u+c,o+="?"+c),p=this.secret.indexOf("PRIVATE KEY")>-1?(0,d.n)(f,this.secret,n.s):this.hmac(this.encode(f),this.encode(this.secret),n.s),r["X-BAPI-SIGN"]=p}else{const e=this.extend(s,{api_key:this.apiKey,recv_window:this.options.recvWindow,timestamp:l}),t=this.keysort(e),h=this.rawencode(t,!0);let c;if(c=this.secret.indexOf("PRIVATE KEY")>-1?(0,d.n)(h,this.secret,n.s):this.hmac(this.encode(h),this.encode(this.secret),n.s),"POST"===i){const t=o.indexOf("spot")>=0,i=this.extend(e,{sign:c});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="+c}}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,h){if(!n)return;const c=this.safeString2(n,"ret_code","retCode");if("0"!==c){if("30084"===c)return;let e;throw e="10005"===c&&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,c,e),new a.ExchangeError(e)}}}},8846:(e,t,i)=>{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)=>{i.d(t,{A:()=>h});var s=i(5661),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(5354);class h 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,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,createPostOnlyOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!1,createStopOrder:!0,deposit:!0,editOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchBidsAsks:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCanceledOrders:!0,fetchClosedOrders:!0,fetchConvertQuote:!0,fetchConvertTrade:!0,fetchConvertTradeHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDeposit:!0,fetchDepositAddress:"emulated",fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!0,fetchDepositMethodId:!0,fetchDepositMethodIds:!0,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchL2OrderBook:!1,fetchLedger:!0,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyBuys:!0,fetchMySells:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!0,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:"emulated",fetchTradingFees:!0,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!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},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.BadRequest,PERMISSION_DENIED:r.PermissionDenied,INVALID_ARGUMENT:r.BadRequest,PREVIEW_STOP_PRICE_ABOVE_LAST_TRADE_PRICE:r.InvalidOrder},broad:{"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-1,a=this.safeDict(s,r),o=this.safeString(i,"cursor");return void 0!==o&&""!==o&&(a.cursor=o,s[r]=a),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,w.push(t)}return w}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"),h=this.safeList(this.options,"stablePairs",[]),c=this.safeNumber(this.fees.trading,"taker"),l=this.safeNumber(this.fees.trading,"maker"),u=this.inArray(i,h)?1e-5:this.safeNumber(t,"taker_fee_rate",c),f=this.inArray(i,h)?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:f,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),h="PERPETUAL"===r,c=this.safeString(s,"contract_root_unit"),l=this.safeString(e,"quote_currency_id"),u=this.safeCurrencyCode(c),f=this.safeCurrencyCode(l),p=this.safeBool(e,"is_disabled");let m,g=u+"/"+f;h?(m="swap",g=g+":"+f):(m="future",g=g+":"+f+"-"+this.yymmdd(n));const v=this.safeNumber(t,"taker_fee_rate"),y=this.safeNumber(t,"maker_fee_rate"),w=v||this.parseNumber("0.06"),b=y||this.parseNumber("0.04");return this.safeMarketStructure({id:i,symbol:g,base:u,quote:f,settle:f,baseId:c,quoteId:l,settleId:l,type:m,spot:!1,margin:!1,swap:h,future:!h,option:!1,active:!p,contract:!0,linear:!0,inverse:!1,taker:w,maker:b,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",[]),h=await this.v2PublicGetExchangeRates(e);this.options.fetchCurrencies=this.extend(t,{currencies:this.arrayConcat(n,d),exchangeRates:h,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",{}),h=this.safeDict(d,"rates",{}),c=Object.keys(h),l=this.arrayConcat(o,n),u={},f={},p={};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:f,currency:n,amount:this.parseNumber(r),before:void 0,after:void 0,status:p,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:c,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(f),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(p,"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){let s;if(void 0!==i){s=t+" "+i.replace("https://","");const e=s.indexOf("?");e>0&&(s=s.slice(0,e))}const r=this.randomBytes(16),a={aud:["retail_rest_api_proxy"],iss:"coinbase-cloud",nbf:e,exp:e+120,sub:this.apiKey,iat:e};void 0!==s&&(a.uri=s);return(0,d.a)(a,this.encode(this.secret),n.s,!1,{kid:this.apiKey,nonce:r,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],h="private"===t[1],c="v3"===d;let l="/"+(c?"api/v3":"v2")+"/"+this.implodeParams(e,s);const u=this.omit(s,this.extractParams(e)),f=l;"GET"===i&&Object.keys(u).length&&(l+="?"+this.urlencodeWithArrayRepeat(u));const p=this.urls.api.rest+l;if(h){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)):c||Object.keys(u).length&&(s+="?"+this.urlencode(u));if(this.apiKey.indexOf("organizations/")>=0||this.secret.startsWith("-----BEGIN")){if(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,p)}else{const e=this.nonce(),t=this.parseToInt(e/1e3).toString(),r=t+i+f+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:p,method:i,body:o,headers:a}}handleErrors(e,t,i,s,a,o,n,d,h){if(void 0===n)return;const c=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,c),this.throwBroadlyMatchedException(this.exceptions.broad,e,c),new r.ExchangeError(c)}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,c),this.throwBroadlyMatchedException(this.exceptions.broad,e,c),new r.ExchangeError(c)}const f=this.safeList(n,"errors");if(void 0!==f&&Array.isArray(f)){if(f.length>0){l=this.safeString(f[0],"id");const e=this.safeString(f[0],"message");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,e,c),new r.ExchangeError(c)}}const p=this.options.advanced;if(!("data"in n)&&!p)throw new r.ExchangeError(this.id+" failed due to a malformed response "+this.json(n))}}},3278:(e,t,i)=>{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)=>{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,cancelAllOrders:!0,cancelOrder:!0,createDepositAddress:!0,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,fetchAccounts:!0,fetchBalance:!0,fetchClosedOrders:!0,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchLedger:!0,fetchMarginMode:!1,fetchMarkets:!0,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchOrderTrades:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:"emulated",fetchWithdrawals:!0,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/fees"],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"],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{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");c.result_limit=i}void 0!==t&&(c.ref_datetime=this.iso8601(t));const u=await this.v1PrivateGetOrders(this.extend(c,s)),f=this.safeList(u,"results",[]);return this.parseOrders(f,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 h=this.safeInteger(s,o,1)-1,c={result_offset:this.safeInteger2(s,"offset","result_offset",h*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.");c.result_limit=i}void 0!==t&&(c.time_from=this.iso8601(t));const l=this.safeStringN(s,["until"]);void 0!==l&&(s=this.omit(s,["until"]),c.ref_datetime=this.iso8601(l));const u=await this.v1PrivateGetPortfoliosFills(this.extend(c,s)),f=this.safeList(u,"results",[]);return this.parseTrades(f,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 h={portfolio:o,type:"send",asset:a.id,address:i,amount:t,currency:a.id,network_arn_id:d,nonce:this.nonce()},c=await this[n](this.extend(h,r));return this.parseTransaction(c,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"),h=t&&i;return{info:e.info,id:d,name:this.safeString(e,"name"),network:this.safeString(e,"network"),active:this.safeBool(e,"active",h),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 h="/"+o+"/"+this.implodeParams(e,s);const c=this.omit(s,this.extractParams(e)),l="/api"+h;"GET"!==i&&"DELETE"!==i||Object.keys(c).length&&(h+="?"+this.urlencodeWithArrayRepeat(c));const u=this.urls.api.rest+h;if(d){this.checkRequiredCredentials();const e=this.nonce().toString();let t="";"GET"!==i&&Object.keys(c).length&&(t=a=this.json(c));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,h){if(void 0===n)return;const c=this.id+" "+o,l=this.safeString(n,"title");if(void 0!==l)throw this.throwExactlyMatchedException(this.exceptions.exact,l,c),this.throwBroadlyMatchedException(this.exceptions.broad,l,c),new r.ExchangeError(c)}}},570:(e,t,i)=>{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"}},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="spot";if([o,t]=this.handleMarketTypeAndParams(i,s,t,o),"spot"===o)a=await this.publicGetApiSpotV1MarketTickers(t);else{if("swap"!==o)throw new r.NotSupported(this.id+" "+i+"() is not supported for "+o+" type of markets");{let e="umcbl";[e,t]=this.handleOptionAndParams(t,i,"productType",e);const s={productType:e};a=await this.publicGetApiMixV1MarketTickers(this.extend(s,t))}}const n=this.safeList(a,"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 h=this.safeDict(d,"data",{}),c=this.safeInteger(h,"ts");return this.parseOrderBook(h,e,c,"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 h;[h,a]=this.handleOptionAndParams(a,o,"until");const c=n.type,l=this.options.timeframes[c],u=this.safeString(l,t,t);let f,p=s;if(void 0===i&&void 0===h||(p=1e3),void 0!==p&&(d.limit=p),n.spot){d.period=u,void 0!==i&&(d.after=i),void 0!==h&&(d.before=h),f=await this.publicGetApiSpotV1MarketCandles(this.extend(d,a));const e=this.safeList(f,"data",[]);return this.parseOHLCVs(e,n,t,i,s)}if(n.swap){if(d.granularity=u,void 0===h&&(h=this.milliseconds()),void 0===i){i=h-1e3*this.parseTimeframe(t)*1e3}let e;return d.startTime=i,d.endTime=h,[e,a]=this.handleOptionAndParams(a,o,"price"),"mark"===e&&(d.kLineType="market mark index"),f=await this.publicGetApiMixV1MarketCandles(this.extend(d,a)),this.parseOHLCVs(f,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 h,c=i;if(void 0===t&&void 0===d||(c=1e3,void 0!==t&&(n.startTime=t),void 0!==d&&(n.endTime=d)),void 0!==c&&(n.limit=c),o.spot)h=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");h=await this.publicGetApiMixV1MarketFillsHistory(this.extend(n,s))}const l=this.safeList(h,"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)),h=this.safeList(d,"data",[]),c=[];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 h=this.safeNumber(e,"margin"),c=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:h,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(c,"100")),initialMargin:h,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)){f=!1;const e=this.safeDict(t,0,{});u=this.safeString(e,"errorCode"),c=this.safeString(e,"errorMsg")}}if(!f)throw this.throwExactlyMatchedException(this.exceptions.exact,u,l),this.throwBroadlyMatchedException(this.exceptions.broad,c,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,h=this.hmac(this.encode(d),this.encode(this.secret),n.s,"base64");r={"ACCESS-KEY":this.apiKey,"ACCESS-SIGN":h,"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)=>{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,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposits:!0,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!1,fetchMarginMode:!1,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchWithdrawals:!0,reduceMargin:!1,setLeverage:!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{i.d(t,{A:()=>h});var s=i(5277),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(4035);class h 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,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:!1,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/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/spot-balance":1,"account/trade-fee-rate":40,"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/margin/borrow-history":40,"assets/margin/interest-limit":1,"assets/deposit-address":40,"assets/deposit-history":40,"assets/withdraw":40,"assets/transfer-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},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,"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/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/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{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,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,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,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactions:"emulated",reduceMargin:!1,setLeverage:!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"]},private:{post:["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"]}},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 fetchMarkets(e={}){const t=await this.publicGetTradingPairs(e),i=this.safeValue(t,"data",[]),s=[];for(let e=0;e{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 h,c={};c.orderType=t,void 0!==s&&(h=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(h));u=this.parseToNumeric(e)}}void 0!==u&&(l=this.costToPrecision(e,u)),"sell"===i?c=this.handleCreateOrderSide(d.baseId,d.quoteId,h,l,c):"buy"===i&&(c=this.handleCreateOrderSide(d.quoteId,d.baseId,l,h,c));const f=this.safeValue(n,"timeInForce");void 0!==f&&(n=this.omit(n,"timeInForce"),c.timeInForce=this.encodeOrderTimeInForce(f));const p=this.safeString2(n,"triggerPrice","stopPrice");void 0!==p&&(n=this.omit(n,["triggerPrice"]),c.stopPrice=this.priceToPrecision(e,p));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)||(c.userData=m);const w=await this.privatePostExchangeOrdersCreate(this.extend(c,n));return this.parseOrder(w,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{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,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,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,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,reduceMargin:!1,setLeverage:!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{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,cancelAllOrders:!0,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createMarketBuyOrderWithCost:!0,createMarketOrderWithCost:!1,createMarketSellOrderWithCost:!1,createOrder:!0,createPostOnlyOrder:!1,createReduceOnlyOrder:!1,createStopLimitOrder:!0,createStopMarketOrder:!0,createStopOrder:!0,deposit:!0,editOrder:!1,fetchAccounts:!1,fetchBalance:!0,fetchBidsAsks:!1,fetchBorrowInterest:!1,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!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,fetchFundingRate:!1,fetchFundingRateHistory:!1,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:void 0,fetchOpenOrders:!0,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,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTradingLimits:!1,fetchTransactionFee:!1,fetchTransactionFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawal:void 0,fetchWithdrawals:!0,fetchWithdrawalWhitelist:!1,reduceMargin:!1,repayCrossMargin:!1,repayIsolatedMargin:!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/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/wallet/v1/config/getall":10,"openapi/wallet/v1/deposit/address":10,"openapi/wallet/v1/deposit/history":1,"openapi/wallet/v1/withdraw/history":1,"openapi/v1/account":10,"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},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/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},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,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{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,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createMarketOrder:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchIsolatedBorrowRate:!1,fetchIsolatedBorrowRates:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginMode:!1,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOpenInterestHistory:!1,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTickers:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,reduceMargin:!1,setLeverage:!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{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:!1,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-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/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}}},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.004"),taker:this.parseNumber("0.004"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("25000"),this.parseNumber("0.0035")],[this.parseNumber("50000"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.001")],[this.parseNumber("250000"),this.parseNumber("0.0009")],[this.parseNumber("1000000"),this.parseNumber("0.0008")],[this.parseNumber("20000000"),this.parseNumber("0.0007")],[this.parseNumber("100000000"),this.parseNumber("0.0006")],[this.parseNumber("200000000"),this.parseNumber("0.0004")]],taker:[[this.parseNumber("0"),this.parseNumber("0.004")],[this.parseNumber("25000"),this.parseNumber("0.0035")],[this.parseNumber("50000"),this.parseNumber("0.0025")],[this.parseNumber("100000"),this.parseNumber("0.0016")],[this.parseNumber("250000"),this.parseNumber("0.00015")],[this.parseNumber("1000000"),this.parseNumber("0.00014")],[this.parseNumber("20000000"),this.parseNumber("0.00013")],[this.parseNumber("100000000"),this.parseNumber("0.00012")],[this.parseNumber("200000000"),this.parseNumber("0.0001")]]}}},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"},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,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)),h=this.safeDict(d,"result",{}),c=this.safeList(h,"data",[]);return this.parseOrders(c,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)),h=this.safeDict(d,"result",{}),c=this.safeList(h,"data",[]);return this.parseTrades(c,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(),h=this.parseTimeframe(t),c=this.safeInteger(r,"until",d);r=this.omit(r,["until"]),void 0!==i?(n.start_ts=i-1e3*h,n.end_ts=void 0!==s?this.sum(i,h*s*1e3):c):n.end_ts=c;const l=await this.v1PublicGetPublicGetCandlestick(this.extend(n,r)),u=this.safeDict(l,"result",{}),f=this.safeList(u,"data",[]);return this.parseOHLCVs(f,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=t);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 h=await this.v1PrivatePostPrivateCreateWithdrawal(this.extend(o,r)),c=this.safeDict(h,"result");return this.parseTransaction(c,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{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,cancelAllOrders:!1,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelWithdraw:!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:!1,fetchBalance:!0,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!0,fetchDepositAddress:!1,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!1,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!1,fetchOHLCV:!1,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!1,fetchTickers:!0,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!1,reduceMargin:!1,sandbox:!1,setLeverage:!1,setMargin:!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{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,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?p=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(h),symbol:a,type:d,timeInForce:f,postOnly:this.safeBool(e,"postOnly"),reduceOnly:this.safeBool(e,"reduceOnly"),side:c,price:o,triggerPrice:m,takeProfitPrice:p,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]};return await this.v1PrivateDeleteApiOrdersAllOpen(this.extend(i,t))}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],h=this.implodeParams(e,s);let c=this.implodeHostname(this.urls.api[d]);if(c+="/"+n+"/",s=this.omit(s,this.extractParams(e)),s=this.keysort(s),"public"===d)c+="open/"+h,Object.keys(s).length&&(c+="?"+this.rawencode(s));else{this.checkRequiredCredentials(),r={"X-DEFX-SOURCE":"ccxt"},c+="auth/"+h;const t=this.milliseconds().toString();let n=t;"GET"===i||"api/order/{orderId}"===e?(n+=this.rawencode(s),Object.keys(s).length&&(c+="?"+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:c,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,a,o,n,d){if(!o)return;const h=this.safeBool(o,"success"),c=this.safeDict(o,"err",o),l=this.safeString2(c,"errorCode","code");if(!h){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{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,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","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","deposits/address","orders/leverage"],post:["orders","orders/bracket","orders/batch","products/{product_id}/orders/leverage","positions/change_margin","positions/close_all","wallets/sub_account_balance_transfer","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")]]}}},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),h=this.convertExpireDate(a),c=this.parse8601(h);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:c,expiryDatetime:h,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{i.d(t,{A:()=>h});var s=i(4012),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(8995);class h 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,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),h=this.safeString(s,3),c=this.convertExpireDate(o),l=this.parse8601(c);return{id:a+"-"+this.convertExpireDateToMarketIdDate(o)+"-"+d+"-"+h,symbol:n+"/"+i+":"+t+"-"+o+"-"+d+"-"+h,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:c,optionType:"C"===h?"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 w,b,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+":"+f,(g||m)&&(O=O+"-"+this.yymmdd(y,""),g)){w=this.safeNumber(t,"strike"),b=this.safeString(t,"option_type");const e="call"===b?"C":"P";O=O+"-"+this.numberToString(w)+"-"+e}k=u!==f,S=f===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:f,baseId:d,quoteId:h,settleId:c,type:T,spot:o,margin:!1,swap:p,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:w,optionType:b,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",{}),h=this.safeList(d,"settlements",[]);return this.parseLiquidations(h,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")}}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"),h=this.hmac(this.encode(d),this.encode(this.secret),n.s);r={Authorization:"deri-hmac-sha256 id="+this.apiKey+",ts="+t+",sig="+h+",nonce="+e}}return{url:this.urls.api.rest+o,method:i,body:a,headers:r}}handleErrors(e,t,i,s,r,o,n,d,h){if(!n)return;const c=this.safeValue(n,"error");if(void 0!==c){const e=this.safeString(c,"code"),t=this.id+" "+o;throw this.throwExactlyMatchedException(this.exceptions,e,t),new a.ExchangeError(t)}}}},1839:(e,t,i)=>{i.d(t,{A:()=>c});var s=i(970),r=i(5147),a=i(2079),o=i(8283),n=i(8432),d=i(987),h=i(1579);class c 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:h.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",{}),h=this.safeList(d,"trades",[]);return this.parseTrades(h,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",{}),h=this.safeList(d,"funding_rate_history",[]),c=[];for(let e=0;ethis.safeInteger(e,"num_pages"))return[]}const u=this.safeList(c,"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"),h=this.safeString(i,"desired_amount"),c=this.safeString(i,"filled_amount"),l=this.safeString(i,"order_fee"),u=this.safeStringLower(i,"order_type"),f=this.safeBool(i,"is_bid");let p=this.safeString(i,"direction");void 0===p&&(p=f?"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 w=this.safeInteger(e,"last_update_timestamp"),b=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:w,status:this.parseOrderStatus(b),symbol:o,type:u,timeInForce:this.parseTimeInForce(k),postOnly:void 0,reduceOnly:this.safeBool(i,"reduce_only"),side:p,price:n,triggerPrice:y,takeProfitPrice:v,stopLossPrice:g,average:d,amount:h,filled:c,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)),h=this.safeDict(d,"result",{}),c=this.safeList(h,"trades",[]);return this.parseTrades(c,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)),h=this.safeDict(d,"result",{}),c=this.safeInteger(s,"page");if(void 0!==c){const e=this.safeDict(h,"pagination");if(c>this.safeInteger(e,"num_pages"))return[]}const l=this.safeList(h,"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.A.stringGt(a,"0")?"long":"short";const o=this.safeString(t,"contractSize"),n=this.safeString(e,"mark_price"),d=this.safeInteger(e,"creation_timestamp"),h=this.safeString(e,"unrealized_pnl");a=r.A.stringAbs(a);const c=r.A.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(c),leverage:this.safeNumber(e,"leverage"),unrealizedPnl:this.parseNumber(h),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)),h=this.safeDict(d,"result",{}),c=this.safeInteger(s,"page");if(void 0!==c){const e=this.safeDict(h,"pagination");if(c>this.safeInteger(e,"num_pages"))return[]}const l=this.safeList(h,"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,h){if(!n)return;const c=this.safeDict(n,"error");if(void 0!==c){const e=this.safeString(c,"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)=>{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),h={},c="swap"===o;if(c?(void 0!==t&&(h.start_timestamp=t),void 0!==i&&(h.limit=i)):h.market=o,void 0!==a){h[c?"instrument_id":"symbol"]=a.id}let l;if(void 0!==n||"margin"===o)o="margin",l=await this.privateSpotGetMarginOrderCurrent(this.extend(h,d));else if("spot"===o)l=await this.privateSpotGetSpotOrderCurrent(this.extend(h,d));else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchOpenOrders() not support this market type");l=await this.privateSwapGetTradeOpenOrders(this.extend(h,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),h={};if("swap"===o?void 0!==t&&(h.start_timestamp=t):(h.market=o,void 0!==t&&(h.start_time=this.parseToInt(t/1e3))),void 0!==a){h["swap"===o?"instrument_id":"symbol"]=a.id}let c;if(void 0!==i&&(h.limit=i),void 0!==n||"margin"===o)o="margin",c=await this.privateSpotGetMarginOrderHistory(this.extend(h,d));else if("spot"===o)c=await this.privateSpotGetSpotOrderHistory(this.extend(h,d));else{if("swap"!==o)throw new r.NotSupported(this.id+" fetchOrders() not support this market type");c=await this.privateSwapGetTradeHistoryOrders(this.extend(h,d))}const l=this.safeList(c,"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 h;if("swap"===a?void 0!==s&&(d.instrument_id=s.id):d.market=a,void 0!==o||"margin"===a)a="margin",h=await this.privateSpotGetMarginOrder(this.extend(d,n));else if("spot"===a)h=await this.privateSpotGetSpotOrder(this.extend(d,n));else{if("swap"!==a)throw new r.NotSupported(this.id+" fetchOrder() not support this market type");h=await this.privateSwapGetTradeOrderInfo(this.extend(d,n))}const c=this.safeValue(h,"data"),l="swap"===a?c:this.safeValue(c,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,h]=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 c;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",c=await this.privateSpotGetMarginMytrades(this.extend(o,h));else if("spot"===n)c=await this.privateSpotGetSpotMytrades(this.extend(o,h));else{if("swap"!==n)throw new r.NotSupported(this.id+" fetchMyTrades() not support this market type");c=await this.privateSwapGetTradeHistoryTrades(this.extend(o,h))}const l="swap"===n?"data":"list",u=this.safeList(c,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 h="swap"===o?"currency":"currency_mark";let c,l,u;if(void 0!==e&&(c=this.currency(e),a[h]=c.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,c,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")),h=this.parse8601(this.safeString(e,"finished_date")),c=this.parseTransactionStatus(this.safeString(e,"state")),l=this.safeNumber(e,"amount"),u=this.safeNumber(e,"fee");let f;void 0!==u&&(f={currency:n,cost:u});const p=this.safeString(e,"chain");return{info:e,id:i,txid:a,timestamp:d,datetime:this.iso8601(d),network:p,address:s,addressTo:s,addressFrom:void 0,tag:r,tagTo:r,tagFrom:void 0,type:void 0,amount:l,currency:n,status:c,updated:h,internal:void 0,comment:void 0,fee:f}}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",{}),h=this.safeString(d,i,i),c=this.safeString(d,s,s),l={},u="swap"===i,f="swap"===s;let p;const m=this.currencyToPrecision(e,t);if(u||f){if("1"!==h&&"1"!==c)throw new r.ExchangeError(this.id+" transfer() supports transferring between spot and swap, spot and margin, spot and OTC only");l.type=f?1:2,l.currency=n,l.transfer_amount=m,p=await this.privateSwapPostAccountTransfer(this.extend(l,a))}else l.currency_mark=n,l.num=m,l.from=h,l.to=c,p=await this.privateSpotPostTransfer(this.extend(l,a));return this.parseTransfer(p,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"),h=this.parseBorrowInterests(d,o);return this.filterByCurrencySinceLimit(h,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 h="swap"===a?"data":"positions",c=this.safeValue(d,h,[]),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{i.d(t,{A:()=>c});var s=i(6351),r=i(2079),a=i(6414),o=i(8283),n=i(5147),d=i(4852),h=i(1579);class c extends s.A{describe(){return this.deepExtend(super.describe(),{id:"ellipx",name:"Ellipx",countries:["PL"],rateLimit:200,version:"v1",certified:!1,pro:!1,has:{CORS:void 0,spot:!0,margin:!1,swap:!1,future:!1,option:!1,addMargin:!1,cancelAllOrders:!1,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!1,cancelWithdraw:!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:!1,fetchBalance:!0,fetchCanceledAndClosedOrders:!1,fetchCanceledOrders:!1,fetchClosedOrder:!1,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDeposits:!1,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!1,fetchFundingRateHistory:!1,fetchFundingRates:!1,fetchIndexOHLCV:!1,fetchLedger:!1,fetchLeverage:!1,fetchLeverageTiers:!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:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!1,fetchTicker:!0,fetchTickers:!1,fetchTime:!1,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!1,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!1,reduceMargin:!1,sandbox:!1,setLeverage:!1,setMargin:!1,setPositionMode:!1,transfer:!1,withdraw:!0},timeframes:{"1m":"1m","5m":"5m","10m":"10m","1h":"1h","6h":"6h","12h":"12h","1d":"1d"},urls:{logo:"https://github.com/user-attachments/assets/e07c3f40-281c-4cdf-bacf-fa1c58218a2c",api:{public:"https://data.ellipx.com",private:"https://app.ellipx.com/_rest",_rest:"https://app.ellipx.com/_rest"},www:"https://www.ellipx.com",doc:"https://docs.google.com/document/d/1ZXzTQYffKE_EglTaKptxGQERRnunuLHEMmar7VC9syM",fees:"https://www.ellipx.com/pages/pricing",referral:""},api:{_rest:{get:{Market:1,"Market/{currencyPair}":1,"Crypto/Token/Info":1}},public:{get:{"Market/{currencyPair}:getDepth":1,"Market/{currencyPair}:ticker":1,"Market/{currencyPair}:getTrades":1,"Market/{currencyPair}:getGraph":1,"CMC:summary":1,"CMC/{currencyPair}:ticker":1}},private:{get:{"User/Wallet":1,"Market/{currencyPair}/Order":1,"Market/Order/{orderUuid}":1,"Market/{currencyPair}/Trade":1,"Market/TradeFee:query":1,"Unit/{currency}":1,"Crypto/Token/{currency}":1,"Crypto/Token/{currency}:chains":1},post:{"Market/{currencyPair}/Order":1,"Crypto/Address:fetch":1,"Crypto/Disbursement:withdraw":1},delete:{"Market/Order/{orderUuid}":1}}},fees:{trading:{tierBased:!0,feeSide:"get",percentage:!0,maker:this.parseNumber("0.0025"),taker:this.parseNumber("0.0030"),tiers:{maker:[[this.parseNumber("0"),this.parseNumber("0.0025")],[this.parseNumber("10000"),this.parseNumber("0.0020")],[this.parseNumber("50000"),this.parseNumber("0.0015")],[this.parseNumber("100000"),this.parseNumber("0.0010")],[this.parseNumber("1000000"),this.parseNumber("0.0008")],[this.parseNumber("5000000"),this.parseNumber("0.0003")],[this.parseNumber("15000000"),this.parseNumber("0.0000")],[this.parseNumber("75000000"),this.parseNumber("0.0000")],[this.parseNumber("100000000"),this.parseNumber("0.0000")]],taker:[[this.parseNumber("0"),this.parseNumber("0.0030")],[this.parseNumber("10000"),this.parseNumber("0.0025")],[this.parseNumber("50000"),this.parseNumber("0.0020")],[this.parseNumber("100000"),this.parseNumber("0.0015")],[this.parseNumber("1000000"),this.parseNumber("0.0012")],[this.parseNumber("5000000"),this.parseNumber("0.0010")],[this.parseNumber("15000000"),this.parseNumber("0.0008")],[this.parseNumber("75000000"),this.parseNumber("0.0005")],[this.parseNumber("100000000"),this.parseNumber("0.0003")]]}},stablecoin:{tierBased:!1,percentage:!0,maker:this.parseNumber("0.0000"),taker:this.parseNumber("0.000015")}},options:{defaultType:"spot",recvWindow:5e3,broker:"CCXT",networks:{Bitcoin:"Bitcoin",Ethereum:"ERC20"},defaultNetwork:"defaultNetwork",defaultNetworkCodeReplacements:{BTC:"Bitcoin",ETH:"Ethereum"}},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:!0,marketBuyRequiresPrice:!1,iceberg:!1},createOrders:void 0,fetchMyTrades:void 0,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:void 0,daysBack:void 0,untilDays:void 0,trigger:!1,trailing:!1,symbolRequired:!0},fetchClosedOrders:void 0,fetchOHLCV:{limit:100}},swap:{linear:void 0,inverse:void 0},future:{linear:void 0,inverse:void 0}},commonCurrencies:{},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},broad:{}},precisionMode:h.kb})}sign(e,t="public",i="GET",s={},r=void 0,n=void 0){e=this.implodeParams(e,s);let h=this.urls.api[t]+"/"+e;if("private"===t){this.checkRequiredCredentials();const t=this.uuid(),r=this.seconds().toString();n="GET"===i?"":this.json(s),s=this.extend({_key:this.apiKey,_time:r,_nonce:t},s);const h=this.urlencode(s),c=this.hash(this.encode(n),d.s),l=this.base16ToBinary(c),u=this.numberToBE(0,1),f=[this.encode(i),u,this.encode(e),u,this.encode(h),u,l],p=this.binaryConcatArray(f),m=this.secret,g=this.calculateMod(m.length,4),v=g?4-g:0;let y=this.secret.replaceAll("-","+");y=y.replaceAll("_","/"),y=y.padEnd(this.secret.length+v,"=");const w=this.base64ToBinary(y),b=this.arraySlice(w,0,32),k=(0,o.q4)(p,b,a.ev);s._sign=k}return Object.keys(s).length&&(h+="?"+this.urlencode(s)),"GET"===i?n=void 0:r={"Content-Type":"application/json"},{url:h,method:i,body:n,headers:r}}calculateMod(e,t){return e%t}async fetchMarkets(e={}){const t=await this._restGetMarket(e),i=this.safeValue(t,"data",[]);return this.parseMarkets(i)}parseMarket(e){const t=this.safeString(e,"Key"),i=this.safeString(e.Primary,"Key"),s=this.safeString(e.Secondary,"Key"),r=this.safeString(e.Primary,"Crypto_Token__"),a=this.safeString(e.Secondary,"Crypto_Token__"),o="active"===this.safeString(e,"Status"),n=this.safeTimestamp(e.Created,"unix"),d=this.parseNumber(this.parsePrecision(this.safeString(e.Primary,"Decimals"))),h=this.parseNumber(this.parsePrecision(this.safeString(e.Secondary,"Decimals"))),c=this.fees;return this.safeMarketStructure({id:t,symbol:i+"/"+s,base:i,quote:s,settle:void 0,baseId:r,quoteId:a,settleId:void 0,type:"spot",spot:!0,margin:!1,swap:!1,future:!1,option:!1,active:o,contract:!1,linear:void 0,inverse:void 0,taker:c.trading.taker,maker:c.trading.maker,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:d,price:h},limits:{amount:{min:void 0,max:void 0},price:{min:void 0,max:void 0},cost:{min:void 0,max:void 0}},info:e,created:n})}async fetchTicker(e,t={}){await this.loadMarkets();const i=this.market(e),s={currencyPair:i.id},r=await this.publicGetMarketCurrencyPairTicker(this.extend(s,t)),a=this.safeValue(r.data,"ticker",{});return this.parseTicker(a,i)}parseTicker(e,t=void 0){const i=this.safeIntegerProduct(e,"time",1e3),s=this.parseAmount(this.safeValue(e,"open")),r=this.parseAmount(this.safeValue(e,"high")),a=this.parseAmount(this.safeValue(e,"low")),o=this.parseAmount(this.safeValue(e,"close")),n=this.parseAmount(this.safeValue(e,"avg")),d=this.parseAmount(this.safeValue(e,"vwap")),h=this.parseAmount(this.safeValue(e,"vol")),c=this.parseAmount(this.safeValue(e,"secvol"));return this.safeTicker({symbol:this.safeSymbol(void 0,t),timestamp:i,datetime:this.iso8601(i),high:r,low:a,bid:void 0,bidVolume:void 0,ask:void 0,askVolume:void 0,vwap:d,open:s,close:o,last:o,previousClose:void 0,change:void 0,percentage:void 0,average:n,baseVolume:h,quoteVolume:c,info:e},t)}async fetchOrderBook(e,t=void 0,i={}){await this.loadMarkets();const s={currencyPair:this.market(e).id},r=await this.publicGetMarketCurrencyPairGetDepth(this.extend(s,i)),a=this.safeValue(r,"data",{}),o=this.milliseconds(),n=a.bids.length,d=a.asks.length;for(let e=0;e0){const e=s[0],t=this.safeDict(e,"Balance_Date",{});i.timestamp=this.safeInteger(t,"unixms"),i.datetime=this.iso8601(i.timestamp)}for(let e=0;e{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(c,0)),percentage:h}}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 h=this.safeString(e,"quantity");if(void 0===h){const t="buy"===o?"in_amount":"out_amount";h=this.safeString(e,t)}const c=this.safeString(e,"price"),l=this.safeString(e,"amount"),u=this.safeValue(e,"trades",[]),f=this.safeInteger(e,"client_id");let p,m=this.safeString(e,"stop_price");return"0"===m&&(m=void 0),"buy"!==a&&"sell"!==a&&(p=a),this.safeOrder({id:i,clientOrderId:f,datetime:this.iso8601(r),timestamp:r,lastTradeTimestamp:this.safeIntegerProduct(e,"updated",1e-6),status:this.parseStatus(this.safeString(e,"order_status")),symbol:d,type:p,timeInForce:void 0,postOnly:void 0,side:o,price:c,triggerPrice:m,cost:l,amount:h,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,h;if(n.offset=void 0!==t?i:0,n.limit=i,void 0!==e&&(d=this.market(e)),o)return h=await this.privatePostUserCancelledOrders(this.extend(n,s)),s=this.extend(s,{status:"canceled"}),this.parseOrders(h,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 h=await this.privatePostWithdrawCrypt(this.extend(o,r));return this.parseTransaction(h,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 h,c;const l=this.safeString(e,"account");if("deposit"===o)c=l;else if("withdrawal"===o&&(h=l,void 0!==h)){const e=h.split(":");2===e.length&&(h=this.safeString(e,1),h=h.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:h,addressFrom:void 0,addressTo:h,tag:void 0,tagFrom:void 0,tagTo:void 0,updated:this.safeTimestamp(e,"updated"),comment:c,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,h){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)=>{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")}}})}}},9403:(e,t,i)=>{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.io",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.io/docs/developers/apiv4/en/",www:"https://gate.io/",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"}},test:{public:{futures:"https://fx-api-testnet.gateio.ws/api/v4",delivery:"https://fx-api-testnet.gateio.ws/api/v4",options:"https://fx-api-testnet.gateio.ws/api/v4"},private:{futures:"https://fx-api-testnet.gateio.ws/api/v4",delivery:"https://fx-api-testnet.gateio.ws/api/v4",options:"https://fx-api-testnet.gateio.ws/api/v4"}},referral:{url:"https://www.gate.io/signup/2436035",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}},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}},margin:{get:{currency_pairs:1,"currency_pairs/{currency_pair}":1,funding_book:1,"cross/currencies":1,"cross/currencies/{currency}":1,"uni/currency_pairs":1,"uni/currency_pairs/{currency_pair}":1}},flash_swap:{get:{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}},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}}},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},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,account_mode:20/15,borrowable:20/15,transferable:20/15,loans:20/15,loan_records:20/15,interest_records:20/15,estimate_rate:20/15,currency_discount_tiers:20/15,risk_units:20/15,unified_mode:20/15,loan_margin_tiers:20/15,"leverage/user_currency_config":20/15,"leverage/user_currency_setting":20/15},post:{account_mode:20/15,loans:200/15,portfolio_calculator:20/15,"leverage/user_currency_setting":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,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,"uni/estimate_rate":20/15,"uni/loans":20/15,"uni/loan_records":20/15,"uni/interest_records":20/15,"uni/borrowable":20/15},post:{auto_repay:20/15,loans:20/15,merged_loans:20/15,"loans/{loan_id}/repayment":20/15,"cross/loans":20/15,"cross/repayments":20/15,"uni/loans":20/15},patch:{"loans/{loan_id}":20/15,"loan_records/{loan_record_id}":20/15},delete:{"loans/{loan_id}":20/15}},flash_swap:{get:{currencies:1,currency_pairs:1,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}/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_tiers":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}/risk_limit":1,"{settle}/dual_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}/price_orders":.4},put:{"{settle}/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/currencies":20/15,"uni/currencies/{currency}":20/15,"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},post:{"uni/lends":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,"collateral/currencies":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,"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,rate_limit:20/15,stp_groups:20/15,"stp_groups/{stp_id}/users":20/15,"stp_groups/debit_fee":20/15},post:{stp_groups:20/15,"stp_groups/{stp_id}/users":20/15},delete:{"stp_groups/{stp_id}/users":20/15}},rebate:{get:{"agency/transaction_history":20/15,"agency/commission_history":20/15}}}},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",POLYGON:"POL",MATIC:"POL",OP:"OPETH",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"},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.BadRequest,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,NO_CHANGE: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},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),h=this.safeString(s,3),c=this.convertExpireDate(n),l=this.parse8601(c);return{id:o+"_"+t+"-20"+n+"-"+d+"-"+h,symbol:o+"/"+t+":"+i+"-"+n+"-"+d+"-"+h,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:c,optionType:"C"===h?"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=this.safeBool(this.options,"sandboxMode",!1);let i=[this.fetchContractMarkets(e),this.fetchOptionMarkets(e)];if(!t){const t=[this.fetchSpotMarkets(e)];i=this.arrayConcat(i,t)}const s=await Promise.all(i),r=this.safeValue(s,0,[]),a=this.safeValue(s,1,[]),o=this.safeValue(s,2,[]),n=this.arrayConcat(r,a);return this.arrayConcat(n,o)}async fetchSpotMarkets(e={}){const t=this.publicMarginGetCurrencyPairs(e),i=this.publicSpotGetCurrencyPairs(e),[s,a]=await Promise.all([t,i]),o=this.indexBy(s,"id"),n=[];for(let e=0;e10)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"!==c[0]&&(c="t-"+c),O.text=c}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(h){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===c){let t,s;p?(t="buy"===i?1:2,s=this.priceToPrecision(e,u)):m&&(t="buy"===i?2:1,s=this.priceToPrecision(e,f));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!==b&&(O.initial.tif=b)}else{const r=this.safeValue(this.options,"createOrder",{});let o;if([o,n]=this.getMarginMode(!0,n),void 0===b&&(b="gtc"),O={put:{type:t,side:i,price:this.priceToPrecision(e,a),amount:this.amountToPrecision(e,s),account:o,time_in_force:b},market:d.id},void 0===c){const t=this.safeInteger(r,"expiration"),s=this.safeInteger(n,"expiration",t);let a,o;p?(a="buy"===i?">=":"<=",o=this.priceToPrecision(e,u)):m&&(a="buy"===i?"<=":">=",o=this.priceToPrecision(e,f)),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 h=this.market(t);let c;[c,d]=this.handleMarketTypeAndParams("editOrder",h,d);let l=this.convertTypeToAccount(c),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 "+c+" markets");const f={order_id:e.toString(),currency_pair:h.id,account:l};return void 0!==a&&(h.spot?f.amount=this.amountToPrecision(t,a):f.size="sell"===s?this.parseToNumeric(r.Y.stringNeg(this.amountToPrecision(t,a))):this.parseToNumeric(this.amountToPrecision(t,a))),void 0!==n&&(f.price=this.priceToPrecision(t,n)),h.spot||(f.settle=h.settleId),this.extend(f,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 h;return h=n.spot?await this.privateSpotPatchOrdersOrderId(d):await this.privateFuturesPutSettleOrdersOrderId(d),this.parseOrder(h,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"),h=this.safeString(i,"side"),c=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),h=this.safeString(e,"side",h),c=this.safeString(e,"price",c);let u=this.safeString(e,"left"),f=this.safeString(e,"filled_total");const p=this.safeNumber(s,"price");let m=this.safeNumber2(e,"avg_deal_price","fill_price");if(p&&(u=d,f="0"),a){o=r.Y.stringEquals(c,"0")&&"IOC"===n?"market":"limit",h=r.Y.stringGt(d,"0")?"buy":"sell"}const g=this.safeStringN(e,["finish_as","status","open"]);let v=this.safeInteger(e,"create_time_ms");void 0===v&&(v=this.safeTimestamp2(e,"create_time","ctime"));let y=this.safeInteger(e,"update_time_ms");void 0===y&&(y=this.safeTimestamp2(e,"update_time","finish_time"));let w="contract";("currency_pair"in e||"market"in e)&&(w="spot");const b=this.safeString2(e,"currency_pair","market",a),k=this.safeSymbol(b,t,"_",w),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 x=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"===h&&(x=r.Y.stringDiv(u,t),c=void 0,f=d,d=r.Y.stringDiv(d,t))}return this.safeOrder({id:this.safeString(e,"id"),clientOrderId:this.safeString(e,"text"),timestamp:v,datetime:this.iso8601(v),lastTradeTimestamp:y,status:M,symbol:k,type:o,timeInForce:n,postOnly:l,reduceOnly:this.safeValue(e,"is_reduce_only"),side:h,price:c,triggerPrice:p,average:m,amount:r.Y.stringAbs(d),cost:r.Y.stringAbs(f),filled:void 0,remaining:x,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),h="swap"===n||"future"===n||"option"===n,[c,l]=h?this.prepareRequest(s,n,d):this.spotOrderPrepareRequest(s,r,d);return c.order_id=o.toString(),[c,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,h]=this.fetchOrderRequest(e,t,i);let c;if("spot"===a||"margin"===a)c=n?await this.privateSpotGetPriceOrdersOrderId(this.extend(d,h)):await this.privateSpotGetOrdersOrderId(this.extend(d,h));else if("swap"===a)c=n?await this.privateFuturesGetSettlePriceOrdersOrderId(this.extend(d,h)):await this.privateFuturesGetSettleOrdersOrderId(this.extend(d,h));else if("future"===a)c=n?await this.privateDeliveryGetSettlePriceOrdersOrderId(this.extend(d,h)):await this.privateDeliveryGetSettleOrdersOrderId(this.extend(d,h));else{if("option"!==a)throw new o.NotSupported(this.id+" fetchOrder() not support this market type");c=await this.privateOptionsGetOrdersOrderId(this.extend(d,h))}return this.parseOrder(c,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 h={};[h,s]=this.prepareRequest(a,n,s),void 0!==t&&(h.from=this.parseToInt(t/1e3)),void 0!==r&&(s=this.omit(s,"until"),h.to=this.parseToInt(r/1e3)),void 0!==i&&(h.limit=i);const c=await this.privateFuturesGetSettleOrdersTimerange(this.extend(h,s));return this.parseOrders(c,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 h={};if([h,r]=d?this.multiOrderSpotPrepareRequest(a,o,r):this.prepareRequest(a,n,r),d&&o&&(h=this.omit(h,"account")),"closed"===e&&(e="finished"),h.status=e,void 0!==s&&(h.limit=s),d){void 0!==i&&(h.from=this.parseToInt(i/1e3));const e=this.safeInteger(r,"until");void 0!==e&&(r=this.omit(r,"until"),h.to=this.parseToInt(e/1e3))}const[c,l]=this.handleParamString2(r,"lastId","last_id");return void 0!==c&&(h.last_id=c),[h,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),h=this.safeString(d,0),[c,l]=this.prepareOrdersByStatusRequest(e,t,i,s,r),u="spot"===h||"margin"===h,f="open"===e,p=u&&f&&!n;let m;if(u)m=n?await this.privateSpotGetPriceOrders(this.extend(c,l)):f?await this.privateSpotGetOpenOrders(this.extend(c,l)):await this.privateSpotGetOrders(this.extend(c,l));else if("swap"===h)m=n?await this.privateFuturesGetSettlePriceOrders(this.extend(c,l)):await this.privateFuturesGetSettleOrders(this.extend(c,l));else if("future"===h)m=n?await this.privateDeliveryGetSettlePriceOrders(this.extend(c,l)):await this.privateDeliveryGetSettleOrders(this.extend(c,l));else{if("option"!==h)throw new o.NotSupported(this.id+" fetchOrders() not support this market type");m=await this.privateOptionsGetOrders(this.extend(c,l))}let g=m;if(p){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 h,c=this.safeString(a,"marginMode",n),l=this.numberToString(e);if(void 0!==d&&(c="cross",l=d),"cross"===c||"cross_margin"===c?(r.cross_leverage_limit=l,r.leverage="0"):r.leverage=l,s.swap)h=await this.privateFuturesPostSettlePositionsContractLeverage(this.extend(r,a));else{if(!s.future)throw new o.NotSupported(this.id+" setLeverage() not support this market type");h=await this.privateDeliveryPostSettlePositionsContractLeverage(this.extend(r,a))}return h}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 h;void 0!==d&&(h="0"===d?"cross":"isolated");let c,l=this.safeString(e,"pnl_fee");if(void 0===l){const e="0.00075";l=r.Y.stringMul(e,n),c=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(c),initialMarginPercentage:this.parseNumber(r.Y.stringDiv(c,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:h,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.privateFuturesGetSettleRiskLimitTiers(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 h=s,c=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(h),maxLeverage:this.parseNumber(r.Y.stringDiv("1",c)),info:e}),h=r.Y.stringAdd(h,s),c=r.Y.stringAdd(c,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||s||"PATCH"===i)Object.keys(c).length&&(t=this.urlencode(c),t.indexOf("currencies=")>=0&&t.indexOf("%2C")>=0&&(t=t.replaceAll("%2C",",")),f+="?"+t),"PATCH"===i&&(a=this.json(c));else{const e=this.safeValue(c,"query",{});Object.keys(e).length&&(t=this.urlencode(e),f+="?"+t),c=this.omit(c,"query"),a=this.json(c)}const o=void 0===a?"":a,d=this.hash(this.encode(o),n.Zf),l=this.nonce(),p=this.parseToInt(l/1e3).toString(),m="/api/"+this.version+u,g=[i.toUpperCase(),m,t,d,p].join("\n"),v=this.hmac(this.encode(g),this.encode(this.secret),n.Zf);r={KEY:this.apiKey,Timestamp:p,SIGN:v,"Content-Type":"application/json"}}return{url:f,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 h=await this.publicFuturesGetSettleContractStats(this.extend(d,r));return this.parseOpenInterestsHistory(h,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 h=await this.publicOptionsGetSettlements(this.extend(d,s)),c=this.parseSettlements(h,r),l=this.sortBy(c,"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("-"),h={underlying:this.safeString(d,0),contract:n};void 0!==t&&(h.from=t),void 0!==i&&(h.limit=i);const c=await this.privateOptionsGetMySettlements(this.extend(h,s)),l=this.safeValue(c,"result",{}),u=this.safeValue(l,"list",[]),f=this.parseSettlements(u,r),p=this.sortBy(f,"timestamp");return this.filterBySymbolSinceLimit(p,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 h=this.safeString(e,"balance"),c=this.safeString(e,"change"),l=this.parseNumber(r.Y.stringSub(h,c));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{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)=>{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"]},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"}}},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(" "),h=this.safeNumber(d,0),c=s[2].replace("","").split(" "),l=o.length-0,u=l-3,f=s[3].replace("","").split(" "),p=this.safeStringLower(f,1,o.slice(u,l)),m=this.safeStringLower(c,1,o.replace(p,"")),g=this.safeCurrencyCode(m),v=this.safeCurrencyCode(p);n.push({id:o,symbol:g+"/"+v,base:g,quote:v,settle:void 0,baseId:m,quoteId:p,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(c,0),price:this.safeNumber(f,0)},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: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,c=d.replace("PERP",""),l=this.safeDict(this.options,"conflictingMarkets",{}),u=c.toLowerCase();if(u in l){const e=l[u];i=e.base,s=e.quote,h&&(r=e.quote)}else{const e=this.handleOption("fetchMarketsFromAPI","quoteCurrencies",[]);for(let t=0;t{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,cancelAllOrders:!0,cancelAllOrdersAfter:!1,cancelOrder:!0,cancelOrders:!0,cancelWithdraw:!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,fetchBalance:!0,fetchCanceledAndClosedOrders:!0,fetchCanceledOrders:!0,fetchClosedOrder:!0,fetchClosedOrders:!1,fetchConvertCurrencies:!1,fetchConvertQuote:!1,fetchConvertTrade:!1,fetchConvertTradeHistory:!1,fetchCurrencies:!0,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,fetchDeposits:!0,fetchDepositsWithdrawals:!1,fetchFundingHistory:!1,fetchFundingRate:!0,fetchFundingRateHistory:!0,fetchFundingRates:!0,fetchIndexOHLCV:!1,fetchLedger:!0,fetchLeverage:!0,fetchLeverageTiers:!0,fetchMarginAdjustmentHistory:!1,fetchMarginMode:!1,fetchMarketLeverageTiers:"emulated",fetchMarkets:!0,fetchMarkOHLCV:!1,fetchMyTrades:!0,fetchOHLCV:!0,fetchOpenInterestHistory:!1,fetchOpenOrder:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchOrderTrades:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!0,fetchPositionsForSymbol:!0,fetchPositionsHistory:!1,fetchPremiumIndexOHLCV:!1,fetchStatus:!0,fetchTicker:!0,fetchTickers:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!0,fetchTradingFees:!0,fetchTransactions:!1,fetchTransfers:!1,fetchWithdrawals:!0,reduceMargin:!1,sandbox:!1,setLeverage:!0,setMargin:!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",h=!0,c=!1,l="";const u=t.split("-");"PERPETUAL"===this.safeString(u,1)&&(d="swap",h=!1,c=!0,n=this.safeString(e,"underlying"),l+=":"+r);const f=this.safeCurrencyCode(n),p=f+"/"+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 w=this.safeList(e,"filters",[]),b=this.indexBy(w,"filterType"),k=this.safeDict(b,"PRICE_FILTER",{}),S=this.safeDict(b,"LOT_SIZE",{}),O=this.safeDict(b,"MIN_NOTIONAL",{}),T=this.omitZero(this.safeString(O,"min_notional")),P=this.safeString(e,"contractMultiplier");let I,M,x=this.safeString(S,"stepSize"),_=this.safeString(S,"minQty"),A=this.safeString(S,"maxQty");if(c){x=a.Y.stringDiv(x,P),_=a.Y.stringDiv(_,P),A=a.Y.stringDiv(A,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=h?this.safeDict(C,"spot"):this.safeDict(C,"swap");return this.safeMarketStructure({id:t,symbol:p,base:f,quote:s,baseId:n,quoteId:i,active:m,type:d,subType:v,spot:h,margin:this.safeBool(e,"allowMargin"),swap:c,future:!1,option:!1,contract:c,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(x),price:this.safeNumber(k,"tickSize")},limits:{amount:{min:this.parseNumber(_),max:this.parseNumber(A)},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&&(c="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:c,referenceId:void 0,referenceAccount:void 0,type:a,currency:n,symbol:void 0,amount:h,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,h=this.safeString(o,"cost");if(!d&&void 0!==h)throw new r.NotSupported(this.id+" createOrder() supports cost parameter for spot market buy orders only");const c=this.createSpotOrderRequest(e,t,i,s,a,o);let l={};return this.safeBool(o,"test")?(o=this.omit(o,"test"),l=await this.privatePostApiV1SpotOrderTest(c)):l=d&&void 0===h?await this.privatePostApiV11SpotOrder(c):await this.privatePostApiV1SpotOrder(c),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 h="MARKET"===t;let c,l=!1;return[l,a]=this.handlePostOnly(h,"LIMIT_MAKER"===t,a),l&&"LIMIT"===t&&(n.type="LIMIT_MAKER"),[c,a]=this.handleParamString(a,"clientOrderId"),void 0!==c&&(a.newClientOrderId=c),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 h,c="_OPEN";d&&(c="_CLOSE"),o.side=i.toUpperCase()+c,[h,a]=this.handleParamString(a,"timeInForce");let l=!1;[l,a]=this.handlePostOnly(n,"LIMIT_MAKER"===h,a),l&&(h="LIMIT_MAKER"),void 0!==h&&(o.timeInForce=h);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{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{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)=>{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},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":1,"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":1,"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":1,"linear-swap-api/v1/swap_cross_switch_lever_rate":1,"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}}}},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-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,"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?c=this.safeString(e,"field-cash-amount"):(l=this.safeString2(e,"volume","amount"),c=this.safeStringN(e,["filled-cash-amount","field-cash-amount","trade_turnover"]));const u=this.safeStringN(e,["filled-amount","field-amount","trade_volume"]),f=this.safeString2(e,"price","order_price");let p,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,p={cost:m,currency:i}}const g=this.safeString(e,"trade_avg_price"),v=this.safeValue(e,"trades"),y=this.safeInteger(e,"reduce_only");let w;return void 0!==y&&(w=0!==y),this.safeOrder({info:e,id:r,clientOrderId:h,timestamp:d,datetime:this.iso8601(d),lastTradeTimestamp:void 0,symbol:t.symbol,type:o,timeInForce:void 0,postOnly:void 0,side:a,price:f,triggerPrice:this.safeString2(e,"stop-price","trigger_price"),average:g,cost:c,amount:l,filled:u,remaining:void 0,status:s,reduceOnly:w,fee:p,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 h;[h,n]=this.handleMarginModeAndParams("createOrder",n);const c={"account-id":await this.fetchAccountIdByType(d.type,h,e),symbol:d.id};let l=t.replace("buy-","");l=l.replace("sell-","");const u=this.safeValue(this.options,d.type,{}),f=this.safeStringN(n,["triggerPrice","stopPrice","stop-price"]);if(void 0===f){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(c["stop-price"]=this.priceToPrecision(e,f),c.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 p;[p,n]=this.handlePostOnly("market"===l,"limit-maker"===l,n),p&&(l="limit-maker");const m=this.safeString(n,"timeInForce","GTC");"FOK"===m?l+="-fok":"IOC"===m&&(l="ioc"),c.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");c["client-order-id"]=t+this.uuid()}else c["client-order-id"]=g;if("cross"===h?c.source="super-margin-api":"isolated"===h?c.source="margin-api":"c2c"===h&&(c.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);c.amount=t}else c.amount=this.amountToPrecision(e,s);return l in this.safeValue(u,"limitOrderTypes",{})&&(c.price=this.priceToPrecision(e,o)),n=this.omit(n,["triggerPrice","stopPrice","stop-price","clientOrderId","client-order-id","operator","timeInForce"]),this.extend(c,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 h=this.safeString(o,"timeInForce","GTC");"FOK"===h?t="fok":"IOC"===h&&(t="ioc");const c=this.safeNumberN(o,["triggerPrice","stopPrice","trigger_price"]),l=this.safeNumber2(o,"stopLossPrice","sl_trigger_price"),u=this.safeNumber2(o,"takeProfitPrice","tp_trigger_price"),f=this.safeString2(o,"trailingPercent","callback_rate"),p=this.safeNumber(o,"trailingTriggerPrice",r),m=void 0!==f,g=void 0!==l,v=void 0!==u;if(void 0!==c){const t=this.safeString2(o,"triggerType","trigger_type","le");n.trigger_type=t,n.trigger_price=this.priceToPrecision(e,c),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(f,"100");n.callback_rate=this.parseToNumeric(e),n.active_price=p,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||(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 w=this.safeValue(this.options,"broker",{}),b=this.safeString(w,"id");return n.channel_code=b,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"]),h=this.safeNumber2(o,"stopLossPrice","sl_trigger_price"),c=this.safeNumber2(o,"takeProfitPrice","tp_trigger_price"),l=void 0!==this.safeNumber(o,"trailingPercent"),u=void 0!==d,f=void 0!==h,p=void 0!==c;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):f||p?await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(d):l?await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(d):await this.contractPrivatePostLinearSwapApiV1SwapOrder(d):"cross"===e&&(m=u?await this.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(d):f||p?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):f||p?await this.contractPrivatePostSwapApiV1SwapTpslOrder(d):l?await this.contractPrivatePostSwapApiV1SwapTrackOrder(d):await this.contractPrivatePostSwapApiV1SwapOrder(d):n.future&&(m=u?await this.contractPrivatePostApiV1ContractTriggerOrder(d):f||p?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):(f?(g=this.safeValue(m,"data",{}),v=this.safeValue(g,"sl_order",{})):p?(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),h=[];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 h="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:h,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,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 h;void 0!==s&&(d["addr-tag"]=s),[h,o]=this.handleNetworkCodeAndParams(o),void 0!==h&&(d.chain=this.networkCodeToId(h,e)),t=parseFloat(this.currencyToPrecision(e,t,h));const c=this.safeValue(this.options,"withdraw",{});if(this.safeBool(c,"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,h,{});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,h);o=this.omit(o,"fee");const c=this.numberToString(t),l=a.Y.stringSub(c,s),u=parseFloat(l);d.fee=parseFloat(s),t=parseFloat(this.currencyToPrecision(e,u,h))}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 h=this.convertTypeToAccount(i),c=this.convertTypeToAccount(s);const l="cross"===c,u="cross"===h,f=this.inArray(c,this.ids),p=this.inArray(h,this.ids),m="pro"===h,g="pro"===c;if(m&&g)throw new r.BadRequest(this.id+" transfer () cannot make a transfer between "+i+" and "+s);let v;if("futures"===h||"futures"===c){let e=h+"-to-"+c;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&&f)n.symbol=c,v=await this.privatePostDwTransferInMargin(this.extend(n,a));else if(p&&g)n.symbol=h,v=await this.privatePostDwTransferOutMargin(this.extend(n,a));else{if("linear"===d){"swap"===h||"linear-swap"===i?h="linear-swap":c="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":h,n.to=g?"spot":c,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,"page_index","current_page",1,50);await this.loadMarkets();const o=this.market(e),n={contract_code:o.id};let d;if(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 h=this.safeValue(d,"data"),c=this.safeValue(h,"current_page"),l=this.safeValue(h,"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",[]),h=this.safeInteger(n,"ts"),c=[];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",[]),h=this.safeValue(d,0),c=this.parseMarginLoan(h,r);return this.extend(c,{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),h=this.parseMarginLoan(d,s);return this.extend(h,{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 h=this.safeValue(d,"data"),c=this.safeValue(h,"settlement_record"),l=this.parseSettlements(c,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{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)=>{i.d(t,{A:()=>c});var s=i(9023),r=i(2079),a=i(5147),o=i(1579),n=i(8432),d=i(987),h=i(8283);class c 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,fetchTicker:"emulated",fetchTickers:!0,fetchTime:!1,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}}}},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,zeroAddress:"0x0000000000000000000000000000000000000000"},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}async fetchCurrencies(e={}){const t=await this.publicPostInfo(this.extend({type:"meta"},e)),i=this.safeList(t,"universe",[]),s={};for(let e=0;e=34?e:this.parseToNumeric(e),user:s},o=await this.publicPostInfo(this.extend(a,i)),n=this.safeDict(o,"order");return this.parseOrder(n,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.safeString(i,"coin");let r;void 0!==s&&(r=this.coinToMarketId(s));const o=(t=void 0===this.safeString(i,"id")?this.safeMarket(r,void 0):this.safeMarket(r,t)).symbol,n=this.safeInteger(i,"timestamp"),d=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 c=this.safeString2(i,"origSz","totalSz"),l=this.safeString(i,"sz"),u=this.safeStringUpper(i,"tif");let f;return void 0!==u&&(f="ALO"===u),this.safeOrder({info:e,id:this.safeString(i,"oid"),clientOrderId:this.safeString(i,"cloid"),timestamp:n,datetime:this.iso8601(n),lastTradeTimestamp:void 0,lastUpdateTimestamp:this.safeInteger(e,"statusTimestamp"),symbol:o,type:this.parseOrderType(this.safeStringLower(i,"orderType")),timeInForce:u,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:c,cost:void 0,average:this.safeString(i,"avgPx"),filled:a.Y.stringSub(c,l),remaining:l,status:this.parseOrderStatus(d),fee:void 0,trades:void 0},t)}parseOrderStatus(e){return 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;[r,s]=this.handlePublicAddress("fetchMyTrades",s),await this.loadMarkets();const a=this.safeMarket(e),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 h=this.safeString(e,"side");void 0!==h&&(h="A"===h?"sell":"buy");const c=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:h,takerOrMaker:l,price:s,amount:r,cost:void 0,fee:{cost:c,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,{})}async fetchPositions(e=void 0,t={}){let i;await this.loadMarkets(),[i,t]=this.handlePublicAddress("fetchPositions",t),e=this.marketSymbols(e);const s={type:"clearinghouseState",user:i},r=await this.publicPostInfo(this.extend(s,t)),a=this.safeList(r,"assetPositions",[]),o=[];for(let e=0;e swap transfer");let e,i=this.numberToString(t);[e,a]=this.handleOptionAndParams(a,"transfer","vaultAddress"),e=this.formatVaultAddress(e),void 0!==e&&(i=i+" subaccount:"+e);const d="perp"===s||"swap"===s,h={hyperliquidChain:o?"Testnet":"Mainnet",amount:i,toPerp:d,nonce:n},c=this.buildUsdClassSendSig(h),l={action:{hyperliquidChain:h.hyperliquidChain,signatureChainId:"0x66eee",type:"usdClassTransfer",amount:i,toPerp:d,nonce:n},nonce:n,signature:c};void 0!==e&&(l.vaultAddress=e);return await this.privatePostExchange(l)}if(this.checkAddress(s),void 0!==e&&"USDC"!==(e=e.toUpperCase()))throw new r.NotSupported(this.id+" transfer() only support USDC");const d={hyperliquidChain:o?"Testnet":"Mainnet",destination:s,amount:this.numberToString(t),time:n},h=this.buildUsdSendSig(d),c={action:{hyperliquidChain:d.hyperliquidChain,signatureChainId:"0x66eee",destination:s,amount:t.toString(),time:n,type:"usdSend"},nonce:n,signature:h},l=await this.privatePostExchange(c);return this.parseTransfer(l)}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,h={};if(void 0!==o)h={type:"vaultTransfer",vaultAddress:"0x"+o,isDeposit:!1,usd:t},d=this.signL1Action(h,n);else{const e={hyperliquidChain:this.safeBool(this.options,"sandboxMode",!1)?"Testnet":"Mainnet",destination:i,amount:t.toString(),time:n};d=this.buildWithdrawSig(e),h={hyperliquidChain:e.hyperliquidChain,signatureChainId:"0x66eee",destination:i,amount:t.toString(),time:n,type:"withdraw3"}}const c={action:h,nonce:n,signature:d},l=await this.privatePostExchange(c);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 r;await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchDepositsWithdrawals",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)),d=this.extractTypeFromDelta(n),h=this.filterByArray(d,"type",["deposit"],!1);return this.parseTransactions(h,void 0,t,i)}async fetchWithdrawals(e=void 0,t=void 0,i=void 0,s={}){let r;await this.loadMarkets(),[r,s]=this.handlePublicAddress("fetchDepositsWithdrawals",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)),d=this.extractTypeFromDelta(n),h=this.filterByArray(d,"type",["withdraw"],!1);return this.parseTransactions(h,void 0,t,i)}async fetchOpenInterests(e=void 0,t={}){await this.loadMarkets(),e=this.marketSymbols(e);const i=await this.fetchSwapMarkets();return this.parseOpenInterests(i,e)}async fetchOpenInterest(e,t={}){e=this.symbol(e),await this.loadMarkets();return(await this.fetchOpenInterests([e],t))[e]}parseOpenInterest(e,t=void 0){e=this.safeDict(e,"info",{});const i=this.safeString(e,"name");let s;return void 0!==i&&(s=this.coinToMarketId(i)),this.safeOpenInterest({symbol:this.safeSymbol(s),openInterestAmount:this.safeNumber(e,"openInterest"),openInterestValue:void 0,timestamp:void 0,datetime:void 0,info:e},t)}async fetchFundingHistory(e=void 0,t=void 0,i=void 0,s={}){let r,a;await this.loadMarkets(),void 0!==e&&(r=this.market(e)),[a,s]=this.handlePublicAddress("fetchFundingHistory",s);const o={user:a,type:"userFunding"};void 0!==t&&(o.startTime=t);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.parseIncomes(d,r,t,i)}parseIncome(e,t=void 0){const i=this.safeString(e,"hash"),s=this.safeInteger(e,"time"),r=this.safeDict(e,"delta"),a=this.safeString(r,"coin")+"/USDC:USDC",o=this.safeMarket(a).symbol,n=this.safeString(r,"usdc"),d=this.safeCurrencyCode("USDC"),h=this.safeNumber(r,"fundingRate");return{info:e,symbol:o,code:d,timestamp:s,datetime:this.iso8601(s),id:i,amount:this.parseNumber(n),rate:h}}extractTypeFromDelta(e=[]){const t=[];for(let i=0;i-1||e.indexOf("@")>-1?e:e+"/USDC:USDC"}handleErrors(e,t,i,s,a,o,n,d,h){if(!n)return;const c=this.safeString(n,"status",""),l=this.safeString(n,"error");let u;if("err"===c)u=this.safeString(n,"response");else if(void 0!==l)u=l;else{const e=this.safeDict(n,"response",{}),t=this.safeDict(e,"data",{}),i=this.safeList(t,"statuses",[]),s=this.safeDict(i,0);u=this.safeString(s,"error")}const f=this.id+" "+o,p=void 0!==u&&""!==u;if(p&&(this.throwExactlyMatchedException(this.exceptions.exact,u,f),this.throwBroadlyMatchedException(this.exceptions.broad,u,f)),p)throw new r.ExchangeError(f)}sign(e,t="public",i="GET",s={},r=void 0,a=void 0){const o=this.implodeHostname(this.urls.api[t])+"/"+e;return"POST"===i&&(r={"Content-Type":"application/json"},a=this.json(s)),{url:o,method:i,body:a,headers:r}}calculateRateLimiterCost(e,t,i,s,r={}){if("byType"in r&&"type"in s){const e=s.type,t=r.byType;if(e in t)return t[e]}return this.safeValue(r,"cost",1)}parseCreateEditOrderArgs(e,t,i,s,r,a=void 0,o={}){const n=this.market(t);let d;[d,o]=this.handleOptionAndParams(o,"createOrder","vaultAddress"),d=this.formatVaultAddress(d);const h={symbol:t=n.symbol,type:i,side:s,amount:r,price:a,params:o},c={};return void 0!==d&&(c.vaultAddress=d),void 0!==e&&(h.id=e),[h,c]}}},4162:(e,t,i)=>{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,cancelOrder:!0,closeAllPositions:!1,closePosition:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDepositAddress:!0,fetchDepositAddresses:!1,fetchDepositAddressesByNetwork:!1,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,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!0,reduceMargin:!1,setLeverage:!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":h.indexOf("Offer")>=0&&(d="sell"),h.indexOf("Market")>=0?h="market":h.indexOf("Limit")>=0&&(h="limit"));const c=this.parse8601(this.safeString(e,"CreatedTimestampUtc")),l=this.safeString(e,"VolumeFilled"),u=this.safeString(e,"FeePercent");let f;return void 0!==u&&void 0!==l&&(f=r.Y.stringMul(u,l)),this.safeOrder({info:e,id:this.safeString(e,"OrderGuid"),clientOrderId:void 0,timestamp:c,datetime:this.iso8601(c),lastTradeTimestamp:void 0,symbol:i,type:h,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:f,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),h=this.parseNumber(n),c=this.parseNumber(r.Y.stringMul(o,n)),l=this.safeString(e,"PrimaryCurrencyCode"),u=this.safeString(e,"SecondaryCurrencyCode");let f;void 0!==l&&void 0!==u&&(f=l+"/"+u);const p=this.safeSymbol(f,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:p,order:a,type:void 0,side:m,takerOrMaker:void 0,price:d,amount:h,cost:c,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{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,cancelAllOrders:!1,cancelOrder:!0,cancelOrders:!1,closeAllPositions:!1,closePosition:!1,createDepositAddress:!1,createOrder:!0,createReduceOnlyOrder:!1,createStopLimitOrder:!1,createStopMarketOrder:!1,createStopOrder:!1,fetchBalance:!0,fetchBorrowRateHistories:!1,fetchBorrowRateHistory:!1,fetchClosedOrders:!0,fetchCrossBorrowRate:!1,fetchCrossBorrowRates:!1,fetchDeposit:!1,fetchDepositAddress:"emulated",fetchDepositAddresses:!0,fetchDepositAddressesByNetwork:!1,fetchDeposits:!1,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,fetchOpenInterestHistory:!1,fetchOpenOrders:!0,fetchOrder:!0,fetchOrderBook:!0,fetchOrders:!1,fetchPosition:!1,fetchPositionHistory:!1,fetchPositionMode:!1,fetchPositions:!1,fetchPositionsForSymbol:!1,fetchPositionsHistory:!1,fetchPositionsRisk:!1,fetchPremiumIndexOHLCV:!1,fetchTicker:!0,fetchTime:!0,fetchTrades:!0,fetchTradingFee:!1,fetchTradingFees:!1,fetchTransactionFee:!0,fetchTransactionFees:!1,fetchTransactions:"emulated",fetchTransfer:!1,fetchTransfers:!1,fetchWithdrawal:!1,fetchWithdrawals:!1,reduceMargin:!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}},options:{recvWindow:5e3,timeDifference:0,adjustForTimeDifference:!1,networks:{XLM:"Stellar Token",BSC:"bep20",TRC20:"trc20",MATIC:"polygon"},timeframes:{"1m":"1","15m":"15","30m":"30","1h":"60","4h":"240","1d":"1D","3d":"3D","1w":"1W"}},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{i.d(t,{A:()=>h});var s=i(2459),r=i(2079),a=i(5147),o=i(1579),n=i(4852),d=i(7481);class h 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,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"},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"}},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: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:{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;eO&&(O=t)}const P="online"===this.safeString(i,"status");n.push({id:t,wsId:this.safeString(i,"wsname"),symbol:c+"/"+l,base:c,quote:l,settle:void 0,baseId:d,quoteId:h,settleId:void 0,altname:i.altname,type:"spot",spot:T,margin:k>0,swap:!1,future:!1,option:!1,active:P,contract:!1,linear:void 0,inverse:void 0,taker:w,maker:m,contractSize:void 0,expiry:void 0,expiryDatetime:void 0,strike:void 0,optionType:void 0,precision:{amount:O,price:S},limits:{leverage:{min:this.parseNumber("1"),max:this.safeNumber(b,k-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}safeCurrency(e,t=void 0){return void 0!==e&&e.length>3&&(0!==e.indexOf("X")&&0!==e.indexOf("Z")||e.indexOf(".")>0||"ZEUS"===e||(e=e.slice(1))),super.safeCurrency(e,t)}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",{}),h=this.safeValue(d,"wsname");return void 0!==h&&(n=this.safeValue(o,h,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),h=this.safeValue(e,"c",[]),c=this.safeString(h,0),l=this.safeValue(e,"h",[]),u=this.safeValue(e,"l",[]),f=this.safeValue(e,"b",[]),p=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(f,0),bidVolume:this.safeString(f,2),ask:this.safeString(p,0),askVolume:this.safeString(p,2),vwap:n,open:this.safeString(e,"o"),close:c,last:c,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)),h=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),c={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"),f=this.safeBool(e,"maker");let p;return void 0!==f&&(p=f?"maker":"taker"),void 0===s?s=this.iso8601(i):i=this.parse8601(s),this.safeTrade({id:d,order:h,info:e,timestamp:i,datetime:s,symbol:l,type:a,side:r,takerOrMaker:p,price:o,amount:n,cost:u,fee:c},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],h=d.length;if(h<=0)return[];const c=d[h-1],l=this.safeString(n,"last");return c.push(l),d[h-1]=c,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,h=await this.privatePostAddOrder(this.extend(n[0],n[1])),c=this.safeDict(h,"result");return c.usingCost=d,this.parseOrder(c)}findMarketByAltnameOrId(e){const t=this.safeValue(this.options,"marketsByAltname",{});return e in t?t[e]:this.safeMarket(e)}getDelistedMarketById(e){if(void 0===e)return e;let t=this.safeValue(this.options.delistedMarketsById,e);if(void 0!==t)return t;let i=3,s=3,r=6;8===e.length?(i=4,s=4,r=8):7===e.length&&(i=4,s=4,r=7);const a=e.slice(0,i),o=e.slice(s,r),n=this.safeCurrencyCode(a),d=this.safeCurrencyCode(o);return t={symbol:n+"/"+d,base:n,quote:d,baseId:a,quoteId:o},this.options.delistedMarketsById[e]=t,t}parseOrderStatus(e){return this.safeString({pending:"open",open:"open",closed:"closed",canceled:"canceled",expired:"expired"},e,e)}parseOrderType(e){return this.safeString({"take-profit":"market","stop-loss":"market","stop-loss-limit":"limit","take-profit-limit":"limit","trailing-stop-limit":"limit"},e,e)}parseOrder(e,t=void 0){const i=this.safeBool(e,"usingCost",!1);e=this.omit(e,"usingCost");const s=this.safeDict(e,"descr",{}),r=this.safeDict(e,"descr");let o,n,d,h,c,l,u,f;if(o=void 0!==r?this.safeString(r,"order"):this.safeString(e,"descr"),void 0!==o){const e=o.split(" ");n=this.safeString(e,0),i?u=this.safeString(e,1):l=this.safeString(e,1),h=this.safeString(e,2);const t=this.safeString(e,4),s=this.safeString(e,5);d="limit"===t||"market"===t?t:t+" "+s,"stop loss"===d||"take profit"===d?(f=this.safeString(e,6),c=this.safeString(e,9)):"limit"===d&&(c=this.safeString(e,5))}n=this.safeString(s,"type",n),d=this.safeString(s,"ordertype",d),h=this.safeString(s,"pair",h);const p=this.findMarketByAltnameOrId(h);let m;void 0!==p?t=p:void 0!==h&&(t=this.getDelistedMarketById(h));const g=this.safeTimestamp(e,"opentm");l=this.safeString(e,"vol",l);const v=this.safeString(e,"vol_exec");let y;c=this.safeString(s,"price",c),void 0!==c&&(c.endsWith("%")||a.Y.stringEquals(c,"0.00000")||a.Y.stringEquals(c,"0"))&&(c=void 0),void 0===c&&(c=this.safeString(s,"price2"),c=this.safeString2(e,"limitprice","price",c));const w=this.safeString(e,"oflags","");let b=w.indexOf("post")>-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},w.indexOf("fciq")>=0?y.currency=t.quote:w.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(b&&(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!w||v||y||(s.price=this.priceToPrecision(t,a));const T=this.safeBool2(o,"reduceOnly","reduce_only");if(u)c?(s.price=this.priceToPrecision(t,d),s.ordertype=w?"stop-loss-limit":"stop-loss"):l&&(s.price=this.priceToPrecision(t,h),s.ordertype=w?"take-profit-limit":"take-profit"),w&&(s.price2=this.priceToPrecision(t,a));else if(v||y){let e;void 0!==p&&(e=p.endsWith("%")?"+"+p:"+"+p+"%");const t=void 0!==f?"+"+f: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,w||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!==p?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 x;if([x,o]=this.handlePostOnly(M,!1,o),x){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 h={txid:e};const c=this.safeString2(n,"clientOrderId","cl_ord_id");void 0!==c&&(h.cl_ord_id=c,n=this.omit(n,["clientOrderId","cl_ord_id"]),h=this.omit(h,"txid"));const l="market"===i;let u;[u,n]=this.handlePostOnly(l,!1,n),u&&(h.post_only="true"),void 0!==a&&(h.order_qty=this.amountToPrecision(t,a)),void 0!==o&&(h.limit_price=this.priceToPrecision(t,o));let f=this.safeStringN(n,["stopLossPrice","takeProfitPrice","trailingAmount","trailingPercent","trailingLimitAmount","trailingLimitPercent"]);if(void 0!==f){const e=this.safeString(n,"offset");n=this.omit(n,["stopLossPrice","takeProfitPrice","trailingAmount","trailingPercent","trailingLimitAmount","trailingLimitPercent","offset"]),void 0!==e?(f=e+f,h.trigger_price=f):h.trigger_price=this.priceToPrecision(t,f)}const p=await this.privatePostAmendOrder(this.extend(h,n)),m=this.safeDict(p,"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 h=this.safeDict(n,"result",{}),c=this.safeDict(h,"open",{}),l=[],u=Object.keys(c);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 h={asset:i.id,method:d},c=await this.privatePostDepositAddresses(this.extend(h,t)),l=this.safeValue(c,"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),this.checkAddress(i),"key"in a){await this.loadMarkets();const s=this.currency(e),r={asset:s.id,amount:t,address:i},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)),h=this.parseTransfer(d,o);return this.extend(h,{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 h="CancelOrderBatch"===e;this.checkRequiredCredentials();const c=this.nonce().toString();a=h||i?this.json(this.extend({nonce:c},s)):this.urlencodeNested(this.extend({nonce:c},s));const l=this.encode(c+a),u=this.hash(l,n.s,"binary"),f=this.encode(o),p=this.binaryConcat(f,u),m=this.base64ToBinary(this.secret),g=this.hmac(p,m,d.Zf,"base64");(r={"API-Key":this.apiKey,"API-Sign":g})["Content-Type"]=h||i?"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,h){if(520===e)throw new r.ExchangeNotAvailable(this.id+" "+e.toString()+" "+t);if(void 0!==n&&"{"===o[0]&&"string"!=typeof n&&"error"in n){if(n.error.length){const e=this.id+" "+o;for(let t=0;t{i.d(t,{A:()=>h});var s=i(1359),r=i(1579),a=i(2079),o=i(5147),n=i(4852),d=i(7481);class h 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:!1,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,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:!1,fetchOrderBook:!0,fetchOrders:!1,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.futures.kraken.com/#introduction"],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"],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"}}},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:5e3}},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,h,c;if(n)o="index";else{d=a.indexOf("_vanilla")>=0,h=!d;const e=this.safeString(t,"lastTradingTime");o=void 0===e?"swap":"future",c=this.parse8601(e)}const l="swap"===o,u="future"===o;let f=r;const p=r.split("_"),m=this.safeString(p,1),g=m.slice(0,m.length-3),v="usd",y=this.safeCurrencyCode(g),w=this.safeCurrencyCode(v);let b,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")?(b=y,k=g,h=!0):(b=w,k=v,h=!1),d=!h,f=y+"/"+w+":"+b,u&&(f=f+"-"+this.yymmdd(c))}s.push({id:r,symbol:f,base:y,quote:w,settle:b,baseId:g,quoteId:v,settleId:k,type:o,spot:!1,margin:!1,swap:l,future:u,option:!1,index:n,active:void 0,contract:P,linear:d,inverse:h,contractSize:this.safeNumber(t,"contractSize"),maintenanceMarginRate:void 0,expiry:c,expiryDatetime:this.iso8601(c),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&&(c=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:c,takerOrMaker:m,price:s,amount:p?r:void 0,cost:f,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 h={symbol:o.id,side:i,size:this.amountToPrecision(e,s)},c=this.safeString2(a,"clientOrderId","cliOrdId");void 0!==c&&(h.cliOrdId=c);const l=this.safeString2(a,"triggerPrice","stopPrice"),u=void 0!==l,f=this.safeString(a,"stopLossPrice"),p=this.safeString(a,"takeProfitPrice"),m=void 0!==f,g=void 0!==p,v=m||g,y=this.safeString(a,"triggerSignal","last");let w=this.safeValue(a,"reduceOnly");return(v||u)&&(h.triggerSignal=y),u?(t="stp",h.stopPrice=this.priceToPrecision(e,l)):v&&(w=!0,m?(t="stp",h.stopPrice=this.priceToPrecision(e,f)):g&&(t="take_profit",h.stopPrice=this.priceToPrecision(e,p))),w&&(h.reduceOnly=!0),h.orderType=t,void 0!==r&&(h.limitPrice=this.priceToPrecision(e,r)),a=this.omit(a,["clientOrderId","timeInForce","triggerPrice","stopLossPrice","takeProfitPrice"]),this.extend(h,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),h=this.safeValue(d,"sendStatus"),c=this.safeString(h,"status");return this.verifyOrderActionSuccess(c,"createOrder",["filled"]),this.parseOrder(h,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 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 c=this.account();if(i)c.total=this.safeString(d,"quantity"),c.free=this.safeString(d,"available");else if(s)c.used="0.0",c.total=d;else{const t=this.safeValue(e,"auxiliary");c.free=this.safeString(t,"af"),c.total=this.safeString(t,"pv")}a[h]=c}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{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:!1,fetchFundingRateHistory:!1,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:!1,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"},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},post:{"bullet-public":15}},private:{get:{"user-info":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,"migrate/user/account/status":3,"affiliate/inviter/statistics":30},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,"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}},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},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,"bullet-private":15},delete:{"orders/{orderId}":1.5,"orders/client-order/{clientOid}":1.5,orders:45,stopOrders:22.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/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},post:{"earn/orders":7.5},delete:{"earn/orders":7.5}}},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:{"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,"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,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},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",OP:"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"},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={}){const t=await this.publicGetStatus(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={}){let t;[t,e]=this.handleOptionAndParams(e,"fetchMarkets","fetchTickersFees",!0);const i=[];i.push(this.publicGetSymbols(e));const s=this.checkRequiredCredentials(!1),r=s&&this.safeBool(e,"marginables",!0);r&&(i.push(this.privateGetMarginSymbols(e)),i.push(this.privateGetIsolatedSymbols(e))),t&&i.push(this.publicGetMarketAllTickers(e)),s&&i.push(this.loadMigrationStatus());const o=await Promise.all(i),n=this.safeList(o[0],"data"),d=r?this.safeDict(o[1],"data",{}):{},h=this.safeList(d,"items",[]),c=this.indexBy(h,"symbol"),l=r?o[2]:{},u=this.safeList(l,"data",[]),f=this.indexBy(u,"symbol"),p=r?3:1,m=this.safeDict(o,p,{}),g=this.safeList(this.safeDict(m,"data",{}),"ticker",[]),v=this.indexBy(g,"symbol"),y=[];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 h=this.safeString(e,"status");let c;const l=this.safeString(e,"fee");if(void 0!==l){let e;void 0!==o&&(e=a.Y.stringDiv(l,o)),c={cost:this.parseNumber(l),rate:this.parseNumber(e),currency:s}}let u=this.safeInteger2(e,"createdAt","createAt"),f=this.safeInteger(e,"updatedAt");!("createdAt"in e)&&(d="address"in e?"withdrawal":"deposit",void 0!==u&&(u*=1e3),void 0!==f&&(f*=1e3));const p=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(h),comment:this.safeString(e,"remark"),internal:p,fee:c,updated:f}}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",{}),h=this.safeList(d,"items",[]);return this.parseTransactions(h,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",{}),h=this.safeList(d,"items",[]);return this.parseTransactions(h,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,h]=this.handleMarginModeAndParams("fetchBalance",e);let c;const l={},u="isolated"===d||"isolated"===n,f="cross"===d||"margin"===n;let p;u?(void 0!==i&&(l.balanceCurrency=i.id),c=await this.privateGetIsolatedAccounts(this.extend(l,h))):f?c=await this.privateGetMarginAccount(this.extend(l,h)):(void 0!==i&&(l.currency=i.id),l.type=n,c=await this.privateGetAccounts(this.extend(l,h)));const m={info:c,timestamp:void 0,datetime:void 0};if(u){p=this.safeDict(c,"data",{});const e=this.safeValue(p,"assets",p);for(let t=0;t{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,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},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.InvalidOrder,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},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"}},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.safeValue(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.safeValue(t,"data",[]);for(let e=0;e-1?"long":"short");const d=r.Y.stringAbs(this.safeString(e,"posCost")),h=this.safeString(e,"posInit"),c=r.Y.stringDiv(h,d),l=this.safeString(e,"unrealisedPnl"),u=this.safeValue(e,"crossMode");let f;return void 0!==u&&(f=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(h),initialMarginPercentage:this.parseNumber(c),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:f,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"),h=this.createContractOrderRequest(e,t,i,s,r,a);let c;c=n?await this.futuresPrivatePostOrdersTest(h):d?await this.futuresPrivatePostStOrders(h):await this.futuresPrivatePostOrders(h);const l=this.safeDict(c,"data",{});return this.parseOrder(l,o)}async createOrders(e,t={}){await this.loadMarkets();const i=[];for(let t=0;t