@@ -4,20 +4,10 @@ import { IPriceListener, IPricePusher } from "./interface";
4
4
import { PriceConfig , shouldUpdate , UpdateCondition } from "./price-config" ;
5
5
import { Logger } from "pino" ;
6
6
import { PricePusherMetrics } from "./metrics" ;
7
- import { SuperWalletClient } from "./evm/super-wallet" ;
8
-
9
- // Define the wallet balance info interface
10
- interface WalletBalanceInfo {
11
- client : SuperWalletClient ;
12
- address : `0x${string } `;
13
- network : string ;
14
- updateInterval : DurationInSeconds ;
15
- }
16
7
17
8
export class Controller {
18
9
private pushingFrequency : DurationInSeconds ;
19
10
private metrics ?: PricePusherMetrics ;
20
- private walletBalanceInfo ?: WalletBalanceInfo ;
21
11
22
12
constructor (
23
13
private priceConfigs : PriceConfig [ ] ,
@@ -28,46 +18,20 @@ export class Controller {
28
18
config : {
29
19
pushingFrequency : DurationInSeconds ;
30
20
metrics ?: PricePusherMetrics ;
31
- walletBalanceInfo ?: WalletBalanceInfo ;
32
21
} ,
33
22
) {
34
23
this . pushingFrequency = config . pushingFrequency ;
35
24
this . metrics = config . metrics ;
36
- this . walletBalanceInfo = config . walletBalanceInfo ;
37
25
38
26
// Set the number of price feeds if metrics are enabled
39
27
this . metrics ?. setPriceFeedsTotal ( this . priceConfigs . length ) ;
40
28
}
41
29
42
- // Get wallet balance and update metrics
43
- private async updateWalletBalance ( ) : Promise < void > {
44
- if ( ! this . metrics || ! this . walletBalanceInfo ) return ;
45
-
46
- try {
47
- const { client, address, network } = this . walletBalanceInfo ;
48
- const balance = await client . getBalance ( {
49
- address : address ,
50
- } ) ;
51
-
52
- this . metrics . updateWalletBalance ( address , network , balance ) ;
53
- this . logger . debug (
54
- `Updated wallet balance: ${ address } = ${ balance . toString ( ) } ` ,
55
- ) ;
56
- } catch ( error ) {
57
- this . logger . error ( { error } , "Error fetching wallet balance for metrics" ) ;
58
- }
59
- }
60
-
61
30
async start ( ) {
62
31
// start the listeners
63
32
await this . sourcePriceListener . start ( ) ;
64
33
await this . targetPriceListener . start ( ) ;
65
34
66
- // Update wallet balance initially if metrics are enabled
67
- if ( this . metrics && this . walletBalanceInfo ) {
68
- await this . updateWalletBalance ( ) ;
69
- }
70
-
71
35
// wait for the listeners to get updated. There could be a restart
72
36
// before this run and we need to respect the cooldown duration as
73
37
// their might be a message sent before.
@@ -80,11 +44,6 @@ export class Controller {
80
44
const pricesToPush : PriceConfig [ ] = [ ] ;
81
45
const pubTimesToPush : UnixTimestamp [ ] = [ ] ;
82
46
83
- // Update wallet balance if metrics are enabled
84
- if ( this . metrics && this . walletBalanceInfo ) {
85
- await this . updateWalletBalance ( ) ;
86
- }
87
-
88
47
for ( const priceConfig of this . priceConfigs ) {
89
48
const priceId = priceConfig . id ;
90
49
const alias = priceConfig . alias ;
0 commit comments