1
1
import { task , types } from "hardhat/config" ;
2
+ import { prepareAndLogTransaction } from "../../../chainDeploy/helpers/logging" ;
2
3
3
4
export default task ( "market:set-borrow-cap" , "Set borrow cap on market" )
4
5
. addParam ( "admin" , "Named account from which to set the borrow caps" , "deployer" , types . string )
5
6
. addParam ( "market" , "The address of the CToken" , undefined , types . string )
6
7
. addParam ( "maxBorrow" , "Maximum amount of tokens that can be borrowed" , undefined , types . string )
7
- . setAction ( async ( { market, maxBorrow } , { viem } ) => {
8
+ . setAction ( async ( { market, maxBorrow } , { viem, getNamedAccounts } ) => {
9
+ const { deployer } = await getNamedAccounts ( ) ;
8
10
const publicClient = await viem . getPublicClient ( ) ;
9
11
const cToken = await viem . getContractAt ( "ICErc20" , market ) ;
10
12
const comptroller = await cToken . read . comptroller ( ) ;
@@ -20,59 +22,75 @@ export default task("market:set-borrow-cap", "Set borrow cap on market")
20
22
return ;
21
23
}
22
24
23
- const tx = await pool . write . _setMarketBorrowCaps ( [ [ cToken . address ] , [ newBorrowCap ] ] ) ;
24
- await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
25
- console . log ( "tx: " , tx ) ;
26
- const newBorrowCapSet = await pool . read . borrowCaps ( [ cToken . address ] ) ;
27
- console . log ( `New borrow cap set: ${ newBorrowCapSet . toString ( ) } ` ) ;
25
+ const feeDistributor = await viem . getContractAt ( "FeeDistributor" , await pool . read . ionicAdmin ( ) ) ;
26
+ const owner = await feeDistributor . read . owner ( ) ;
27
+
28
+ if ( owner . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
29
+ await prepareAndLogTransaction ( {
30
+ contractInstance : pool ,
31
+ functionName : "_setMarketBorrowCaps" ,
32
+ args : [ [ cToken . address ] , [ newBorrowCap ] ] ,
33
+ description : `Set borrow cap of ${ await cToken . read . underlying ( ) } to ${ newBorrowCap } ` ,
34
+ inputs : [
35
+ { internalType : "address[]" , name : "cTokens" , type : "address[]" } ,
36
+ { internalType : "uint256[]" , name : "newBorrowCaps" , type : "uint256[]" }
37
+ ]
38
+ } ) ;
39
+ } else {
40
+ const tx = await pool . write . _setMarketBorrowCaps ( [ [ cToken . address ] , [ newBorrowCap ] ] ) ;
41
+ await publicClient . waitForTransactionReceipt ( { hash : tx } ) ;
42
+ console . log ( "tx: " , tx ) ;
43
+ const newBorrowCapSet = await pool . read . borrowCaps ( [ cToken . address ] ) ;
44
+ console . log ( `New borrow cap set: ${ newBorrowCapSet . toString ( ) } ` ) ;
45
+ }
28
46
} ) ;
29
47
30
- task ( "market:set-borrow-cap-whitelist" , "Pauses borrowing on a market" )
31
- . addParam ( "admin" , "Named account from which to set the borrow cap whitelist" , "deployer" , types . string )
32
- . addParam ( "market" , "The address of the CToken" , undefined , types . string )
33
- . addParam ( "account" , "Account to be whitelisted / removed from whitelist" , undefined , types . string )
34
- . addOptionalParam ( "whitelist" , "Set whitelist to true ot false" , true , types . boolean )
35
- . setAction ( async ( { admin, market, account, whitelist } , { ethers } ) => {
36
- const signer = await ethers . getNamedSigner ( admin ) ;
48
+ // task("market:set-borrow-cap-whitelist", "Pauses borrowing on a market")
49
+ // .addParam("admin", "Named account from which to set the borrow cap whitelist", "deployer", types.string)
50
+ // .addParam("market", "The address of the CToken", undefined, types.string)
51
+ // .addParam("account", "Account to be whitelisted / removed from whitelist", undefined, types.string)
52
+ // .addOptionalParam("whitelist", "Set whitelist to true ot false", true, types.boolean)
53
+ // .setAction(async ({ admin, market, account, whitelist }, { ethers }) => {
54
+ // const signer = await ethers.getNamedSigner(admin);
37
55
38
- const ionicSdkModule = await import ( "../../ionicSdk" ) ;
39
- const sdk = await ionicSdkModule . getOrCreateIonic ( signer ) ;
56
+ // const ionicSdkModule = await import("../../ionicSdk");
57
+ // const sdk = await ionicSdkModule.getOrCreateIonic(signer);
40
58
41
- const cToken = sdk . createICErc20 ( market , signer ) ;
42
- const comptroller = await cToken . callStatic . comptroller ( ) ;
43
- const pool = sdk . createComptroller ( comptroller , signer ) ;
59
+ // const cToken = sdk.createICErc20(market, signer);
60
+ // const comptroller = await cToken.callStatic.comptroller();
61
+ // const pool = sdk.createComptroller(comptroller, signer);
44
62
45
- const currentBorrowCap = await pool . callStatic . supplyCaps ( cToken . address ) ;
46
- console . log ( `Current borrow cap is ${ currentBorrowCap } ` ) ;
63
+ // const currentBorrowCap = await pool.callStatic.supplyCaps(cToken.address);
64
+ // console.log(`Current borrow cap is ${currentBorrowCap}`);
47
65
48
- const whitelistStatus = await pool . callStatic . supplyCapWhitelist ( market , account ) ;
49
- if ( whitelistStatus == whitelist ) {
50
- console . log ( `Whitelist status is already ${ whitelist } ` ) ;
51
- return ;
52
- } else {
53
- console . log ( `Whitelist status is ${ whitelistStatus } , setting to ${ whitelist } ` ) ;
54
- const tx : providers . TransactionResponse = await pool . _supplyCapWhitelist ( market , account , whitelist ) ;
55
- await tx . wait ( ) ;
56
- console . log ( `Whitelist status for ${ account } set: ${ await pool . callStatic . supplyCapWhitelist ( market , account ) } ` ) ;
57
- }
58
- } ) ;
66
+ // const whitelistStatus = await pool.callStatic.supplyCapWhitelist(market, account);
67
+ // if (whitelistStatus == whitelist) {
68
+ // console.log(`Whitelist status is already ${whitelist}`);
69
+ // return;
70
+ // } else {
71
+ // console.log(`Whitelist status is ${whitelistStatus}, setting to ${whitelist}`);
72
+ // const tx: providers.TransactionResponse = await pool._supplyCapWhitelist(market, account, whitelist);
73
+ // await tx.wait();
74
+ // console.log(`Whitelist status for ${account} set: ${await pool.callStatic.supplyCapWhitelist(market, account)}`);
75
+ // }
76
+ // });
59
77
60
- task ( "market:set-borrow-cap-guardian" , "Set borrow cap guardian on market" )
61
- . addParam ( "poolAddress" , "The address of the pool" , undefined , types . string )
62
- . addParam ( "borrowGuardian" , "The address of the borrow cap guardian" , undefined , types . string )
63
- . setAction ( async ( { poolAddress, borrowGuardian } , { ethers, getNamedAccounts } ) => {
64
- const { deployer } = await getNamedAccounts ( ) ;
65
- console . log ( "signer: " , deployer ) ;
78
+ // task("market:set-borrow-cap-guardian", "Set borrow cap guardian on market")
79
+ // .addParam("poolAddress", "The address of the pool", undefined, types.string)
80
+ // .addParam("borrowGuardian", "The address of the borrow cap guardian", undefined, types.string)
81
+ // .setAction(async ({ poolAddress, borrowGuardian }, { ethers, getNamedAccounts }) => {
82
+ // const { deployer } = await getNamedAccounts();
83
+ // console.log("signer: ", deployer);
66
84
67
- const signer = await ethers . getSigner ( deployer ) ;
85
+ // const signer = await ethers.getSigner(deployer);
68
86
69
- const ionicSdkModule = await import ( "../../ionicSdk" ) ;
70
- const sdk = await ionicSdkModule . getOrCreateIonic ( signer ) ;
87
+ // const ionicSdkModule = await import("../../ionicSdk");
88
+ // const sdk = await ionicSdkModule.getOrCreateIonic(signer);
71
89
72
- const pool = sdk . createComptroller ( poolAddress , signer ) ;
90
+ // const pool = sdk.createComptroller(poolAddress, signer);
73
91
74
- const tx : providers . TransactionResponse = await pool . _setBorrowCapGuardian ( borrowGuardian ) ;
75
- await tx . wait ( ) ;
92
+ // const tx: providers.TransactionResponse = await pool._setBorrowCapGuardian(borrowGuardian);
93
+ // await tx.wait();
76
94
77
- console . log ( `Configured the borrow cap guardian to : ${ borrowGuardian } ` ) ;
78
- } ) ;
95
+ // console.log(`Configured the borrow cap guardian to : ${borrowGuardian}`);
96
+ // });
0 commit comments