Skip to content

Commit

Permalink
Linting fixes (#783)
Browse files Browse the repository at this point in the history
* minor fix

* linting fix
  • Loading branch information
Manoj Patra authored Jul 14, 2023
1 parent 81230ff commit 5e71bb5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default migration("1689168483_add_maticx_collateral", {
)
);

const event = (await txn.wait()).events.find(
const event = txn.events.find(
(event) => event.event === "ProposalCreated"
);
const [proposalId] = event.args;
Expand Down
96 changes: 48 additions & 48 deletions scenario/AddMaticxCollateralScenario.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
import { scenario } from "./context/CometContext";
import { expect } from "chai";
import { utils } from "ethers";
import { exp } from "../test/helpers";
import { COMP_WHALES, calldata } from "../src/deploy";
import { impersonateAddress } from "../plugins/scenario/utils";
import { fastL2GovernanceExecute, matchesDeployment } from "./utils";
import { BaseBridgeReceiver } from "../build/types";
import { World } from "../plugins/scenario";
import { scenario } from './context/CometContext';
import { expect } from 'chai';
import { utils } from 'ethers';
import { exp } from '../test/helpers';
import { COMP_WHALES, calldata } from '../src/deploy';
import { impersonateAddress } from '../plugins/scenario/utils';
import { fastL2GovernanceExecute, matchesDeployment } from './utils';
import { BaseBridgeReceiver } from '../build/types';
import { World } from '../plugins/scenario';

const MATICX_WHALES = {
polygon: ["0x68B9220B8E617b7700aCAE1a5Ff43F3eb29257F3"],
polygon: ['0x68B9220B8E617b7700aCAE1a5Ff43F3eb29257F3'],
};

scenario.only(
"add new asset maticx",
'add new asset maticx',
{
filter: async (ctx) =>
matchesDeployment(ctx, [{ network: "polygon" }, { network: "mumbai" }]),
matchesDeployment(ctx, [{ network: 'polygon' }, { network: 'mumbai' }]),
tokenBalances: {
$comet: { $base: ">= 1" },
$comet: { $base: '>= 1' },
},
},
async (
{ comet, configurator, proxyAdmin, actors, bridgeReceiver },
context
) => {
console.log("DEBUG::0");
console.log('DEBUG::0');
const { albert } = actors;
console.log("DEBUG::1");
console.log('DEBUG::1');
const dm = context.world.deploymentManager;
console.log("DEBUG::2");
console.log('DEBUG::2');
const maticx = await dm.existing(
"MATICX",
"0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6",
'MATICX',
'0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6',
context.world.base.network,
"contracts/ERC20.sol:ERC20"
'contracts/ERC20.sol:ERC20'
);
console.log("DEBUG::3");
console.log('DEBUG::3');
const maticxPricefeed = await dm.existing(
"MATICX:priceFeed",
"0x5d37E4b374E6907de8Fc7fb33EE3b0af403C7403",
'MATICX:priceFeed',
'0x5d37E4b374E6907de8Fc7fb33EE3b0af403C7403',
context.world.base.network
);
console.log("DEBUG::4");
console.log('DEBUG::4');

// Allocate some tokens to Albert
const maticxWhaleSigner = await impersonateAddress(
dm,
MATICX_WHALES.polygon[0]
);
console.log("DEBUG::5");
console.log('DEBUG::5');
console.log(
"whale balance:",
'whale balance:',
await maticx.balanceOf(maticxWhaleSigner.address)
);
// console.log(await maticx.proxyOwner());
await maticx
.connect(maticxWhaleSigner)
.transfer(albert.address, exp(9000, 18).toString());
console.log("DEBUG::6");
console.log('DEBUG::6');

// Execute a governance proposal to:
// 1. Add new asset via Configurator
Expand All @@ -72,27 +72,27 @@ scenario.only(
liquidationFactor: exp(0.9, 18),
supplyCap: exp(6_000_000, 18),
};
console.log("DEBUG::7");
console.log('DEBUG::7');

const addAssetCalldata = await calldata(
configurator.populateTransaction.addAsset(comet.address, newAssetConfig)
);
console.log("DEBUG::8");
console.log('DEBUG::8');

const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode(
["address", "address"],
['address', 'address'],
[configurator.address, comet.address]
);
console.log("DEBUG::9");
console.log('DEBUG::9');

const l2ProposalData = utils.defaultAbiCoder.encode(
["address[]", "uint256[]", "string[]", "bytes[]"],
['address[]', 'uint256[]', 'string[]', 'bytes[]'],
[
[configurator.address, proxyAdmin.address],
[0, 0],
[
"addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))",
"deployAndUpgradeTo(address,address)",
'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))',
'deployAndUpgradeTo(address,address)',
],
[addAssetCalldata, deployAndUpgradeToCalldata],
]
Expand All @@ -103,39 +103,39 @@ scenario.only(
bridgeReceiver,
context.world
);
console.log("DEBUG::10");
console.log('DEBUG::10');

// Try to supply new token and borrow base
const baseAssetAddress = await comet.baseToken();
console.log("DEBUG::11", baseAssetAddress);
console.log('DEBUG::11', baseAssetAddress);

const borrowAmount = 1000n * (await comet.baseScale()).toBigInt();
console.log("DEBUG::12", borrowAmount.toString());
console.log('DEBUG::12', borrowAmount.toString());

const supplyAmount = exp(9000, 18);
console.log("DEBUG::13");
console.log('DEBUG::13');

await maticx
.connect(albert.signer)
["approve(address,uint256)"](comet.address, supplyAmount);
console.log("DEBUG::14");
.approve(comet.address, supplyAmount);
console.log('DEBUG::14');

await albert.supplyAsset({ asset: maticx.address, amount: supplyAmount });
console.log(
"DEBUG::15",
'DEBUG::15',
await albert.getCometCollateralBalance(maticx.address)
);

await albert.withdrawAsset({
asset: baseAssetAddress,
amount: borrowAmount,
});
console.log("DEBUG::16");
console.log('DEBUG::16');

const cometMaticxAssetInfo = await comet.getAssetInfoByAddress(
"0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6"
'0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6'
);
console.log("maticx index:", cometMaticxAssetInfo.offset);
console.log('maticx index:', cometMaticxAssetInfo.offset);

expect(await albert.getCometCollateralBalance(maticx.address)).to.be.equal(
supplyAmount
Expand All @@ -152,12 +152,12 @@ async function fastL1ToPolygonGovernanceExecute(
const governanceDeploymentManager = world.auxiliaryDeploymentManager;
if (!governanceDeploymentManager) {
throw new Error(
"cannot execute governance without governance deployment manager"
'cannot execute governance without governance deployment manager'
);
}

const compWhale =
world.base.network === "polygon"
world.base.network === 'polygon'
? COMP_WHALES.mainnet[0]
: COMP_WHALES.testnet[0];
const proposer = await impersonateAddress(
Expand All @@ -167,19 +167,19 @@ async function fastL1ToPolygonGovernanceExecute(
); // give them enough ETH to make the proposal

const sendMessageToChildCalldata = utils.defaultAbiCoder.encode(
["address", "bytes"],
['address', 'bytes'],
[bridgeReceiver.address, l2ProposalData]
);

const fxRoot = await governanceDeploymentManager.getContractOrThrow("fxRoot");
const fxRoot = await governanceDeploymentManager.getContractOrThrow('fxRoot');

await fastL2GovernanceExecute(
governanceDeploymentManager,
world.deploymentManager,
proposer,
[fxRoot.address],
[0],
["sendMessageToChild(address,bytes)"],
['sendMessageToChild(address,bytes)'],
[sendMessageToChildCalldata]
);
}

0 comments on commit 5e71bb5

Please sign in to comment.