-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
chore(root): add script to fetch trx:usdt balance for addresses
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
examples/ts/trx/fetch-addresses-not-eligible-for-usdt-consolidation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Fetch receive addresses with USDT balance and less than 35 TRX balance | ||
* | ||
* Copyright 2024, BitGo, Inc. All Rights Reserved. | ||
*/ | ||
import { BitGoAPI } from '@bitgo/sdk-api'; | ||
import { Trx } from '@bitgo/sdk-coin-trx'; | ||
import * as fs from 'fs'; | ||
require('dotenv').config({ path: '../../.env' }); | ||
|
||
const bitgo = new BitGoAPI({ | ||
accessToken: '', | ||
env: 'prod', | ||
}); | ||
|
||
const coin = 'trx:usdt'; | ||
bitgo.register(coin, Trx.createInstance); | ||
|
||
const walletId = ''; | ||
|
||
async function main() { | ||
const wallet = await bitgo.coin(coin).wallets().get({ id: walletId }); | ||
let prevId = undefined; | ||
let index = 1; | ||
do { | ||
const addresses = await wallet.addresses({ includeBalances: true, prevId }); | ||
prevId = addresses.nextBatchPrevId; | ||
// console.log(JSON.stringify(addresses)); | ||
for (let { address, balance, needsConsolidation } of addresses.addresses) { | ||
const { tokens, spendableBalanceString } = balance; | ||
const usdtBalance = tokens['trx:usdt']?.spendableBalanceString; | ||
|
||
if (!(usdtBalance > 0 && spendableBalanceString >= 36000000)) { | ||
if (needsConsolidation === false) { | ||
const data = `${address} `; | ||
fs.appendFileSync('usdt-not-eligible-addresses.txt', data); | ||
} | ||
} | ||
index += 1; | ||
} | ||
} while (prevId !== undefined); | ||
} | ||
|
||
main().catch((e) => console.error(e)); |