Skip to content

Commit

Permalink
Merge pull request ccxt#17071 from ndubel/patch-103
Browse files Browse the repository at this point in the history
gate withdraw, parseTransactions fix
  • Loading branch information
kroitor authored Mar 6, 2023
2 parents 9cc2d6a + 742866b commit ae5bb0b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions js/gate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,8 @@ module.exports = class gate extends Exchange {
if (network !== undefined) {
request['chain'] = network;
params = this.omit (params, 'network');
} else {
request['chain'] = currency['id'];
}
const response = await this.privateWithdrawalsPostWithdrawals (this.extend (request, params));
//
Expand Down Expand Up @@ -3062,31 +3064,34 @@ module.exports = class gate extends Exchange {
//
const id = this.safeString (transaction, 'id');
let type = undefined;
let amount = this.safeString (transaction, 'amount');
let amountString = this.safeString (transaction, 'amount');
if (id !== undefined) {
if (id[0] === 'b') {
// GateCode handling
type = Precise.stringGt (amount, '0') ? 'deposit' : 'withdrawal';
amount = Precise.stringAbs (amount);
type = Precise.stringGt (amountString, '0') ? 'deposit' : 'withdrawal';
amountString = Precise.stringAbs (amountString);
} else {
type = this.parseTransactionType (id[0]);
}
}
const feeCostString = this.safeString (transaction, 'fee');
if (type === 'withdrawal') {
amountString = Precise.stringSub (amountString, feeCostString);
}
const currencyId = this.safeString (transaction, 'currency');
const code = this.safeCurrencyCode (currencyId);
const txid = this.safeString (transaction, 'txid');
const rawStatus = this.safeString (transaction, 'status');
const status = this.parseTransactionStatus (rawStatus);
const address = this.safeString (transaction, 'address');
const fee = this.safeNumber (transaction, 'fee');
const tag = this.safeString (transaction, 'memo');
const timestamp = this.safeTimestamp (transaction, 'timestamp');
return {
'info': transaction,
'id': id,
'txid': txid,
'currency': code,
'amount': this.parseNumber (amount),
'amount': this.parseNumber (amountString),
'network': undefined,
'address': address,
'addressTo': undefined,
Expand All @@ -3099,7 +3104,10 @@ module.exports = class gate extends Exchange {
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'updated': undefined,
'fee': fee,
'fee': {
'currency': code,
'cost': this.parseNumber (feeCostString),
},
};
}

Expand Down

0 comments on commit ae5bb0b

Please sign in to comment.