Skip to content

Commit

Permalink
refactor: rollback base bundler renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed May 18, 2024
1 parent 6aea002 commit 530abd2
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

![image (4)](https://github.com/morpho-org/morpho-blue-bundlers/assets/44097430/5cb0796b-c20c-415e-840d-8b0705836dc8)

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 [`CoreBundler`](./src/CoreBundler.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/)).
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`](./src/ethereum/EthereumPermitBundler.sol)).

Expand Down
4 changes: 2 additions & 2 deletions src/CoreBundler.sol → src/BaseBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {UNSET_INITIATOR} from "./libraries/ConstantsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

/// @title CoreBundler
/// @title BaseBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Enables calling multiple functions in a single call to the same contract (self).
/// @dev Every bundler must inherit from this contract.
/// @dev Every bundler inheriting from this contract must have their external functions payable as they will be
/// delegate called by the `multicall` function (which is payable, and thus might pass a non-null ETH value). It is
/// recommended not to rely on `msg.value` as the same value can be reused for multiple calls.
abstract contract CoreBundler is IMulticall {
abstract contract BaseBundler is IMulticall {
using SafeTransferLib for ERC20;

/* STORAGE */
Expand Down
4 changes: 2 additions & 2 deletions src/ERC20WrapperBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";
import {ERC20Wrapper} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Wrapper.sol";

/// @title ERC20WrapperBundler
Expand All @@ -14,7 +14,7 @@ import {ERC20Wrapper} from "../lib/openzeppelin-contracts/contracts/token/ERC20/
/// @notice Enables the wrapping and unwrapping of ERC20 tokens. The largest usecase is to wrap permissionless tokens to
/// their permissioned counterparts and access permissioned markets on Morpho Blue. Permissioned tokens can be built
/// using: https://github.com/morpho-org/erc20-permissioned
abstract contract ERC20WrapperBundler is CoreBundler {
abstract contract ERC20WrapperBundler is BaseBundler {
using SafeTransferLib for ERC20;

/* WRAPPER ACTIONS */
Expand Down
4 changes: 2 additions & 2 deletions src/ERC4626Bundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title ERC4626Bundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Bundler contract managing interactions with ERC4626 compliant tokens.
abstract contract ERC4626Bundler is CoreBundler {
abstract contract ERC4626Bundler is BaseBundler {
using SafeTransferLib for ERC20;

/* ACTIONS */
Expand Down
6 changes: 3 additions & 3 deletions src/MorphoBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {MarketParams, Signature, Authorization, IMorpho} from "../lib/morpho-blu
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title MorphoBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Bundler contract managing interactions with Morpho.
abstract contract MorphoBundler is CoreBundler, IMorphoBundler {
abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
using SafeTransferLib for ERC20;

/* IMMUTABLES */
Expand Down Expand Up @@ -264,7 +264,7 @@ abstract contract MorphoBundler is CoreBundler, IMorphoBundler {
_multicall(abi.decode(data, (bytes[])));
}

/// @inheritdoc CoreBundler
/// @inheritdoc BaseBundler
function _isSenderAuthorized() internal view virtual override returns (bool) {
return super._isSenderAuthorized() || msg.sender == address(MORPHO);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Permit2Bundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {Permit2Lib} from "../lib/permit2/src/libraries/Permit2Lib.sol";
import {SafeCast160} from "../lib/permit2/src/libraries/SafeCast160.sol";
import {ERC20} from "../lib/solmate/src/tokens/ERC20.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title Permit2Bundler
/// @author Morpho Labs
/// @custom:contact security@morpho.xyz
/// @notice Bundler contract managing interactions with Uniswap's Permit2.
abstract contract Permit2Bundler is CoreBundler {
abstract contract Permit2Bundler is BaseBundler {
using SafeCast160 for uint256;

/* ACTIONS */
Expand Down
4 changes: 2 additions & 2 deletions src/PermitBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pragma solidity 0.8.24;

import {IERC20Permit} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title PermitBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.xyz
/// @notice Bundler contract managing interactions with tokens implementing EIP-2612.
abstract contract PermitBundler is CoreBundler {
abstract contract PermitBundler is BaseBundler {
/// @notice Permits the given `amount` of `asset` from sender to be spent by the bundler via EIP-2612 Permit with
/// the given `deadline` & EIP-712 signature's `v`, `r` & `s`.
/// @param asset The address of the token to be permitted.
Expand Down
4 changes: 2 additions & 2 deletions src/StEthBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title StEthBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Contract allowing to bundle multiple interactions with stETH together.
abstract contract StEthBundler is CoreBundler {
abstract contract StEthBundler is BaseBundler {
using SafeTransferLib for ERC20;

/* IMMUTABLES */
Expand Down
4 changes: 2 additions & 2 deletions src/TransferBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title TransferBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Enables transfer of ERC20 and native tokens.
/// @dev Assumes that any tokens left on the contract can be seized by anyone.
abstract contract TransferBundler is CoreBundler {
abstract contract TransferBundler is BaseBundler {
using SafeTransferLib for ERC20;

/* TRANSFER ACTIONS */
Expand Down
4 changes: 2 additions & 2 deletions src/UrdBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {IUniversalRewardsDistributor} from

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

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title UrdBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.xyz
/// @notice Bundler that allows to claim token rewards on the Universal Rewards Distributor.
abstract contract UrdBundler is CoreBundler {
abstract contract UrdBundler is BaseBundler {
/// @notice Claims `amount` of `reward` on behalf of `account` on the given rewards distributor, using `proof`.
/// @dev Assumes the given distributor implements IUniversalRewardsDistributor.
/// @param distributor The address of the reward distributor contract.
Expand Down
4 changes: 2 additions & 2 deletions src/WNativeBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "./CoreBundler.sol";
import {BaseBundler} from "./BaseBundler.sol";

/// @title WNativeBundler
/// @author Morpho Labs
/// @custom:contact security@morpho.org
/// @notice Bundler contract managing interactions with network's wrapped native token.
/// @notice "wrapped native" refers to forks of WETH.
abstract contract WNativeBundler is CoreBundler {
abstract contract WNativeBundler is BaseBundler {
using SafeTransferLib for ERC20;

/* IMMUTABLES */
Expand Down
4 changes: 2 additions & 2 deletions src/chain-agnostic/ChainAgnosticBundlerV2.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.24;

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {TransferBundler} from "../TransferBundler.sol";
import {PermitBundler} from "../PermitBundler.sol";
import {Permit2Bundler} from "../Permit2Bundler.sol";
Expand Down Expand Up @@ -32,7 +32,7 @@ contract ChainAgnosticBundlerV2 is
/* INTERNAL */

/// @inheritdoc MorphoBundler
function _isSenderAuthorized() internal view override(CoreBundler, MorphoBundler) returns (bool) {
function _isSenderAuthorized() internal view override(BaseBundler, MorphoBundler) returns (bool) {
return MorphoBundler._isSenderAuthorized();
}
}
4 changes: 2 additions & 2 deletions src/ethereum/EthereumBundlerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {MainnetLib} from "./libraries/MainnetLib.sol";

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {TransferBundler} from "../TransferBundler.sol";
import {EthereumPermitBundler} from "./EthereumPermitBundler.sol";
import {Permit2Bundler} from "../Permit2Bundler.sol";
Expand Down Expand Up @@ -36,7 +36,7 @@ contract EthereumBundlerV2 is
/* INTERNAL */

/// @inheritdoc MorphoBundler
function _isSenderAuthorized() internal view override(CoreBundler, MorphoBundler) returns (bool) {
function _isSenderAuthorized() internal view override(BaseBundler, MorphoBundler) returns (bool) {
return MorphoBundler._isSenderAuthorized();
}
}
4 changes: 2 additions & 2 deletions src/goerli/GoerliBundlerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {GoerliLib} from "./libraries/GoerliLib.sol";

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {TransferBundler} from "../TransferBundler.sol";
import {PermitBundler} from "../PermitBundler.sol";
import {Permit2Bundler} from "../Permit2Bundler.sol";
Expand Down Expand Up @@ -36,7 +36,7 @@ contract GoerliBundlerV2 is
/* INTERNAL */

/// @inheritdoc MorphoBundler
function _isSenderAuthorized() internal view override(CoreBundler, MorphoBundler) returns (bool) {
function _isSenderAuthorized() internal view override(BaseBundler, MorphoBundler) returns (bool) {
return MorphoBundler._isSenderAuthorized();
}
}
4 changes: 2 additions & 2 deletions src/migration/AaveV2MigrationBundlerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IAaveV2} from "./interfaces/IAaveV2.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {StEthBundler} from "../StEthBundler.sol";
import {MigrationBundler, ERC20} from "./MigrationBundler.sol";

Expand Down Expand Up @@ -62,7 +62,7 @@ contract AaveV2MigrationBundlerV2 is MigrationBundler, StEthBundler {
/* INTERNAL */

/// @inheritdoc MigrationBundler
function _isSenderAuthorized() internal view virtual override(CoreBundler, MigrationBundler) returns (bool) {
function _isSenderAuthorized() internal view virtual override(BaseBundler, MigrationBundler) returns (bool) {
return MigrationBundler._isSenderAuthorized();
}
}
4 changes: 2 additions & 2 deletions src/migration/CompoundV2MigrationBundlerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ICToken} from "./interfaces/ICToken.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {WNativeBundler} from "../WNativeBundler.sol";
import {MigrationBundler, ERC20} from "./MigrationBundler.sol";

Expand Down Expand Up @@ -80,7 +80,7 @@ contract CompoundV2MigrationBundlerV2 is WNativeBundler, MigrationBundler {
/* INTERNAL */

/// @inheritdoc MigrationBundler
function _isSenderAuthorized() internal view override(CoreBundler, MigrationBundler) returns (bool) {
function _isSenderAuthorized() internal view override(BaseBundler, MigrationBundler) returns (bool) {
return MigrationBundler._isSenderAuthorized();
}
}
4 changes: 2 additions & 2 deletions src/migration/MigrationBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {SafeTransferLib, ERC20} from "../../lib/solmate/src/utils/SafeTransferLib.sol";

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {TransferBundler} from "../TransferBundler.sol";
import {PermitBundler} from "../PermitBundler.sol";
import {Permit2Bundler} from "../Permit2Bundler.sol";
Expand All @@ -24,7 +24,7 @@ abstract contract MigrationBundler is TransferBundler, PermitBundler, Permit2Bun
/* INTERNAL */

/// @inheritdoc MorphoBundler
function _isSenderAuthorized() internal view virtual override(CoreBundler, MorphoBundler) returns (bool) {
function _isSenderAuthorized() internal view virtual override(BaseBundler, MorphoBundler) returns (bool) {
return MorphoBundler._isSenderAuthorized();
}
}
4 changes: 2 additions & 2 deletions src/sepolia/SepoliaBundlerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {SepoliaLib} from "./libraries/SepoliaLib.sol";

import {CoreBundler} from "../CoreBundler.sol";
import {BaseBundler} from "../BaseBundler.sol";
import {TransferBundler} from "../TransferBundler.sol";
import {PermitBundler} from "../PermitBundler.sol";
import {Permit2Bundler} from "../Permit2Bundler.sol";
Expand Down Expand Up @@ -40,7 +40,7 @@ contract SepoliaBundlerV2 is
/* INTERNAL */

/// @inheritdoc MorphoBundler
function _isSenderAuthorized() internal view override(CoreBundler, MorphoBundler) returns (bool) {
function _isSenderAuthorized() internal view override(BaseBundler, MorphoBundler) returns (bool) {
return MorphoBundler._isSenderAuthorized();
}
}
2 changes: 1 addition & 1 deletion test/forge/CoreBundlerEnshrinedLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import "./helpers/LocalTest.sol";

contract CoreBundlerEnshrinedLocalTest is CoreBundler, LocalTest {
contract BaseBundlerEnshrinedLocalTest is BaseBundler, LocalTest {
function checkInitiator(address expectedInitiator) public payable protected {
require(initiator() == expectedInitiator, "unexpected initiator");
}
Expand Down
4 changes: 2 additions & 2 deletions test/forge/CoreBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";

import "./helpers/LocalTest.sol";

contract CoreBundlerLocalTest is LocalTest {
contract BaseBundlerLocalTest is LocalTest {
function testMulticallEmpty() public {
bundler.multicall(bundle);
}

function testNestedMulticall() public {
bundle.push(abi.encodeCall(CoreBundler.multicall, (callbackBundle)));
bundle.push(abi.encodeCall(BaseBundler.multicall, (callbackBundle)));

vm.expectRevert(bytes(ErrorsLib.ALREADY_INITIATED));
bundler.multicall(bundle);
Expand Down
2 changes: 1 addition & 1 deletion test/forge/fork/migration/helpers/MigrationForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 {CoreBundler} from "../../../../../src/CoreBundler.sol";
import {BaseBundler} from "../../../../../src/BaseBundler.sol";
import {PermitBundler} from "../../../../../src/PermitBundler.sol";
import {Permit2Bundler} from "../../../../../src/Permit2Bundler.sol";
import {ERC4626Bundler} from "../../../../../src/ERC4626Bundler.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/forge/helpers/CommonTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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 {CoreBundler} from "../../../src/CoreBundler.sol";
import {BaseBundler} from "../../../src/BaseBundler.sol";
import {PermitBundler} from "../../../src/PermitBundler.sol";
import {TransferBundler} from "../../../src/TransferBundler.sol";
import {ERC4626Bundler} from "../../../src/ERC4626Bundler.sol";
Expand Down Expand Up @@ -61,7 +61,7 @@ abstract contract CommonTest is Test {
IrmMock internal irm;
OracleMock internal oracle;

CoreBundler internal bundler;
BaseBundler internal bundler;

bytes[] internal bundle;
bytes[] internal callbackBundle;
Expand Down

0 comments on commit 530abd2

Please sign in to comment.