1
+ import { viem } from "hardhat" ;
1
2
import { task , types } from "hardhat/config" ;
2
3
import { Address , getAddress , zeroAddress } from "viem" ;
3
4
@@ -54,7 +55,8 @@ task("flywheel:deploy-static-rewards-fw", "Deploy static rewards flywheel for LM
54
55
task ( "flywheel:deploy-static-rewards" , "Deploy static rewards flywheel for LM rewards" )
55
56
. addParam ( "name" , "String to append to the flywheel contract name" , undefined , types . string )
56
57
. addParam ( "flywheel" , "flywheel to which to add the rewards contract" , undefined , types . string )
57
- . setAction ( async ( { signer, name, flywheel } , { viem, deployments, getNamedAccounts } ) => {
58
+ . setAction ( async ( { name, flywheel } , { viem, deployments, getNamedAccounts } ) => {
59
+ const publicClient = await viem . getPublicClient ( ) ;
58
60
const { deployer } = await getNamedAccounts ( ) ;
59
61
const rewards = await deployments . deploy ( `WithdrawableFlywheelStaticRewards_${ name } ` , {
60
62
contract : "WithdrawableFlywheelStaticRewards" ,
@@ -68,11 +70,9 @@ task("flywheel:deploy-static-rewards", "Deploy static rewards flywheel for LM re
68
70
waitConfirmations : 1
69
71
} ) ;
70
72
71
- const ionicSdkModule = await import ( "../ionicSdk" ) ;
72
- const sdk = await ionicSdkModule . getOrCreateIonic ( deployer ) ;
73
-
74
- const tx = await sdk . setFlywheelRewards ( flywheel , rewards . address ) ;
75
- await tx . wait ( ) ;
73
+ const flywheelContract = await viem . getContractAt ( "IonicFlywheel" , flywheel ) ;
74
+ const tx = await flywheelContract . write . setFlywheelRewards ( [ rewards . address as Address ] ) ;
75
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
76
76
return rewards ;
77
77
} ) ;
78
78
@@ -143,13 +143,11 @@ task("flywheel:deploy-dynamic-rewards-fw", "Deploy dynamic rewards flywheel for
143
143
let contractName ;
144
144
if ( booster != "" ) {
145
145
flywheelBooster = await viem . getContractAt ( booster , ( await deployments . get ( booster ) ) . address as Address ) ;
146
- }
147
- else flywheelBooster = zeroAddress ;
146
+ } else flywheelBooster = zeroAddress ;
148
147
149
148
if ( name . includes ( "Borrow" ) ) {
150
149
contractName = "IonicFlywheelBorrow" ;
151
- }
152
- else contractName = "IonicFlywheel"
150
+ } else contractName = "IonicFlywheel" ;
153
151
154
152
console . log ( { signer, name, rewardToken, booster, strategies, pool } ) ;
155
153
const flywheel = await deployments . deploy ( `${ contractName } _${ name } ` , {
@@ -191,7 +189,8 @@ task("flywheel:deploy-dynamic-rewards-fw", "Deploy dynamic rewards flywheel for
191
189
task ( "flywheel:deploy-dynamic-rewards" , "Deploy dynamic rewards flywheel for LM rewards" )
192
190
. addParam ( "name" , "String to append to the flywheel contract name" , undefined , types . string )
193
191
. addParam ( "flywheel" , "flywheel to which to add the rewards contract" , undefined , types . string )
194
- . setAction ( async ( { name, flywheel } , { deployments, getNamedAccounts } ) => {
192
+ . setAction ( async ( { name, flywheel } , { viem, deployments, getNamedAccounts } ) => {
193
+ const publicClient = await viem . getPublicClient ( ) ;
195
194
const { deployer } = await getNamedAccounts ( ) ;
196
195
const rewards = await deployments . deploy ( `IonicFlywheelDynamicRewards_${ name } ` , {
197
196
contract : "IonicFlywheelDynamicRewards" ,
@@ -203,12 +202,9 @@ task("flywheel:deploy-dynamic-rewards", "Deploy dynamic rewards flywheel for LM
203
202
] ,
204
203
waitConfirmations : 1
205
204
} ) ;
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 ( ) ;
205
+ const flywheelContract = await viem . getContractAt ( "IonicFlywheel" , flywheel ) ;
206
+ const tx = await flywheelContract . write . setFlywheelRewards ( [ rewards . address as Address ] ) ;
207
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
212
208
return rewards ;
213
209
} ) ;
214
210
@@ -225,4 +221,4 @@ task("flywheel:deploy-borrow-booster", "Deploy flywheel borrow bosster for LM re
225
221
} ) ;
226
222
227
223
return booster ;
228
- } ) ;
224
+ } ) ;
0 commit comments