Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename "v2" (option 1) #415

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Each Bundler is a domain-specific abstract layer of contract that implements som

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, instanciating all the intermediary domain-specific bundlers and associated parameters (such as chain-specific protocol addresses, e.g. [`EthereumBundler`](./src/ethereum/EthereumBundler.sol)).
User-end bundlers are provided in each chain-specific folder, instanciating all the intermediary domain-specific bundlers and associated parameters (such as chain-specific protocol addresses, e.g. [`EthereumBundlerV2`](./src/ethereum/EthereumBundlerV2.sol)).

## Getting Started

Expand Down
20 changes: 10 additions & 10 deletions pkg/BundlerAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
UrdBundler__factory,
WNativeBundler__factory,
StEthBundler__factory,
AaveV2MigrationBundler__factory,
AaveV3MigrationBundler__factory,
AaveV3OptimizerMigrationBundler__factory,
CompoundV2MigrationBundler__factory,
CompoundV3MigrationBundler__factory,
AaveV2MigrationBundlerV2__factory,
AaveV3MigrationBundlerV2__factory,
AaveV3OptimizerMigrationBundlerV2__factory,
CompoundV2MigrationBundlerV2__factory,
CompoundV3MigrationBundlerV2__factory,
EthereumPermitBundler__factory,
IAllowanceTransfer,
ERC20WrapperBundler__factory,
Expand All @@ -34,11 +34,11 @@ export class BundlerAction {
private static ST_ETH_BUNDLER_IFC = StEthBundler__factory.createInterface();
private static ETHEREUM_PERMIT_BUNDLER_IFC = EthereumPermitBundler__factory.createInterface();

private static AAVE_V2_BUNDLER_IFC = AaveV2MigrationBundler__factory.createInterface();
private static AAVE_V3_BUNDLER_IFC = AaveV3MigrationBundler__factory.createInterface();
private static AAVE_V3_OPTIMIZER_BUNDLER_IFC = AaveV3OptimizerMigrationBundler__factory.createInterface();
private static COMPOUND_V2_BUNDLER_IFC = CompoundV2MigrationBundler__factory.createInterface();
private static COMPOUND_V3_BUNDLER_IFC = CompoundV3MigrationBundler__factory.createInterface();
private static AAVE_V2_BUNDLER_IFC = AaveV2MigrationBundlerV2__factory.createInterface();
private static AAVE_V3_BUNDLER_IFC = AaveV3MigrationBundlerV2__factory.createInterface();
private static AAVE_V3_OPTIMIZER_BUNDLER_IFC = AaveV3OptimizerMigrationBundlerV2__factory.createInterface();
private static COMPOUND_V2_BUNDLER_IFC = CompoundV2MigrationBundlerV2__factory.createInterface();
private static COMPOUND_V3_BUNDLER_IFC = CompoundV3MigrationBundlerV2__factory.createInterface();

/* ERC20 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {UrdBundler} from "../UrdBundler.sol";
import {MorphoBundler} from "../MorphoBundler.sol";
import {ERC20WrapperBundler} from "../ERC20WrapperBundler.sol";

/// @title EthereumBundler
/// @title EthereumBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract specific to Ethereum.
contract EthereumBundler is
contract EthereumBundlerV2 is
TransferBundler,
EthereumPermitBundler,
Permit2Bundler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {UrdBundler} from "../UrdBundler.sol";
import {MorphoBundler} from "../MorphoBundler.sol";
import {ERC20WrapperBundler} from "../ERC20WrapperBundler.sol";

/// @title GoerliBundler
/// @title GoerliBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract specific to the Goerli testnet.
contract GoerliBundler is
contract GoerliBundlerV2 is
TransferBundler,
PermitBundler,
Permit2Bundler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {BaseBundler} from "../BaseBundler.sol";
import {StEthBundler} from "../StEthBundler.sol";
import {MigrationBundler, ERC20} from "./MigrationBundler.sol";

/// @title AaveV2MigrationBundler
/// @title AaveV2MigrationBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Contract allowing to migrate a position from Aave V2 to Morpho Blue easily.
/// If deploying to Ethereum, deploy `AaveV2EthereumMigrationBundler` instead.
contract AaveV2MigrationBundler is MigrationBundler, StEthBundler {
contract AaveV2MigrationBundlerV2 is MigrationBundler, StEthBundler {
/* IMMUTABLES */

/// @dev The AaveV2 contract address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {ErrorsLib} from "../libraries/ErrorsLib.sol";

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

/// @title AaveV3MigrationBundler
/// @title AaveV3MigrationBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Contract allowing to migrate a position from Aave V3 to Morpho Blue easily.
contract AaveV3MigrationBundler is MigrationBundler {
contract AaveV3MigrationBundlerV2 is MigrationBundler {
/* IMMUTABLES */

/// @dev The AaveV3 contract address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {ErrorsLib} from "../libraries/ErrorsLib.sol";

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

/// @title AaveV3OptimizerMigrationBundler
/// @title AaveV3OptimizerMigrationBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Contract allowing to migrate a position from AaveV3 Optimizer to Morpho Blue easily.
contract AaveV3OptimizerMigrationBundler is MigrationBundler {
contract AaveV3OptimizerMigrationBundlerV2 is MigrationBundler {
/* IMMUTABLES */

/// @dev The AaveV3 optimizer contract address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {BaseBundler} from "../BaseBundler.sol";
import {WNativeBundler} from "../WNativeBundler.sol";
import {MigrationBundler, ERC20} from "./MigrationBundler.sol";

/// @title CompoundV2MigrationBundler
/// @title CompoundV2MigrationBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Contract allowing to migrate a position from Compound V2 to Morpho Blue easily.
contract CompoundV2MigrationBundler is WNativeBundler, MigrationBundler {
contract CompoundV2MigrationBundlerV2 is WNativeBundler, MigrationBundler {
/* IMMUTABLES */

/// @dev The address of the cETH contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {ErrorsLib} from "../libraries/ErrorsLib.sol";

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

/// @title CompoundV3MigrationBundler
/// @title CompoundV3MigrationBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Contract allowing to migrate a position from Compound V3 to Morpho Blue easily.
contract CompoundV3MigrationBundler is MigrationBundler {
contract CompoundV3MigrationBundlerV2 is MigrationBundler {
/* CONSTRUCTOR */

/// @param morpho The Morpho contract Address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {UrdBundler} from "../UrdBundler.sol";
import {MorphoBundler} from "../MorphoBundler.sol";
import {ERC20WrapperBundler} from "../ERC20WrapperBundler.sol";

/// @title SepoliaBundler
/// @title SepoliaBundlerV2
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract specific to the Sepolia testnet.
contract SepoliaBundler is
contract SepoliaBundlerV2 is
TransferBundler,
PermitBundler,
Permit2Bundler,
Expand Down
4 changes: 2 additions & 2 deletions test/forge/ethereum/EthereumBundlerEthereumTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

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

import "../../../src/ethereum/EthereumBundler.sol";
import "../../../src/ethereum/EthereumBundlerV2.sol";

import "./helpers/EthereumTest.sol";

Expand All @@ -17,7 +17,7 @@ contract EthereumBundlerEthereumTest is EthereumTest {
function setUp() public override {
super.setUp();

bundler = new EthereumBundler(address(morpho));
bundler = new EthereumBundlerV2(address(morpho));

vm.prank(USER);
morpho.setAuthorization(address(bundler), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 "../../../../src/migration/AaveV2MigrationBundler.sol";
import "../../../../src/migration/AaveV2MigrationBundlerV2.sol";

import "./helpers/EthereumMigrationTest.sol";

Expand All @@ -27,21 +27,21 @@ contract AaveV2MigrationBundlerEthereumTest is EthereumMigrationTest {

vm.label(AAVE_V2_POOL, "Aave V2 Pool");

bundler = new AaveV2MigrationBundler(address(morpho), AAVE_V2_POOL, WST_ETH);
bundler = new AaveV2MigrationBundlerV2(address(morpho), AAVE_V2_POOL, WST_ETH);
}

function testAaveV2RepayUninitiated(uint256 amount) public {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV2MigrationBundler(address(bundler)).aaveV2Repay(marketParams.loanToken, amount, 1);
AaveV2MigrationBundlerV2(address(bundler)).aaveV2Repay(marketParams.loanToken, amount, 1);
}

function testAaveV2WithdrawUninitiated(uint256 amount) public {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV2MigrationBundler(address(bundler)).aaveV2Withdraw(marketParams.loanToken, amount);
AaveV2MigrationBundlerV2(address(bundler)).aaveV2Withdraw(marketParams.loanToken, amount);
}

function testAaveV2RepayZeroAmount() public {
Expand Down Expand Up @@ -240,10 +240,10 @@ contract AaveV2MigrationBundlerEthereumTest is EthereumMigrationTest {
/* ACTIONS */

function _aaveV2Repay(address asset, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(AaveV2MigrationBundler.aaveV2Repay, (asset, amount, RATE_MODE));
return abi.encodeCall(AaveV2MigrationBundlerV2.aaveV2Repay, (asset, amount, RATE_MODE));
}

function _aaveV2Withdraw(address asset, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(AaveV2MigrationBundler.aaveV2Withdraw, (asset, amount));
return abi.encodeCall(AaveV2MigrationBundlerV2.aaveV2Withdraw, (asset, amount));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {IAToken} from "./interfaces/IAToken.sol";
import {IAaveV3} from "../../../../src/migration/interfaces/IAaveV3.sol";

import {SigUtils, Permit} from "../../helpers/SigUtils.sol";
import "../../../../src/migration/AaveV3MigrationBundler.sol";
import "../../../../src/migration/AaveV3MigrationBundlerV2.sol";

import "./helpers/EthereumMigrationTest.sol";

Expand All @@ -27,15 +27,15 @@ contract AaveV3MigrationBundlerEthereumTest is EthereumMigrationTest {

vm.label(AAVE_V3_POOL, "Aave V3 Pool");

bundler = new AaveV3MigrationBundler(address(morpho), address(AAVE_V3_POOL));
bundler = new AaveV3MigrationBundlerV2(address(morpho), address(AAVE_V3_POOL));
vm.label(address(bundler), "Aave V3 Migration Bundler");
}

function testAaveV3RepayUninitiated(uint256 amount) public {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV3MigrationBundler(address(bundler)).aaveV3Repay(marketParams.loanToken, amount, 1);
AaveV3MigrationBundlerV2(address(bundler)).aaveV3Repay(marketParams.loanToken, amount, 1);
}

function testAaveV3RepayZeroAmount() public {
Expand Down Expand Up @@ -290,10 +290,10 @@ contract AaveV3MigrationBundlerEthereumTest is EthereumMigrationTest {
}

function _aaveV3Repay(address asset, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(AaveV3MigrationBundler.aaveV3Repay, (asset, amount, RATE_MODE));
return abi.encodeCall(AaveV3MigrationBundlerV2.aaveV3Repay, (asset, amount, RATE_MODE));
}

function _aaveV3Withdraw(address asset, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(AaveV3MigrationBundler.aaveV3Withdraw, (asset, amount));
return abi.encodeCall(AaveV3MigrationBundlerV2.aaveV3Withdraw, (asset, amount));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ pragma solidity ^0.8.0;

import {Authorization as AaveV3OptimizerAuthorization} from "../../../../src/migration/interfaces/IAaveV3Optimizer.sol";

import {
AaveV3OptimizerMigrationBundler,
IAaveV3Optimizer,
Signature as MA3Signature
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure with what this was clashing, but it works without now, so I removed it

} from "../../../../src/migration/AaveV3OptimizerMigrationBundler.sol";
import "../../../../src/migration/AaveV3OptimizerMigrationBundlerV2.sol";

import "./helpers/EthereumMigrationTest.sol";

Expand All @@ -29,14 +25,14 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {

vm.label(AAVE_V3_OPTIMIZER, "AaveV3Optimizer");

bundler = new AaveV3OptimizerMigrationBundler(address(morpho), address(AAVE_V3_OPTIMIZER));
bundler = new AaveV3OptimizerMigrationBundlerV2(address(morpho), address(AAVE_V3_OPTIMIZER));
}

function testAaveV3OptimizerRepayUninitiated(uint256 amount) public {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV3OptimizerMigrationBundler(address(bundler)).aaveV3OptimizerRepay(marketParams.loanToken, amount);
AaveV3OptimizerMigrationBundlerV2(address(bundler)).aaveV3OptimizerRepay(marketParams.loanToken, amount);
}

function testAaveV3Optimizer3RepayZeroAmount() public {
Expand All @@ -57,12 +53,12 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {
AaveV3OptimizerAuthorization(owner, address(this), true, 0, SIGNATURE_DEADLINE)
);

MA3Signature memory sig;
Signature memory sig;
(sig.v, sig.r, sig.s) = vm.sign(privateKey, digest);

bundle.push(
abi.encodeCall(
AaveV3OptimizerMigrationBundler.aaveV3OptimizerApproveManagerWithSig,
AaveV3OptimizerMigrationBundlerV2.aaveV3OptimizerApproveManagerWithSig,
(true, 0, SIGNATURE_DEADLINE, sig, false)
)
);
Expand Down Expand Up @@ -188,10 +184,10 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {
function testAaveV3OptimizerApproveManagerUninitiated(uint256 amount) public {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

MA3Signature memory sig;
Signature memory sig;

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV3OptimizerMigrationBundler(address(bundler)).aaveV3OptimizerApproveManagerWithSig(
AaveV3OptimizerMigrationBundlerV2(address(bundler)).aaveV3OptimizerApproveManagerWithSig(
true, 0, SIGNATURE_DEADLINE, sig, false
);
}
Expand All @@ -200,7 +196,7 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV3OptimizerMigrationBundler(address(bundler)).aaveV3OptimizerWithdraw(
AaveV3OptimizerMigrationBundlerV2(address(bundler)).aaveV3OptimizerWithdraw(
marketParams.loanToken, amount, MAX_ITERATIONS
);
}
Expand All @@ -209,7 +205,7 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
AaveV3OptimizerMigrationBundler(address(bundler)).aaveV3OptimizerWithdrawCollateral(
AaveV3OptimizerMigrationBundlerV2(address(bundler)).aaveV3OptimizerWithdrawCollateral(
marketParams.loanToken, amount
);
}
Expand All @@ -228,22 +224,22 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {
AaveV3OptimizerAuthorization(vm.addr(privateKey), manager, isAllowed, nonce, SIGNATURE_DEADLINE)
);

MA3Signature memory sig;
Signature memory sig;
(sig.v, sig.r, sig.s) = vm.sign(privateKey, digest);

return abi.encodeCall(
AaveV3OptimizerMigrationBundler.aaveV3OptimizerApproveManagerWithSig,
AaveV3OptimizerMigrationBundlerV2.aaveV3OptimizerApproveManagerWithSig,
(isAllowed, nonce, SIGNATURE_DEADLINE, sig, skipRevert)
);
}

function _aaveV3OptimizerRepay(address underlying, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(AaveV3OptimizerMigrationBundler.aaveV3OptimizerRepay, (underlying, amount));
return abi.encodeCall(AaveV3OptimizerMigrationBundlerV2.aaveV3OptimizerRepay, (underlying, amount));
}

function _aaveV3OptimizerWithdraw(address underlying, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(
AaveV3OptimizerMigrationBundler.aaveV3OptimizerWithdraw, (underlying, amount, MAX_ITERATIONS)
AaveV3OptimizerMigrationBundlerV2.aaveV3OptimizerWithdraw, (underlying, amount, MAX_ITERATIONS)
);
}

Expand All @@ -252,6 +248,6 @@ contract AaveV3OptimizerMigrationBundlerEthereumTest is EthereumMigrationTest {
pure
returns (bytes memory)
{
return abi.encodeCall(AaveV3OptimizerMigrationBundler.aaveV3OptimizerWithdrawCollateral, (underlying, amount));
return abi.encodeCall(AaveV3OptimizerMigrationBundlerV2.aaveV3OptimizerWithdrawCollateral, (underlying, amount));
}
}
Loading
Loading