Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 224352e

Browse files
committed
fix: irms
1 parent 362a58d commit 224352e

File tree

7 files changed

+1493
-12
lines changed

7 files changed

+1493
-12
lines changed

chainDeploy/helpers/irms.ts

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ const prudentiaParams: Record<number, PrudentiaConfig[]> = {
2929
blocksPerYear: 15768000,
3030
underlying: underlying(assets, assetSymbols.USDT),
3131
rateController: PRUDENTIA_RATE_CONTROLLER_MODE
32+
},
33+
{
34+
symbol: assetSymbols.WETH,
35+
blocksPerYear: 15768000,
36+
underlying: underlying(assets, assetSymbols.WETH),
37+
rateController: PRUDENTIA_RATE_CONTROLLER_MODE
3238
}
3339
]
3440
};

deploy/02-deploy-comptroller-set-extensions.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DeployFunction } from "hardhat-deploy/types";
22
import { Address, encodeFunctionData, Hash, zeroAddress } from "viem";
33

4-
import { logTransaction } from "../chainDeploy/helpers/logging";
4+
import { logTransaction, prepareAndLogTransaction } from "../chainDeploy/helpers/logging";
55

66
const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) => {
77
const { deployer, multisig } = await getNamedAccounts();
@@ -55,14 +55,16 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
5555
]);
5656
if (latestComptrollerImplementation === zeroAddress || latestComptrollerImplementation !== comptroller.address) {
5757
if ((await fuseFeeDistributor.read.owner()).toLowerCase() !== deployer.toLowerCase()) {
58-
logTransaction(
59-
"Set Latest Comptroller Implementation",
60-
encodeFunctionData({
61-
abi: fuseFeeDistributor.abi,
62-
functionName: "_setLatestComptrollerImplementation",
63-
args: [oldComptroller.address as Address, comptroller.address]
64-
})
65-
);
58+
await prepareAndLogTransaction({
59+
contractInstance: fuseFeeDistributor,
60+
functionName: "_setLatestComptrollerImplementation",
61+
args: [oldComptroller.address as Address, comptroller.address],
62+
description: "Set Latest Comptroller Implementation",
63+
inputs: [
64+
{ internalType: "address", name: "oldImplementation", type: "address" },
65+
{ internalType: "address", name: "newImplementation", type: "address" }
66+
]
67+
});
6668
} else {
6769
tx = await fuseFeeDistributor.write._setLatestComptrollerImplementation([
6870
oldComptroller.address as Address,

deployments/mode/PrudentiaInterestRateModel_WETH.json

+276
Large diffs are not rendered by default.

deployments/mode/solcInputs/5b8c5f5813b84412a483d91baee9e592.json

+1,142
Large diffs are not rendered by default.

deploymentsBrief/mode.json

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@
173173
"PrudentiaInterestRateModel_USDT": {
174174
"address": "0xC58DCC0cbc02355cF1aD6b5398dE49152ae72E2E"
175175
},
176+
"PrudentiaInterestRateModel_WETH": {
177+
"address": "0xb0a9B9F6FD960108df5B508DA5abe476d8e37F09"
178+
},
176179
"PythPriceOracle": {
177180
"address": "0x52Ee6E740C1785412e51A381B0d87fb1692a7b23"
178181
},

tasks/chain-specific/mode/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./market";

tasks/chain-specific/mode.ts renamed to tasks/chain-specific/mode/market.ts

+54-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { task } from "hardhat/config";
1+
import { task, types } from "hardhat/config";
22
import { Address, formatUnits } from "viem";
33

4-
import { assets as modeAssets } from "../../../monorepo/packages/chains/src/mode/assets";
4+
import { assets as modeAssets } from "../../../../monorepo/packages/chains/src/mode/assets";
5+
import { assetSymbols } from "../../../../monorepo/packages/types/dist";
6+
import { prepareAndLogTransaction } from "../../../chainDeploy/helpers/logging";
57

8+
const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556";
69
task("market:set-cf:mode:main", "Sets caps on a market").setAction(async (_, { viem, run }) => {
7-
const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556";
810
for (const asset of modeAssets) {
911
const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER);
1012
const cToken = await pool.read.cTokensByUnderlying([asset.underlying]);
@@ -19,6 +21,55 @@ task("market:set-cf:mode:main", "Sets caps on a market").setAction(async (_, { v
1921
}
2022
});
2123

24+
task("mode:irm:set-prudentia", "Set new IRM to ctoken").setAction(
25+
async (_, { viem, deployments, getNamedAccounts }) => {
26+
const { deployer } = await getNamedAccounts();
27+
const toSet: { symbol: string; irm: string }[] = [
28+
{ symbol: assetSymbols.USDC, irm: "PrudentiaInterestRateModel_USDC" },
29+
{ symbol: assetSymbols.USDT, irm: "PrudentiaInterestRateModel_USDT" },
30+
{ symbol: assetSymbols.WETH, irm: "PrudentiaInterestRateModel_WETH" }
31+
];
32+
const assets = modeAssets.filter((a) => toSet.map((a) => a.symbol).includes(a.symbol));
33+
console.log(
34+
"assets: ",
35+
assets.map((a) => a.symbol)
36+
);
37+
const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER);
38+
const ffd = await viem.getContractAt(
39+
"FeeDistributor",
40+
(await deployments.get("FeeDistributor")).address as Address
41+
);
42+
const admin = await ffd.read.owner();
43+
for (const asset of assets) {
44+
const cTokenAddress = await pool.read.cTokensByUnderlying([asset.underlying]);
45+
console.log("cToken: ", cTokenAddress);
46+
const publicClient = await viem.getPublicClient();
47+
48+
const cToken = await viem.getContractAt("ICErc20", cTokenAddress);
49+
const irm = toSet.find((a) => a.symbol === asset.symbol)?.irm;
50+
if (!irm) {
51+
throw new Error(`IRM not found for ${asset.symbol}`);
52+
}
53+
const irmDeployment = await deployments.get(irm);
54+
console.log("admin.toLowerCase(): ", admin.toLowerCase());
55+
console.log("deployer.toLowerCase(): ", deployer.toLowerCase());
56+
if (admin.toLowerCase() !== deployer.toLowerCase()) {
57+
await prepareAndLogTransaction({
58+
contractInstance: cToken,
59+
functionName: "_setInterestRateModel",
60+
args: [irmDeployment.address],
61+
description: `Set IRM of ${await cToken.read.underlying()} to ${irmDeployment.address}`,
62+
inputs: [{ internalType: "address", name: "newInterestRateModel", type: "address" }]
63+
});
64+
} else {
65+
const tx = await cToken.write._setInterestRateModel([irmDeployment.address as Address]);
66+
await publicClient.waitForTransactionReceipt({ hash: tx });
67+
console.log(`Set IRM of ${await cToken.read.underlying()} to ${irmDeployment.address}`);
68+
}
69+
}
70+
}
71+
);
72+
2273
task("prudentia:upgrade:pool", "Upgrades a pool to the latest comptroller implementation").setAction(
2374
async (_, { viem, deployments, getNamedAccounts }) => {
2475
const { deployer } = await getNamedAccounts();

0 commit comments

Comments
 (0)