Skip to content

Commit

Permalink
fix: added simulations for adding market
Browse files Browse the repository at this point in the history
  • Loading branch information
web3rover committed Aug 20, 2024
1 parent 7e05692 commit a9aea6e
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 7 deletions.
45 changes: 39 additions & 6 deletions multisig/proposals/sepolia/vip-052/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ export const MOCK_ACCOUNTANT = "0x04d7B1244Ff052319D154E627004EaE5b7a05FCf";
export const ACCOUNTANT_ORACLE = "0x64672DD083F847893F307fe85c6f9C122F2EE3EB";
const RATE = "1004263421125944312";
export const weETHs = "0xE233527306c2fa1E159e251a2E5893334505A5E0";

const INITIAL_SUPPLY = parseUnits("10.009201470952191487", 18);
export const SUPPLY_CAP = parseUnits("180", 18);
export const BORROW_CAP = parseUnits("0", 18);
const CF = parseUnits("0.8", 18);
const LT = parseUnits("0.85", 18);
export const vweETHs = "0xB3A201887396F57bad3fF50DFd02022fE1Fd1774";

export const vip052 = () => {
return makeProposal([
Expand All @@ -23,13 +28,41 @@ export const vip052 = () => {
target: sepolia.RESILIENT_ORACLE,
signature: "setTokenConfig((address,address[3],bool[3]))",
params: [
[
weETHs,
[ACCOUNTANT_ORACLE, ethers.constants.AddressZero, ethers.constants.AddressZero],
[true, false, false],
],
[weETHs, [ACCOUNTANT_ORACLE, ethers.constants.AddressZero, ethers.constants.AddressZero], [true, false, false]],
],
},

// Add Market
{
target: weETHs,
signature: "faucet(uint256)",
params: [INITIAL_SUPPLY],
},
{
target: weETHs,
signature: "approve(address,uint256)",
params: [sepolia.POOL_REGISTRY, 0],
},
{
target: weETHs,
signature: "approve(address,uint256)",
params: [sepolia.POOL_REGISTRY, INITIAL_SUPPLY],
},
{
target: vweETHs,
signature: "setReduceReservesBlockDelta(uint256)",
params: ["7200"],
},
{
target: sepolia.POOL_REGISTRY,
signature: "addMarket((address,uint256,uint256,uint256,address,uint256,uint256))",
params: [[vweETHs, CF, LT, INITIAL_SUPPLY, sepolia.VTREASURY, SUPPLY_CAP, BORROW_CAP]],
},
{
target: vweETHs,
signature: "setProtocolSeizeShare(uint256)",
params: [parseUnits("0.01", 18)],
},
]);
};

Expand Down
90 changes: 89 additions & 1 deletion multisig/simulations/sepolia/vip-052/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@ import { checkVToken } from "src/vip-framework/checks/checkVToken";
import { checkInterestRate } from "src/vip-framework/checks/interestRateModel";
import { forking, pretendExecutingVip } from "src/vip-framework/index";

import { weETHs, vip052, ACCOUNTANT_ORACLE, MOCK_ACCOUNTANT } from "../../../proposals/sepolia/vip-052";
import { BORROW_CAP, SUPPLY_CAP, vip052, vweETHs, weETHs } from "../../../proposals/sepolia/vip-052";
import POOL_REGISTRY_ABI from "./abi/PoolRegistry.json";
import RESILIENT_ORACLE_ABI from "./abi/ResilientOracle.json";
import COMPTROLLER_ABI from "./abi/comptroller.json";
import ERC20_ABI from "./abi/erc20.json";
import VTOKEN_ABI from "./abi/vToken.json";

const { sepolia } = NETWORK_ADDRESSES;
const LIQUID_STAKED_COMPTROLLER = "0xd79CeB8EF8188E44b7Eb899094e8A3A4d7A1e236";
const PROTOCOL_SHARE_RESERVE = "0xbea70755cc3555708ca11219adB0db4C80F6721B";

forking(6536889, async () => {
let resilientOracle: Contract;
let poolRegistry: Contract;
let vweETHsContract: Contract;
let comptroller: Contract;
let weETHsContract: Contract;

before(async () => {
await impersonateAccount(sepolia.NORMAL_TIMELOCK);
await setBalance(sepolia.NORMAL_TIMELOCK, parseUnits("1000", 18));

resilientOracle = await ethers.getContractAt(RESILIENT_ORACLE_ABI, sepolia.RESILIENT_ORACLE);
poolRegistry = await ethers.getContractAt(POOL_REGISTRY_ABI, sepolia.POOL_REGISTRY);
vweETHsContract = await ethers.getContractAt(VTOKEN_ABI, vweETHs);
comptroller = await ethers.getContractAt(COMPTROLLER_ABI, LIQUID_STAKED_COMPTROLLER);
weETHsContract = await ethers.getContractAt(ERC20_ABI, weETHs, await ethers.getSigner(sepolia.NORMAL_TIMELOCK));
});

describe("Pre-VIP behavior", () => {
Expand All @@ -37,6 +51,80 @@ forking(6536889, async () => {

it("check price", async () => {
expect(await resilientOracle.getPrice(weETHs)).to.be.closeTo(parseUnits("2662", 18), parseUnits("1", 18));
expect(await resilientOracle.getUnderlyingPrice(vweETHs)).to.be.closeTo(
parseUnits("2662", 18),
parseUnits("1", 18),
);
});

it("should have 8 markets in liquid staked pool", async () => {
const poolVTokens = await comptroller.getAllMarkets();
expect(poolVTokens).to.have.lengthOf(8);
});

it("should add vweETHs to the pool", async () => {
const registeredVToken = await poolRegistry.getVTokenForAsset(comptroller.address, weETHs);
expect(registeredVToken).to.equal(vweETHs);
});

it("check ownership", async () => {
expect(await vweETHsContract.owner()).to.equal(sepolia.GUARDIAN);
});

it("check supply", async () => {
const expectedSupply = parseUnits("10.00920147", 8);
expect(await vweETHsContract.balanceOf(sepolia.VTREASURY)).to.equal(expectedSupply);
});

it("check borrow and supply caps", async () => {
expect(await comptroller.borrowCaps(vweETHs)).equals(BORROW_CAP);
expect(await comptroller.supplyCaps(vweETHs)).equals(SUPPLY_CAP);
});

it("should set vweETHs collateral factor to 80% and Liquidation threshold to 85%", async () => {
const market = await comptroller.markets(vweETHs);
expect(market.collateralFactorMantissa).to.equal(parseUnits("0.80", 18));
expect(market.liquidationThresholdMantissa).to.equal(parseUnits("0.85", 18));
});

it("check protocol share reserve", async () => {
expect(await vweETHsContract.protocolShareReserve()).equals(PROTOCOL_SHARE_RESERVE);
});

it("check reserve factor", async () => {
expect(await vweETHsContract.reserveFactorMantissa()).equals(parseUnits("0.25", 18));
});

it("check protocol seize share", async () => {
expect(await vweETHsContract.protocolSeizeShareMantissa()).equals(parseUnits("0.01", 18));
});

it("check vToken", async () => {
checkVToken(vweETHs, {
name: "Venus weETHs (Liquid Staked ETH)",
symbol: "vweETHs_LiquidStakedETH",
decimals: 8,
underlying: weETHs,
exchangeRate: parseUnits("1.0000000000951316136311121730", 28),
comptroller: LIQUID_STAKED_COMPTROLLER,
});
});

it("check IR", async () => {
const IR = await vweETHsContract.interestRateModel();
checkInterestRate(
IR,
"vweETHsContract_Core",
{ base: "0", multiplier: "0.09", jump: "0.75", kink: "0.45" },
BigNumber.from(2628000),
);
});

it("check Pool", async () => {
await weETHsContract.faucet(parseUnits("100", 18));
await checkIsolatedPoolsComptrollers({
[LIQUID_STAKED_COMPTROLLER]: sepolia.NORMAL_TIMELOCK,
});
});
});
});

0 comments on commit a9aea6e

Please sign in to comment.