ccxt-look 1.81.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/eslintcache +1 -0
- package/.dockerignore +6 -0
- package/.eslintignore +1 -0
- package/.gitattributes +5 -0
- package/.readthedocs.yaml +16 -0
- package/CONTRIBUTING.md +1049 -0
- package/LICENSE.txt +21 -0
- package/README.md +537 -0
- package/SECURITY.md +5 -0
- package/build/cleanup-old-tags.js +94 -0
- package/build/countries.js +256 -0
- package/build/export-exchanges.js +520 -0
- package/build/fs.js +51 -0
- package/build/transpile.js +1772 -0
- package/build/vss.js +78 -0
- package/ccxt.browser.js +7 -0
- package/ccxt.d.ts +692 -0
- package/ccxt.js +171 -0
- package/cleanup.sh +2 -0
- package/composer-install.sh +20 -0
- package/dist/ccxt.browser.js +208383 -0
- package/gource.sh +3 -0
- package/index.html +7 -0
- package/js/.eslintrc +87 -0
- package/js/aax.js +2686 -0
- package/js/ascendex.js +2584 -0
- package/js/base/.eslintrc.js +43 -0
- package/js/base/Exchange.js +2371 -0
- package/js/base/Precise.js +283 -0
- package/js/base/errorHierarchy.js +47 -0
- package/js/base/errors.js +55 -0
- package/js/base/functions/crypto.js +158 -0
- package/js/base/functions/encode.js +118 -0
- package/js/base/functions/generic.js +270 -0
- package/js/base/functions/misc.js +138 -0
- package/js/base/functions/number.js +329 -0
- package/js/base/functions/platform.js +38 -0
- package/js/base/functions/string.js +21 -0
- package/js/base/functions/throttle.js +79 -0
- package/js/base/functions/time.js +210 -0
- package/js/base/functions/type.js +66 -0
- package/js/base/functions.js +28 -0
- package/js/bequant.js +32 -0
- package/js/bibox.js +1407 -0
- package/js/bigone.js +1366 -0
- package/js/binance.js +5652 -0
- package/js/binancecoinm.js +46 -0
- package/js/binanceus.js +46 -0
- package/js/binanceusdm.js +49 -0
- package/js/bit2c.js +535 -0
- package/js/bitbank.js +842 -0
- package/js/bitbay.js +16 -0
- package/js/bitbns.js +1073 -0
- package/js/bitcoincom.js +15 -0
- package/js/bitfinex.js +1433 -0
- package/js/bitfinex2.js +2025 -0
- package/js/bitflyer.js +840 -0
- package/js/bitforex.js +614 -0
- package/js/bitget.js +2397 -0
- package/js/bithumb.js +980 -0
- package/js/bitmart.js +2516 -0
- package/js/bitmex.js +1809 -0
- package/js/bitopro.js +1443 -0
- package/js/bitpanda.js +1782 -0
- package/js/bitrue.js +1747 -0
- package/js/bitso.js +1062 -0
- package/js/bitstamp.js +1757 -0
- package/js/bitstamp1.js +343 -0
- package/js/bittrex.js +1876 -0
- package/js/bitvavo.js +1579 -0
- package/js/bkex.js +1233 -0
- package/js/bl3p.js +346 -0
- package/js/blockchaincom.js +969 -0
- package/js/btcalpha.js +680 -0
- package/js/btcbox.js +477 -0
- package/js/btcmarkets.js +1022 -0
- package/js/btctradeua.js +466 -0
- package/js/btcturk.js +734 -0
- package/js/buda.js +946 -0
- package/js/bw.js +1265 -0
- package/js/bybit.js +3372 -0
- package/js/bytetrade.js +1336 -0
- package/js/cdax.js +1646 -0
- package/js/cex.js +1410 -0
- package/js/coinbase.js +1342 -0
- package/js/coinbaseprime.js +31 -0
- package/js/coinbasepro.js +1466 -0
- package/js/coincheck.js +755 -0
- package/js/coinex.js +3400 -0
- package/js/coinfalcon.js +880 -0
- package/js/coinmate.js +794 -0
- package/js/coinone.js +816 -0
- package/js/coinspot.js +345 -0
- package/js/crex24.js +1636 -0
- package/js/cryptocom.js +1832 -0
- package/js/currencycom.js +1748 -0
- package/js/delta.js +1547 -0
- package/js/deribit.js +2148 -0
- package/js/digifinex.js +1585 -0
- package/js/eqonex.js +1660 -0
- package/js/exmo.js +1670 -0
- package/js/fairdesk.js +1231 -0
- package/js/flowbtc.js +35 -0
- package/js/fmfwio.js +34 -0
- package/js/ftx.js +2751 -0
- package/js/ftxus.js +38 -0
- package/js/gateio.js +4174 -0
- package/js/gemini.js +1397 -0
- package/js/hitbtc.js +1343 -0
- package/js/hitbtc3.js +2329 -0
- package/js/hollaex.js +1486 -0
- package/js/huobi.js +5706 -0
- package/js/huobijp.js +1710 -0
- package/js/huobipro.js +18 -0
- package/js/idex.js +1439 -0
- package/js/independentreserve.js +649 -0
- package/js/indodax.js +742 -0
- package/js/itbit.js +722 -0
- package/js/kraken.js +2179 -0
- package/js/kucoin.js +2571 -0
- package/js/kucoinfutures.js +1771 -0
- package/js/kuna.js +809 -0
- package/js/latoken.js +1445 -0
- package/js/lbank.js +760 -0
- package/js/liquid.js +1432 -0
- package/js/luno.js +873 -0
- package/js/lykke.js +1147 -0
- package/js/mercado.js +771 -0
- package/js/mexc.js +3151 -0
- package/js/ndax.js +2233 -0
- package/js/novadax.js +1318 -0
- package/js/oceanex.js +816 -0
- package/js/okcoin.js +3841 -0
- package/js/okex.js +16 -0
- package/js/okex5.js +16 -0
- package/js/okx.js +4795 -0
- package/js/paymium.js +498 -0
- package/js/phemex.js +2957 -0
- package/js/poloniex.js +1674 -0
- package/js/probit.js +1346 -0
- package/js/qtrade.js +1588 -0
- package/js/ripio.js +1061 -0
- package/js/static_dependencies/BN/bn.js +3526 -0
- package/js/static_dependencies/README.md +1 -0
- package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
- package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
- package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
- package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
- package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
- package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
- package/js/static_dependencies/node-fetch/index.js +1564 -0
- package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
- package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
- package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
- package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
- package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
- package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
- package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
- package/js/static_dependencies/node-rsa/formats/components.js +71 -0
- package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
- package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
- package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
- package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
- package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
- package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
- package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
- package/js/static_dependencies/node-rsa/utils.js +98 -0
- package/js/static_dependencies/qs/formats.js +18 -0
- package/js/static_dependencies/qs/index.js +11 -0
- package/js/static_dependencies/qs/parse.js +242 -0
- package/js/static_dependencies/qs/stringify.js +269 -0
- package/js/static_dependencies/qs/utils.js +230 -0
- package/js/stex.js +1925 -0
- package/js/test/.eslintrc.js +42 -0
- package/js/test/Exchange/test.balance.js +61 -0
- package/js/test/Exchange/test.borrowRate.js +32 -0
- package/js/test/Exchange/test.currency.js +52 -0
- package/js/test/Exchange/test.fetchBalance.js +23 -0
- package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
- package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
- package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
- package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
- package/js/test/Exchange/test.fetchCurrencies.js +35 -0
- package/js/test/Exchange/test.fetchDeposits.js +31 -0
- package/js/test/Exchange/test.fetchFundingFees.js +19 -0
- package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
- package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
- package/js/test/Exchange/test.fetchLedger.js +42 -0
- package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
- package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
- package/js/test/Exchange/test.fetchMarkets.js +33 -0
- package/js/test/Exchange/test.fetchMyTrades.js +42 -0
- package/js/test/Exchange/test.fetchOHLCV.js +46 -0
- package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
- package/js/test/Exchange/test.fetchOrderBook.js +25 -0
- package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
- package/js/test/Exchange/test.fetchOrders.js +41 -0
- package/js/test/Exchange/test.fetchPositions.js +47 -0
- package/js/test/Exchange/test.fetchStatus.js +35 -0
- package/js/test/Exchange/test.fetchTicker.js +38 -0
- package/js/test/Exchange/test.fetchTickers.js +49 -0
- package/js/test/Exchange/test.fetchTrades.js +39 -0
- package/js/test/Exchange/test.fetchTradingFee.js +18 -0
- package/js/test/Exchange/test.fetchTradingFees.js +22 -0
- package/js/test/Exchange/test.fetchTransactions.js +31 -0
- package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
- package/js/test/Exchange/test.ledgerItem.js +46 -0
- package/js/test/Exchange/test.leverageTier.js +33 -0
- package/js/test/Exchange/test.loadMarkets.js +35 -0
- package/js/test/Exchange/test.market.js +129 -0
- package/js/test/Exchange/test.ohlcv.js +33 -0
- package/js/test/Exchange/test.order.js +62 -0
- package/js/test/Exchange/test.orderbook.js +61 -0
- package/js/test/Exchange/test.position.js +21 -0
- package/js/test/Exchange/test.throttle.js +94 -0
- package/js/test/Exchange/test.ticker.js +95 -0
- package/js/test/Exchange/test.trade.js +68 -0
- package/js/test/Exchange/test.tradingFee.js +34 -0
- package/js/test/Exchange/test.transaction.js +35 -0
- package/js/test/base/.eslintrc +38 -0
- package/js/test/base/functions/test.crypto.js +110 -0
- package/js/test/base/functions/test.datetime.js +62 -0
- package/js/test/base/functions/test.generic.js +152 -0
- package/js/test/base/functions/test.number.js +362 -0
- package/js/test/base/functions/test.time.js +56 -0
- package/js/test/base/functions/test.type.js +53 -0
- package/js/test/base/test.base.js +193 -0
- package/js/test/errors/test.InsufficientFunds.js +86 -0
- package/js/test/errors/test.InvalidNonce.js +64 -0
- package/js/test/errors/test.InvalidOrder.js +35 -0
- package/js/test/errors/test.OrderNotFound.js +39 -0
- package/js/test/test.js +426 -0
- package/js/test/test.timeout_hang.js +12 -0
- package/js/therock.js +1431 -0
- package/js/tidebit.js +632 -0
- package/js/tidex.js +939 -0
- package/js/timex.js +1283 -0
- package/js/upbit.js +1622 -0
- package/js/vcc.js +1353 -0
- package/js/wavesexchange.js +2185 -0
- package/js/wazirx.js +732 -0
- package/js/whitebit.js +1352 -0
- package/js/woo.js +1577 -0
- package/js/xena.js +1948 -0
- package/js/yobit.js +1129 -0
- package/js/zaif.js +647 -0
- package/js/zb.js +4088 -0
- package/js/zipmex.js +40 -0
- package/js/zonda.js +1497 -0
- package/multilang.sh +159 -0
- package/package.json +591 -0
- package/postinstall.js +103 -0
@@ -0,0 +1,969 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
const Exchange = require ('./base/Exchange');
|
5
|
+
const { ExchangeError, AuthenticationError, OrderNotFound, InsufficientFunds, ArgumentsRequired } = require ('./base/errors');
|
6
|
+
const { TICK_SIZE } = require ('./base/functions/number');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class blockchaincom extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'blockchaincom',
|
15
|
+
'secret': undefined,
|
16
|
+
'name': 'Blockchain.com',
|
17
|
+
'countries': [ 'LX' ],
|
18
|
+
'rateLimit': 500, // prev 1000
|
19
|
+
'version': 'v3',
|
20
|
+
'has': {
|
21
|
+
'CORS': false,
|
22
|
+
'spot': true,
|
23
|
+
'margin': undefined, // on exchange but not implemented in CCXT
|
24
|
+
'swap': false,
|
25
|
+
'future': false,
|
26
|
+
'option': false,
|
27
|
+
'cancelOrder': true,
|
28
|
+
'cancelOrders': true,
|
29
|
+
'createOrder': true,
|
30
|
+
'createStopLimitOrder': true,
|
31
|
+
'createStopMarketOrder': true,
|
32
|
+
'createStopOrder': true,
|
33
|
+
'fetchBalance': true,
|
34
|
+
'fetchCanceledOrders': true,
|
35
|
+
'fetchClosedOrders': true,
|
36
|
+
'fetchDeposit': true,
|
37
|
+
'fetchDepositAddress': true,
|
38
|
+
'fetchDeposits': true,
|
39
|
+
'fetchFundingHistory': false,
|
40
|
+
'fetchFundingRate': false,
|
41
|
+
'fetchFundingRateHistory': false,
|
42
|
+
'fetchFundingRates': false,
|
43
|
+
'fetchIndexOHLCV': false,
|
44
|
+
'fetchL2OrderBook': true,
|
45
|
+
'fetchL3OrderBook': true,
|
46
|
+
'fetchLedger': false,
|
47
|
+
'fetchMarkets': true,
|
48
|
+
'fetchMarkOHLCV': false,
|
49
|
+
'fetchMyTrades': true,
|
50
|
+
'fetchOHLCV': false,
|
51
|
+
'fetchOpenOrders': true,
|
52
|
+
'fetchOrder': true,
|
53
|
+
'fetchOrderBook': true,
|
54
|
+
'fetchPremiumIndexOHLCV': false,
|
55
|
+
'fetchTicker': true,
|
56
|
+
'fetchTickers': true,
|
57
|
+
'fetchTrades': false,
|
58
|
+
'fetchTradingFee': false,
|
59
|
+
'fetchTradingFees': true,
|
60
|
+
'fetchTransfer': false,
|
61
|
+
'fetchTransfers': false,
|
62
|
+
'fetchWithdrawal': true,
|
63
|
+
'fetchWithdrawals': true,
|
64
|
+
'fetchWithdrawalWhitelist': true, // fetches exchange specific benficiary-ids needed for withdrawals
|
65
|
+
'transfer': false,
|
66
|
+
'withdraw': true,
|
67
|
+
},
|
68
|
+
'timeframes': undefined,
|
69
|
+
'urls': {
|
70
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/147515585-1296e91b-7398-45e5-9d32-f6121538533f.jpeg',
|
71
|
+
'test': {
|
72
|
+
'public': 'https://testnet-api.delta.exchange',
|
73
|
+
'private': 'https://testnet-api.delta.exchange',
|
74
|
+
},
|
75
|
+
'api': {
|
76
|
+
'public': 'https://api.blockchain.com/v3/exchange',
|
77
|
+
'private': 'https://api.blockchain.com/v3/exchange',
|
78
|
+
},
|
79
|
+
'www': 'https://blockchain.com',
|
80
|
+
'doc': [
|
81
|
+
'https://api.blockchain.com/v3',
|
82
|
+
],
|
83
|
+
'fees': 'https://exchange.blockchain.com/fees',
|
84
|
+
},
|
85
|
+
'api': {
|
86
|
+
'public': {
|
87
|
+
'get': {
|
88
|
+
'tickers': 1, // fetchTickers
|
89
|
+
'tickers/{symbol}': 1, // fetchTicker
|
90
|
+
'symbols': 1, // fetchMarkets
|
91
|
+
'symbols/{symbol}': 1, // fetchMarket
|
92
|
+
'l2/{symbol}': 1, // fetchL2OrderBook
|
93
|
+
'l3/{symbol}': 1, // fetchL3OrderBook
|
94
|
+
},
|
95
|
+
},
|
96
|
+
'private': {
|
97
|
+
'get': {
|
98
|
+
'fees': 1, // fetchFees
|
99
|
+
'orders': 1, // fetchOpenOrders, fetchClosedOrders
|
100
|
+
'orders/{orderId}': 1, // fetchOrder(id)
|
101
|
+
'trades': 1,
|
102
|
+
'fills': 1, // fetchMyTrades
|
103
|
+
'deposits': 1, // fetchDeposits
|
104
|
+
'deposits/{depositId}': 1, // fetchDeposit
|
105
|
+
'accounts': 1, // fetchBalance
|
106
|
+
'accounts/{account}/{currency}': 1,
|
107
|
+
'whitelist': 1, // fetchWithdrawalWhitelist
|
108
|
+
'whitelist/{currency}': 1, // fetchWithdrawalWhitelistByCurrency
|
109
|
+
'withdrawals': 1, // fetchWithdrawalWhitelist
|
110
|
+
'withdrawals/{withdrawalId}': 1, // fetchWithdrawalById
|
111
|
+
},
|
112
|
+
'post': {
|
113
|
+
'orders': 1, // createOrder
|
114
|
+
'deposits/{currency}': 1, // fetchDepositAddress by currency (only crypto supported)
|
115
|
+
'withdrawals': 1, // withdraw
|
116
|
+
},
|
117
|
+
'delete': {
|
118
|
+
'orders': 1, // cancelOrders
|
119
|
+
'orders/{orderId}': 1, // cancelOrder
|
120
|
+
},
|
121
|
+
},
|
122
|
+
},
|
123
|
+
'fees': {
|
124
|
+
'trading': {
|
125
|
+
'feeSide': 'get',
|
126
|
+
'tierBased': true,
|
127
|
+
'percentage': true,
|
128
|
+
'tiers': {
|
129
|
+
'taker': [
|
130
|
+
[ this.parseNumber ('0'), this.parseNumber ('0.004') ],
|
131
|
+
[ this.parseNumber ('10000'), this.parseNumber ('0.0022') ],
|
132
|
+
[ this.parseNumber ('50000'), this.parseNumber ('0.002') ],
|
133
|
+
[ this.parseNumber ('100000'), this.parseNumber ('0.0018') ],
|
134
|
+
[ this.parseNumber ('500000'), this.parseNumber ('0.0018') ],
|
135
|
+
[ this.parseNumber ('1000000'), this.parseNumber ('0.0018') ],
|
136
|
+
[ this.parseNumber ('2500000'), this.parseNumber ('0.0018') ],
|
137
|
+
[ this.parseNumber ('5000000'), this.parseNumber ('0.0016') ],
|
138
|
+
[ this.parseNumber ('25000000'), this.parseNumber ('0.0014') ],
|
139
|
+
[ this.parseNumber ('100000000'), this.parseNumber ('0.0011') ],
|
140
|
+
[ this.parseNumber ('500000000'), this.parseNumber ('0.0008') ],
|
141
|
+
[ this.parseNumber ('1000000000'), this.parseNumber ('0.0006') ],
|
142
|
+
],
|
143
|
+
'maker': [
|
144
|
+
[ this.parseNumber ('0'), this.parseNumber ('0.002') ],
|
145
|
+
[ this.parseNumber ('10000'), this.parseNumber ('0.0012') ],
|
146
|
+
[ this.parseNumber ('50000'), this.parseNumber ('0.001') ],
|
147
|
+
[ this.parseNumber ('100000'), this.parseNumber ('0.0008') ],
|
148
|
+
[ this.parseNumber ('500000'), this.parseNumber ('0.0007000000000000001') ],
|
149
|
+
[ this.parseNumber ('1000000'), this.parseNumber ('0.0006') ],
|
150
|
+
[ this.parseNumber ('2500000'), this.parseNumber ('0.0005') ],
|
151
|
+
[ this.parseNumber ('5000000'), this.parseNumber ('0.0004') ],
|
152
|
+
[ this.parseNumber ('25000000'), this.parseNumber ('0.0003') ],
|
153
|
+
[ this.parseNumber ('100000000'), this.parseNumber ('0.0002') ],
|
154
|
+
[ this.parseNumber ('500000000'), this.parseNumber ('0.0001') ],
|
155
|
+
[ this.parseNumber ('1000000000'), this.parseNumber ('0') ],
|
156
|
+
],
|
157
|
+
},
|
158
|
+
},
|
159
|
+
},
|
160
|
+
'requiredCredentials': {
|
161
|
+
'apiKey': false,
|
162
|
+
'secret': true,
|
163
|
+
},
|
164
|
+
'precisionMode': TICK_SIZE,
|
165
|
+
'exceptions': {
|
166
|
+
'exact': {
|
167
|
+
'401': AuthenticationError,
|
168
|
+
'404': OrderNotFound,
|
169
|
+
},
|
170
|
+
'broad': {},
|
171
|
+
},
|
172
|
+
});
|
173
|
+
}
|
174
|
+
|
175
|
+
async fetchMarkets (params = {}) {
|
176
|
+
//
|
177
|
+
// "USDC-GBP": {
|
178
|
+
// "base_currency": "USDC",
|
179
|
+
// "base_currency_scale": 6,
|
180
|
+
// "counter_currency": "GBP",
|
181
|
+
// "counter_currency_scale": 2,
|
182
|
+
// "min_price_increment": 10000,
|
183
|
+
// "min_price_increment_scale": 8,
|
184
|
+
// "min_order_size": 500000000,
|
185
|
+
// "min_order_size_scale": 8,
|
186
|
+
// "max_order_size": 0,
|
187
|
+
// "max_order_size_scale": 8,
|
188
|
+
// "lot_size": 10000,
|
189
|
+
// "lot_size_scale": 8,
|
190
|
+
// "status": "open",
|
191
|
+
// "id": 68,
|
192
|
+
// "auction_price": 0,
|
193
|
+
// "auction_size": 0,
|
194
|
+
// "auction_time": "",
|
195
|
+
// "imbalance": 0
|
196
|
+
// }
|
197
|
+
//
|
198
|
+
const markets = await this.publicGetSymbols (params);
|
199
|
+
const marketIds = Object.keys (markets);
|
200
|
+
const result = [];
|
201
|
+
for (let i = 0; i < marketIds.length; i++) {
|
202
|
+
const marketId = marketIds[i];
|
203
|
+
const market = this.safeValue (markets, marketId);
|
204
|
+
const baseId = this.safeString (market, 'base_currency');
|
205
|
+
const quoteId = this.safeString (market, 'counter_currency');
|
206
|
+
const base = this.safeCurrencyCode (baseId);
|
207
|
+
const quote = this.safeCurrencyCode (quoteId);
|
208
|
+
const numericId = this.safeNumber (market, 'id');
|
209
|
+
let active = undefined;
|
210
|
+
const marketState = this.safeString (market, 'status');
|
211
|
+
if (marketState === 'open') {
|
212
|
+
active = 'true';
|
213
|
+
} else {
|
214
|
+
active = 'false';
|
215
|
+
}
|
216
|
+
// price precision
|
217
|
+
const minPriceIncrementString = this.safeString (market, 'min_price_increment');
|
218
|
+
const minPriceIncrementScaleString = this.safeString (market, 'min_price_increment_scale');
|
219
|
+
const minPriceScalePrecisionString = this.parsePrecision (minPriceIncrementScaleString);
|
220
|
+
const pricePrecisionString = Precise.stringMul (minPriceIncrementString, minPriceScalePrecisionString);
|
221
|
+
const pricePrecision = this.parseNumber (pricePrecisionString);
|
222
|
+
// amount precision
|
223
|
+
const lotSizeString = this.safeString (market, 'lot_size');
|
224
|
+
const lotSizeScaleString = this.safeString (market, 'lot_size_scale');
|
225
|
+
const lotSizeScalePrecisionString = this.parsePrecision (lotSizeScaleString);
|
226
|
+
const amountPrecisionString = Precise.stringMul (lotSizeString, lotSizeScalePrecisionString);
|
227
|
+
const amountPrecision = this.parseNumber (amountPrecisionString);
|
228
|
+
// minimum order size
|
229
|
+
const minOrderSizeString = this.safeString (market, 'min_order_size');
|
230
|
+
const minOrderSizeScaleString = this.safeString (market, 'min_order_size_scale');
|
231
|
+
const minOrderSizeScalePrecisionString = this.parsePrecision (minOrderSizeScaleString);
|
232
|
+
const minOrderSizePreciseString = Precise.stringMul (minOrderSizeString, minOrderSizeScalePrecisionString);
|
233
|
+
const minOrderSize = this.parseNumber (minOrderSizePreciseString);
|
234
|
+
// maximum order size
|
235
|
+
let maxOrderSize = undefined;
|
236
|
+
maxOrderSize = this.safeString (market, 'max_order_size');
|
237
|
+
if (maxOrderSize !== '0') {
|
238
|
+
const maxOrderSizeScaleString = this.safeString (market, 'max_order_size_scale');
|
239
|
+
const maxOrderSizeScalePrecisionString = this.parsePrecision (maxOrderSizeScaleString);
|
240
|
+
const maxOrderSizeString = Precise.stringMul (maxOrderSize, maxOrderSizeScalePrecisionString);
|
241
|
+
maxOrderSize = this.parseNumber (maxOrderSizeString);
|
242
|
+
} else {
|
243
|
+
maxOrderSize = undefined;
|
244
|
+
}
|
245
|
+
result.push ({
|
246
|
+
'info': market,
|
247
|
+
'id': marketId,
|
248
|
+
'numericId': numericId,
|
249
|
+
'symbol': base + '/' + quote,
|
250
|
+
'base': base,
|
251
|
+
'quote': quote,
|
252
|
+
'settle': undefined,
|
253
|
+
'baseId': baseId,
|
254
|
+
'quoteId': quoteId,
|
255
|
+
'settleId': undefined,
|
256
|
+
'type': 'spot',
|
257
|
+
'spot': true,
|
258
|
+
'margin': false,
|
259
|
+
'swap': false,
|
260
|
+
'future': false,
|
261
|
+
'option': false,
|
262
|
+
'active': active,
|
263
|
+
'contract': false,
|
264
|
+
'linear': undefined,
|
265
|
+
'inverse': undefined,
|
266
|
+
'contractSize': undefined,
|
267
|
+
'expiry': undefined,
|
268
|
+
'expiryDatetime': undefined,
|
269
|
+
'strike': undefined,
|
270
|
+
'optionType': undefined,
|
271
|
+
'precision': {
|
272
|
+
'amount': amountPrecision,
|
273
|
+
'price': pricePrecision,
|
274
|
+
},
|
275
|
+
'limits': {
|
276
|
+
'leverage': {
|
277
|
+
'min': undefined,
|
278
|
+
'max': undefined,
|
279
|
+
},
|
280
|
+
'amount': {
|
281
|
+
'min': minOrderSize,
|
282
|
+
'max': maxOrderSize,
|
283
|
+
},
|
284
|
+
'price': {
|
285
|
+
'min': undefined,
|
286
|
+
'max': undefined,
|
287
|
+
},
|
288
|
+
'cost': {
|
289
|
+
'min': undefined,
|
290
|
+
'max': undefined,
|
291
|
+
},
|
292
|
+
},
|
293
|
+
});
|
294
|
+
}
|
295
|
+
return result;
|
296
|
+
}
|
297
|
+
|
298
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
299
|
+
return await this.fetchL3OrderBook (symbol, limit, params);
|
300
|
+
}
|
301
|
+
|
302
|
+
async fetchL3OrderBook (symbol, limit = undefined, params = {}) {
|
303
|
+
await this.loadMarkets ();
|
304
|
+
const request = {
|
305
|
+
'symbol': this.marketId (symbol),
|
306
|
+
};
|
307
|
+
if (limit !== undefined) {
|
308
|
+
request['depth'] = limit;
|
309
|
+
}
|
310
|
+
const response = await this.publicGetL3Symbol (this.extend (request, params));
|
311
|
+
return this.parseOrderBook (response, symbol, undefined, 'bids', 'asks', 'px', 'qty');
|
312
|
+
}
|
313
|
+
|
314
|
+
async fetchL2OrderBook (symbol, limit = undefined, params = {}) {
|
315
|
+
await this.loadMarkets ();
|
316
|
+
const request = {
|
317
|
+
'symbol': this.marketId (symbol),
|
318
|
+
};
|
319
|
+
if (limit !== undefined) {
|
320
|
+
request['depth'] = limit;
|
321
|
+
}
|
322
|
+
const response = await this.publicGetL2Symbol (this.extend (request, params));
|
323
|
+
return this.parseOrderBook (response, symbol, undefined, 'bids', 'asks', 'px', 'qty');
|
324
|
+
}
|
325
|
+
|
326
|
+
parseTicker (ticker, market = undefined) {
|
327
|
+
//
|
328
|
+
// {
|
329
|
+
// "symbol": "BTC-USD",
|
330
|
+
// "price_24h": 47791.86,
|
331
|
+
// "volume_24h": 362.88635738,
|
332
|
+
// "last_trade_price": 47587.75
|
333
|
+
// }
|
334
|
+
//
|
335
|
+
const marketId = this.safeString (ticker, 'symbol');
|
336
|
+
const symbol = this.safeSymbol (marketId, market, '-');
|
337
|
+
const last = this.safeString (ticker, 'last_trade_price');
|
338
|
+
const baseVolume = this.safeString (ticker, 'volume_24h');
|
339
|
+
const open = this.safeString (ticker, 'price_24h');
|
340
|
+
return this.safeTicker ({
|
341
|
+
'symbol': symbol,
|
342
|
+
'timestamp': undefined,
|
343
|
+
'datetime': undefined,
|
344
|
+
'high': undefined,
|
345
|
+
'low': undefined,
|
346
|
+
'bid': undefined,
|
347
|
+
'bidVolume': undefined,
|
348
|
+
'ask': undefined,
|
349
|
+
'askVolume': undefined,
|
350
|
+
'vwap': undefined,
|
351
|
+
'open': open,
|
352
|
+
'close': undefined,
|
353
|
+
'last': last,
|
354
|
+
'previousClose': undefined,
|
355
|
+
'change': undefined,
|
356
|
+
'percentage': undefined,
|
357
|
+
'average': undefined,
|
358
|
+
'baseVolume': baseVolume,
|
359
|
+
'quoteVolume': undefined,
|
360
|
+
'info': ticker,
|
361
|
+
}, market, false);
|
362
|
+
}
|
363
|
+
|
364
|
+
async fetchTicker (symbol, params = {}) {
|
365
|
+
await this.loadMarkets ();
|
366
|
+
const market = this.market (symbol);
|
367
|
+
const request = {
|
368
|
+
'symbol': market['id'],
|
369
|
+
};
|
370
|
+
const response = await this.publicGetTickersSymbol (this.extend (request, params));
|
371
|
+
return this.parseTicker (response, market);
|
372
|
+
}
|
373
|
+
|
374
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
375
|
+
await this.loadMarkets ();
|
376
|
+
const tickers = await this.publicGetTickers (params);
|
377
|
+
return this.parseTickers (tickers, symbols);
|
378
|
+
}
|
379
|
+
|
380
|
+
parseOrderState (state) {
|
381
|
+
const states = {
|
382
|
+
'OPEN': 'open',
|
383
|
+
'REJECTED': 'rejected',
|
384
|
+
'FILLED': 'closed',
|
385
|
+
'CANCELED': 'canceled',
|
386
|
+
'PART_FILLED': 'open',
|
387
|
+
'EXPIRED': 'expired',
|
388
|
+
};
|
389
|
+
return this.safeString (states, state, state);
|
390
|
+
}
|
391
|
+
|
392
|
+
parseOrder (order, market = undefined) {
|
393
|
+
//
|
394
|
+
// {
|
395
|
+
// clOrdId: '00001',
|
396
|
+
// ordType: 'MARKET',
|
397
|
+
// ordStatus: 'FILLED',
|
398
|
+
// side: 'BUY',
|
399
|
+
// symbol: 'USDC-USDT',
|
400
|
+
// exOrdId: '281775861306290',
|
401
|
+
// price: null,
|
402
|
+
// text: 'Fill',
|
403
|
+
// lastShares: '30.0',
|
404
|
+
// lastPx: '0.9999',
|
405
|
+
// leavesQty: '0.0',
|
406
|
+
// cumQty: '30.0',
|
407
|
+
// avgPx: '0.9999',
|
408
|
+
// timestamp: '1633940339619'
|
409
|
+
// }
|
410
|
+
//
|
411
|
+
const clientOrderId = this.safeString (order, 'clOrdId');
|
412
|
+
const type = this.safeStringLower (order, 'ordType');
|
413
|
+
const statusId = this.safeString (order, 'ordStatus');
|
414
|
+
const state = this.parseOrderState (statusId);
|
415
|
+
const side = this.safeStringLower (order, 'side');
|
416
|
+
const marketId = this.safeString (order, 'symbol');
|
417
|
+
const symbol = this.safeSymbol (marketId, market, '-');
|
418
|
+
const exchangeOrderId = this.safeString (order, 'exOrdId');
|
419
|
+
const price = (type !== 'market') ? this.safeString (order, 'price') : undefined;
|
420
|
+
const average = this.safeNumber (order, 'avgPx');
|
421
|
+
const timestamp = this.safeInteger (order, 'timestamp');
|
422
|
+
const datetime = this.iso8601 (timestamp);
|
423
|
+
const filled = this.safeString (order, 'cumQty');
|
424
|
+
const remaining = this.safeString (order, 'leavesQty');
|
425
|
+
const result = this.safeOrder ({
|
426
|
+
'id': exchangeOrderId,
|
427
|
+
'clientOrderId': clientOrderId,
|
428
|
+
'datetime': datetime,
|
429
|
+
'timestamp': timestamp,
|
430
|
+
'lastTradeTimestamp': undefined,
|
431
|
+
'status': state,
|
432
|
+
'symbol': symbol,
|
433
|
+
'type': type,
|
434
|
+
'timeInForce': undefined,
|
435
|
+
'side': side,
|
436
|
+
'price': price,
|
437
|
+
'average': average,
|
438
|
+
'amount': undefined,
|
439
|
+
'filled': filled,
|
440
|
+
'remaining': remaining,
|
441
|
+
'cost': undefined,
|
442
|
+
'trades': [],
|
443
|
+
'fees': {},
|
444
|
+
'info': order,
|
445
|
+
});
|
446
|
+
return result;
|
447
|
+
}
|
448
|
+
|
449
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
450
|
+
await this.loadMarkets ();
|
451
|
+
const market = this.market (symbol);
|
452
|
+
const orderType = this.safeString (params, 'ordType', type);
|
453
|
+
const uppercaseOrderType = orderType.toUpperCase ();
|
454
|
+
const clientOrderId = this.safeString2 (params, 'clientOrderId', 'clOrdId', this.uuid16 ());
|
455
|
+
params = this.omit (params, [ 'ordType', 'clientOrderId', 'clOrdId' ]);
|
456
|
+
const request = {
|
457
|
+
// 'stopPx' : limit price
|
458
|
+
// 'timeInForce' : "GTC" for Good Till Cancel, "IOC" for Immediate or Cancel, "FOK" for Fill or Kill, "GTD" Good Till Date
|
459
|
+
// 'expireDate' : expiry date in the format YYYYMMDD
|
460
|
+
// 'minQty' : The minimum quantity required for an IOC fill
|
461
|
+
'ordType': uppercaseOrderType,
|
462
|
+
'symbol': market['id'],
|
463
|
+
'side': side.toUpperCase (),
|
464
|
+
'orderQty': this.amountToPrecision (symbol, amount),
|
465
|
+
'clOrdId': clientOrderId,
|
466
|
+
};
|
467
|
+
const stopPrice = this.safeValue2 (params, 'stopPx', 'stopPrice');
|
468
|
+
params = this.omit (params, [ 'stopPx', 'stopPrice' ]);
|
469
|
+
if (uppercaseOrderType === 'STOP' || uppercaseOrderType === 'STOPLIMIT') {
|
470
|
+
if (stopPrice === undefined) {
|
471
|
+
throw new ArgumentsRequired (this.id + ' createOrder() requires a stopPx or stopPrice param for a ' + uppercaseOrderType + ' order');
|
472
|
+
}
|
473
|
+
}
|
474
|
+
if (stopPrice !== undefined) {
|
475
|
+
if (uppercaseOrderType === 'MARKET') {
|
476
|
+
request['ordType'] = 'STOP';
|
477
|
+
} else if (uppercaseOrderType === 'LIMIT') {
|
478
|
+
request['ordType'] = 'STOPLIMIT';
|
479
|
+
}
|
480
|
+
}
|
481
|
+
let priceRequired = false;
|
482
|
+
let stopPriceRequired = false;
|
483
|
+
if (request['ordType'] === 'LIMIT' || request['ordType'] === 'STOPLIMIT') {
|
484
|
+
priceRequired = true;
|
485
|
+
}
|
486
|
+
if (request['ordType'] === 'STOP' || request['ordType'] === 'STOPLIMIT') {
|
487
|
+
stopPriceRequired = true;
|
488
|
+
}
|
489
|
+
if (priceRequired) {
|
490
|
+
request['price'] = this.priceToPrecision (symbol, price);
|
491
|
+
}
|
492
|
+
if (stopPriceRequired) {
|
493
|
+
request['stopPx'] = this.priceToPrecision (symbol, stopPrice);
|
494
|
+
}
|
495
|
+
const response = await this.privatePostOrders (this.extend (request, params));
|
496
|
+
return this.parseOrder (response, market);
|
497
|
+
}
|
498
|
+
|
499
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
500
|
+
const request = {
|
501
|
+
'orderId': id,
|
502
|
+
};
|
503
|
+
const response = await this.privateDeleteOrdersOrderId (this.extend (request, params));
|
504
|
+
return {
|
505
|
+
'id': id,
|
506
|
+
'info': response,
|
507
|
+
};
|
508
|
+
}
|
509
|
+
|
510
|
+
async cancelOrders (ids, symbol = undefined, params = {}) {
|
511
|
+
// cancels all open orders if no symbol specified
|
512
|
+
// cancels all open orders of specified symbol, if symbol is specified
|
513
|
+
await this.loadMarkets ();
|
514
|
+
const request = {
|
515
|
+
// 'symbol': marketId,
|
516
|
+
};
|
517
|
+
if (symbol !== undefined) {
|
518
|
+
const marketId = this.marketId (symbol);
|
519
|
+
request['symbol'] = marketId;
|
520
|
+
}
|
521
|
+
const response = await this.privateDeleteOrders (this.extend (request, params));
|
522
|
+
return {
|
523
|
+
'symbol': symbol,
|
524
|
+
'info': response,
|
525
|
+
};
|
526
|
+
}
|
527
|
+
|
528
|
+
async fetchTradingFees (params = {}) {
|
529
|
+
await this.loadMarkets ();
|
530
|
+
const response = await this.privateGetFees (params);
|
531
|
+
//
|
532
|
+
// {
|
533
|
+
// makerRate: "0.002",
|
534
|
+
// takerRate: "0.004",
|
535
|
+
// volumeInUSD: "0.0"
|
536
|
+
// }
|
537
|
+
//
|
538
|
+
const makerFee = this.safeNumber (response, 'makerRate');
|
539
|
+
const takerFee = this.safeNumber (response, 'takerRate');
|
540
|
+
const result = {};
|
541
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
542
|
+
const symbol = this.symbols[i];
|
543
|
+
result[symbol] = {
|
544
|
+
'info': response,
|
545
|
+
'symbol': symbol,
|
546
|
+
'maker': makerFee,
|
547
|
+
'taker': takerFee,
|
548
|
+
};
|
549
|
+
}
|
550
|
+
return result;
|
551
|
+
}
|
552
|
+
|
553
|
+
async fetchCanceledOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
554
|
+
const state = 'CANCELED';
|
555
|
+
return await this.fetchOrdersByState (state, symbol, since, limit, params);
|
556
|
+
}
|
557
|
+
|
558
|
+
async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
559
|
+
const state = 'FILLED';
|
560
|
+
return await this.fetchOrdersByState (state, symbol, since, limit, params);
|
561
|
+
}
|
562
|
+
|
563
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
564
|
+
const state = 'OPEN';
|
565
|
+
return await this.fetchOrdersByState (state, symbol, since, limit, params);
|
566
|
+
}
|
567
|
+
|
568
|
+
async fetchOrdersByState (state, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
569
|
+
await this.loadMarkets ();
|
570
|
+
const request = {
|
571
|
+
// 'to': unix epoch ms
|
572
|
+
// 'from': unix epoch ms
|
573
|
+
'status': state,
|
574
|
+
'limit': 100,
|
575
|
+
};
|
576
|
+
let market = undefined;
|
577
|
+
if (symbol !== undefined) {
|
578
|
+
market = this.market (symbol);
|
579
|
+
request['symbol'] = market['id'];
|
580
|
+
}
|
581
|
+
const response = await this.privateGetOrders (this.extend (request, params));
|
582
|
+
return this.parseOrders (response, market, since, limit);
|
583
|
+
}
|
584
|
+
|
585
|
+
parseTrade (trade, market = undefined) {
|
586
|
+
//
|
587
|
+
// {
|
588
|
+
// "exOrdId":281685751028507,
|
589
|
+
// "tradeId":281685434947633,
|
590
|
+
// "execId":8847494003,
|
591
|
+
// "side":"BUY",
|
592
|
+
// "symbol":"AAVE-USDT",
|
593
|
+
// "price":405.34,
|
594
|
+
// "qty":0.1,
|
595
|
+
// "fee":0.162136,
|
596
|
+
// "timestamp":1634559249687
|
597
|
+
// }
|
598
|
+
//
|
599
|
+
const orderId = this.safeString (trade, 'exOrdId');
|
600
|
+
const tradeId = this.safeString (trade, 'tradeId');
|
601
|
+
const side = this.safeString (trade, 'side').toLowerCase ();
|
602
|
+
const marketId = this.safeString (trade, 'symbol');
|
603
|
+
const priceString = this.safeString (trade, 'price');
|
604
|
+
const amountString = this.safeString (trade, 'qty');
|
605
|
+
const timestamp = this.safeInteger (trade, 'timestamp');
|
606
|
+
const datetime = this.iso8601 (timestamp);
|
607
|
+
market = this.safeMarket (marketId, market, '-');
|
608
|
+
const symbol = market['symbol'];
|
609
|
+
let fee = undefined;
|
610
|
+
const feeCostString = this.safeString (trade, 'fee');
|
611
|
+
if (feeCostString !== undefined) {
|
612
|
+
const feeCurrency = market['quote'];
|
613
|
+
fee = { 'cost': feeCostString, 'currency': feeCurrency };
|
614
|
+
}
|
615
|
+
return this.safeTrade ({
|
616
|
+
'id': tradeId,
|
617
|
+
'timestamp': timestamp,
|
618
|
+
'datetime': datetime,
|
619
|
+
'symbol': symbol,
|
620
|
+
'order': orderId,
|
621
|
+
'type': undefined,
|
622
|
+
'side': side,
|
623
|
+
'takerOrMaker': undefined,
|
624
|
+
'price': priceString,
|
625
|
+
'amount': amountString,
|
626
|
+
'cost': undefined,
|
627
|
+
'fee': fee,
|
628
|
+
'info': trade,
|
629
|
+
}, market);
|
630
|
+
}
|
631
|
+
|
632
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
633
|
+
await this.loadMarkets ();
|
634
|
+
const request = {};
|
635
|
+
if (limit !== undefined) {
|
636
|
+
request['limit'] = limit;
|
637
|
+
}
|
638
|
+
let market = undefined;
|
639
|
+
if (symbol !== undefined) {
|
640
|
+
request['symbol'] = this.marketId (symbol);
|
641
|
+
market = this.market (symbol);
|
642
|
+
}
|
643
|
+
const trades = await this.privateGetFills (this.extend (request, params));
|
644
|
+
return this.parseTrades (trades, market, since, limit, params); // need to define
|
645
|
+
}
|
646
|
+
|
647
|
+
async fetchDepositAddress (code, params = {}) {
|
648
|
+
await this.loadMarkets ();
|
649
|
+
const currency = this.currency (code);
|
650
|
+
const request = {
|
651
|
+
'currency': currency['id'],
|
652
|
+
};
|
653
|
+
const response = await this.privatePostDepositsCurrency (this.extend (request, params));
|
654
|
+
const rawAddress = this.safeString (response, 'address');
|
655
|
+
let tag = undefined;
|
656
|
+
let address = undefined;
|
657
|
+
if (rawAddress !== undefined) {
|
658
|
+
// if a tag or memo is used it is separated by a colon in the 'address' value
|
659
|
+
[ address, tag ] = rawAddress.split (':');
|
660
|
+
}
|
661
|
+
const result = { 'info': response };
|
662
|
+
result['currency'] = currency['code'];
|
663
|
+
result['address'] = address;
|
664
|
+
if (tag !== undefined) {
|
665
|
+
result['tag'] = tag;
|
666
|
+
}
|
667
|
+
return result;
|
668
|
+
}
|
669
|
+
|
670
|
+
parseTransactionState (state) {
|
671
|
+
const states = {
|
672
|
+
'COMPLETED': 'ok', //
|
673
|
+
'REJECTED': 'failed',
|
674
|
+
'PENDING': 'pending',
|
675
|
+
'FAILED': 'failed',
|
676
|
+
'REFUNDED': 'refunded',
|
677
|
+
};
|
678
|
+
return this.safeString (states, state, state);
|
679
|
+
}
|
680
|
+
|
681
|
+
parseTransaction (transaction, currency = undefined) {
|
682
|
+
//
|
683
|
+
// deposit
|
684
|
+
//
|
685
|
+
// {
|
686
|
+
// "depositId":"748e9180-be0d-4a80-e175-0156150efc95",
|
687
|
+
// "amount":0.009,
|
688
|
+
// "currency":"ETH",
|
689
|
+
// "address":"0xEC6B5929D454C8D9546d4221ace969E1810Fa92c",
|
690
|
+
// "state":"COMPLETED",
|
691
|
+
// "txHash":"582114562140e51a80b481c2dfebaf62b4ab9769b8ff54820bb67e34d4a3ab0c",
|
692
|
+
// "timestamp":1633697196241
|
693
|
+
// }
|
694
|
+
//
|
695
|
+
// withdrawal
|
696
|
+
//
|
697
|
+
// {
|
698
|
+
// "amount":30.0,
|
699
|
+
// "currency":"USDT",
|
700
|
+
// "beneficiary":"cab00d11-6e7f-46b7-b453-2e8ef6f101fa", // blockchain specific id
|
701
|
+
// "withdrawalId":"99df5ef7-eab6-4033-be49-312930fbd1ea",
|
702
|
+
// "fee":34.005078,
|
703
|
+
// "state":"COMPLETED",
|
704
|
+
// "timestamp":1634218452549
|
705
|
+
// }
|
706
|
+
//
|
707
|
+
let type = undefined;
|
708
|
+
let id = undefined;
|
709
|
+
const amount = this.safeNumber (transaction, 'amount');
|
710
|
+
const timestamp = this.safeInteger (transaction, 'timestamp');
|
711
|
+
const currencyId = this.safeString (transaction, 'currency');
|
712
|
+
const code = this.safeCurrencyCode (currencyId, currency);
|
713
|
+
const state = this.safeString (transaction, 'state');
|
714
|
+
if ('depositId' in transaction) {
|
715
|
+
type = 'deposit';
|
716
|
+
id = this.safeString (transaction, 'depositId');
|
717
|
+
} else if ('withdrawalId' in transaction) {
|
718
|
+
type = 'withdrawal';
|
719
|
+
id = this.safeString (transaction, 'withdrawalId');
|
720
|
+
}
|
721
|
+
const feeCost = (type === 'withdrawal') ? this.safeNumber (transaction, 'fee') : undefined;
|
722
|
+
let fee = undefined;
|
723
|
+
if (feeCost !== undefined) {
|
724
|
+
fee = { 'currency': code, 'cost': feeCost };
|
725
|
+
}
|
726
|
+
const address = this.safeString (transaction, 'address');
|
727
|
+
const txid = this.safeString (transaction, 'txhash');
|
728
|
+
const result = {
|
729
|
+
'info': transaction,
|
730
|
+
'id': id,
|
731
|
+
'txid': txid,
|
732
|
+
'timestamp': timestamp,
|
733
|
+
'datetime': this.iso8601 (timestamp),
|
734
|
+
'network': undefined,
|
735
|
+
'addressFrom': undefined,
|
736
|
+
'address': address,
|
737
|
+
'addressTo': address,
|
738
|
+
'tagFrom': undefined,
|
739
|
+
'tag': undefined,
|
740
|
+
'tagTo': undefined,
|
741
|
+
'type': type,
|
742
|
+
'amount': amount,
|
743
|
+
'currency': code,
|
744
|
+
'status': this.parseTransactionState (state), // 'status': 'pending', // 'ok', 'failed', 'canceled', string
|
745
|
+
'updated': undefined,
|
746
|
+
'comment': undefined,
|
747
|
+
'fee': fee,
|
748
|
+
};
|
749
|
+
return result;
|
750
|
+
}
|
751
|
+
|
752
|
+
async fetchWithdrawalWhitelist (params = {}) {
|
753
|
+
await this.loadMarkets ();
|
754
|
+
const response = await this.privateGetWhitelist ();
|
755
|
+
const result = [];
|
756
|
+
for (let i = 0; i < response.length; i++) {
|
757
|
+
const entry = response[i];
|
758
|
+
result.push ({
|
759
|
+
'beneficiaryId': this.safeString (entry, 'whitelistId'),
|
760
|
+
'name': this.safeString (entry, 'name'),
|
761
|
+
'currency': this.safeString (entry, 'currency'),
|
762
|
+
'info': entry,
|
763
|
+
});
|
764
|
+
}
|
765
|
+
return result;
|
766
|
+
}
|
767
|
+
|
768
|
+
async fetchWithdrawalWhitelistByCurrency (currency, params = {}) {
|
769
|
+
await this.loadMarkets ();
|
770
|
+
const request = {
|
771
|
+
'currency': this.currencyId (currency),
|
772
|
+
};
|
773
|
+
const response = await this.privateGetWhitelistCurrency (this.extend (request, params));
|
774
|
+
const result = [];
|
775
|
+
for (let i = 0; i < response.length; i++) {
|
776
|
+
const entry = response[i];
|
777
|
+
result.push ({
|
778
|
+
'beneficiaryId': this.safeString (entry, 'whitelistId'),
|
779
|
+
'name': this.safeString (entry, 'name'),
|
780
|
+
'currency': this.safeString (entry, 'currency'),
|
781
|
+
'info': entry,
|
782
|
+
});
|
783
|
+
}
|
784
|
+
return result;
|
785
|
+
}
|
786
|
+
|
787
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
788
|
+
await this.loadMarkets ();
|
789
|
+
const currency = this.currency (code);
|
790
|
+
const request = {
|
791
|
+
'amount': amount,
|
792
|
+
'currency': currency['id'],
|
793
|
+
// 'beneficiary': address/id,
|
794
|
+
'sendMax': false,
|
795
|
+
};
|
796
|
+
const response = await this.privatePostWithdrawals (this.extend (request, params));
|
797
|
+
//
|
798
|
+
// {
|
799
|
+
// amount: "30.0",
|
800
|
+
// currency: "USDT",
|
801
|
+
// beneficiary: "adcd43fb-9ba6-41f7-8c0d-7013482cb88f",
|
802
|
+
// withdrawalId: "99df5ef7-eab6-4033-be49-312930fbd1ea",
|
803
|
+
// fee: "34.005078",
|
804
|
+
// state: "PENDING",
|
805
|
+
// timestamp: "1634218452595"
|
806
|
+
// },
|
807
|
+
//
|
808
|
+
return this.parseTransaction (response, currency);
|
809
|
+
}
|
810
|
+
|
811
|
+
async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) {
|
812
|
+
await this.loadMarkets ();
|
813
|
+
const request = {
|
814
|
+
// 'from' : integer timestamp in ms
|
815
|
+
// 'to' : integer timestamp in ms
|
816
|
+
};
|
817
|
+
if (since !== undefined) {
|
818
|
+
request['from'] = since;
|
819
|
+
}
|
820
|
+
const response = await this.privateGetWithdrawals (this.extend (request, params));
|
821
|
+
return this.parseTransactions (response, code, since, limit);
|
822
|
+
}
|
823
|
+
|
824
|
+
async fetchWithdrawal (id, code = undefined, params = {}) {
|
825
|
+
await this.loadMarkets ();
|
826
|
+
const request = {
|
827
|
+
'withdrawalId': id,
|
828
|
+
};
|
829
|
+
const response = await this.privateGetWithdrawalsWithdrawalId (this.extend (request, params));
|
830
|
+
return this.parseTransaction (response);
|
831
|
+
}
|
832
|
+
|
833
|
+
async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) {
|
834
|
+
await this.loadMarkets ();
|
835
|
+
const request = {
|
836
|
+
// 'from' : integer timestamp in ms
|
837
|
+
// 'to' : integer timestap in ms
|
838
|
+
};
|
839
|
+
if (since !== undefined) {
|
840
|
+
request['from'] = since;
|
841
|
+
}
|
842
|
+
const response = await this.privateGetDeposits (this.extend (request, params));
|
843
|
+
return this.parseTransactions (response, code, since, limit);
|
844
|
+
}
|
845
|
+
|
846
|
+
async fetchDeposit (id, code = undefined, params = {}) {
|
847
|
+
await this.loadMarkets ();
|
848
|
+
const depositId = this.safeString (params, 'depositId', id);
|
849
|
+
const request = {
|
850
|
+
'depositId': depositId,
|
851
|
+
};
|
852
|
+
const deposit = await this.privateGetDepositsDepositId (this.extend (request, params));
|
853
|
+
return this.parseTransaction (deposit);
|
854
|
+
}
|
855
|
+
|
856
|
+
async fetchBalance (params = {}) {
|
857
|
+
await this.loadMarkets ();
|
858
|
+
const accountName = this.safeString (params, 'account', 'primary');
|
859
|
+
params = this.omit (params, 'account');
|
860
|
+
const request = {
|
861
|
+
'account': accountName,
|
862
|
+
};
|
863
|
+
const response = await this.privateGetAccounts (this.extend (request, params));
|
864
|
+
//
|
865
|
+
// {
|
866
|
+
// "primary": [
|
867
|
+
// {
|
868
|
+
// "currency":"ETH",
|
869
|
+
// "balance":0.009,
|
870
|
+
// "available":0.009,
|
871
|
+
// "balance_local":30.82869,
|
872
|
+
// "available_local":30.82869,
|
873
|
+
// "rate":3425.41
|
874
|
+
// },
|
875
|
+
// ...
|
876
|
+
// ]
|
877
|
+
// }
|
878
|
+
//
|
879
|
+
const balances = this.safeValue (response, accountName);
|
880
|
+
if (balances === undefined) {
|
881
|
+
throw new ExchangeError (this.id + ' fetchBalance() could not find the "' + accountName + '" account');
|
882
|
+
}
|
883
|
+
const result = { 'info': response };
|
884
|
+
for (let i = 0; i < balances.length; i++) {
|
885
|
+
const entry = balances[i];
|
886
|
+
const currencyId = this.safeString (entry, 'currency');
|
887
|
+
const code = this.safeCurrencyCode (currencyId);
|
888
|
+
const account = this.account ();
|
889
|
+
account['free'] = this.safeString (entry, 'available');
|
890
|
+
account['total'] = this.safeString (entry, 'balance');
|
891
|
+
result[code] = account;
|
892
|
+
}
|
893
|
+
return this.safeBalance (result);
|
894
|
+
}
|
895
|
+
|
896
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
897
|
+
// note: only works with exchange-order-id
|
898
|
+
// does not work with clientOrderId
|
899
|
+
await this.loadMarkets ();
|
900
|
+
const request = {
|
901
|
+
'orderId': id,
|
902
|
+
};
|
903
|
+
const response = await this.privateGetOrdersOrderId (this.extend (request, params));
|
904
|
+
//
|
905
|
+
// {
|
906
|
+
// "exOrdId": 11111111,
|
907
|
+
// "clOrdId": "ABC",
|
908
|
+
// "ordType": "MARKET",
|
909
|
+
// "ordStatus": "FILLED",
|
910
|
+
// "side": "BUY",
|
911
|
+
// "price": 0.12345,
|
912
|
+
// "text": "string",
|
913
|
+
// "symbol": "BTC-USD",
|
914
|
+
// "lastShares": 0.5678,
|
915
|
+
// "lastPx": 3500.12,
|
916
|
+
// "leavesQty": 10,
|
917
|
+
// "cumQty": 0.123345,
|
918
|
+
// "avgPx": 345.33,
|
919
|
+
// "timestamp": 1592830770594
|
920
|
+
// }
|
921
|
+
//
|
922
|
+
return this.parseOrder (response);
|
923
|
+
}
|
924
|
+
|
925
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
926
|
+
const requestPath = '/' + this.implodeParams (path, params);
|
927
|
+
let url = this.urls['api'][api] + requestPath;
|
928
|
+
const query = this.omit (params, this.extractParams (path));
|
929
|
+
if (api === 'public') {
|
930
|
+
if (Object.keys (query).length) {
|
931
|
+
url += '?' + this.urlencode (query);
|
932
|
+
}
|
933
|
+
} else if (api === 'private') {
|
934
|
+
this.checkRequiredCredentials ();
|
935
|
+
headers = {
|
936
|
+
'X-API-Token': this.secret,
|
937
|
+
};
|
938
|
+
if ((method === 'GET')) {
|
939
|
+
if (Object.keys (query).length) {
|
940
|
+
url += '?' + this.urlencode (query);
|
941
|
+
}
|
942
|
+
} else {
|
943
|
+
body = this.json (query);
|
944
|
+
headers['Content-Type'] = 'application/json';
|
945
|
+
}
|
946
|
+
}
|
947
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
948
|
+
}
|
949
|
+
|
950
|
+
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
951
|
+
// {"timestamp":"2021-10-21T15:13:58.837+00:00","status":404,"error":"Not Found","message":"","path":"/orders/505050"
|
952
|
+
if (response === undefined) {
|
953
|
+
return;
|
954
|
+
}
|
955
|
+
const text = this.safeString (response, 'text');
|
956
|
+
if (text !== undefined) { // if trade currency account is empty returns 200 with rejected order
|
957
|
+
if (text === 'Insufficient Balance') {
|
958
|
+
throw new InsufficientFunds (this.id + ' ' + body);
|
959
|
+
}
|
960
|
+
}
|
961
|
+
const errorCode = this.safeString (response, 'status');
|
962
|
+
const errorMessage = this.safeString (response, 'error');
|
963
|
+
if (code !== undefined) {
|
964
|
+
const feedback = this.id + ' ' + this.json (response);
|
965
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback);
|
966
|
+
this.throwBroadlyMatchedException (this.exceptions['broad'], errorMessage, feedback);
|
967
|
+
}
|
968
|
+
}
|
969
|
+
};
|