Skip to content

Commit

Permalink
Merge pull request #269 from morpho-org/revert/fix/ci
Browse files Browse the repository at this point in the history
Add IRM gas tests
  • Loading branch information
MerlinEgalite authored Jan 16, 2024
2 parents 32d6433 + 36a5c1f commit 92892b2
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 1,542 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
[submodule "lib/morpho-blue"]
path = lib/morpho-blue
url = https://github.com/morpho-org/morpho-blue
[submodule "lib/universal-rewards-distributor"]
path = lib/universal-rewards-distributor
url = https://github.com/morpho-org/universal-rewards-distributor
[submodule "lib/morpho-blue-irm"]
path = lib/morpho-blue-irm
url = https://github.com/morpho-labs/morpho-blue-irm
[submodule "lib/erc4626-tests"]
path = lib/erc4626-tests
url = https://github.com/a16z/erc4626-tests
1 change: 1 addition & 0 deletions lib/morpho-blue-irm
Submodule morpho-blue-irm added at a7d9cc
1 change: 0 additions & 1 deletion lib/universal-rewards-distributor
Submodule universal-rewards-distributor deleted from 8aaa00
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
"lib/**/*"
],
"scripts": {
"prepare": "husky install",
"postinstall": "forge install",
"prepare": "husky install && forge install",
"build:forge": "FOUNDRY_PROFILE=build forge build",
"build:hardhat": "npx hardhat compile",
"build:blue": "cd lib/morpho-blue/ && yarn build:forge && cd ../..",
"build:hardhat": "hardhat compile",
"build:blue": "yarn --cwd lib/morpho-blue/ build:forge",
"build:irm": "yarn --cwd lib/morpho-blue-irm/ build:forge",
"typecheck": "tsc --noEmit",
"test:forge": "yarn build:blue && FOUNDRY_PROFILE=test forge test",
"test:hardhat": "yarn build:blue && npx hardhat test",
"test:hardhat": "yarn build:blue && yarn build:irm && hardhat test",
"lint": "yarn lint:forge && yarn lint:ts",
"lint:ts": "prettier --check test/hardhat",
"lint:forge": "forge fmt --check",
"lint:fix": "yarn lint:forge:fix && yarn lint:ts:fix",
"lint:ts:fix": "prettier --write test/hardhat",
"lint:forge:fix": "forge fmt",
"clean": "npx hardhat clean && forge clean"
"clean": "hardhat clean && forge clean"
},
"repository": {
"type": "git",
Expand All @@ -39,37 +39,37 @@
},
"homepage": "https://github.com/morpho-org/metamorpho#readme",
"dependencies": {
"ethers": "^6.7.1",
"ethers-maths": "^5.0.0",
"ethers": "^6.9.2",
"ethers-maths": "^5.0.2",
"lodash": "^4.17.21"
},
"devDependencies": {
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.2",
"@nomicfoundation/hardhat-ethers": "^3.0.4",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-foundry": "^1.1.1",
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.3.6",
"@types/lodash": "^4.14.199",
"@types/mocha": "^10.0.2",
"@types/node": "^20.8.2",
"chai": "^4.3.10",
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.11",
"@types/lodash": "^4.14.202",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.0",
"chai": "^4.4.0",
"dotenv": "^16.3.1",
"hardhat": "^2.18.0",
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-tracer": "^2.6.0",
"hardhat-tracer": "^2.7.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"prettier": "^3.1.1",
"solidity-coverage": "^0.8.5",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typechain": "^8.3.1",
"typescript": "^5.2.2"
"typechain": "^8.3.2",
"typescript": "^5.3.3"
},
"lint-staged": {
"*.sol": "forge fmt",
Expand All @@ -95,4 +95,4 @@
],
"importOrderSeparation": true
}
}
}
22 changes: 10 additions & 12 deletions test/hardhat/MetaMorpho.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AbiCoder, MaxUint256, ZeroAddress, ZeroHash, keccak256, toBigInt } from "ethers";
import hre from "hardhat";
import _range from "lodash/range";
import { ERC20Mock, OracleMock, MetaMorpho, IMorpho, MetaMorphoFactory, MetaMorpho__factory, IrmMock } from "types";
import { ERC20Mock, OracleMock, MetaMorpho, IMorpho, MetaMorphoFactory, MetaMorpho__factory, IIrm } from "types";
import { MarketParamsStruct } from "types/src/MetaMorpho";

import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
Expand All @@ -13,19 +13,15 @@ import {
} from "@nomicfoundation/hardhat-network-helpers/dist/src/helpers/time";

// Must use relative import path.
import AdaptiveCurveIrmArtifact from "../../lib/morpho-blue-irm/out/AdaptiveCurveIrm.sol/AdaptiveCurveIrm.json";
import MorphoArtifact from "../../lib/morpho-blue/out/Morpho.sol/Morpho.json";

// Without the division it overflows.
const initBalance = MaxUint256 / 10000000000000000n;
const oraclePriceScale = 1000000000000000000000000000000000000n;
const nbMarkets = 5;
const nbMarkets = 10;
const timelock = 3600 * 24 * 7; // 1 week.

const ln2 = 693147180559945309n;
const targetUtilization = 800000000000000000n;
const speedFactor = 277777777777n;
const initialRate = 317097920n;

let seed = 42;
const random = () => {
seed = (seed * 16807) % 2147483647;
Expand Down Expand Up @@ -71,7 +67,7 @@ describe("MetaMorpho", () => {
let loan: ERC20Mock;
let collateral: ERC20Mock;
let oracle: OracleMock;
let irm: IrmMock;
let irm: IIrm;

let factory: MetaMorphoFactory;
let metaMorpho: MetaMorpho;
Expand Down Expand Up @@ -148,11 +144,13 @@ describe("MetaMorpho", () => {

const morphoAddress = await morpho.getAddress();

const IrmMockFactory = await hre.ethers.getContractFactory("IrmMock", admin);

irm = await IrmMockFactory.deploy();
const AdaptiveCurveIrmFactory = await hre.ethers.getContractFactory(
AdaptiveCurveIrmArtifact.abi,
AdaptiveCurveIrmArtifact.bytecode.object,
admin,
);

await irm.setApr(BigInt.WAD / 100n); // 1%
irm = (await AdaptiveCurveIrmFactory.deploy(morphoAddress)) as IIrm;

const loanAddress = await loan.getAddress();
const collateralAddress = await collateral.getAddress();
Expand Down
Loading

0 comments on commit 92892b2

Please sign in to comment.