Skip to content

Commit

Permalink
refactor: rename wrapper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Oct 24, 2023
1 parent f33171a commit 6bde5b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/ERC20WrapperBundler.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IERC20} from "../lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol";

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";
Expand All @@ -26,7 +24,7 @@ abstract contract ERC20WrapperBundler is BaseBundler {
/// @dev Assumes that `wrapper` is implements the `ERC20Wrapper` interface.
/// @param wrapper The address of the ERC20 wrapper contract.
/// @param amount The amount of underlying tokens to deposit.
function depositFor(address wrapper, uint256 amount) external {
function erc20WrapperDepositFor(address wrapper, uint256 amount) external {
ERC20 underlying = ERC20(address(ERC20Wrapper(wrapper).underlying()));

amount = Math.min(amount, underlying.balanceOf(address(this)));
Expand All @@ -45,7 +43,7 @@ abstract contract ERC20WrapperBundler is BaseBundler {
/// @param wrapper The address of the ERC20 wrapper contract.
/// @param account The address receiving the underlying tokens.
/// @param amount The amount of wrapped tokens to burn.
function withdrawTo(address wrapper, address account, uint256 amount) external {
function erc20WrapperWithdrawTo(address wrapper, address account, uint256 amount) external {
require(account != address(0), ErrorsLib.ZERO_ADDRESS);
require(amount != 0, ErrorsLib.ZERO_AMOUNT);

Expand Down
10 changes: 5 additions & 5 deletions test/forge/ERC20WrapperBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract ERC20WrapperBundlerBundlerLocalTest is LocalTest {
loanWrapper = new ERC20WrapperMock(loanToken, "Wrapped Loan Token", "WLT");
}

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

bundle.push(_erc20WrapperDepositFor(address(loanWrapper), amount));
Expand All @@ -33,14 +33,14 @@ contract ERC20WrapperBundlerBundlerLocalTest is LocalTest {
assertEq(loanWrapper.balanceOf(RECEIVER), amount, "loanWrapper.balanceOf(RECEIVER)");
}

function testDepositForZeroAmount() public {
function testErc20WrapperDepositForZeroAmount() public {
bundle.push(_erc20WrapperDepositFor(address(loanWrapper), 0));

vm.expectRevert(bytes(ErrorsLib.ZERO_AMOUNT));
bundler.multicall(bundle);
}

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

loanWrapper.setBalance(address(bundler), amount);
Expand All @@ -54,7 +54,7 @@ contract ERC20WrapperBundlerBundlerLocalTest is LocalTest {
assertEq(loanToken.balanceOf(RECEIVER), amount, "loan.balanceOf(RECEIVER)");
}

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

bundle.push(_erc20WrapperWithdrawTo(address(loanWrapper), address(0), amount));
Expand All @@ -63,7 +63,7 @@ contract ERC20WrapperBundlerBundlerLocalTest is LocalTest {
bundler.multicall(bundle);
}

function testWithdrawToZeroAmount() public {
function testErc20WrapperWithdrawToZeroAmount() public {
bundle.push(_erc20WrapperWithdrawTo(address(loanWrapper), RECEIVER, 0));

vm.expectRevert(bytes(ErrorsLib.ZERO_AMOUNT));
Expand Down
4 changes: 2 additions & 2 deletions test/forge/helpers/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ abstract contract BaseTest is Test {
/* ERC20 WRAPPER ACTIONS */

function _erc20WrapperDepositFor(address asset, uint256 amount) internal pure returns (bytes memory) {
return abi.encodeCall(ERC20WrapperBundler.depositFor, (asset, amount));
return abi.encodeCall(ERC20WrapperBundler.erc20WrapperDepositFor, (asset, amount));
}

function _erc20WrapperWithdrawTo(address asset, address account, uint256 amount)
internal
pure
returns (bytes memory)
{
return abi.encodeCall(ERC20WrapperBundler.withdrawTo, (asset, account, amount));
return abi.encodeCall(ERC20WrapperBundler.erc20WrapperWithdrawTo, (asset, account, amount));
}

/* ERC4626 ACTIONS */
Expand Down

0 comments on commit 6bde5b8

Please sign in to comment.