Skip to content

Commit

Permalink
Merge pull request ccxt#17903 from ProfHollander/patch-6
Browse files Browse the repository at this point in the history
feat(bybit): fetchCurrencies enhancement
  • Loading branch information
kroitor authored May 15, 2023
2 parents 2b47ba1 + 18f2f2a commit 5c330aa
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions ts/src/bybit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1280,30 +1280,49 @@ export default class bybit extends Exchange {
const chains = this.safeValue (currency, 'chains', []);
const networks = {};
let minPrecision = undefined;
let minWithdrawFeeString = undefined;
let minWithdrawString = undefined;
let minDepositString = undefined;
let deposit = false;
let withdraw = false;
for (let j = 0; j < chains.length; j++) {
const chain = chains[j];
const networkId = this.safeString (chain, 'chain');
const networkCode = this.networkIdToCode (networkId);
const precision = this.parseNumber (this.parsePrecision (this.safeString (chain, 'minAccuracy')));
minPrecision = (minPrecision === undefined) ? precision : Math.min (minPrecision, precision);
const depositAllowed = this.safeInteger (chain, 'chainDeposit') === 1;
deposit = (depositAllowed) ? depositAllowed : deposit;
const withdrawAllowed = this.safeInteger (chain, 'chainWithdraw') === 1;
withdraw = (withdrawAllowed) ? withdrawAllowed : withdraw;
const withdrawFeeString = this.safeString (chain, 'withdrawFee');
if (withdrawFeeString !== undefined) {
minWithdrawFeeString = (minWithdrawFeeString === undefined) ? withdrawFeeString : Precise.stringMin (withdrawFeeString, minWithdrawFeeString);
}
const minNetworkWithdrawString = this.safeString (chain, 'withdrawMin');
if (minNetworkWithdrawString !== undefined) {
minWithdrawString = (minWithdrawString === undefined) ? minNetworkWithdrawString : Precise.stringMin (minNetworkWithdrawString, minWithdrawString);
}
const minNetworkDepositString = this.safeString (chain, 'depositMin');
if (minNetworkDepositString !== undefined) {
minDepositString = (minDepositString === undefined) ? minNetworkDepositString : Precise.stringMin (minNetworkDepositString, minDepositString);
}
networks[networkCode] = {
'info': chain,
'id': networkId,
'network': networkCode,
'active': undefined,
'active': depositAllowed && withdrawAllowed,
'deposit': depositAllowed,
'withdraw': withdrawAllowed,
'fee': this.safeNumber (chain, 'withdrawFee'),
'fee': this.parseNumber (withdrawFeeString),
'precision': precision,
'limits': {
'withdraw': {
'min': this.safeNumber (chain, 'withdrawMin'),
'min': this.parseNumber (minNetworkWithdrawString),
'max': undefined,
},
'deposit': {
'min': this.safeNumber (chain, 'depositMin'),
'min': this.parseNumber (minNetworkDepositString),
'max': undefined,
},
},
Expand All @@ -1314,16 +1333,24 @@ export default class bybit extends Exchange {
'code': code,
'id': currencyId,
'name': name,
'active': undefined,
'deposit': undefined,
'withdraw': undefined,
'fee': undefined,
'active': deposit && withdraw,
'deposit': deposit,
'withdraw': withdraw,
'fee': this.parseNumber (minWithdrawFeeString),
'precision': minPrecision,
'limits': {
'amount': {
'min': undefined,
'max': undefined,
},
'withdraw': {
'min': this.parseNumber (minWithdrawString),
'max': undefined,
},
'deposit': {
'min': this.parseNumber (minDepositString),
'max': undefined,
},
},
'networks': networks,
};
Expand Down

0 comments on commit 5c330aa

Please sign in to comment.