Skip to content

Commit

Permalink
fix: deployer can set caps
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Dec 5, 2022
1 parent cd92e1d commit 9876266
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
14 changes: 14 additions & 0 deletions deploy/004-deploy-pool-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
);

await tx.wait();

tx = await accessControlManager.giveCallPermission(
ethers.constants.AddressZero,
"setMarketBorrowCaps(address[],uint256[])",
deployer,
);
await tx.wait();

tx = await accessControlManager.giveCallPermission(
ethers.constants.AddressZero,
"setMarketSupplyCaps(address[],uint256[])",
deployer,
);
await tx.wait();
};

func.tags = ["PoolsRegistry"];
Expand Down
34 changes: 17 additions & 17 deletions deploy/006-deploy-mock-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
import { convertToUnit } from "../helpers/utils";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts }: any = hre;
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer, proxyAdmin } = await getNamedAccounts();
const deployerSigner = await hre.ethers.getNamedSigner("deployer");

const BNX = await ethers.getContract("MockBNX");
const BSW = await ethers.getContract("MockBSW");
Expand All @@ -25,7 +26,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const accessControlManager = await ethers.getContract("AccessControlManager");

const Pool1Comptroller: DeployResult = await deploy("Pool 1", {
const Pool1Comptroller: DeployResult = await deploy("Pool 2", {
contract: "Comptroller",
from: deployer,
args: [poolRegistry.address, accessControlManager.address],
Expand All @@ -43,13 +44,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

tx = await poolRegistry.createRegistryPool(
"Pool 1",
proxyAdmin,
ComptrollerBeacon.address,
closeFactor,
liquidationIncentive,
minLiquidatableCollateral,
priceOracle.address,
);

await tx.wait();

const pools = await poolRegistry.callStatic.getAllPools();
Expand All @@ -61,7 +62,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const vToken = await VToken.deploy();
await vToken.deployed();

const VTokenBeacon: DeployResult = await deploy("VTokenBeacon", {
const vTokenBeacon: DeployResult = await deploy("VTokenBeacon", {
contract: "Beacon",
from: deployer,
args: [vToken.address],
Expand All @@ -84,7 +85,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
liquidationThreshold: convertToUnit(0.7, 18),
accessControlManager: accessControlManager.address,
vTokenProxyAdmin: proxyAdmin,
tokenImplementation_: VTokenBeacon.address,
beaconAddress: vTokenBeacon.address,
});
await tx.wait();

Expand All @@ -106,23 +107,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
liquidationThreshold: convertToUnit(0.7, 18),
accessControlManager: accessControlManager.address,
vTokenProxyAdmin: proxyAdmin,
tokenImplementation_: VTokenBeacon.address,
beaconAddress: vTokenBeacon.address,
});

console.log("Pools added to pool: " + comptroller1Proxy.address);
const PoolLens = await ethers.getContract("PoolLens");

const bnxVToken = await poolRegistry.getVTokenForAsset(comptroller1Proxy.address, BNX.address);
const bswVToken = await poolRegistry.getVTokenForAsset(comptroller1Proxy.address, BSW.address);
const vBSWAddress = await PoolLens.getVTokenForAsset(poolRegistry.address, comptroller1Proxy.address, BSW.address);

comptroller1Proxy.setMarketBorrowCaps(
[bnxVToken.address],
["0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"],
);
const vBNXAddress = await PoolLens.getVTokenForAsset(poolRegistry.address, comptroller1Proxy.address, BNX.address);

comptroller1Proxy.setMarketSupplyCaps(
[bswVToken.address],
["0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"],
);
const INT_MAX = ethers.constants.MaxUint256;

comptroller1Proxy.connect(deployerSigner).setMarketBorrowCaps([vBNXAddress, vBSWAddress], [INT_MAX, INT_MAX]);

comptroller1Proxy.connect(deployerSigner).setMarketSupplyCaps([vBNXAddress, vBSWAddress], [INT_MAX, INT_MAX]);

console.log("Pools added to pool: " + comptroller1Proxy.address);
};

func.tags = ["Pools"];
Expand Down

0 comments on commit 9876266

Please sign in to comment.