Repository: ccxt/ccxt
Pull request: binance: update currency code when fetch fiat transactions ccxt/ccxt#16224
fix: ccxt/ccxt#16224

The currency code of USD is BUSD when get fiat orders. Added a map for this, in case binance use another currency for other fiat.

Problem statement:
binance can't fetch all fiat deposits
- Programming Language version: js
- CCXT version: 2.4.64

`fetchDeposits` in `binance` exchange is not able to get all fiat deposits. If I do not specify the `code` parameter all crypto deposits are returned. To fetch fiat deposits I have to iterate over all fiat currencies. Is this a bug or intended behavior? The Binance API is capable of returning all fiat deposits.

Hints from issue discussion:

Commit message: binance: update parseTransaction

Patch to review:
diff --git a/js/binance.js b/js/binance.js
index 19f46e61e570c..303fbe5736cea 100644
--- a/js/binance.js
+++ b/js/binance.js
@@ -1146,6 +1146,9 @@ module.exports = class binance extends Exchange {
                     'JPY': true,
                     'NZD': true,
                 },
+                'reverseCurrencyToLeagalMoney': {
+                    'BUSD': 'USD',
+                },
             },
             // https://binance-docs.github.io/apidocs/spot/en/#error-codes-2
             'exceptions': {
@@ -4336,6 +4339,7 @@ module.exports = class binance extends Exchange {
         //     {
         //       "orderNo": "25ced37075c1470ba8939d0df2316e23",
         //       "fiatCurrency": "EUR",
+        //       "transactionType": 0,
         //       "indicatedAmount": "15.00",
         //       "amount": "15.00",
         //       "totalFee": "0.00",
@@ -4362,19 +4366,17 @@ module.exports = class binance extends Exchange {
             txid = txid.slice (18);
         }
         const currencyId = this.safeString2 (transaction, 'coin', 'fiatCurrency');
-        const code = this.safeCurrencyCode (currencyId, currency);
+        let code = this.safeCurrencyCode (currencyId, currency);
         let timestamp = undefined;
         const insertTime = this.safeInteger2 (transaction, 'insertTime', 'createTime');
-        const applyTime = this.parse8601 (this.safeString (transaction, 'applyTime'));
+        const updated = this.safeInteger2 (transaction, 'successTime', 'updateTime');
         let type = this.safeString (transaction, 'type');
         if (type === undefined) {
-            if ((insertTime !== undefined) && (applyTime === undefined)) {
-                type = 'deposit';
-                timestamp = insertTime;
-            } else if ((insertTime === undefined) && (applyTime !== undefined)) {
-                type = 'withdrawal';
-                timestamp = applyTime;
-            }
+            const txType = this.safeString (transaction, 'transactionType');
+            type = (txType === '0') ? 'deposit' : 'withdrawal';
+            timestamp = insertTime;
+            const reverseCurrencyToLeagalMoney = this.safeValue (this.options, 'reverseCurrencyToLeagalMoney');
+            code = this.safeString (reverseCurrencyToLeagalMoney, code, code);
         }
         const status = this.parseTransactionStatusByType (this.safeString (transaction, 'status'), type);
         const amount = this.safeNumber (transaction, 'amount');
@@ -4383,7 +4385,6 @@ module.exports = class binance extends Exchange {
         if (feeCost !== undefined) {
             fee = { 'currency': code, 'cost': feeCost };
         }
-        const updated = this.safeInteger2 (transaction, 'successTime', 'updateTime');
         let internal = this.safeInteger (transaction, 'transferType');
         if (internal !== undefined) {
             internal = internal ? true : false;


Code review comments:
diff_hunk: @@ -1146,6 +1146,9 @@ module.exports = class binance extends Exchange {
                     'JPY': true,
                     'NZD': true,
                 },
+                'reverseCurrencyToLeagalMoney': {
path: js/binance.js
text: @user1:
we have a typo here, and the name does not seem very clear. Maybe something like `legalMoneyCurrenciesById` ? 

@author:
@user1 that makes more sense