Skip to content

Commit

Permalink
Merge branch 'refactor/monorepo-2' of github.com:morpho-labs/morpho-s…
Browse files Browse the repository at this point in the history
…tack into feat/packages-viem
  • Loading branch information
Rubilmax committed Sep 27, 2024
2 parents e9ebad0 + 698bd16 commit bfa5b93
Show file tree
Hide file tree
Showing 30 changed files with 68 additions and 72 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ node_modules/
/cache_hardhat
/artifacts

# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

*.log
3 changes: 0 additions & 3 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

git submodule update --init --recursive
yarn
3 changes: 0 additions & 3 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

git submodule update --init --recursive
yarn
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
3 changes: 0 additions & 3 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit "${1}"
Binary file removed .yarn/install-state.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

![bundler-3](https://github.com/morpho-org/morpho-blue-bundlers/assets/74971347/827630e1-7abc-4f9d-a494-fe3fa7aa7053)

Each Bundler is a domain-specific abstract layer of contract that implements some functions that can be bundled in a single call by EOAs to a single contract. They all inherit from [`BaseBundler`](./contracts/BaseBundler.sol) that enables bundling multiple function calls into a single `multicall(bytes[] calldata data)` call to the end bundler contract. Each chain-specific bundler is available under their chain-specific folder (e.g. [`ethereum`](./contracts/ethereum/)).
Each Bundler is a domain-specific abstract layer of contract that implements some functions that can be bundled in a single call by EOAs to a single contract. They all inherit from [`BaseBundler`](./src/BaseBundler.sol) that enables bundling multiple function calls into a single `multicall(bytes[] calldata data)` call to the end bundler contract. Each chain-specific bundler is available under their chain-specific folder (e.g. [`ethereum`](./src/ethereum/)).

Some chain-specific domains are also scoped to the chain-specific folder, because they are not expected to be used on any other chain (e.g. DAI and its specific `permit` function is only available on Ethereum - see [`EthereumPermitBundler`](./contracts/ethereum/EthereumPermitBundler.sol)).
Some chain-specific domains are also scoped to the chain-specific folder, because they are not expected to be used on any other chain (e.g. DAI and its specific `permit` function is only available on Ethereum - see [`EthereumPermitBundler`](./src/ethereum/EthereumPermitBundler.sol)).

User-end bundlers are provided in each chain-specific folder, instantiating all the intermediary domain-specific bundlers and associated parameters (such as chain-specific protocol addresses, e.g. [`EthereumBundlerV2`](./contracts/ethereum/EthereumBundlerV2.sol)).
User-end bundlers are provided in each chain-specific folder, instantiating all the intermediary domain-specific bundlers and associated parameters (such as chain-specific protocol addresses, e.g. [`EthereumBundlerV2`](./src/ethereum/EthereumBundlerV2.sol)).

## Deployments

Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sizes = true
src = "src"
fs_permissions = [
{ access = "read", path = "./out/"},
{ access = "read", path = "./config/"}
{ access = "read", path = "./test/config/"}
]
libs = ["lib"]
via-ir = true
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"scripts": {
"prepare": "husky && forge install",
"build": "FOUNDRY_PROFILE=build forge build",
"typecheck": "tsc --noEmit",
"test": "FOUNDRY_PROFILE=test forge test",
"test:local": "FOUNDRY_MATCH_CONTRACT=LocalTest yarn test",
"test:fork": "FOUNDRY_MATCH_CONTRACT=ForkTest yarn test",
Expand All @@ -45,7 +44,7 @@
"@lerna-lite/publish": "3.8.0",
"@lerna-lite/version": "^3.7.1",
"@types/node": "^20.8.6",
"husky": "^8.0.3",
"husky": "^9.1.6",
"lint-staged": "^14.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/ethers/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-ethers";
import "@typechain/hardhat";

import config from "../../hardhat.config";
import config from "../hardhat.config";

config.typechain = {
outDir: "src/types/",
Expand Down
2 changes: 1 addition & 1 deletion packages/ethers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"baseUrl": "."
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/MorphoBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {

import {SigUtils} from "./helpers/SigUtils.sol";
import {ErrorsLib} from "../src/libraries/ErrorsLib.sol";
import {ErrorsLib as MorphoErrorsLib} from "../../lib/morpho-blue/src/libraries/ErrorsLib.sol";
import {MarketParamsLib} from "../../lib/morpho-blue/src/libraries/MarketParamsLib.sol";
import {ErrorsLib as MorphoErrorsLib} from "../lib/morpho-blue/src/libraries/ErrorsLib.sol";
import {MarketParamsLib} from "../lib/morpho-blue/src/libraries/MarketParamsLib.sol";

import "./helpers/MetaMorphoLocalTest.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/PermitBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import {SigUtils, Permit} from "./helpers/SigUtils.sol";

import {ErrorsLib} from "../src/libraries/ErrorsLib.sol";
import {IERC20Permit} from "../../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {IERC20Permit} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {ERC20PermitMock} from "../src/mocks/ERC20PermitMock.sol";

import "./helpers/LocalTest.sol";
Expand Down
10 changes: 5 additions & 5 deletions test/SelectorClashTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity ^0.8.0;

import "../src/interfaces/IWNative.sol";
import "../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import "../../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
import "../../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "../../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Wrapper.sol";
import "../../lib/universal-rewards-distributor/src/interfaces/IUniversalRewardsDistributor.sol";
import "../lib/morpho-blue/src/interfaces/IMorpho.sol";
import "../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
import "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Wrapper.sol";
import "../lib/universal-rewards-distributor/src/interfaces/IUniversalRewardsDistributor.sol";

// The bundler can do call to arbitrary contracts, we make sure no selectors clash by inheriting all the interfaces in
// one single contract.
Expand Down
6 changes: 3 additions & 3 deletions test/UrdBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
pragma solidity ^0.8.0;

import {IUniversalRewardsDistributor} from
"../../lib/universal-rewards-distributor/src/interfaces/IUniversalRewardsDistributor.sol";
"../lib/universal-rewards-distributor/src/interfaces/IUniversalRewardsDistributor.sol";

import {ErrorsLib} from "../src/libraries/ErrorsLib.sol";
import {ErrorsLib as UrdErrorsLib} from "../../lib/universal-rewards-distributor/src/libraries/ErrorsLib.sol";
import {ErrorsLib as UrdErrorsLib} from "../lib/universal-rewards-distributor/src/libraries/ErrorsLib.sol";

import {Merkle} from "../../lib/murky/src/Merkle.sol";
import {Merkle} from "../lib/murky/src/Merkle.sol";

import "./helpers/LocalTest.sol";

Expand Down
2 changes: 1 addition & 1 deletion config/ConfigLib.sol → test/config/ConfigLib.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {stdJson} from "../lib/forge-std/src/StdJson.sol";
import {stdJson} from "../../lib/forge-std/src/StdJson.sol";

struct Config {
string json;
Expand Down
4 changes: 2 additions & 2 deletions config/Configured.sol → test/config/Configured.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import {Config, ConfigMarket, ConfigLib} from "./ConfigLib.sol";

import {StdChains, VmSafe} from "../lib/forge-std/src/StdChains.sol";
import {StdChains, VmSafe} from "../../lib/forge-std/src/StdChains.sol";

import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";

Expand Down Expand Up @@ -54,7 +54,7 @@ abstract contract Configured is StdChains {
// Fetch config.
if (bytes(CONFIG.json).length == 0) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/", network, ".json");
string memory path = string.concat(root, "/test/config/", network, ".json");

CONFIG.json = vm.readFile(path);
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/fork/BundlerForkTest.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IAllowanceTransfer} from "../../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";
import {IAllowanceTransfer} from "../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";

import {EthereumBundlerV2} from "../../src/ethereum/EthereumBundlerV2.sol";
import {ChainAgnosticBundlerV2} from "../../src/chain-agnostic/ChainAgnosticBundlerV2.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/fork/PermitBundlerForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";
import {DaiPermit, Permit} from "../helpers/SigUtils.sol";

import "../../src/ethereum/EthereumPermitBundler.sol";
import {IERC20Permit} from "../../../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {IERC20Permit} from "../../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {ERC20PermitMock} from "../../src/mocks/ERC20PermitMock.sol";

import "./helpers/ForkTest.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/fork/StEthBundlerForkTest.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IAllowanceTransfer} from "../../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";
import {IAllowanceTransfer} from "../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";

import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";

Expand Down
6 changes: 3 additions & 3 deletions test/fork/helpers/ForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ pragma solidity ^0.8.0;

import {IStEth} from "../../../src/interfaces/IStEth.sol";
import {IWstEth} from "../../../src/interfaces/IWstEth.sol";
import {IAllowanceTransfer} from "../../../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";
import {IAllowanceTransfer} from "../../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";

import {Permit2Lib} from "../../../../lib/permit2/src/libraries/Permit2Lib.sol";
import {Permit2Lib} from "../../../lib/permit2/src/libraries/Permit2Lib.sol";

import {Permit2Bundler} from "../../../src/Permit2Bundler.sol";
import {WNativeBundler} from "../../../src/WNativeBundler.sol";
import {StEthBundler} from "../../../src/StEthBundler.sol";
import {EthereumBundlerV2} from "../../../src/ethereum/EthereumBundlerV2.sol";
import {ChainAgnosticBundlerV2} from "../../../src/chain-agnostic/ChainAgnosticBundlerV2.sol";

import "../../../../config/Configured.sol";
import "../../config/Configured.sol";
import "../../helpers/CommonTest.sol";

abstract contract ForkTest is CommonTest, Configured {
Expand Down
2 changes: 1 addition & 1 deletion test/fork/migration/AaveV2MigrationBundlerForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import {IStEth} from "../../../src/interfaces/IStEth.sol";
import {IAaveV2} from "../../../src/migration/interfaces/IAaveV2.sol";
import {IERC4626} from "../../../../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
import {IERC4626} from "../../../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";

import "../../../src/migration/AaveV2MigrationBundlerV2.sol";

Expand Down
10 changes: 5 additions & 5 deletions test/fork/migration/helpers/MigrationForkTest.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {SafeTransferLib, ERC20} from "../../../../../lib/solmate/src/utils/SafeTransferLib.sol";
import {SafeTransferLib, ERC20} from "../../../../lib/solmate/src/utils/SafeTransferLib.sol";
import {ErrorsLib} from "../../../../src/libraries/ErrorsLib.sol";
import {MarketParamsLib} from "../../../../../lib/morpho-blue/src/libraries/MarketParamsLib.sol";
import {MorphoLib} from "../../../../../lib/morpho-blue/src/libraries/periphery/MorphoLib.sol";
import {Market} from "../../../../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {MorphoBalancesLib} from "../../../../../lib/morpho-blue/src/libraries/periphery/MorphoBalancesLib.sol";
import {MarketParamsLib} from "../../../../lib/morpho-blue/src/libraries/MarketParamsLib.sol";
import {MorphoLib} from "../../../../lib/morpho-blue/src/libraries/periphery/MorphoLib.sol";
import {Market} from "../../../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {MorphoBalancesLib} from "../../../../lib/morpho-blue/src/libraries/periphery/MorphoBalancesLib.sol";

import "../../helpers/ForkTest.sol";
import {BaseBundler} from "../../../../src/BaseBundler.sol";
Expand Down
30 changes: 15 additions & 15 deletions test/helpers/CommonTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import {
MarketParams,
Authorization as MorphoBlueAuthorization,
Signature as MorphoBlueSignature
} from "../../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {IPublicAllocatorBase} from "../../../lib/public-allocator/src/interfaces/IPublicAllocator.sol";
} from "../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {IPublicAllocatorBase} from "../../lib/public-allocator/src/interfaces/IPublicAllocator.sol";

import {SigUtils} from "./SigUtils.sol";
import {MarketParamsLib} from "../../../lib/morpho-blue/src/libraries/MarketParamsLib.sol";
import {SharesMathLib} from "../../../lib/morpho-blue/src/libraries/SharesMathLib.sol";
import {MathLib, WAD} from "../../../lib/morpho-blue/src/libraries/MathLib.sol";
import {UtilsLib} from "../../../lib/morpho-blue/src/libraries/UtilsLib.sol";
import {SafeTransferLib, ERC20} from "../../../lib/solmate/src/utils/SafeTransferLib.sol";
import {MorphoLib} from "../../../lib/morpho-blue/src/libraries/periphery/MorphoLib.sol";
import {MorphoBalancesLib} from "../../../lib/morpho-blue/src/libraries/periphery/MorphoBalancesLib.sol";
import {MarketParamsLib} from "../../lib/morpho-blue/src/libraries/MarketParamsLib.sol";
import {SharesMathLib} from "../../lib/morpho-blue/src/libraries/SharesMathLib.sol";
import {MathLib, WAD} from "../../lib/morpho-blue/src/libraries/MathLib.sol";
import {UtilsLib} from "../../lib/morpho-blue/src/libraries/UtilsLib.sol";
import {SafeTransferLib, ERC20} from "../../lib/solmate/src/utils/SafeTransferLib.sol";
import {MorphoLib} from "../../lib/morpho-blue/src/libraries/periphery/MorphoLib.sol";
import {MorphoBalancesLib} from "../../lib/morpho-blue/src/libraries/periphery/MorphoBalancesLib.sol";
import {
LIQUIDATION_CURSOR,
MAX_LIQUIDATION_INCENTIVE_FACTOR,
ORACLE_PRICE_SCALE
} from "../../../lib/morpho-blue/src/libraries/ConstantsLib.sol";
} from "../../lib/morpho-blue/src/libraries/ConstantsLib.sol";

import {IrmMock} from "../../../lib/morpho-blue/src/mocks/IrmMock.sol";
import {OracleMock} from "../../../lib/morpho-blue/src/mocks/OracleMock.sol";
import {WETH} from "../../../lib/solmate/src/tokens/WETH.sol";
import {IrmMock} from "../../lib/morpho-blue/src/mocks/IrmMock.sol";
import {OracleMock} from "../../lib/morpho-blue/src/mocks/OracleMock.sol";
import {WETH} from "../../lib/solmate/src/tokens/WETH.sol";

import {BaseBundler} from "../../src/BaseBundler.sol";
import {PermitBundler} from "../../src/PermitBundler.sol";
Expand All @@ -37,8 +37,8 @@ import {MorphoBundler, Withdrawal} from "../../src/MorphoBundler.sol";
import {ERC20WrapperBundler} from "../../src/ERC20WrapperBundler.sol";
import {ChainAgnosticBundlerV2} from "../../src/chain-agnostic/ChainAgnosticBundlerV2.sol";

import "../../../lib/forge-std/src/Test.sol";
import "../../../lib/forge-std/src/console2.sol";
import "../../lib/forge-std/src/Test.sol";
import "../../lib/forge-std/src/console2.sol";

uint256 constant MIN_AMOUNT = 1000;
uint256 constant MAX_AMOUNT = 2 ** 64; // Must be less than or equal to type(uint160).max.
Expand Down
10 changes: 5 additions & 5 deletions test/helpers/SigUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity ^0.8.0;

import {ICompoundV3} from "../../src/migration/interfaces/ICompoundV3.sol";
import {Authorization} from "../../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {IAllowanceTransfer} from "../../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";
import {Authorization} from "../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {IAllowanceTransfer} from "../../lib/permit2/src/interfaces/IAllowanceTransfer.sol";
import {
Authorization as AaveV3OptimizerAuthorization,
AUTHORIZATION_TYPEHASH as AAVE_V3_OPTIMIZER_AUTHORIZATION_TYPEHASH
Expand All @@ -14,9 +14,9 @@ import {
AUTHORIZATION_TYPEHASH as COMPOUND_V3_AUTHORIZATION_TYPEHASH
} from "../../src/migration/interfaces/ICompoundV3.sol";

import {PermitHash} from "../../../lib/permit2/src/libraries/PermitHash.sol";
import {ECDSA} from "../../../lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
import {AUTHORIZATION_TYPEHASH} from "../../../lib/morpho-blue/src/libraries/ConstantsLib.sol";
import {PermitHash} from "../../lib/permit2/src/libraries/PermitHash.sol";
import {ECDSA} from "../../lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
import {AUTHORIZATION_TYPEHASH} from "../../lib/morpho-blue/src/libraries/ConstantsLib.sol";

bytes32 constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ __metadata:
"@lerna-lite/publish": "npm:3.8.0"
"@lerna-lite/version": "npm:^3.7.1"
"@types/node": "npm:^20.8.6"
husky: "npm:^8.0.3"
husky: "npm:^9.1.6"
lint-staged: "npm:^14.0.1"
ts-node: "npm:^10.9.1"
typescript: "npm:^5.2.2"
Expand Down Expand Up @@ -5735,12 +5735,12 @@ __metadata:
languageName: node
linkType: hard

"husky@npm:^8.0.3":
version: 8.0.3
resolution: "husky@npm:8.0.3"
"husky@npm:^9.1.6":
version: 9.1.6
resolution: "husky@npm:9.1.6"
bin:
husky: lib/bin.js
checksum: 10c0/6722591771c657b91a1abb082e07f6547eca79144d678e586828ae806499d90dce2a6aee08b66183fd8b085f19d20e0990a2ad396961746b4c8bd5bdb619d668
husky: bin.js
checksum: 10c0/705673db4a247c1febd9c5df5f6a3519106cf0335845027bb50a15fba9b1f542cb2610932ede96fd08008f6d9f49db0f15560509861808b0031cdc0e7c798bac
languageName: node
linkType: hard

Expand Down

0 comments on commit bfa5b93

Please sign in to comment.