@@ -5,6 +5,7 @@ import Web3 from 'web3';
5
5
import { APP_TOOLKIT , IAppToolkit } from '~app-toolkit/app-toolkit.interface' ;
6
6
import { Register } from '~app-toolkit/decorators' ;
7
7
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present' ;
8
+ import { CurveVotingEscrowContractPositionBalanceHelper } from '~apps/curve/helpers/curve.voting-escrow.contract-position-balance-helper' ;
8
9
import { BalanceFetcher } from '~balance/balance-fetcher.interface' ;
9
10
import { Network } from '~types/network.interface' ;
10
11
@@ -16,15 +17,18 @@ import {
16
17
DopexGOhmSsov ,
17
18
DopexRdpxSsov ,
18
19
DopexStaking ,
20
+ DopexVotingEscrow ,
21
+ DopexVotingEscrowRewards ,
19
22
} from '../contracts' ;
20
23
import { DOPEX_DEFINITION } from '../dopex.definition' ;
21
24
import { DopexSsovClaimableBalancesStrategy } from '../helpers/dopex.ssov.claimable-balances-strategy' ;
22
25
import { DopexSsovContractPositionBalanceHelper } from '../helpers/dopex.ssov.contract-position-balance-helper' ;
23
26
import { DopexSsovDepositBalanceStrategy } from '../helpers/dopex.ssov.deposit-balance-strategy' ;
24
27
25
28
const network = Network . ARBITRUM_MAINNET ;
29
+ const appId = DOPEX_DEFINITION . id ;
26
30
27
- @Register . BalanceFetcher ( DOPEX_DEFINITION . id , network )
31
+ @Register . BalanceFetcher ( appId , network )
28
32
export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
29
33
constructor (
30
34
@Inject ( APP_TOOLKIT ) private readonly appToolkit : IAppToolkit ,
@@ -36,13 +40,15 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
36
40
private readonly dopexSsovDepositBalanceStrategy : DopexSsovDepositBalanceStrategy ,
37
41
@Inject ( DopexSsovClaimableBalancesStrategy )
38
42
private readonly dopexSsovClaimableBalancesStrategy : DopexSsovClaimableBalancesStrategy ,
43
+ @Inject ( CurveVotingEscrowContractPositionBalanceHelper )
44
+ private readonly curveVotingEscrowContractPositionBalanceHelper : CurveVotingEscrowContractPositionBalanceHelper ,
39
45
) { }
40
46
41
47
private async getSsovBalances ( address : string ) {
42
48
return Promise . all ( [
43
49
this . dopexSsovContractPositionBalanceHelper . getBalances < DopexDpxSsov > ( {
44
50
address,
45
- appId : DOPEX_DEFINITION . id ,
51
+ appId,
46
52
groupId : DOPEX_DEFINITION . groups . dpxSsov . id ,
47
53
network,
48
54
resolveSsovContract : ( { address, network } ) => this . dopexContractFactory . dopexDpxSsov ( { address, network } ) ,
@@ -61,7 +67,7 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
61
67
} ) ,
62
68
this . dopexSsovContractPositionBalanceHelper . getBalances < DopexRdpxSsov > ( {
63
69
address,
64
- appId : DOPEX_DEFINITION . id ,
70
+ appId,
65
71
groupId : DOPEX_DEFINITION . groups . rdpxSsov . id ,
66
72
network,
67
73
resolveSsovContract : ( { address, network } ) => this . dopexContractFactory . dopexRdpxSsov ( { address, network } ) ,
@@ -80,7 +86,7 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
80
86
} ) ,
81
87
this . dopexSsovContractPositionBalanceHelper . getBalances < DopexEthSsov > ( {
82
88
address,
83
- appId : DOPEX_DEFINITION . id ,
89
+ appId,
84
90
groupId : DOPEX_DEFINITION . groups . ethSsov . id ,
85
91
network,
86
92
resolveSsovContract : ( { address, network } ) => this . dopexContractFactory . dopexEthSsov ( { address, network } ) ,
@@ -109,7 +115,7 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
109
115
} ) ,
110
116
this . dopexSsovContractPositionBalanceHelper . getBalances < DopexGOhmSsov > ( {
111
117
address,
112
- appId : DOPEX_DEFINITION . id ,
118
+ appId,
113
119
groupId : DOPEX_DEFINITION . groups . gohmSsov . id ,
114
120
network,
115
121
resolveSsovContract : ( { address, network } ) => this . dopexContractFactory . dopexGOhmSsov ( { address, network } ) ,
@@ -122,7 +128,7 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
122
128
} ) ,
123
129
this . dopexSsovContractPositionBalanceHelper . getBalances < DopexGmxSsov > ( {
124
130
address,
125
- appId : DOPEX_DEFINITION . id ,
131
+ appId,
126
132
groupId : DOPEX_DEFINITION . groups . gmxSsov . id ,
127
133
network,
128
134
resolveSsovContract : ( { address, network } ) => this . dopexContractFactory . dopexGmxSsov ( { address, network } ) ,
@@ -157,7 +163,7 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
157
163
private async getStakedBalances ( address : string ) {
158
164
return this . appToolkit . helpers . singleStakingContractPositionBalanceHelper . getBalances < DopexStaking > ( {
159
165
address,
160
- appId : DOPEX_DEFINITION . id ,
166
+ appId,
161
167
groupId : DOPEX_DEFINITION . groups . farm . id ,
162
168
network,
163
169
resolveContract : ( { address, network } ) => this . dopexContractFactory . dopexStaking ( { address, network } ) ,
@@ -170,10 +176,31 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
170
176
} ) ;
171
177
}
172
178
179
+ private async getVotingEscrowBalances ( address : string ) {
180
+ return this . curveVotingEscrowContractPositionBalanceHelper . getBalances < DopexVotingEscrow , DopexVotingEscrowRewards > (
181
+ {
182
+ address,
183
+ appId,
184
+ groupId : DOPEX_DEFINITION . groups . votingEscrow . id ,
185
+ network,
186
+ resolveContract : ( { address } ) => this . dopexContractFactory . dopexVotingEscrow ( { network, address } ) ,
187
+ resolveRewardContract : ( { address } ) =>
188
+ this . dopexContractFactory . dopexVotingEscrowRewards ( { network, address } ) ,
189
+ resolveLockedTokenBalance : ( { contract, multicall } ) =>
190
+ multicall
191
+ . wrap ( contract )
192
+ . locked ( address )
193
+ . then ( v => v . amount ) ,
194
+ resolveRewardTokenBalance : ( { contract, multicall } ) => multicall . wrap ( contract ) . earned ( address ) ,
195
+ } ,
196
+ ) ;
197
+ }
198
+
173
199
async getBalances ( address : string ) {
174
- const [ ssovBalances , stakedBalances ] = await Promise . all ( [
200
+ const [ ssovBalances , stakedBalances , votingEscrowBalances ] = await Promise . all ( [
175
201
this . getSsovBalances ( address ) ,
176
202
this . getStakedBalances ( address ) ,
203
+ this . getVotingEscrowBalances ( address ) ,
177
204
] ) ;
178
205
179
206
return presentBalanceFetcherResponse ( [
@@ -185,6 +212,10 @@ export class ArbitrumDopexBalanceFetcher implements BalanceFetcher {
185
212
label : 'Staking' ,
186
213
assets : [ ...stakedBalances ] ,
187
214
} ,
215
+ {
216
+ label : 'Voting Escrow' ,
217
+ assets : votingEscrowBalances ,
218
+ } ,
188
219
] ) ;
189
220
}
190
221
}
0 commit comments