Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Debugger022 committed Jun 16, 2023
1 parent cff7477 commit 7a7185c
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions simulations/vip-diamond-comptroller-testnet/simulations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ forking(29886033, async () => {
treasuryPercent: any,
liquidatorContract: any,
comptrollerLens: any,
market: any,
venusSupplierIndex: any,
venusBorrowerIndex: any,
venusBorrowSpeeds: any,
venusSupplySpeeds: any;

const borrowSpeeds: any = {};
const supplySpeeds: any = {}
const userBorrowIndexes: any = {};
const userSupplyIndexes: any = {};
const markets: any = {};

let BUSD: ethers.contract;
let usdtHolder: ethers.Signer;
Expand Down Expand Up @@ -128,8 +129,6 @@ forking(29886033, async () => {

liquidationIncentiveMantissa = await unitroller.liquidationIncentiveMantissa();

allMarkets = await unitroller.allMarkets(0);

venusRate = await unitroller.venusRate();

venusSpeeds = await unitroller.venusSpeeds(BUSD.address);
Expand All @@ -145,7 +144,6 @@ forking(29886033, async () => {
vaiController = await unitroller.vaiController();

mintedVAIs = await unitroller.mintedVAIs(busdHolder.address);
unitroller.minte;

mintVAIGuardianPaused = await unitroller.mintVAIGuardianPaused();

Expand All @@ -171,20 +169,24 @@ forking(29886033, async () => {

comptrollerLens = await unitroller.comptrollerLens();

// cheking all public mappings
market = await unitroller.markets(vBUSD.address);
// checking all public mappings
allMarkets = await unitroller.getAllMarkets();

venusBorrowerIndex = await unitroller.venusBorrowerIndex(vBUSD.address, busdHolder.address);
for( const marketIndex in allMarkets) {
const marketAddress = allMarkets[marketIndex].toString()

venusSupplierIndex = await unitroller.venusSupplierIndex(vBUSD.address, busdHolder.address);
borrowSpeeds[marketAddress] = await unitroller.venusBorrowSpeeds(marketAddress)
supplySpeeds[marketAddress] = await unitroller.venusSupplySpeeds(marketAddress);
markets[marketAddress] = await unitroller.markets(marketAddress);

venusBorrowSpeeds = await unitroller.venusBorrowSpeeds(vUSDT.address);
venusSupplySpeeds = await unitroller.venusSupplySpeeds(vUSDT.address);
userBorrowIndexes[marketAddress] = await unitroller.venusBorrowerIndex(marketAddress, busdHolder.address);
userSupplyIndexes[marketAddress] = await unitroller.venusSupplierIndex(marketAddress, busdHolder.address);
}
});
});
});

testVip("VIP-Diamond TRON Contract Migration", vipDiamondTestnet());
testVip("VIP-Diamond Contract Migration", vipDiamondTestnet());

describe("Verify Storage slots after VIP execution", async () => {
// These tests checks the storage collision of comptroller while updating it via diamond.
Expand Down Expand Up @@ -218,9 +220,6 @@ forking(29886033, async () => {
const liquidationIncentiveMantissaAfterUpgrade = await diamondUnitroller.liquidationIncentiveMantissa();
expect(liquidationIncentiveMantissa).to.equal(liquidationIncentiveMantissaAfterUpgrade);

const allMarketsAfterUpgrade = await diamondUnitroller.allMarkets(0);
expect(allMarkets).to.equal(allMarketsAfterUpgrade);

const venusRateAfterUpgrade = await diamondUnitroller.venusRate();
expect(venusRate).to.equal(venusRateAfterUpgrade);

Expand Down Expand Up @@ -281,23 +280,25 @@ forking(29886033, async () => {
const comptrollerLensUpgrade = await diamondUnitroller.comptrollerLens();
expect(comptrollerLens).to.equal(comptrollerLensUpgrade);

// cheking all public mappings
const marketUpgrade = await diamondUnitroller.markets(vBUSD.address);
expect(market.collateralFactorMantissa).to.equal(marketUpgrade.collateralFactorMantissa);
expect(market.isListed).to.equal(marketUpgrade.isListed);
expect(market.isVenus).to.equal(marketUpgrade.isVenus);

const venusBorrowerIndexUpgrade = await diamondUnitroller.venusBorrowerIndex(vBUSD.address, busdHolder.address);
expect(venusBorrowerIndex).to.equal(venusBorrowerIndexUpgrade);

const venusSupplierIndexUpgrade = await diamondUnitroller.venusSupplierIndex(vBUSD.address, busdHolder.address);
expect(venusSupplierIndex).to.equal(venusSupplierIndexUpgrade);

const venusBorrowSpeedsUpgrade = await diamondUnitroller.venusBorrowSpeeds(vUSDT.address);
const venusSupplySpeedsUpgrade = await diamondUnitroller.venusSupplySpeeds(vUSDT.address);

expect(venusBorrowSpeeds).to.equal(venusBorrowSpeedsUpgrade);
expect(venusSupplySpeeds).to.equal(venusSupplySpeedsUpgrade);
// checking all public mappings
for( const marketIndex in allMarkets) {
const marketAddress = allMarkets[marketIndex].toString()

const marketUpgrade = await diamondUnitroller.markets(marketAddress);
expect(markets[marketAddress].collateralFactorMantissa).to.equal(marketUpgrade.collateralFactorMantissa);
expect(markets[marketAddress].isListed).to.equal(marketUpgrade.isListed);
expect(markets[marketAddress].isVenus).to.equal(marketUpgrade.isVenus);

const venusBorrowSpeed = await diamondUnitroller.venusBorrowSpeeds(marketAddress);
const venusSupplySpeed = await diamondUnitroller.venusSupplySpeeds(marketAddress);
expect(borrowSpeeds[marketAddress]).to.equal(venusBorrowSpeed);
expect(supplySpeeds[marketAddress]).to.equal(venusSupplySpeed);

const userBorrowIndex = await diamondUnitroller.venusBorrowerIndex(marketAddress, busdHolder.address);
const userSupplyIndex= await diamondUnitroller.venusSupplierIndex(marketAddress, busdHolder.address);
expect(userBorrowIndexes[marketAddress]).to.equal(userBorrowIndex);
expect(userSupplyIndexes[marketAddress]).to.equal(userSupplyIndex);
}
});
});
});
Expand All @@ -320,7 +321,7 @@ forking(29886033, async () => {
expect(await diamondUnitroller.closeFactorMantissa()).to.equals(parseUnits(currentCloseFactor, 0));
});

it("setting setting Liquidation Incentive", async () => {
it("setting Liquidation Incentive", async () => {
await diamondUnitroller.connect(owner)._setLiquidationIncentive(parseUnits("13", 17));
expect(await diamondUnitroller.liquidationIncentiveMantissa()).to.equal(parseUnits("13", 17));

Expand Down

0 comments on commit 7a7185c

Please sign in to comment.