ccxt 4.3.28 → 4.3.30
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/README.md +3 -3
- package/dist/ccxt.browser.min.js +30 -0
- package/dist/ccxt.browser.min.js.LICENSE.txt +12 -0
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/base/ws/OrderBookSide.js +4 -4
- package/dist/cjs/src/bingx.js +98 -84
- package/dist/cjs/src/bitmart.js +72 -0
- package/dist/cjs/src/coinex.js +260 -311
- package/dist/cjs/src/kucoin.js +1 -0
- package/dist/cjs/src/pro/bitfinex.js +4 -4
- package/dist/cjs/src/pro/bitfinex2.js +2 -2
- package/dist/cjs/src/pro/bitmex.js +3 -3
- package/dist/cjs/src/pro/blockchaincom.js +2 -2
- package/dist/cjs/src/pro/cryptocom.js +4 -4
- package/dist/cjs/src/pro/deribit.js +9 -9
- package/dist/cjs/src/pro/idex.js +1 -1
- package/dist/cjs/src/pro/luno.js +4 -5
- package/dist/cjs/src/pro/mexc.js +2 -2
- package/dist/cjs/src/whitebit.js +55 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +7 -0
- package/js/src/abstract/bitmart.d.ts +1 -0
- package/js/src/base/Exchange.js +6 -0
- package/js/src/base/ws/Cache.d.ts +1 -1
- package/js/src/base/ws/OrderBookSide.d.ts +4 -5
- package/js/src/base/ws/OrderBookSide.js +4 -4
- package/js/src/bingx.js +98 -84
- package/js/src/bitmart.d.ts +2 -1
- package/js/src/bitmart.js +72 -0
- package/js/src/coinex.d.ts +5 -6
- package/js/src/coinex.js +260 -311
- package/js/src/kucoin.js +1 -0
- package/js/src/pro/bitfinex.js +4 -4
- package/js/src/pro/bitfinex2.js +2 -2
- package/js/src/pro/bitmex.js +3 -3
- package/js/src/pro/blockchaincom.js +2 -2
- package/js/src/pro/cryptocom.js +4 -4
- package/js/src/pro/deribit.js +9 -9
- package/js/src/pro/idex.js +1 -1
- package/js/src/pro/luno.js +4 -5
- package/js/src/pro/mexc.js +2 -2
- package/js/src/whitebit.d.ts +2 -0
- package/js/src/whitebit.js +55 -5
- package/package.json +4 -2
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -76,7 +76,7 @@ class coinex extends coinex$1 {
|
|
|
76
76
|
'fetchFundingRates': true,
|
|
77
77
|
'fetchIndexOHLCV': false,
|
|
78
78
|
'fetchIsolatedBorrowRate': true,
|
|
79
|
-
'fetchIsolatedBorrowRates':
|
|
79
|
+
'fetchIsolatedBorrowRates': false,
|
|
80
80
|
'fetchLeverage': 'emulated',
|
|
81
81
|
'fetchLeverages': true,
|
|
82
82
|
'fetchLeverageTiers': true,
|
|
@@ -4779,113 +4779,106 @@ class coinex extends coinex$1 {
|
|
|
4779
4779
|
//
|
|
4780
4780
|
// fetchDeposits
|
|
4781
4781
|
//
|
|
4782
|
-
//
|
|
4783
|
-
//
|
|
4784
|
-
//
|
|
4785
|
-
//
|
|
4786
|
-
//
|
|
4787
|
-
//
|
|
4788
|
-
//
|
|
4789
|
-
//
|
|
4790
|
-
//
|
|
4791
|
-
//
|
|
4792
|
-
//
|
|
4793
|
-
//
|
|
4794
|
-
//
|
|
4795
|
-
//
|
|
4796
|
-
//
|
|
4797
|
-
//
|
|
4798
|
-
//
|
|
4799
|
-
// "transfer_method": "onchain",
|
|
4800
|
-
// "status": "finish",
|
|
4801
|
-
// "status_display": "finish",
|
|
4802
|
-
// "remark": "",
|
|
4803
|
-
// "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
|
4804
|
-
// }
|
|
4782
|
+
// {
|
|
4783
|
+
// "deposit_id": 5173806,
|
|
4784
|
+
// "created_at": 1714021652557,
|
|
4785
|
+
// "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
|
|
4786
|
+
// "tx_id_display": "",
|
|
4787
|
+
// "ccy": "USDT",
|
|
4788
|
+
// "chain": "TRC20",
|
|
4789
|
+
// "deposit_method": "ON_CHAIN",
|
|
4790
|
+
// "amount": "30",
|
|
4791
|
+
// "actual_amount": "",
|
|
4792
|
+
// "to_address": "TYewD2pVWDUwfNr9A",
|
|
4793
|
+
// "confirmations": 20,
|
|
4794
|
+
// "status": "FINISHED",
|
|
4795
|
+
// "tx_explorer_url": "https://tronscan.org/#/transaction",
|
|
4796
|
+
// "to_addr_explorer_url": "https://tronscan.org/#/address",
|
|
4797
|
+
// "remark": ""
|
|
4798
|
+
// }
|
|
4805
4799
|
//
|
|
4806
4800
|
// fetchWithdrawals
|
|
4807
4801
|
//
|
|
4808
|
-
//
|
|
4809
|
-
//
|
|
4810
|
-
//
|
|
4811
|
-
//
|
|
4812
|
-
//
|
|
4813
|
-
//
|
|
4814
|
-
//
|
|
4815
|
-
//
|
|
4816
|
-
//
|
|
4817
|
-
//
|
|
4818
|
-
//
|
|
4819
|
-
//
|
|
4820
|
-
//
|
|
4821
|
-
//
|
|
4822
|
-
//
|
|
4823
|
-
//
|
|
4824
|
-
//
|
|
4825
|
-
//
|
|
4826
|
-
//
|
|
4827
|
-
//
|
|
4828
|
-
// "tx_fee": "0.001",
|
|
4829
|
-
// "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
|
|
4830
|
-
// }
|
|
4802
|
+
// {
|
|
4803
|
+
// "withdraw_id": 259364,
|
|
4804
|
+
// "created_at": 1701323541548,
|
|
4805
|
+
// "withdraw_method": "ON_CHAIN",
|
|
4806
|
+
// "ccy": "USDT",
|
|
4807
|
+
// "amount": "23.845744",
|
|
4808
|
+
// "actual_amount": "22.445744",
|
|
4809
|
+
// "chain": "TRC20",
|
|
4810
|
+
// "tx_fee": "1.4",
|
|
4811
|
+
// "fee_asset": "USDT",
|
|
4812
|
+
// "fee_amount": "1.4",
|
|
4813
|
+
// "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
|
|
4814
|
+
// "memo": "",
|
|
4815
|
+
// "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
|
|
4816
|
+
// "confirmations": 18,
|
|
4817
|
+
// "explorer_address_url": "https://tronscan.org/#/address",
|
|
4818
|
+
// "explorer_tx_url": "https://tronscan.org/#/transaction",
|
|
4819
|
+
// "remark": "",
|
|
4820
|
+
// "status": "finished"
|
|
4821
|
+
// }
|
|
4831
4822
|
//
|
|
4832
|
-
const
|
|
4833
|
-
|
|
4834
|
-
let tag = this.safeString(transaction, 'remark'); // set but unused
|
|
4823
|
+
const address = this.safeString(transaction, 'to_address');
|
|
4824
|
+
let tag = this.safeString(transaction, 'memo');
|
|
4835
4825
|
if (tag !== undefined) {
|
|
4836
4826
|
if (tag.length < 1) {
|
|
4837
4827
|
tag = undefined;
|
|
4838
4828
|
}
|
|
4839
4829
|
}
|
|
4840
|
-
let
|
|
4830
|
+
let remark = this.safeString(transaction, 'remark');
|
|
4831
|
+
if (remark !== undefined) {
|
|
4832
|
+
if (remark.length < 1) {
|
|
4833
|
+
remark = undefined;
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
let txid = this.safeString(transaction, 'tx_id');
|
|
4841
4837
|
if (txid !== undefined) {
|
|
4842
4838
|
if (txid.length < 1) {
|
|
4843
4839
|
txid = undefined;
|
|
4844
4840
|
}
|
|
4845
4841
|
}
|
|
4846
|
-
const currencyId = this.safeString(transaction, '
|
|
4842
|
+
const currencyId = this.safeString(transaction, 'ccy');
|
|
4847
4843
|
const code = this.safeCurrencyCode(currencyId, currency);
|
|
4848
|
-
const timestamp = this.
|
|
4849
|
-
const type = ('
|
|
4850
|
-
const
|
|
4851
|
-
const networkId = this.safeString(transaction, 'smart_contract_name');
|
|
4852
|
-
const amount = this.safeNumber(transaction, 'actual_amount');
|
|
4844
|
+
const timestamp = this.safeInteger(transaction, 'created_at');
|
|
4845
|
+
const type = ('withdraw_id' in transaction) ? 'withdrawal' : 'deposit';
|
|
4846
|
+
const networkId = this.safeString(transaction, 'chain');
|
|
4853
4847
|
let feeCost = this.safeString(transaction, 'tx_fee');
|
|
4854
|
-
const transferMethod = this.
|
|
4848
|
+
const transferMethod = this.safeStringLower2(transaction, 'withdraw_method', 'deposit_method');
|
|
4855
4849
|
const internal = transferMethod === 'local';
|
|
4856
|
-
let
|
|
4857
|
-
|
|
4850
|
+
let amount = this.safeNumber(transaction, 'actual_amount');
|
|
4851
|
+
if (amount === undefined) {
|
|
4852
|
+
amount = this.safeNumber(transaction, 'amount');
|
|
4853
|
+
}
|
|
4858
4854
|
if (type === 'deposit') {
|
|
4859
4855
|
feeCost = '0';
|
|
4860
|
-
addressTo = address;
|
|
4861
|
-
}
|
|
4862
|
-
else {
|
|
4863
|
-
addressFrom = address;
|
|
4864
4856
|
}
|
|
4857
|
+
const feeCurrencyId = this.safeString(transaction, 'fee_asset');
|
|
4865
4858
|
const fee = {
|
|
4866
4859
|
'cost': this.parseNumber(feeCost),
|
|
4867
|
-
'currency':
|
|
4860
|
+
'currency': this.safeCurrencyCode(feeCurrencyId),
|
|
4868
4861
|
};
|
|
4869
4862
|
return {
|
|
4870
4863
|
'info': transaction,
|
|
4871
|
-
'id':
|
|
4864
|
+
'id': this.safeString2(transaction, 'withdraw_id', 'deposit_id'),
|
|
4872
4865
|
'txid': txid,
|
|
4873
4866
|
'timestamp': timestamp,
|
|
4874
4867
|
'datetime': this.iso8601(timestamp),
|
|
4875
4868
|
'network': this.networkIdToCode(networkId),
|
|
4876
4869
|
'address': address,
|
|
4877
|
-
'addressTo':
|
|
4870
|
+
'addressTo': address,
|
|
4878
4871
|
'addressFrom': undefined,
|
|
4879
4872
|
'tag': tag,
|
|
4880
|
-
'tagTo':
|
|
4881
|
-
'tagFrom':
|
|
4873
|
+
'tagTo': undefined,
|
|
4874
|
+
'tagFrom': undefined,
|
|
4882
4875
|
'type': type,
|
|
4883
|
-
'amount':
|
|
4876
|
+
'amount': amount,
|
|
4884
4877
|
'currency': code,
|
|
4885
|
-
'status': status,
|
|
4878
|
+
'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
|
|
4886
4879
|
'updated': undefined,
|
|
4887
4880
|
'fee': fee,
|
|
4888
|
-
'comment':
|
|
4881
|
+
'comment': remark,
|
|
4889
4882
|
'internal': internal,
|
|
4890
4883
|
};
|
|
4891
4884
|
}
|
|
@@ -5032,66 +5025,57 @@ class coinex extends coinex$1 {
|
|
|
5032
5025
|
* @method
|
|
5033
5026
|
* @name coinex#fetchWithdrawals
|
|
5034
5027
|
* @description fetch all withdrawals made from an account
|
|
5035
|
-
* @see https://
|
|
5036
|
-
* @param {string} code unified currency code
|
|
5028
|
+
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
|
|
5029
|
+
* @param {string} [code] unified currency code
|
|
5037
5030
|
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
5038
|
-
* @param {int} [limit] the maximum number of
|
|
5031
|
+
* @param {int} [limit] the maximum number of withdrawal structures to retrieve
|
|
5039
5032
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5040
5033
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
5041
5034
|
*/
|
|
5035
|
+
await this.loadMarkets();
|
|
5042
5036
|
const request = {};
|
|
5043
5037
|
let currency = undefined;
|
|
5044
5038
|
if (code !== undefined) {
|
|
5045
|
-
await this.loadMarkets();
|
|
5046
5039
|
currency = this.currency(code);
|
|
5047
|
-
request['
|
|
5040
|
+
request['ccy'] = currency['id'];
|
|
5048
5041
|
}
|
|
5049
5042
|
if (limit !== undefined) {
|
|
5050
|
-
request['
|
|
5043
|
+
request['limit'] = limit;
|
|
5051
5044
|
}
|
|
5052
|
-
const response = await this.
|
|
5045
|
+
const response = await this.v2PrivateGetAssetsWithdraw(this.extend(request, params));
|
|
5053
5046
|
//
|
|
5054
|
-
//
|
|
5055
|
-
//
|
|
5056
|
-
//
|
|
5057
|
-
//
|
|
5058
|
-
//
|
|
5059
|
-
//
|
|
5060
|
-
//
|
|
5061
|
-
//
|
|
5062
|
-
//
|
|
5063
|
-
//
|
|
5064
|
-
//
|
|
5065
|
-
//
|
|
5066
|
-
//
|
|
5067
|
-
//
|
|
5068
|
-
//
|
|
5069
|
-
//
|
|
5070
|
-
//
|
|
5071
|
-
//
|
|
5072
|
-
//
|
|
5073
|
-
//
|
|
5074
|
-
//
|
|
5075
|
-
//
|
|
5076
|
-
//
|
|
5077
|
-
//
|
|
5078
|
-
//
|
|
5079
|
-
//
|
|
5080
|
-
//
|
|
5081
|
-
//
|
|
5082
|
-
//
|
|
5083
|
-
//
|
|
5084
|
-
// ],
|
|
5085
|
-
// "total": 1,
|
|
5086
|
-
// "total_page": 1
|
|
5087
|
-
// },
|
|
5088
|
-
// "message": "Success"
|
|
5089
|
-
// }
|
|
5047
|
+
// {
|
|
5048
|
+
// "data": [
|
|
5049
|
+
// {
|
|
5050
|
+
// "withdraw_id": 259364,
|
|
5051
|
+
// "created_at": 1701323541548,
|
|
5052
|
+
// "withdraw_method": "ON_CHAIN",
|
|
5053
|
+
// "ccy": "USDT",
|
|
5054
|
+
// "amount": "23.845744",
|
|
5055
|
+
// "actual_amount": "22.445744",
|
|
5056
|
+
// "chain": "TRC20",
|
|
5057
|
+
// "tx_fee": "1.4",
|
|
5058
|
+
// "fee_asset": "USDT",
|
|
5059
|
+
// "fee_amount": "1.4",
|
|
5060
|
+
// "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
|
|
5061
|
+
// "memo": "",
|
|
5062
|
+
// "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
|
|
5063
|
+
// "confirmations": 18,
|
|
5064
|
+
// "explorer_address_url": "https://tronscan.org/#/address",
|
|
5065
|
+
// "explorer_tx_url": "https://tronscan.org/#/transaction",
|
|
5066
|
+
// "remark": "",
|
|
5067
|
+
// "status": "finished"
|
|
5068
|
+
// },
|
|
5069
|
+
// ],
|
|
5070
|
+
// "pagination": {
|
|
5071
|
+
// "total": 9,
|
|
5072
|
+
// "has_next": true
|
|
5073
|
+
// },
|
|
5074
|
+
// "code": 0,
|
|
5075
|
+
// "message": "OK"
|
|
5076
|
+
// }
|
|
5090
5077
|
//
|
|
5091
|
-
|
|
5092
|
-
if (!Array.isArray(data)) {
|
|
5093
|
-
data = this.safeValue(data, 'data', []);
|
|
5094
|
-
}
|
|
5078
|
+
const data = this.safeList(response, 'data', []);
|
|
5095
5079
|
return this.parseTransactions(data, currency, since, limit);
|
|
5096
5080
|
}
|
|
5097
5081
|
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -5099,95 +5083,85 @@ class coinex extends coinex$1 {
|
|
|
5099
5083
|
* @method
|
|
5100
5084
|
* @name coinex#fetchDeposits
|
|
5101
5085
|
* @description fetch all deposits made to an account
|
|
5102
|
-
* @see https://
|
|
5103
|
-
* @param {string} code unified currency code
|
|
5086
|
+
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
|
|
5087
|
+
* @param {string} [code] unified currency code
|
|
5104
5088
|
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
5105
|
-
* @param {int} [limit] the maximum number of
|
|
5089
|
+
* @param {int} [limit] the maximum number of deposit structures to retrieve
|
|
5106
5090
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5107
5091
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
5108
5092
|
*/
|
|
5093
|
+
await this.loadMarkets();
|
|
5109
5094
|
const request = {};
|
|
5110
5095
|
let currency = undefined;
|
|
5111
5096
|
if (code !== undefined) {
|
|
5112
|
-
await this.loadMarkets();
|
|
5113
5097
|
currency = this.currency(code);
|
|
5114
|
-
request['
|
|
5098
|
+
request['ccy'] = currency['id'];
|
|
5115
5099
|
}
|
|
5116
5100
|
if (limit !== undefined) {
|
|
5117
|
-
request['
|
|
5101
|
+
request['limit'] = limit;
|
|
5118
5102
|
}
|
|
5119
|
-
const response = await this.
|
|
5103
|
+
const response = await this.v2PrivateGetAssetsDepositHistory(this.extend(request, params));
|
|
5120
5104
|
//
|
|
5121
|
-
//
|
|
5122
|
-
//
|
|
5123
|
-
//
|
|
5124
|
-
//
|
|
5125
|
-
//
|
|
5126
|
-
//
|
|
5127
|
-
//
|
|
5128
|
-
//
|
|
5129
|
-
//
|
|
5130
|
-
//
|
|
5131
|
-
//
|
|
5132
|
-
//
|
|
5133
|
-
//
|
|
5134
|
-
//
|
|
5135
|
-
//
|
|
5136
|
-
//
|
|
5137
|
-
//
|
|
5138
|
-
//
|
|
5139
|
-
//
|
|
5140
|
-
//
|
|
5141
|
-
//
|
|
5142
|
-
//
|
|
5143
|
-
//
|
|
5144
|
-
//
|
|
5145
|
-
//
|
|
5146
|
-
//
|
|
5147
|
-
//
|
|
5148
|
-
// "remark": "",
|
|
5149
|
-
// "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
|
|
5150
|
-
// }
|
|
5151
|
-
// ],
|
|
5152
|
-
// "total": 1,
|
|
5153
|
-
// "total_page": 1
|
|
5154
|
-
// },
|
|
5155
|
-
// "message": "Success"
|
|
5156
|
-
// }
|
|
5105
|
+
// {
|
|
5106
|
+
// "data": [
|
|
5107
|
+
// {
|
|
5108
|
+
// "deposit_id": 5173806,
|
|
5109
|
+
// "created_at": 1714021652557,
|
|
5110
|
+
// "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
|
|
5111
|
+
// "tx_id_display": "",
|
|
5112
|
+
// "ccy": "USDT",
|
|
5113
|
+
// "chain": "TRC20",
|
|
5114
|
+
// "deposit_method": "ON_CHAIN",
|
|
5115
|
+
// "amount": "30",
|
|
5116
|
+
// "actual_amount": "",
|
|
5117
|
+
// "to_address": "TYewD2pVWDUwfNr9A",
|
|
5118
|
+
// "confirmations": 20,
|
|
5119
|
+
// "status": "FINISHED",
|
|
5120
|
+
// "tx_explorer_url": "https://tronscan.org/#/transaction",
|
|
5121
|
+
// "to_addr_explorer_url": "https://tronscan.org/#/address",
|
|
5122
|
+
// "remark": ""
|
|
5123
|
+
// },
|
|
5124
|
+
// ],
|
|
5125
|
+
// "paginatation": {
|
|
5126
|
+
// "total": 8,
|
|
5127
|
+
// "has_next": true
|
|
5128
|
+
// },
|
|
5129
|
+
// "code": 0,
|
|
5130
|
+
// "message": "OK"
|
|
5131
|
+
// }
|
|
5157
5132
|
//
|
|
5158
|
-
|
|
5159
|
-
if (!Array.isArray(data)) {
|
|
5160
|
-
data = this.safeValue(data, 'data', []);
|
|
5161
|
-
}
|
|
5133
|
+
const data = this.safeList(response, 'data', []);
|
|
5162
5134
|
return this.parseTransactions(data, currency, since, limit);
|
|
5163
5135
|
}
|
|
5164
5136
|
parseIsolatedBorrowRate(info, market = undefined) {
|
|
5165
5137
|
//
|
|
5166
5138
|
// {
|
|
5167
5139
|
// "market": "BTCUSDT",
|
|
5140
|
+
// "ccy": "USDT",
|
|
5168
5141
|
// "leverage": 10,
|
|
5169
|
-
// "
|
|
5170
|
-
//
|
|
5171
|
-
//
|
|
5172
|
-
//
|
|
5173
|
-
// },
|
|
5174
|
-
// "USDT": {
|
|
5175
|
-
// "min_amount": "60",
|
|
5176
|
-
// "max_amount": "5000000",
|
|
5177
|
-
// "day_rate": "0.001"
|
|
5178
|
-
// }
|
|
5179
|
-
// },
|
|
5142
|
+
// "min_amount": "60",
|
|
5143
|
+
// "max_amount": "500000",
|
|
5144
|
+
// "daily_interest_rate": "0.001"
|
|
5145
|
+
// }
|
|
5180
5146
|
//
|
|
5181
5147
|
const marketId = this.safeString(info, 'market');
|
|
5182
5148
|
market = this.safeMarket(marketId, market, undefined, 'spot');
|
|
5183
|
-
const
|
|
5184
|
-
const
|
|
5149
|
+
const currency = this.safeString(info, 'ccy');
|
|
5150
|
+
const rate = this.safeNumber(info, 'daily_interest_rate');
|
|
5151
|
+
let baseRate = undefined;
|
|
5152
|
+
let quoteRate = undefined;
|
|
5153
|
+
if (currency === market['baseId']) {
|
|
5154
|
+
baseRate = rate;
|
|
5155
|
+
}
|
|
5156
|
+
else if (currency === market['quoteId']) {
|
|
5157
|
+
quoteRate = rate;
|
|
5158
|
+
}
|
|
5185
5159
|
return {
|
|
5186
5160
|
'symbol': market['symbol'],
|
|
5187
5161
|
'base': market['base'],
|
|
5188
|
-
'baseRate':
|
|
5162
|
+
'baseRate': baseRate,
|
|
5189
5163
|
'quote': market['quote'],
|
|
5190
|
-
'quoteRate':
|
|
5164
|
+
'quoteRate': quoteRate,
|
|
5191
5165
|
'period': 86400000,
|
|
5192
5166
|
'timestamp': undefined,
|
|
5193
5167
|
'datetime': undefined,
|
|
@@ -5199,78 +5173,56 @@ class coinex extends coinex$1 {
|
|
|
5199
5173
|
* @method
|
|
5200
5174
|
* @name coinex#fetchIsolatedBorrowRate
|
|
5201
5175
|
* @description fetch the rate of interest to borrow a currency for margin trading
|
|
5202
|
-
* @see https://
|
|
5176
|
+
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
|
|
5203
5177
|
* @param {string} symbol unified symbol of the market to fetch the borrow rate for
|
|
5204
5178
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5179
|
+
* @param {string} params.code unified currency code
|
|
5205
5180
|
* @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
|
|
5206
5181
|
*/
|
|
5207
5182
|
await this.loadMarkets();
|
|
5183
|
+
const code = this.safeString(params, 'code');
|
|
5184
|
+
if (code === undefined) {
|
|
5185
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchIsolatedBorrowRate() requires a code parameter');
|
|
5186
|
+
}
|
|
5187
|
+
params = this.omit(params, 'code');
|
|
5188
|
+
const currency = this.currency(code);
|
|
5208
5189
|
const market = this.market(symbol);
|
|
5209
5190
|
const request = {
|
|
5210
5191
|
'market': market['id'],
|
|
5192
|
+
'ccy': currency['id'],
|
|
5211
5193
|
};
|
|
5212
|
-
const response = await this.
|
|
5194
|
+
const response = await this.v2PrivateGetAssetsMarginInterestLimit(this.extend(request, params));
|
|
5213
5195
|
//
|
|
5214
5196
|
// {
|
|
5215
5197
|
// "code": 0,
|
|
5216
5198
|
// "data": {
|
|
5217
5199
|
// "market": "BTCUSDT",
|
|
5200
|
+
// "ccy": "USDT",
|
|
5218
5201
|
// "leverage": 10,
|
|
5219
|
-
// "
|
|
5220
|
-
//
|
|
5221
|
-
//
|
|
5222
|
-
// "day_rate": "0.001"
|
|
5223
|
-
// },
|
|
5224
|
-
// "USDT": {
|
|
5225
|
-
// "min_amount": "60",
|
|
5226
|
-
// "max_amount": "5000000",
|
|
5227
|
-
// "day_rate": "0.001"
|
|
5228
|
-
// }
|
|
5202
|
+
// "min_amount": "60",
|
|
5203
|
+
// "max_amount": "500000",
|
|
5204
|
+
// "daily_interest_rate": "0.001"
|
|
5229
5205
|
// },
|
|
5230
|
-
// "message": "
|
|
5206
|
+
// "message": "OK"
|
|
5231
5207
|
// }
|
|
5232
5208
|
//
|
|
5233
|
-
const data = this.
|
|
5209
|
+
const data = this.safeDict(response, 'data', {});
|
|
5234
5210
|
return this.parseIsolatedBorrowRate(data, market);
|
|
5235
5211
|
}
|
|
5236
|
-
async
|
|
5212
|
+
async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
5237
5213
|
/**
|
|
5238
5214
|
* @method
|
|
5239
|
-
* @name coinex#
|
|
5240
|
-
* @description fetch the
|
|
5241
|
-
* @see https://
|
|
5215
|
+
* @name coinex#fetchBorrowInterest
|
|
5216
|
+
* @description fetch the interest owed by the user for borrowing currency for margin trading
|
|
5217
|
+
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
|
|
5218
|
+
* @param {string} [code] unified currency code
|
|
5219
|
+
* @param {string} [symbol] unified market symbol when fetch interest in isolated markets
|
|
5220
|
+
* @param {int} [since] the earliest time in ms to fetch borrrow interest for
|
|
5221
|
+
* @param {int} [limit] the maximum number of structures to retrieve
|
|
5242
5222
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5243
|
-
* @returns {object} a list of [
|
|
5223
|
+
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
|
|
5244
5224
|
*/
|
|
5245
5225
|
await this.loadMarkets();
|
|
5246
|
-
const response = await this.v1PrivateGetMarginConfig(params);
|
|
5247
|
-
//
|
|
5248
|
-
// {
|
|
5249
|
-
// "code": 0,
|
|
5250
|
-
// "data": [
|
|
5251
|
-
// {
|
|
5252
|
-
// "market": "BTCUSDT",
|
|
5253
|
-
// "leverage": 10,
|
|
5254
|
-
// "BTC": {
|
|
5255
|
-
// "min_amount": "0.002",
|
|
5256
|
-
// "max_amount": "200",
|
|
5257
|
-
// "day_rate": "0.001"
|
|
5258
|
-
// },
|
|
5259
|
-
// "USDT": {
|
|
5260
|
-
// "min_amount": "60",
|
|
5261
|
-
// "max_amount": "5000000",
|
|
5262
|
-
// "day_rate": "0.001"
|
|
5263
|
-
// }
|
|
5264
|
-
// },
|
|
5265
|
-
// ],
|
|
5266
|
-
// "message": "Success"
|
|
5267
|
-
// }
|
|
5268
|
-
//
|
|
5269
|
-
const data = this.safeValue(response, 'data', []);
|
|
5270
|
-
return this.parseIsolatedBorrowRates(data);
|
|
5271
|
-
}
|
|
5272
|
-
async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
5273
|
-
await this.loadMarkets();
|
|
5274
5226
|
const request = {};
|
|
5275
5227
|
let market = undefined;
|
|
5276
5228
|
if (symbol !== undefined) {
|
|
@@ -5280,77 +5232,62 @@ class coinex extends coinex$1 {
|
|
|
5280
5232
|
if (limit !== undefined) {
|
|
5281
5233
|
request['limit'] = limit;
|
|
5282
5234
|
}
|
|
5283
|
-
const response = await this.
|
|
5235
|
+
const response = await this.v2PrivateGetAssetsMarginBorrowHistory(this.extend(request, params));
|
|
5284
5236
|
//
|
|
5285
5237
|
// {
|
|
5286
|
-
// "
|
|
5287
|
-
//
|
|
5288
|
-
//
|
|
5289
|
-
//
|
|
5290
|
-
//
|
|
5291
|
-
//
|
|
5292
|
-
//
|
|
5293
|
-
//
|
|
5294
|
-
//
|
|
5295
|
-
//
|
|
5296
|
-
//
|
|
5297
|
-
//
|
|
5298
|
-
//
|
|
5299
|
-
//
|
|
5300
|
-
//
|
|
5301
|
-
//
|
|
5302
|
-
//
|
|
5303
|
-
// "unflat_amount": "0",
|
|
5304
|
-
// "expire_time": 1655078027,
|
|
5305
|
-
// "is_renew": true,
|
|
5306
|
-
// "status": "finish"
|
|
5307
|
-
// }
|
|
5308
|
-
// ],
|
|
5309
|
-
// "total_page": 1
|
|
5238
|
+
// "data": [
|
|
5239
|
+
// {
|
|
5240
|
+
// "borrow_id": 2642934,
|
|
5241
|
+
// "created_at": 1654761016000,
|
|
5242
|
+
// "market": "BTCUSDT",
|
|
5243
|
+
// "ccy": "USDT",
|
|
5244
|
+
// "daily_interest_rate": "0.001",
|
|
5245
|
+
// "expired_at": 1655625016000,
|
|
5246
|
+
// "borrow_amount": "100",
|
|
5247
|
+
// "to_repaied_amount": "0",
|
|
5248
|
+
// "is_auto_renew": false,
|
|
5249
|
+
// "status": "finish"
|
|
5250
|
+
// },
|
|
5251
|
+
// ],
|
|
5252
|
+
// "pagination": {
|
|
5253
|
+
// "total": 4,
|
|
5254
|
+
// "has_next": true
|
|
5310
5255
|
// },
|
|
5311
|
-
// "
|
|
5256
|
+
// "code": 0,
|
|
5257
|
+
// "message": "OK"
|
|
5312
5258
|
// }
|
|
5313
5259
|
//
|
|
5314
|
-
const
|
|
5315
|
-
const rows = this.safeValue(data, 'data', []);
|
|
5260
|
+
const rows = this.safeValue(response, 'data', []);
|
|
5316
5261
|
const interest = this.parseBorrowInterests(rows, market);
|
|
5317
5262
|
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
5318
5263
|
}
|
|
5319
5264
|
parseBorrowInterest(info, market = undefined) {
|
|
5320
5265
|
//
|
|
5321
5266
|
// {
|
|
5322
|
-
// "
|
|
5323
|
-
// "
|
|
5324
|
-
// "
|
|
5325
|
-
// "
|
|
5326
|
-
// "
|
|
5327
|
-
// "
|
|
5328
|
-
// "
|
|
5329
|
-
// "
|
|
5330
|
-
// "
|
|
5331
|
-
// "is_renew": true,
|
|
5267
|
+
// "borrow_id": 2642934,
|
|
5268
|
+
// "created_at": 1654761016000,
|
|
5269
|
+
// "market": "BTCUSDT",
|
|
5270
|
+
// "ccy": "USDT",
|
|
5271
|
+
// "daily_interest_rate": "0.001",
|
|
5272
|
+
// "expired_at": 1655625016000,
|
|
5273
|
+
// "borrow_amount": "100",
|
|
5274
|
+
// "to_repaied_amount": "0",
|
|
5275
|
+
// "is_auto_renew": false,
|
|
5332
5276
|
// "status": "finish"
|
|
5333
5277
|
// }
|
|
5334
5278
|
//
|
|
5335
|
-
const marketId = this.safeString(info, '
|
|
5279
|
+
const marketId = this.safeString(info, 'market');
|
|
5336
5280
|
market = this.safeMarket(marketId, market, undefined, 'spot');
|
|
5337
|
-
const
|
|
5338
|
-
const timestamp = this.safeTimestamp(info, 'expire_time');
|
|
5339
|
-
const unflatAmount = this.safeString(info, 'unflat_amount');
|
|
5340
|
-
const loanAmount = this.safeString(info, 'loan_amount');
|
|
5341
|
-
let interest = Precise["default"].stringSub(unflatAmount, loanAmount);
|
|
5342
|
-
if (unflatAmount === '0') {
|
|
5343
|
-
interest = undefined;
|
|
5344
|
-
}
|
|
5281
|
+
const timestamp = this.safeInteger(info, 'expired_at');
|
|
5345
5282
|
return {
|
|
5346
5283
|
'account': undefined,
|
|
5347
|
-
'symbol': symbol,
|
|
5284
|
+
'symbol': market['symbol'],
|
|
5348
5285
|
'marginMode': 'isolated',
|
|
5349
5286
|
'marginType': undefined,
|
|
5350
|
-
'currency': this.safeCurrencyCode(this.safeString(info, '
|
|
5351
|
-
'interest': this.
|
|
5352
|
-
'interestRate': this.safeNumber(info, '
|
|
5353
|
-
'amountBorrowed': this.
|
|
5287
|
+
'currency': this.safeCurrencyCode(this.safeString(info, 'ccy')),
|
|
5288
|
+
'interest': this.safeNumber(info, 'to_repaied_amount'),
|
|
5289
|
+
'interestRate': this.safeNumber(info, 'daily_interest_rate'),
|
|
5290
|
+
'amountBorrowed': this.safeNumber(info, 'borrow_amount'),
|
|
5354
5291
|
'timestamp': timestamp,
|
|
5355
5292
|
'datetime': this.iso8601(timestamp),
|
|
5356
5293
|
'info': info,
|
|
@@ -5361,32 +5298,43 @@ class coinex extends coinex$1 {
|
|
|
5361
5298
|
* @method
|
|
5362
5299
|
* @name coinex#borrowIsolatedMargin
|
|
5363
5300
|
* @description create a loan to borrow margin
|
|
5364
|
-
* @see https://
|
|
5301
|
+
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
|
|
5365
5302
|
* @param {string} symbol unified market symbol, required for coinex
|
|
5366
5303
|
* @param {string} code unified currency code of the currency to borrow
|
|
5367
5304
|
* @param {float} amount the amount to borrow
|
|
5368
5305
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5306
|
+
* @param {boolean} [params.isAutoRenew] whether to renew the margin loan automatically or not, default is false
|
|
5369
5307
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
5370
5308
|
*/
|
|
5371
5309
|
await this.loadMarkets();
|
|
5372
5310
|
const market = this.market(symbol);
|
|
5373
5311
|
const currency = this.currency(code);
|
|
5312
|
+
const isAutoRenew = this.safeBool2(params, 'isAutoRenew', 'is_auto_renew', false);
|
|
5313
|
+
params = this.omit(params, 'isAutoRenew');
|
|
5374
5314
|
const request = {
|
|
5375
5315
|
'market': market['id'],
|
|
5376
|
-
'
|
|
5377
|
-
'
|
|
5316
|
+
'ccy': currency['id'],
|
|
5317
|
+
'borrow_amount': this.currencyToPrecision(code, amount),
|
|
5318
|
+
'is_auto_renew': isAutoRenew,
|
|
5378
5319
|
};
|
|
5379
|
-
const response = await this.
|
|
5320
|
+
const response = await this.v2PrivatePostAssetsMarginBorrow(this.extend(request, params));
|
|
5380
5321
|
//
|
|
5381
5322
|
// {
|
|
5382
5323
|
// "code": 0,
|
|
5383
5324
|
// "data": {
|
|
5384
|
-
// "
|
|
5325
|
+
// "borrow_id": 13784021,
|
|
5326
|
+
// "market": "BTCUSDT",
|
|
5327
|
+
// "ccy": "USDT",
|
|
5328
|
+
// "daily_interest_rate": "0.001",
|
|
5329
|
+
// "expired_at": 1717299948340,
|
|
5330
|
+
// "borrow_amount": "60",
|
|
5331
|
+
// "to_repaied_amount": "60.0025",
|
|
5332
|
+
// "status": "loan"
|
|
5385
5333
|
// },
|
|
5386
|
-
// "message": "
|
|
5334
|
+
// "message": "OK"
|
|
5387
5335
|
// }
|
|
5388
5336
|
//
|
|
5389
|
-
const data = this.
|
|
5337
|
+
const data = this.safeDict(response, 'data', {});
|
|
5390
5338
|
const transaction = this.parseMarginLoan(data, currency);
|
|
5391
5339
|
return this.extend(transaction, {
|
|
5392
5340
|
'amount': amount,
|
|
@@ -5398,12 +5346,12 @@ class coinex extends coinex$1 {
|
|
|
5398
5346
|
* @method
|
|
5399
5347
|
* @name coinex#repayIsolatedMargin
|
|
5400
5348
|
* @description repay borrowed margin and interest
|
|
5401
|
-
* @see https://
|
|
5349
|
+
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
|
|
5402
5350
|
* @param {string} symbol unified market symbol, required for coinex
|
|
5403
5351
|
* @param {string} code unified currency code of the currency to repay
|
|
5404
5352
|
* @param {float} amount the amount to repay
|
|
5405
5353
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5406
|
-
* @param {string} [params.
|
|
5354
|
+
* @param {string} [params.borrow_id] extra parameter that is not required
|
|
5407
5355
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
5408
5356
|
*/
|
|
5409
5357
|
await this.loadMarkets();
|
|
@@ -5411,46 +5359,47 @@ class coinex extends coinex$1 {
|
|
|
5411
5359
|
const currency = this.currency(code);
|
|
5412
5360
|
const request = {
|
|
5413
5361
|
'market': market['id'],
|
|
5414
|
-
'
|
|
5362
|
+
'ccy': currency['id'],
|
|
5415
5363
|
'amount': this.currencyToPrecision(code, amount),
|
|
5416
5364
|
};
|
|
5417
|
-
const response = await this.
|
|
5365
|
+
const response = await this.v2PrivatePostAssetsMarginRepay(this.extend(request, params));
|
|
5418
5366
|
//
|
|
5419
5367
|
// {
|
|
5420
5368
|
// "code": 0,
|
|
5421
|
-
// "data":
|
|
5422
|
-
// "message": "
|
|
5369
|
+
// "data": {},
|
|
5370
|
+
// "message": "OK"
|
|
5423
5371
|
// }
|
|
5424
5372
|
//
|
|
5425
|
-
const
|
|
5373
|
+
const data = this.safeDict(response, 'data', {});
|
|
5374
|
+
const transaction = this.parseMarginLoan(data, currency);
|
|
5426
5375
|
return this.extend(transaction, {
|
|
5427
5376
|
'amount': amount,
|
|
5428
5377
|
'symbol': symbol,
|
|
5429
5378
|
});
|
|
5430
5379
|
}
|
|
5431
5380
|
parseMarginLoan(info, currency = undefined) {
|
|
5432
|
-
//
|
|
5433
|
-
// borrowMargin
|
|
5434
5381
|
//
|
|
5435
5382
|
// {
|
|
5436
|
-
// "
|
|
5437
|
-
//
|
|
5438
|
-
//
|
|
5439
|
-
//
|
|
5440
|
-
//
|
|
5441
|
-
//
|
|
5442
|
-
// "
|
|
5443
|
-
// "
|
|
5444
|
-
// "message": "Success"
|
|
5383
|
+
// "borrow_id": 13784021,
|
|
5384
|
+
// "market": "BTCUSDT",
|
|
5385
|
+
// "ccy": "USDT",
|
|
5386
|
+
// "daily_interest_rate": "0.001",
|
|
5387
|
+
// "expired_at": 1717299948340,
|
|
5388
|
+
// "borrow_amount": "60",
|
|
5389
|
+
// "to_repaied_amount": "60.0025",
|
|
5390
|
+
// "status": "loan"
|
|
5445
5391
|
// }
|
|
5446
5392
|
//
|
|
5393
|
+
const currencyId = this.safeString(info, 'ccy');
|
|
5394
|
+
const marketId = this.safeString(info, 'market');
|
|
5395
|
+
const timestamp = this.safeInteger(info, 'expired_at');
|
|
5447
5396
|
return {
|
|
5448
|
-
'id': this.safeInteger(info, '
|
|
5449
|
-
'currency': this.safeCurrencyCode(
|
|
5450
|
-
'amount':
|
|
5451
|
-
'symbol': undefined,
|
|
5452
|
-
'timestamp':
|
|
5453
|
-
'datetime':
|
|
5397
|
+
'id': this.safeInteger(info, 'borrow_id'),
|
|
5398
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
5399
|
+
'amount': this.safeString(info, 'borrow_amount'),
|
|
5400
|
+
'symbol': this.safeSymbol(marketId, undefined, undefined, 'spot'),
|
|
5401
|
+
'timestamp': timestamp,
|
|
5402
|
+
'datetime': this.iso8601(timestamp),
|
|
5454
5403
|
'info': info,
|
|
5455
5404
|
};
|
|
5456
5405
|
}
|