Skip to content

Commit

Permalink
Merge pull request #119 from morpho-labs/build/blue
Browse files Browse the repository at this point in the history
build(deps): update morpho-blue
  • Loading branch information
MerlinEgalite authored Sep 27, 2023
2 parents 91a07be + 278f35d commit a158653
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion lib/morpho-blue
2 changes: 1 addition & 1 deletion src/MetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 17 additions & 17 deletions test/forge/ERC4626Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -170,15 +170,15 @@ 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);

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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions test/forge/FeeTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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"");
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions test/forge/MarketTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ 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));
vault.submitCap(marketParams, 0);
}

function testSubmitCapMarketNotCreated(MarketParams memory marketParams) public {
marketParams.borrowableToken = address(borrowableToken);
marketParams.loanToken = address(loanToken);

vm.assume(morpho.lastUpdate(marketParams.id()) == 0);

Expand Down Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions test/forge/UrdTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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))"
);
}
}
Loading

0 comments on commit a158653

Please sign in to comment.