diff --git a/lib/morpho-blue b/lib/morpho-blue index 08472125..11e69bb1 160000 --- a/lib/morpho-blue +++ b/lib/morpho-blue @@ -1 +1 @@ -Subproject commit 084721252cca3c40b8c289837b9ed3a33e54b36c +Subproject commit 11e69bb150f4f360174e03c85498b85e74810c53 diff --git a/src/MetaMorpho.sol b/src/MetaMorpho.sol index 6f0bba87..f31b8900 100644 --- a/src/MetaMorpho.sol +++ b/src/MetaMorpho.sol @@ -204,7 +204,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph /* ONLY RISK MANAGER FUNCTIONS */ function submitCap(MarketParams memory marketParams, uint256 newMarketCap) external onlyRiskManager { - require(marketParams.borrowableToken == asset(), ErrorsLib.INCONSISTENT_ASSET); + require(marketParams.loanToken == asset(), ErrorsLib.INCONSISTENT_ASSET); Id id = marketParams.id(); require(MORPHO.lastUpdate(id) != 0, ErrorsLib.MARKET_NOT_CREATED); diff --git a/test/forge/ERC4626Test.sol b/test/forge/ERC4626Test.sol index 6bfa179a..b840e16c 100644 --- a/test/forge/ERC4626Test.sol +++ b/test/forge/ERC4626Test.sol @@ -18,7 +18,7 @@ contract ERC4626Test is BaseTest { uint256 shares = vault.convertToShares(assets); - borrowableToken.setBalance(SUPPLIER, assets); + loanToken.setBalance(SUPPLIER, assets); vm.prank(SUPPLIER); uint256 deposited = vault.mint(shares, ONBEHALF); @@ -31,7 +31,7 @@ contract ERC4626Test is BaseTest { function testDeposit(uint256 assets) public { assets = bound(assets, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, assets); + loanToken.setBalance(SUPPLIER, assets); vm.prank(SUPPLIER); uint256 shares = vault.deposit(assets, ONBEHALF); @@ -44,7 +44,7 @@ contract ERC4626Test is BaseTest { function testRedeemTooMuch(uint256 deposited) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 shares = vault.deposit(deposited, ONBEHALF); @@ -57,7 +57,7 @@ contract ERC4626Test is BaseTest { function testWithdrawAll(uint256 assets) public { assets = bound(assets, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, assets); + loanToken.setBalance(SUPPLIER, assets); vm.prank(SUPPLIER); uint256 minted = vault.deposit(assets, ONBEHALF); @@ -69,14 +69,14 @@ contract ERC4626Test is BaseTest { assertEq(shares, minted, "shares"); assertEq(vault.balanceOf(ONBEHALF), 0, "balanceOf(ONBEHALF)"); - assertEq(borrowableToken.balanceOf(RECEIVER), assets, "borrowableToken.balanceOf(RECEIVER)"); + assertEq(loanToken.balanceOf(RECEIVER), assets, "loanToken.balanceOf(RECEIVER)"); assertEq(morpho.expectedSupplyBalance(allMarkets[0], address(vault)), 0, "expectedSupplyBalance(vault)"); } function testRedeemAll(uint256 deposited) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 minted = vault.deposit(deposited, ONBEHALF); @@ -88,14 +88,14 @@ contract ERC4626Test is BaseTest { assertEq(assets, deposited, "assets"); assertEq(vault.balanceOf(ONBEHALF), 0, "balanceOf(ONBEHALF)"); - assertEq(borrowableToken.balanceOf(RECEIVER), deposited, "borrowableToken.balanceOf(RECEIVER)"); + assertEq(loanToken.balanceOf(RECEIVER), deposited, "loanToken.balanceOf(RECEIVER)"); assertEq(morpho.expectedSupplyBalance(allMarkets[0], address(vault)), 0, "expectedSupplyBalance(vault)"); } function testRedeemNotDeposited(uint256 deposited) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 shares = vault.deposit(deposited, ONBEHALF); @@ -108,7 +108,7 @@ contract ERC4626Test is BaseTest { function testRedeemNotApproved(uint256 deposited) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 shares = vault.deposit(deposited, ONBEHALF); @@ -121,7 +121,7 @@ contract ERC4626Test is BaseTest { function testWithdrawNotApproved(uint256 assets) public { assets = bound(assets, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, assets); + loanToken.setBalance(SUPPLIER, assets); vm.prank(SUPPLIER); vault.deposit(assets, ONBEHALF); @@ -134,7 +134,7 @@ contract ERC4626Test is BaseTest { function testTransferFrom(uint256 deposited, uint256 toTransfer) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 shares = vault.deposit(deposited, ONBEHALF); @@ -155,7 +155,7 @@ contract ERC4626Test is BaseTest { function testTransferFromNotApproved(uint256 deposited, uint256 amount) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 shares = vault.deposit(deposited, ONBEHALF); @@ -170,7 +170,7 @@ contract ERC4626Test is BaseTest { function testWithdrawMoreThanBalanceButLessThanTotalAssets(uint256 deposited, uint256 assets) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -178,7 +178,7 @@ contract ERC4626Test is BaseTest { assets = bound(assets, deposited + 1, type(uint256).max / (deposited + 10 ** DECIMALS_OFFSET)); uint256 toAdd = assets - deposited + 1; - borrowableToken.setBalance(SUPPLIER, toAdd); + loanToken.setBalance(SUPPLIER, toAdd); vm.prank(SUPPLIER); vault.deposit(toAdd, SUPPLIER); @@ -191,7 +191,7 @@ contract ERC4626Test is BaseTest { function testWithdrawMoreThanTotalAssets(uint256 deposited, uint256 assets) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -206,7 +206,7 @@ contract ERC4626Test is BaseTest { function testWithdrawMoreThanBalanceButLessThanLiquidity(uint256 deposited, uint256 assets) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -229,7 +229,7 @@ contract ERC4626Test is BaseTest { function testTransfer(uint256 deposited, uint256 toTransfer) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); uint256 minted = vault.deposit(deposited, ONBEHALF); diff --git a/test/forge/FeeTest.sol b/test/forge/FeeTest.sol index 2fc92ff2..ef276216 100644 --- a/test/forge/FeeTest.sol +++ b/test/forge/FeeTest.sol @@ -27,7 +27,7 @@ contract FeeTest is BaseTest { // Create some debt on the market to accrue interest. - borrowableToken.setBalance(SUPPLIER, 1); + loanToken.setBalance(SUPPLIER, 1); vm.prank(SUPPLIER); morpho.supply(marketParams, 1, 0, ONBEHALF, hex""); @@ -57,7 +57,7 @@ contract FeeTest is BaseTest { function testLastTotalAssets(uint256 deposited) public { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -69,7 +69,7 @@ contract FeeTest is BaseTest { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); withdrawn = bound(withdrawn, MIN_TEST_ASSETS, deposited); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -85,7 +85,7 @@ contract FeeTest is BaseTest { newDeposit = bound(newDeposit, MIN_TEST_ASSETS, MAX_TEST_ASSETS); blocks = _boundBlocks(blocks); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -96,7 +96,7 @@ contract FeeTest is BaseTest { uint256 feeShares = _feeShares(totalAssetsBefore); - borrowableToken.setBalance(SUPPLIER, newDeposit); + loanToken.setBalance(SUPPLIER, newDeposit); vm.prank(SUPPLIER); vault.deposit(newDeposit, ONBEHALF); @@ -110,7 +110,7 @@ contract FeeTest is BaseTest { newDeposit = bound(newDeposit, MIN_TEST_ASSETS, MAX_TEST_ASSETS); blocks = _boundBlocks(blocks); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -123,7 +123,7 @@ contract FeeTest is BaseTest { uint256 shares = vault.convertToShares(newDeposit); - borrowableToken.setBalance(SUPPLIER, newDeposit); + loanToken.setBalance(SUPPLIER, newDeposit); vm.prank(SUPPLIER); vault.mint(shares, ONBEHALF); @@ -137,7 +137,7 @@ contract FeeTest is BaseTest { withdrawn = bound(withdrawn, MIN_TEST_ASSETS, deposited); blocks = _boundBlocks(blocks); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -162,7 +162,7 @@ contract FeeTest is BaseTest { withdrawn = bound(withdrawn, MIN_TEST_ASSETS, deposited); blocks = _boundBlocks(blocks); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -187,7 +187,7 @@ contract FeeTest is BaseTest { vm.assume(fee != FEE); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); @@ -208,7 +208,7 @@ contract FeeTest is BaseTest { deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); blocks = _boundBlocks(blocks); - borrowableToken.setBalance(SUPPLIER, deposited); + loanToken.setBalance(SUPPLIER, deposited); vm.prank(SUPPLIER); vault.deposit(deposited, ONBEHALF); diff --git a/test/forge/MarketTest.sol b/test/forge/MarketTest.sol index 2575cd02..8321994e 100644 --- a/test/forge/MarketTest.sol +++ b/test/forge/MarketTest.sol @@ -33,7 +33,7 @@ contract MarketTest is BaseTest { } function testSubmitCapInconsistentAsset(MarketParams memory marketParams) public { - vm.assume(marketParams.borrowableToken != address(borrowableToken)); + vm.assume(marketParams.loanToken != address(loanToken)); vm.prank(RISK_MANAGER); vm.expectRevert(bytes(ErrorsLib.INCONSISTENT_ASSET)); @@ -41,7 +41,7 @@ contract MarketTest is BaseTest { } function testSubmitCapMarketNotCreated(MarketParams memory marketParams) public { - marketParams.borrowableToken = address(borrowableToken); + marketParams.loanToken = address(loanToken); vm.assume(morpho.lastUpdate(marketParams.id()) == 0); @@ -127,7 +127,7 @@ contract MarketTest is BaseTest { _setCap(allMarkets[1], CAP); _setCap(allMarkets[2], CAP); - borrowableToken.setBalance(SUPPLIER, 1); + loanToken.setBalance(SUPPLIER, 1); vm.prank(SUPPLIER); vault.deposit(1, RECEIVER); diff --git a/test/forge/UrdTest.sol b/test/forge/UrdTest.sol index cd69d1b7..53e1b995 100644 --- a/test/forge/UrdTest.sol +++ b/test/forge/UrdTest.sol @@ -32,7 +32,7 @@ contract UrdTest is BaseTest { vault.setRewardsDistributor(address(0)); } - function testTransferRewardsNotBorrowableToken(uint256 amount) public { + function testTransferRewardsNotLoanToken(uint256 amount) public { vm.prank(OWNER); vault.setRewardsDistributor(address(rewardsDistributor)); @@ -51,31 +51,31 @@ contract UrdTest is BaseTest { ); } - function testTransferRewardsBorrowableToken(uint256 rewards, uint256 idle) public { + function testTransferRewardsLoanToken(uint256 rewards, uint256 idle) public { idle = bound(idle, 0, MAX_TEST_ASSETS); rewards = bound(rewards, 0, MAX_TEST_ASSETS); vm.prank(OWNER); vault.setRewardsDistributor(address(rewardsDistributor)); - borrowableToken.setBalance(address(vault), rewards); + loanToken.setBalance(address(vault), rewards); - borrowableToken.setBalance(address(SUPPLIER), idle); + loanToken.setBalance(address(SUPPLIER), idle); vm.prank(SUPPLIER); vault.deposit(idle, SUPPLIER); assertEq(vault.idle(), idle, "vault.idle()"); - uint256 vaultBalanceBefore = borrowableToken.balanceOf(address(vault)); + uint256 vaultBalanceBefore = loanToken.balanceOf(address(vault)); assertEq(vaultBalanceBefore, idle + rewards, "vaultBalanceBefore"); - vault.transferRewards(address(borrowableToken)); - uint256 vaultBalanceAfter = borrowableToken.balanceOf(address(vault)); + vault.transferRewards(address(loanToken)); + uint256 vaultBalanceAfter = loanToken.balanceOf(address(vault)); assertEq(vaultBalanceAfter, idle, "vaultBalanceAfter"); assertEq( - borrowableToken.balanceOf(address(rewardsDistributor)), + loanToken.balanceOf(address(rewardsDistributor)), rewards, - "borrowableToken.balanceOf(address(rewardsDistributor))" + "loanToken.balanceOf(address(rewardsDistributor))" ); } } diff --git a/test/forge/helpers/BaseTest.sol b/test/forge/helpers/BaseTest.sol index 9451fe3c..dc537e7e 100644 --- a/test/forge/helpers/BaseTest.sol +++ b/test/forge/helpers/BaseTest.sol @@ -46,7 +46,7 @@ contract BaseTest is Test { address internal MORPHO_FEE_RECIPIENT; IMorpho internal morpho; - ERC20Mock internal borrowableToken; + ERC20Mock internal loanToken; ERC20Mock internal collateralToken; OracleMock internal oracle; IrmMock internal irm; @@ -70,8 +70,8 @@ contract BaseTest is Test { morpho = IMorpho(_deploy("lib/morpho-blue/out/Morpho.sol/Morpho.json", abi.encode(MORPHO_OWNER))); vm.label(address(morpho), "Morpho"); - borrowableToken = new ERC20Mock("borrowable", "B"); - vm.label(address(borrowableToken), "Borrowable"); + loanToken = new ERC20Mock("loan", "B"); + vm.label(address(loanToken), "Loan"); collateralToken = new ERC20Mock("collateral", "C"); vm.label(address(collateralToken), "Collateral"); @@ -91,7 +91,7 @@ contract BaseTest is Test { vm.stopPrank(); vm.startPrank(OWNER); - vault = new MetaMorpho(address(morpho), 0, address(borrowableToken), "MetaMorpho Vault", "MMV"); + vault = new MetaMorpho(address(morpho), 0, address(loanToken), "MetaMorpho Vault", "MMV"); vault.setRiskManager(RISK_MANAGER); vault.setIsAllocator(ALLOCATOR, true); @@ -102,7 +102,7 @@ contract BaseTest is Test { uint256 lltv = 0.8 ether / (i + 1); MarketParams memory marketParams = MarketParams({ - borrowableToken: address(borrowableToken), + loanToken: address(loanToken), collateralToken: address(collateralToken), oracle: address(oracle), irm: address(irm), @@ -117,13 +117,13 @@ contract BaseTest is Test { allMarkets.push(marketParams); } - borrowableToken.approve(address(vault), type(uint256).max); + loanToken.approve(address(vault), type(uint256).max); collateralToken.approve(address(vault), type(uint256).max); vm.startPrank(SUPPLIER); - borrowableToken.approve(address(vault), type(uint256).max); + loanToken.approve(address(vault), type(uint256).max); collateralToken.approve(address(vault), type(uint256).max); - borrowableToken.approve(address(morpho), type(uint256).max); + loanToken.approve(address(morpho), type(uint256).max); collateralToken.approve(address(morpho), type(uint256).max); vm.stopPrank(); @@ -131,10 +131,10 @@ contract BaseTest is Test { collateralToken.approve(address(morpho), type(uint256).max); vm.prank(REPAYER); - borrowableToken.approve(address(morpho), type(uint256).max); + loanToken.approve(address(morpho), type(uint256).max); vm.startPrank(ONBEHALF); - borrowableToken.approve(address(vault), type(uint256).max); + loanToken.approve(address(vault), type(uint256).max); collateralToken.approve(address(vault), type(uint256).max); vm.stopPrank(); } diff --git a/test/hardhat/MetaMorpho.spec.ts b/test/hardhat/MetaMorpho.spec.ts index bb5af83d..ca475386 100644 --- a/test/hardhat/MetaMorpho.spec.ts +++ b/test/hardhat/MetaMorpho.spec.ts @@ -50,7 +50,7 @@ describe("MetaMorpho", () => { let borrowers: SignerWithAddress[]; let morpho: IMorpho; - let borrowable: ERC20Mock; + let loan: ERC20Mock; let collateral: ERC20Mock; let oracle: OracleMock; let irm: IrmMock; @@ -70,7 +70,7 @@ describe("MetaMorpho", () => { const ERC20MockFactory = await hre.ethers.getContractFactory("ERC20Mock", admin); - borrowable = await ERC20MockFactory.deploy("DAI", "DAI"); + loan = await ERC20MockFactory.deploy("DAI", "DAI"); collateral = await ERC20MockFactory.deploy("Wrapped BTC", "WBTC"); const OracleMockFactory = await hre.ethers.getContractFactory("OracleMock", admin); @@ -92,13 +92,13 @@ describe("MetaMorpho", () => { irm = await IrmMockFactory.deploy(); const morphoAddress = await morpho.getAddress(); - const borrowableAddress = await borrowable.getAddress(); + const loanAddress = await loan.getAddress(); const collateralAddress = await collateral.getAddress(); const oracleAddress = await oracle.getAddress(); const irmAddress = await irm.getAddress(); allMarketParams = _range(1, 1 + nbMarkets).map((i) => ({ - borrowableToken: borrowableAddress, + loanToken: loanAddress, collateralToken: collateralAddress, oracle: oracleAddress, irm: irmAddress, @@ -114,13 +114,13 @@ describe("MetaMorpho", () => { const IMetaMorphoFactory = await hre.ethers.getContractFactory("MetaMorpho", admin); - metaMorpho = await IMetaMorphoFactory.deploy(morphoAddress, 1, borrowableAddress, "MetaMorpho", "mB"); + metaMorpho = await IMetaMorphoFactory.deploy(morphoAddress, 1, loanAddress, "MetaMorpho", "mB"); const metaMorphoAddress = await metaMorpho.getAddress(); for (const user of users) { - await borrowable.setBalance(user.address, initBalance); - await borrowable.connect(user).approve(metaMorphoAddress, MaxUint256); + await loan.setBalance(user.address, initBalance); + await loan.connect(user).approve(metaMorphoAddress, MaxUint256); await collateral.setBalance(user.address, initBalance); await collateral.connect(user).approve(morphoAddress, MaxUint256); } @@ -149,7 +149,7 @@ describe("MetaMorpho", () => { hre.tracer.nameTags[morphoAddress] = "Morpho"; hre.tracer.nameTags[collateralAddress] = "Collateral"; - hre.tracer.nameTags[borrowableAddress] = "Borrowable"; + hre.tracer.nameTags[loanAddress] = "Loan"; hre.tracer.nameTags[oracleAddress] = "Oracle"; hre.tracer.nameTags[irmAddress] = "IRM"; hre.tracer.nameTags[metaMorphoAddress] = "MetaMorpho";