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