-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update last total assets in accept cap #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -779,6 +779,9 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph | |
} | ||
|
||
marketConfig.enabled = true; | ||
|
||
MarketParams memory marketParams = MORPHO.idToMarketParams(id); | ||
_updateLastTotalAssets(lastTotalAssets + MORPHO.expectedSupplyAssets(marketParams, address(this))); | ||
Comment on lines
+783
to
+784
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This behavior implies that no fee is capture when a non-zero supply market is opened |
||
} | ||
|
||
marketConfig.removableAt = 0; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,6 +7,7 @@ import {SafeCast} from "../../lib/openzeppelin-contracts/contracts/utils/math/Sa | |||||
import "./helpers/IntegrationTest.sol"; | ||||||
|
||||||
contract MarketTest is IntegrationTest { | ||||||
using MathLib for uint256; | ||||||
using MarketParamsLib for MarketParams; | ||||||
using MorphoLib for IMorpho; | ||||||
|
||||||
|
@@ -279,4 +280,39 @@ contract MarketTest is IntegrationTest { | |||||
); | ||||||
vault.updateWithdrawQueue(indexes); | ||||||
} | ||||||
|
||||||
function testenableMarketWithLiquidity(uint256 deposited, uint256 additionalSupply, uint256 blocks) public { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
deposited = bound(deposited, MIN_TEST_ASSETS, MAX_TEST_ASSETS); | ||||||
additionalSupply = bound(additionalSupply, MIN_TEST_ASSETS, MAX_TEST_ASSETS); | ||||||
blocks = _boundBlocks(blocks); | ||||||
|
||||||
Id[] memory supplyQueue = new Id[](1); | ||||||
supplyQueue[0] = allMarkets[0].id(); | ||||||
|
||||||
_setCap(allMarkets[0], deposited); | ||||||
|
||||||
vm.prank(ALLOCATOR); | ||||||
vault.setSupplyQueue(supplyQueue); | ||||||
|
||||||
loanToken.setBalance(SUPPLIER, deposited + additionalSupply); | ||||||
|
||||||
vm.startPrank(SUPPLIER); | ||||||
vault.deposit(deposited, ONBEHALF); | ||||||
morpho.supply(allMarkets[3], additionalSupply, 0, address(vault), hex""); | ||||||
vm.stopPrank(); | ||||||
|
||||||
uint256 collateral = uint256(MAX_TEST_ASSETS).wDivUp(allMarkets[0].lltv); | ||||||
collateralToken.setBalance(BORROWER, collateral); | ||||||
|
||||||
vm.startPrank(BORROWER); | ||||||
morpho.supplyCollateral(allMarkets[0], collateral, BORROWER, hex""); | ||||||
morpho.borrow(allMarkets[0], deposited, 0, BORROWER, BORROWER); | ||||||
vm.stopPrank(); | ||||||
|
||||||
_forward(blocks); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems innocent, but it's not! Great |
||||||
|
||||||
_setCap(allMarkets[3], CAP); | ||||||
|
||||||
assertEq(vault.lastTotalAssets(), deposited + additionalSupply); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.