Skip to content

Commit

Permalink
Fixed dust transfer (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisleekr authored Jun 14, 2021
1 parent 6ccf7c6 commit 14f069a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [0.0.71] - 2021-06-14

- Fixed the issue with dust transfer

## [0.0.70] - 2021-06-14

- Support manual trade for all symbols - [#100](https://github.com/chrisleekr/binance-trading-bot/issues/100)
Expand Down
23 changes: 20 additions & 3 deletions app/cronjob/trailingTradeHelper/__tests__/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ describe('common.js', () => {
return JSON.stringify({ close: '0.04480' });
}

if (
hash === 'trailing-trade-symbols' &&
key === 'TRXBTC-latest-candle'
) {
return JSON.stringify({ close: '0.00000179' });
}

return null;
});

Expand All @@ -330,6 +337,10 @@ describe('common.js', () => {
{
asset: 'TRX',
free: '0.001'
},
{
asset: 'XRP',
free: '2'
}
]
});
Expand All @@ -353,20 +364,26 @@ describe('common.js', () => {
{
asset: 'ETH',
canDustTransfer: false,
estimatedBTC: 0.06584,
estimatedBTC: '0.06584000',
free: '1'
},
{
asset: 'LTC',
canDustTransfer: true,
estimatedBTC: 0.0000448,
estimatedBTC: '0.00004480',
free: '0.001'
},
{
asset: 'TRX',
canDustTransfer: true,
estimatedBTC: '0.00000000',
free: '0.001'
},
{
asset: 'XRP',
canDustTransfer: false,
estimatedBTC: -1,
free: '0.001'
free: '2'
}
]
});
Expand Down
11 changes: 6 additions & 5 deletions app/cronjob/trailingTradeHelper/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ const extendBalancesWithDustTransfer = async (_logger, rawAccountInfo) => {
}

// https://academy.binance.com/en/articles/converting-dust-on-binance
// In order to qualify the dust must have a value less than 0.001BTC
// In order to qualify the dust must have a value less than 0.0003BTC

balance.estimatedBTC =
parseFloat(cachedLatestCandle.close) * parseFloat(balance.free);
balance.estimatedBTC = Number(
parseFloat(cachedLatestCandle.close) * parseFloat(balance.free)
).toFixed(8);

// If the estimated BTC is less than 0.001, then set dust transfer
if (balance.estimatedBTC === 0 || balance.estimatedBTC <= 0.003) {
// If the estimated BTC is less than 0.0003, then set dust transfer
if (balance.estimatedBTC <= 0.0003) {
balance.canDustTransfer = true;
}

Expand Down

0 comments on commit 14f069a

Please sign in to comment.