1
1
import { task } from "hardhat/config" ;
2
2
import { assets as modeAssets } from "../../chains/mode/assets" ;
3
+ import { Address } from "viem" ;
3
4
4
5
task ( "market:set-cf:mode:main" , "Sets caps on a market" ) . setAction ( async ( _ , { viem, run } ) => {
5
6
const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
@@ -16,3 +17,68 @@ task("market:set-cf:mode:main", "Sets caps on a market").setAction(async (_, { v
16
17
}
17
18
}
18
19
} ) ;
20
+
21
+ task ( "prudentia:upgrade:pool" , "Upgrades a pool to the latest comptroller implementation" ) . setAction (
22
+ async ( _ , { viem, deployments, getNamedAccounts } ) => {
23
+ const { deployer } = await getNamedAccounts ( ) ;
24
+ console . log ( "deployer: " , deployer ) ;
25
+ const publicClient = await viem . getPublicClient ( ) ;
26
+ const fuseFeeDistributor = await viem . getContractAt (
27
+ "FeeDistributor" ,
28
+ ( await deployments . get ( "FeeDistributor" ) ) . address as Address
29
+ ) ;
30
+ const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
31
+ const unitroller = await viem . getContractAt ( "Unitroller" , COMPTROLLER ) ;
32
+ const admin = await unitroller . read . admin ( ) ;
33
+ console . log ( "pool admin" , admin ) ;
34
+
35
+ const implBefore = await unitroller . read . comptrollerImplementation ( ) ;
36
+
37
+ const latestImpl = await fuseFeeDistributor . read . latestComptrollerImplementation ( [ implBefore ] ) ;
38
+ console . log ( `current impl ${ implBefore } latest ${ latestImpl } ` ) ;
39
+
40
+ const shouldUpgrade = implBefore !== latestImpl ;
41
+
42
+ if ( shouldUpgrade ) {
43
+ const tx = await unitroller . write . _upgrade ( ) ;
44
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
45
+ console . log ( `Upgraded pool ${ COMPTROLLER } with tx ${ tx } ` ) ;
46
+ }
47
+ }
48
+ ) ;
49
+
50
+ task ( "prudentia:config" , "Sets prudentia config" ) . setAction ( async ( _ , { viem, getNamedAccounts } ) => {
51
+ const { deployer } = await getNamedAccounts ( ) ;
52
+ console . log ( "deployer: " , deployer ) ;
53
+ const publicClient = await viem . getPublicClient ( ) ;
54
+ const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
55
+ const pool = await viem . getContractAt ( "ComptrollerPrudentiaCapsExt" , COMPTROLLER ) ;
56
+ const admin = await pool . read . admin ( ) ;
57
+ console . log ( "admin: " , admin ) ;
58
+ let tx = await pool . write . _setSupplyCapConfig ( [
59
+ { controller : "0x425Ed58c3B836B1c5a073ab5dae3ee6c94336B21" , offset : 0 , decimalShift : - 4 }
60
+ ] ) ;
61
+ console . log ( "set supply cap config tx: " , tx ) ;
62
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
63
+ // set borrow cap config
64
+ tx = await pool . write . _setBorrowCapConfig ( [
65
+ { controller : "0x3060759F0D0BF60c373f9057BB1269c28Bd5Bb66" , offset : 0 , decimalShift : - 4 }
66
+ ] ) ;
67
+
68
+ // set ionusdc IRM
69
+ const ionUSDC = "0x2BE717340023C9e14C1Bb12cb3ecBcfd3c3fB038" ;
70
+ const ionUSDCirm = "0x6a40D802080a37E210Ec87735ABF995b5BC636A6" ;
71
+
72
+ const cToken = await viem . getContractAt ( "ICErc20" , ionUSDC ) ;
73
+ tx = await cToken . write . _setInterestRateModel ( [ ionUSDCirm ] ) ;
74
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
75
+ console . log ( `Set IRM of ${ await cToken . read . symbol ( ) } to ${ ionUSDCirm } ` ) ;
76
+
77
+ // set ionusdt IRM
78
+ const ionUSDT = "0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3" ;
79
+ const ionUSDTirm = "0xC58DCC0cbc02355cF1aD6b5398dE49152ae72E2E" ;
80
+ const cToken2 = await viem . getContractAt ( "ICErc20" , ionUSDT ) ;
81
+ tx = await cToken2 . write . _setInterestRateModel ( [ ionUSDTirm ] ) ;
82
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
83
+ console . log ( `Set IRM of ${ await cToken2 . read . symbol ( ) } to ${ ionUSDTirm } ` ) ;
84
+ } ) ;
0 commit comments