@@ -128,3 +128,101 @@ task("flywheel:add-to-pool", "Create pool if does not exist")
128
128
await publicClient . waitForTransactionReceipt ( { hash : addTx } ) ;
129
129
console . log ( { addTx } ) ;
130
130
} ) ;
131
+
132
+ task ( "flywheel:deploy-dynamic-rewards-fw" , "Deploy dynamic rewards flywheel for LM rewards" )
133
+ . addParam ( "name" , "String to append to the flywheel contract name" , undefined , types . string )
134
+ . addParam ( "rewardToken" , "Reward token of flywheel" , undefined , types . string )
135
+ . addParam ( "booster" , "Kind of booster flywheel to use" , "IonicFlywheelBorrowBooster" , undefined , types . string )
136
+ . addParam ( "strategies" , "address of strategy for which to enable the flywheel" , undefined , types . string )
137
+ . addParam ( "pool" , "comptroller to which to add the flywheel" , undefined , types . string )
138
+ . setAction (
139
+ async ( { signer, name, rewardToken, strategies, pool, booster } , { viem, deployments, run, getNamedAccounts } ) => {
140
+ const { deployer } = await getNamedAccounts ( ) ;
141
+ const publicClient = await viem . getPublicClient ( ) ;
142
+ let flywheelBooster ;
143
+ let contractName ;
144
+ if ( booster != "" ) {
145
+ flywheelBooster = await viem . getContractAt ( booster , ( await deployments . get ( booster ) ) . address as Address ) ;
146
+ }
147
+ else flywheelBooster = zeroAddress ;
148
+
149
+ if ( name . includes ( "Borrow" ) ) {
150
+ contractName = "IonicFlywheelBorrow" ;
151
+ }
152
+ else contractName = "IonicFlywheel"
153
+
154
+ console . log ( { signer, name, rewardToken, booster, strategies, pool } ) ;
155
+ const flywheel = await deployments . deploy ( `${ contractName } _${ name } ` , {
156
+ contract : contractName ,
157
+ from : deployer ,
158
+ log : true ,
159
+ proxy : {
160
+ proxyContract : "OpenZeppelinTransparentProxy" ,
161
+ execute : {
162
+ init : {
163
+ methodName : "initialize" ,
164
+ args : [ rewardToken , zeroAddress , flywheelBooster , deployer ]
165
+ }
166
+ } ,
167
+ owner : deployer
168
+ } ,
169
+ waitConfirmations : 1
170
+ } ) ;
171
+
172
+ console . log ( `Deployed flywheel: ${ flywheel . address } ` ) ;
173
+ const rewards = await run ( "flywheel:deploy-dynamic-rewards" , { name : name , flywheel : flywheel . address } ) ;
174
+ console . log ( `Deployed rewards: ${ rewards . address } ` ) ;
175
+ const _flywheel = await viem . getContractAt ( `${ contractName } ` , flywheel . address as Address ) ;
176
+ const tx = await _flywheel . write . setFlywheelRewards ( [ rewards . address ] ) ;
177
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
178
+
179
+ console . log ( `Set rewards (${ rewards . address } ) to flywheel (${ flywheel . address } )` ) ;
180
+ const strategyAddresses = strategies . split ( "," ) ;
181
+ for ( const strategy of strategyAddresses ) {
182
+ console . log ( `Adding strategy ${ strategy } to flywheel ${ flywheel . address } ` ) ;
183
+ await run ( "flywheel:add-strategy-for-rewards" , { flywheel : flywheel . address , strategy } ) ;
184
+ console . log ( `Added strategy (${ strategy } ) to flywheel (${ flywheel . address } )` ) ;
185
+ }
186
+ await run ( "flywheel:add-to-pool" , { flywheel : flywheel . address , pool } ) ;
187
+ console . log ( `Added flywheel (${ flywheel . address } ) to pool (${ pool } )` ) ;
188
+ }
189
+ ) ;
190
+
191
+ task ( "flywheel:deploy-dynamic-rewards" , "Deploy dynamic rewards flywheel for LM rewards" )
192
+ . addParam ( "name" , "String to append to the flywheel contract name" , undefined , types . string )
193
+ . addParam ( "flywheel" , "flywheel to which to add the rewards contract" , undefined , types . string )
194
+ . setAction ( async ( { name, flywheel } , { deployments, getNamedAccounts } ) => {
195
+ const { deployer } = await getNamedAccounts ( ) ;
196
+ const rewards = await deployments . deploy ( `IonicFlywheelDynamicRewards_${ name } ` , {
197
+ contract : "IonicFlywheelDynamicRewards" ,
198
+ from : deployer ,
199
+ log : true ,
200
+ args : [
201
+ flywheel , // flywheel
202
+ 2592000 // owner
203
+ ] ,
204
+ waitConfirmations : 1
205
+ } ) ;
206
+
207
+ const ionicSdkModule = await import ( "../ionicSdk" ) ;
208
+ const sdk = await ionicSdkModule . getOrCreateIonic ( deployer ) ;
209
+
210
+ const tx = await sdk . setFlywheelRewards ( flywheel , rewards . address ) ;
211
+ await tx . wait ( ) ;
212
+ return rewards ;
213
+ } ) ;
214
+
215
+ task ( "flywheel:deploy-borrow-booster" , "Deploy flywheel borrow bosster for LM rewards" )
216
+ . addParam ( "name" , "String to append to the flywheel contract name" , undefined , types . string )
217
+ . setAction ( async ( { name, flywheel } , { deployments, getNamedAccounts } ) => {
218
+ const { deployer } = await getNamedAccounts ( ) ;
219
+ const booster = await deployments . deploy ( `IonicFlywheelBorrowBooster_${ name } ` , {
220
+ contract : "IonicFlywheelBorrowBooster" ,
221
+ from : deployer ,
222
+ log : true ,
223
+ args : [ ] ,
224
+ waitConfirmations : 1
225
+ } ) ;
226
+
227
+ return booster ;
228
+ } ) ;
0 commit comments