Skip to content

Commit

Permalink
refactor(remappings): use relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 17, 2023
1 parent eee7875 commit 49f699d
Show file tree
Hide file tree
Showing 45 changed files with 144 additions and 161 deletions.
2 changes: 1 addition & 1 deletion 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 "@forge-std/StdJson.sol";
import {stdJson} from "../lib/forge-std/src/StdJson.sol";

struct Config {
string json;
Expand Down
2 changes: 1 addition & 1 deletion 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 "@forge-std/StdChains.sol";
import {StdChains, VmSafe} from "../lib/forge-std/src/StdChains.sol";

abstract contract Configured is StdChains {
using ConfigLib for Config;
Expand Down
21 changes: 1 addition & 20 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
config/=config/
src/=src/
test/=test/

solmate/=lib/solmate/

@forge-std/=lib/morpho-blue/lib/forge-std/src/
@solmate/=lib/solmate/src/
@morpho-v1/=lib/morpho-v1/src/
@morpho-blue/=lib/morpho-blue/src/
@morpho-utils/=lib/morpho-utils/src/
@universal-rewards-distributor/=lib/universal-rewards-distributor/src/
@morpho-aave-v3/=lib/morpho-aave-v3/src
@openzeppelin/=lib/openzeppelin-contracts/contracts/
@permit2/=lib/permit2/src/

@uniswap/v3-core=lib/v3-core/contracts/
@uniswap/v3-periphery=lib/v3-periphery/contracts/

@aave/v3-core=lib/aave-v3-core/contracts/

@murky/=lib/murky/
solmate/=lib/permit2/lib/solmate/
18 changes: 9 additions & 9 deletions src/ERC4626Bundler.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

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

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "solmate/src/utils/SafeTransferLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

Expand Down Expand Up @@ -67,13 +67,13 @@ abstract contract ERC4626Bundler is BaseBundler {
require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
/// Do not check `receiver != address(this)` to allow the bundler to receive the underlying asset.

address initiator = initiator();
address _initiator = initiator();

assets = Math.min(assets, IERC4626(vault).maxWithdraw(initiator));
assets = Math.min(assets, IERC4626(vault).maxWithdraw(_initiator));

require(assets != 0, ErrorsLib.ZERO_AMOUNT);

IERC4626(vault).withdraw(assets, receiver, initiator);
IERC4626(vault).withdraw(assets, receiver, _initiator);
}

/// @notice Redeems the given amount of `shares` from the given ERC4626 `vault`, transferring assets to `receiver`.
Expand All @@ -84,12 +84,12 @@ abstract contract ERC4626Bundler is BaseBundler {
require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
/// Do not check `receiver != address(this)` to allow the bundler to receive the underlying asset.

address initiator = initiator();
address _initiator = initiator();

shares = Math.min(shares, IERC4626(vault).maxRedeem(initiator));
shares = Math.min(shares, IERC4626(vault).maxRedeem(_initiator));

require(shares != 0, ErrorsLib.ZERO_SHARES);

IERC4626(vault).redeem(shares, receiver, initiator);
IERC4626(vault).redeem(shares, receiver, _initiator);
}
}
6 changes: 3 additions & 3 deletions src/MorphoBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
pragma solidity 0.8.21;

import {IMorphoBundler} from "./interfaces/IMorphoBundler.sol";
import {MarketParams, Signature, Authorization, IMorpho} from "@morpho-blue/interfaces/IMorpho.sol";
import {MarketParams, Signature, Authorization, IMorpho} from "../lib/morpho-blue/src/interfaces/IMorpho.sol";

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

import {Math} from "@morpho-utils/math/Math.sol";
import {SafeTransferLib, ERC20} from "solmate/src/utils/SafeTransferLib.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

Expand Down
12 changes: 6 additions & 6 deletions src/Permit2Bundler.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.21;

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

import "./libraries/ConstantsLib.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {Math} from "@morpho-utils/math/Math.sol";
import {ERC20} from "solmate/src/tokens/ERC20.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ERC20} from "../lib/solmate/src/tokens/ERC20.sol";

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

Expand All @@ -24,14 +24,14 @@ abstract contract Permit2Bundler is BaseBundler {
external
payable
{
address initiator = initiator();
uint256 amount = Math.min(permit.permitted.amount, ERC20(permit.permitted.token).balanceOf(initiator));
address _initiator = initiator();
uint256 amount = Math.min(permit.permitted.amount, ERC20(permit.permitted.token).balanceOf(_initiator));

require(amount != 0, ErrorsLib.ZERO_AMOUNT);

ISignatureTransfer.SignatureTransferDetails memory transferDetails =
ISignatureTransfer.SignatureTransferDetails({to: address(this), requestedAmount: amount});

ISignatureTransfer(PERMIT2).permitTransferFrom(permit, transferDetails, initiator, signature);
ISignatureTransfer(PERMIT2).permitTransferFrom(permit, transferDetails, _initiator, signature);
}
}
4 changes: 2 additions & 2 deletions src/PermitBundler.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.21;

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

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

Expand All @@ -13,7 +13,7 @@ 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`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Pass `skipRevert = true` to avoid reverting the whole bundle in case the signature expired.
/// @dev Pass `skipRevert == true` to avoid reverting the whole bundle in case the signature expired.
function permit(address asset, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s, bool skipRevert)
external
payable
Expand Down
4 changes: 2 additions & 2 deletions src/StEthBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity 0.8.21;
import {IWstEth} from "./interfaces/IWstEth.sol";
import {IStEth} from "./interfaces/IStEth.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "solmate/src/utils/SafeTransferLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

Expand Down
10 changes: 5 additions & 5 deletions src/TransferBundler.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "solmate/src/utils/SafeTransferLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

Expand Down Expand Up @@ -49,11 +49,11 @@ abstract contract TransferBundler is BaseBundler {
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Pass `amount = type(uint256).max` to transfer all.
function erc20TransferFrom(address asset, uint256 amount) external payable {
address initiator = initiator();
amount = Math.min(amount, ERC20(asset).balanceOf(initiator));
address _initiator = initiator();
amount = Math.min(amount, ERC20(asset).balanceOf(_initiator));

require(amount != 0, ErrorsLib.ZERO_AMOUNT);

ERC20(asset).safeTransferFrom(initiator, address(this), amount);
ERC20(asset).safeTransferFrom(_initiator, address(this), amount);
}
}
3 changes: 2 additions & 1 deletion src/UrdBundler.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/WNativeBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity 0.8.21;

import {IWNative} from "./interfaces/IWNative.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "solmate/src/utils/SafeTransferLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IMorphoBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IMorphoSupplyCallback,
IMorphoSupplyCollateralCallback,
IMorphoFlashLoanCallback
} from "@morpho-blue/interfaces/IMorphoCallbacks.sol";
} from "../../lib/morpho-blue/src/interfaces/IMorphoCallbacks.sol";

interface IMorphoBundler is
IMorphoSupplyCallback,
Expand Down
4 changes: 2 additions & 2 deletions src/migration/AaveV2MigrationBundler.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {ILendingPool} from "@morpho-v1/aave-v2/interfaces/aave/ILendingPool.sol";
import {ILendingPool} from "../../lib/morpho-v1/src/aave-v2/interfaces/aave/ILendingPool.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";

import {MigrationBundler, ERC20} from "./MigrationBundler.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/migration/AaveV3MigrationBundler.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IPool} from "@aave/v3-core/interfaces/IPool.sol";
import {IPool} from "../../lib/aave-v3-core/contracts/interfaces/IPool.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";

import {MigrationBundler, ERC20} from "./MigrationBundler.sol";
Expand Down
6 changes: 3 additions & 3 deletions src/migration/AaveV3OptimizerMigrationBundler.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IMorpho as IAaveV3Optimizer} from "@morpho-aave-v3/interfaces/IMorpho.sol";
import {IMorpho as IAaveV3Optimizer} from "../../lib/morpho-aave-v3/src/interfaces/IMorpho.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";
import {Types} from "@morpho-aave-v3/libraries/Types.sol";
import {Types} from "../../lib/morpho-aave-v3/src/libraries/Types.sol";

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

Expand Down
2 changes: 1 addition & 1 deletion src/migration/CompoundV2MigrationBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.21;
import {ICEth} from "./interfaces/ICEth.sol";
import {ICToken} from "./interfaces/ICToken.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";

import {WNativeBundler} from "../WNativeBundler.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/migration/CompoundV3MigrationBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.21;

import {ICompoundV3} from "./interfaces/ICompoundV3.sol";

import {Math} from "@morpho-utils/math/Math.sol";
import {Math} from "../../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "../libraries/ErrorsLib.sol";

import {MigrationBundler, ERC20} from "./MigrationBundler.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/migration/MigrationBundler.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.21;

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

import {TransferBundler} from "../TransferBundler.sol";
import {PermitBundler} from "../PermitBundler.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/ERC20Mock.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 {ERC20} from "@openzeppelin/token/ERC20/ERC20.sol";
import {ERC20} from "../../lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";

contract ERC20Mock is ERC20 {
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {}
Expand Down
4 changes: 2 additions & 2 deletions src/mocks/ERC20PermitMock.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

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

contract ERC20PermitMock is ERC20Permit {
constructor(string memory _name, string memory _symbol) ERC20Permit(_name) ERC20(_name, _symbol) {}
Expand Down
6 changes: 3 additions & 3 deletions src/mocks/ERC4626Mock.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

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

contract ERC4626Mock is ERC4626 {
constructor(address asset, string memory name, string memory symbol) ERC4626(IERC20(asset)) ERC20(name, symbol) {}
Expand Down
6 changes: 3 additions & 3 deletions src/mocks/IrmMock.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {IIrm} from "@morpho-blue/interfaces/IIrm.sol";
import {MarketParams, Market} from "@morpho-blue/interfaces/IMorpho.sol";
import {IIrm} from "../../lib/morpho-blue/src/interfaces/IIrm.sol";
import {MarketParams, Market} from "../../lib/morpho-blue/src/interfaces/IMorpho.sol";

import {MathLib} from "@morpho-blue/libraries/MathLib.sol";
import {MathLib} from "../../lib/morpho-blue/src/libraries/MathLib.sol";

contract IrmMock is IIrm {
using MathLib for uint128;
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/OracleMock.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 {IOracle} from "@morpho-blue/interfaces/IOracle.sol";
import {IOracle} from "../../lib/morpho-blue/src/interfaces/IOracle.sol";

contract OracleMock is IOracle {
uint256 public price;
Expand Down
6 changes: 3 additions & 3 deletions test/forge/ERC4626BundlerLocalTest.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

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

import {ERC4626Mock} from "src/mocks/ERC4626Mock.sol";
import "src/mocks/bundlers/ERC4626BundlerMock.sol";
import {ERC4626Mock} from "../../src/mocks/ERC4626Mock.sol";
import "../../src/mocks/bundlers/ERC4626BundlerMock.sol";

import "./helpers/LocalTest.sol";

Expand Down
6 changes: 3 additions & 3 deletions test/forge/MorphoBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity ^0.8.0;

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

import "src/mocks/bundlers/MorphoBundlerMock.sol";
import "../../src/mocks/bundlers/MorphoBundlerMock.sol";

import "./helpers/LocalTest.sol";

Expand Down
4 changes: 2 additions & 2 deletions test/forge/PermitBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity ^0.8.0;

import {SigUtils, Permit} from "test/forge/helpers/SigUtils.sol";

import "src/mocks/bundlers/PermitBundlerMock.sol";
import {ERC20PermitMock} from "src/mocks/ERC20PermitMock.sol";
import "../../src/mocks/bundlers/PermitBundlerMock.sol";
import {ERC20PermitMock} from "../../src/mocks/ERC20PermitMock.sol";

import "./helpers/LocalTest.sol";

Expand Down
Loading

0 comments on commit 49f699d

Please sign in to comment.