1
1
import { task } from "hardhat/config" ;
2
2
import { assets as modeAssets } from "../../chains/mode/assets" ;
3
- import { Address } from "viem" ;
3
+ import { Address , formatUnits } from "viem" ;
4
4
5
5
task ( "market:set-cf:mode:main" , "Sets caps on a market" ) . setAction ( async ( _ , { viem, run } ) => {
6
6
const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
@@ -83,4 +83,48 @@ task("prudentia:config", "Sets prudentia config").setAction(async (_, { viem, ge
83
83
tx = await cToken2 . write . _setInterestRateModel ( [ ionUSDTirm ] ) ;
84
84
await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
85
85
console . log ( `Set IRM of ${ await cToken2 . read . symbol ( ) } to ${ ionUSDTirm } ` ) ;
86
+ } ) ;
87
+
88
+ task ( "prudentia:print-supply-cap-config" , "Prints supply cap config" ) . setAction ( async ( _ , { viem } ) => {
89
+ const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
90
+ const pool = await viem . getContractAt ( "ComptrollerPrudentiaCapsExt" , COMPTROLLER ) ;
91
+ const supplyCapConfig = await pool . read . getSupplyCapConfig ( ) ;
92
+ console . log ( "supply cap config: " , supplyCapConfig ) ;
93
+ } ) ;
94
+
95
+ task ( "prudentia:print-borrow-cap-config" , "Prints borrow cap config" ) . setAction ( async ( _ , { viem } ) => {
96
+ const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
97
+ const pool = await viem . getContractAt ( "ComptrollerPrudentiaCapsExt" , COMPTROLLER ) ;
98
+ const borrowCapConfig = await pool . read . getBorrowCapConfig ( ) ;
99
+ console . log ( "supply cap config: " , borrowCapConfig ) ;
100
+ } ) ;
101
+
102
+ task ( "prudentia:print-supply-cap" , "Prints supply cap" ) . addParam ( "cToken" , "The address of the cToken" ) . setAction ( async ( taskArgs , { viem } ) => {
103
+ const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
104
+ const pool = await viem . getContractAt ( "Comptroller" , COMPTROLLER ) ;
105
+
106
+ // Get underlying token
107
+ const cTokenContract = await viem . getContractAt ( "CErc20" , taskArgs . cToken ) ;
108
+ const underlyingToken = await cTokenContract . read . underlying ( ) ;
109
+ // Get underlying decimals
110
+ const underlyingTokenContract = await viem . getContractAt ( "ERC20" , underlyingToken ) ;
111
+ const underlyingDecimals = await underlyingTokenContract . read . decimals ( ) ;
112
+
113
+ const supplyCaps = await pool . read . effectiveSupplyCaps ( [ taskArgs . cToken ] ) ;
114
+ console . log ( "Supply cap for " + taskArgs . cToken + ": " , supplyCaps + " = " + formatUnits ( supplyCaps , underlyingDecimals ) ) ;
115
+ } ) ;
116
+
117
+ task ( "prudentia:print-borrow-cap" , "Prints supply cap" ) . addParam ( "cToken" , "The address of the cToken" ) . setAction ( async ( taskArgs , { viem } ) => {
118
+ const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556" ;
119
+ const pool = await viem . getContractAt ( "Comptroller" , COMPTROLLER ) ;
120
+
121
+ // Get underlying token
122
+ const cTokenContract = await viem . getContractAt ( "CErc20" , taskArgs . cToken ) ;
123
+ const underlyingToken = await cTokenContract . read . underlying ( ) ;
124
+ // Get underlying decimals
125
+ const underlyingTokenContract = await viem . getContractAt ( "ERC20" , underlyingToken ) ;
126
+ const underlyingDecimals = await underlyingTokenContract . read . decimals ( ) ;
127
+
128
+ const supplyCaps = await pool . read . effectiveBorrowCaps ( [ taskArgs . cToken ] ) ;
129
+ console . log ( "Supply cap for " + taskArgs . cToken + ": " , supplyCaps + " = " + formatUnits ( supplyCaps , underlyingDecimals ) ) ;
86
130
} ) ;
0 commit comments