6
6
COMPOUNDING_CONTRACT_ADDRESS ,
7
7
WITHDRAWAL_CONTRACT_ADDRESS ,
8
8
TICKER_NAME ,
9
+ EXCESS_INHIBITOR ,
9
10
} from '../../utils/envVars' ;
10
11
11
12
export type Queue = {
@@ -35,13 +36,23 @@ const getRequiredFee = (queueLength: BigNumber): BigNumber => {
35
36
export const getCompoundingQueueLength = async (
36
37
web3 : Web3
37
38
) : Promise < BigNumber > => {
38
- const queueLengthHex = await web3 . eth . getStorageAt (
39
- COMPOUNDING_CONTRACT_ADDRESS ! ,
40
- 0 // EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT
41
- ) ;
42
-
43
- if ( ! queueLengthHex )
44
- throw new Error ( 'Unable to get compounding queue length' ) ;
39
+ let queueLengthHex ;
40
+ try {
41
+ queueLengthHex = await web3 . eth . getStorageAt (
42
+ COMPOUNDING_CONTRACT_ADDRESS ! ,
43
+ 0 // EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT
44
+ ) ;
45
+
46
+ if ( ! queueLengthHex ) {
47
+ throw new Error ( 'Unable to get compounding queue length' ) ;
48
+ }
49
+ if ( queueLengthHex === EXCESS_INHIBITOR ) {
50
+ throw new Error ( 'Compounding queue is disabled' ) ;
51
+ }
52
+ } catch ( error ) {
53
+ console . error ( error ) ;
54
+ queueLengthHex = '0x0' ;
55
+ }
45
56
46
57
return new BigNumber ( queueLengthHex ) ;
47
58
} ;
@@ -58,13 +69,22 @@ export const getCompoundingQueue = async (web3: Web3): Promise<Queue> => {
58
69
export const getWithdrawalQueueLength = async (
59
70
web3 : Web3
60
71
) : Promise < BigNumber > => {
61
- const queueLengthHex = await web3 . eth . getStorageAt (
62
- WITHDRAWAL_CONTRACT_ADDRESS ! ,
63
- 0 // EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT
64
- ) ;
65
-
66
- if ( ! queueLengthHex ) {
67
- throw new Error ( 'Unable to get withdrawal queue length' ) ;
72
+ let queueLengthHex ;
73
+ try {
74
+ queueLengthHex = await web3 . eth . getStorageAt (
75
+ WITHDRAWAL_CONTRACT_ADDRESS ! ,
76
+ 0 // EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT
77
+ ) ;
78
+
79
+ if ( ! queueLengthHex ) {
80
+ throw new Error ( 'Unable to get withdrawal queue length' ) ;
81
+ }
82
+ if ( queueLengthHex === EXCESS_INHIBITOR ) {
83
+ throw new Error ( 'Withdrawal queue is disabled' ) ;
84
+ }
85
+ } catch ( error ) {
86
+ console . error ( error ) ;
87
+ queueLengthHex = '0x0' ;
68
88
}
69
89
70
90
return new BigNumber ( queueLengthHex ) ;
0 commit comments