Skip to content

Commit

Permalink
feat: market
Browse files Browse the repository at this point in the history
  • Loading branch information
rhlsthrm committed Dec 18, 2024
1 parent dd9db73 commit e6b2c29
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions packages/contracts/tasks/chain-specific/superseed/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,58 @@ task("markets:deploy:superseed:new", "deploy new superseed assets").setAction(as
}
}
});

task("superseed:set-caps:new", "one time setup").setAction(async (_, { viem, run, getNamedAccounts, deployments }) => {
const { deployer } = await getNamedAccounts();
const assetsToDeploy: string[] = [assetSymbols.WETH];
for (const asset of superseed.assets.filter((asset) => assetsToDeploy.includes(asset.symbol))) {
const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER_MAIN);
const cToken = await pool.read.cTokensByUnderlying([asset.underlying]);
const asExt = await viem.getContractAt("CTokenFirstExtension", cToken);
const admin = await pool.read.admin();
const ap = await deployments.get("AddressesProvider");
if (admin.toLowerCase() !== deployer.toLowerCase()) {
await prepareAndLogTransaction({
contractInstance: asExt,
functionName: "_setAddressesProvider",
args: [ap.address as Address],
description: "Set Addresses Provider",
inputs: [
{
internalType: "address",
name: "_ap",
type: "address"
}
]
});
} else {
const tx = await asExt.write._setAddressesProvider([ap.address as Address]);
console.log("set addresses provider", tx);
}

await run("market:set-borrow-cap", {
market: cToken,
maxBorrow: asset.initialBorrowCap
});

await run("market:set-supply-cap", {
market: cToken,
maxSupply: asset.initialSupplyCap
});
}
});

task("market:set-cf:superseed:new", "Sets CF on a market").setAction(async (_, { viem, run }) => {
for (const asset of superseed.assets.filter((asset) => asset.symbol === assetSymbols.WETH)) {
const pool = await viem.getContractAt("IonicComptroller", COMPTROLLER_MAIN);
const cToken = await pool.read.cTokensByUnderlying([asset.underlying]);
console.log("cToken: ", cToken, asset.symbol);

if (asset.initialCf) {
await run("market:set:ltv", {
marketAddress: cToken,
ltv: asset.initialCf
});
}
}
});

0 comments on commit e6b2c29

Please sign in to comment.