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

Commit d16701e

Browse files
committed
feat: deploy
1 parent 8db0a81 commit d16701e

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

tasks/chain-specific/mode/market.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { prepareAndLogTransaction } from "../../../chainDeploy/helpers/logging";
88
const COMPTROLLER = "0xfb3323e24743caf4add0fdccfb268565c0685556";
99

1010
task("markets:deploy:mode:new", "deploy new mode assets").setAction(async (_, { viem, run }) => {
11-
const assetsToDeploy: string[] = [assetSymbols.USDe, assetSymbols.sUSDe];
11+
const assetsToDeploy: string[] = [assetSymbols.USDe];
1212
for (const asset of modeAssets.filter((asset) => assetsToDeploy.includes(asset.symbol))) {
1313
await run("market:deploy", {
1414
signer: "deployer",

tasks/market/deploy.ts

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { task, types } from "hardhat/config";
22
import { Address, encodeAbiParameters, parseAbiParameters, parseEther } from "viem";
33

44
import { MarketConfig } from "../../chainDeploy";
5+
import { prepareAndLogTransaction } from "../../chainDeploy/helpers/logging";
56

67
task("market:deploy", "deploy market")
78
.addParam("signer", "Named account to use for tx", "deployer", types.string)
@@ -12,7 +13,8 @@ task("market:deploy", "deploy market")
1213
.addParam("name", "CToken name", undefined, types.string)
1314
.addOptionalParam("initialSupplyCap", "Initial supply cap", undefined, types.string)
1415
.addOptionalParam("initialBorrowCap", "Initial borrow cap", undefined, types.string)
15-
.setAction(async (taskArgs, { viem, deployments }) => {
16+
.setAction(async (taskArgs, { viem, deployments, getNamedAccounts }) => {
17+
const { deployer } = await getNamedAccounts();
1618
const publicClient = await viem.getPublicClient();
1719
const comptroller = await viem.getContractAt("IonicComptroller", taskArgs.comptroller as Address);
1820

@@ -51,28 +53,43 @@ task("market:deploy", "deploy market")
5153
]
5254
);
5355

56+
const feeDistributor = await viem.getContractAt("FeeDistributor", config.feeDistributor);
57+
const owner = await feeDistributor.read.owner();
5458
// Test Transaction
55-
const errorCode = await comptroller.simulate._deployMarket([
56-
delegateType,
57-
constructorData,
58-
implementationData,
59-
collateralFactorBN
60-
]);
59+
const errorCode = await comptroller.simulate._deployMarket(
60+
[delegateType, constructorData, implementationData, collateralFactorBN],
61+
{ account: owner }
62+
);
6163
if (errorCode.result !== 0n) {
6264
throw `Unable to _deployMarket: ${errorCode.result}`;
6365
}
64-
// Make actual Transaction
65-
const tx = await comptroller.write._deployMarket([
66-
delegateType,
67-
constructorData,
68-
implementationData,
69-
collateralFactorBN
70-
]);
71-
console.log("tx", tx);
66+
if (owner.toLowerCase() !== deployer.toLowerCase()) {
67+
await prepareAndLogTransaction({
68+
contractInstance: comptroller,
69+
functionName: "_deployMarket",
70+
args: [delegateType, constructorData, implementationData, collateralFactorBN],
71+
description: `Deploy market for ${config.underlying}`,
72+
inputs: [
73+
{ internalType: "uint8", name: "delegateType", type: "uint8" },
74+
{ internalType: "bytes", name: "constructorData", type: "bytes" },
75+
{ internalType: "bytes", name: "implementationData", type: "bytes" },
76+
{ internalType: "uint256", name: "collateralFactor", type: "uint256" }
77+
]
78+
});
79+
} else {
80+
// Make actual Transaction
81+
const tx = await comptroller.write._deployMarket([
82+
delegateType,
83+
constructorData,
84+
implementationData,
85+
collateralFactorBN
86+
]);
87+
console.log("tx", tx);
7288

73-
// Recreate Address of Deployed Market
74-
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx });
75-
if (receipt.status !== "success") {
76-
throw `Failed to deploy market for ${config.underlying}`;
89+
// Recreate Address of Deployed Market
90+
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx });
91+
if (receipt.status !== "success") {
92+
throw `Failed to deploy market for ${config.underlying}`;
93+
}
7794
}
7895
});

0 commit comments

Comments
 (0)