@@ -2,7 +2,7 @@ import { Connection } from "@solana/web3.js";
2
2
// import fetch from "cross-fetch";
3
3
import { IAgentRuntime , Memory , Provider , State } from "../core/types.ts" ;
4
4
import settings from "../core/settings.ts" ;
5
- import BigNumber from " bignumber.js" ;
5
+ import { toBN , BN } from '../utils/ bignumber.js' ;
6
6
import {
7
7
ProcessedTokenData ,
8
8
TokenSecurityData ,
@@ -609,40 +609,38 @@ export class TokenProvider {
609
609
) : Promise < Array < { holderAddress : string ; balanceUsd : string } > > {
610
610
const holdersData = await this . fetchHolderList ( ) ;
611
611
612
- const tokenPriceUsd = new BigNumber ( tradeData . price ) ;
612
+ const tokenPriceUsd = toBN ( tradeData . price ) ;
613
613
614
614
const highValueHolders = holdersData
615
615
. filter ( ( holder ) => {
616
- const balanceUsd = new BigNumber ( holder . balance ) . multipliedBy (
616
+ const balanceUsd = toBN ( holder . balance ) . multipliedBy (
617
617
tokenPriceUsd
618
618
) ;
619
619
return balanceUsd . isGreaterThan ( 5 ) ;
620
620
} )
621
621
. map ( ( holder ) => ( {
622
622
holderAddress : holder . address ,
623
- balanceUsd : new BigNumber ( holder . balance )
624
- . multipliedBy ( tokenPriceUsd )
625
- . toFixed ( 2 ) ,
623
+ balanceUsd : toBN ( holder . balance ) . multipliedBy ( tokenPriceUsd ) . toFixed ( 2 ) ,
626
624
} ) ) ;
627
625
628
626
return highValueHolders ;
629
627
}
630
628
631
629
async checkRecentTrades ( tradeData : TokenTradeData ) : Promise < boolean > {
632
- return new BigNumber ( tradeData . volume_24h_usd ) . isGreaterThan ( 0 ) ;
630
+ return toBN ( tradeData . volume_24h_usd ) . isGreaterThan ( 0 ) ;
633
631
}
634
632
635
633
async countHighSupplyHolders (
636
634
securityData : TokenSecurityData
637
635
) : Promise < number > {
638
636
try {
639
- const ownerBalance = new BigNumber ( securityData . ownerBalance ) ;
637
+ const ownerBalance = toBN ( securityData . ownerBalance ) ;
640
638
const totalSupply = ownerBalance . plus ( securityData . creatorBalance ) ;
641
639
642
640
const highSupplyHolders = await this . fetchHolderList ( ) ;
643
641
const highSupplyHoldersCount = highSupplyHolders . filter (
644
642
( holder ) => {
645
- const balance = new BigNumber ( holder . balance ) ;
643
+ const balance = toBN ( holder . balance ) ;
646
644
return balance . dividedBy ( totalSupply ) . isGreaterThan ( 0.02 ) ;
647
645
}
648
646
) . length ;
@@ -738,8 +736,8 @@ export class TokenProvider {
738
736
output += `- Unique Wallets (24h): ${ data . tradeData . unique_wallet_24h } \n` ;
739
737
output += `- Price Change (24h): ${ data . tradeData . price_change_24h_percent } %\n` ;
740
738
output += `- Price Change (12h): ${ data . tradeData . price_change_12h_percent } %\n` ;
741
- output += `- Volume (24h USD): $${ new BigNumber ( data . tradeData . volume_24h_usd ) . toFixed ( 2 ) } \n` ;
742
- output += `- Current Price: $${ new BigNumber ( data . tradeData . price ) . toFixed ( 2 ) } \n\n` ;
739
+ output += `- Volume (24h USD): $${ toBN ( data . tradeData . volume_24h_usd ) . toFixed ( 2 ) } \n` ;
740
+ output += `- Current Price: $${ toBN ( data . tradeData . price ) . toFixed ( 2 ) } \n\n` ;
743
741
744
742
// Holder Distribution Trend
745
743
output += `**Holder Distribution Trend:** ${ data . holderDistributionTrend } \n\n` ;
@@ -771,10 +769,10 @@ export class TokenProvider {
771
769
output += `\n**Pair ${ index + 1 } :**\n` ;
772
770
output += `- DEX: ${ pair . dexId } \n` ;
773
771
output += `- URL: ${ pair . url } \n` ;
774
- output += `- Price USD: $${ new BigNumber ( pair . priceUsd ) . toFixed ( 6 ) } \n` ;
775
- output += `- Volume (24h USD): $${ new BigNumber ( pair . volume . h24 ) . toFixed ( 2 ) } \n` ;
772
+ output += `- Price USD: $${ toBN ( pair . priceUsd ) . toFixed ( 6 ) } \n` ;
773
+ output += `- Volume (24h USD): $${ toBN ( pair . volume . h24 ) . toFixed ( 2 ) } \n` ;
776
774
output += `- Boosts Active: ${ pair . boosts && pair . boosts . active } \n` ;
777
- output += `- Liquidity USD: $${ new BigNumber ( pair . liquidity . usd ) . toFixed ( 2 ) } \n` ;
775
+ output += `- Liquidity USD: $${ toBN ( pair . liquidity . usd ) . toFixed ( 2 ) } \n` ;
778
776
} ) ;
779
777
}
780
778
output += `\n` ;
0 commit comments