Skip to content

Commit

Permalink
Merge pull request #366 from morpho-org/fix/issue-N-06
Browse files Browse the repository at this point in the history
add `onMorphoLiquidate`
  • Loading branch information
MerlinEgalite authored Nov 9, 2023
2 parents b1d94d7 + 9f458f0 commit 82f3fe8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/MorphoBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
_callback(data);
}

function onMorphoLiquidate(uint256, bytes calldata data) external {
// Don't need to approve Morpho to pull tokens because it should already be approved max.
_callback(data);
}

function onMorphoFlashLoan(uint256, bytes calldata data) external {
// Don't need to approve Morpho to pull tokens because it should already be approved max.
_callback(data);
Expand Down
3 changes: 2 additions & 1 deletion test/forge/MorphoBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ contract MorphoBundlerLocalTest is LocalTest {
seizedCollateral.mulDivUp(ORACLE_PRICE_SCALE / 2, ORACLE_PRICE_SCALE).wDivUp(incentiveFactor);
uint256 expectedRepaidShares = repaidAssets.toSharesDown(amountBorrowed, borrowShares);

bundle.push(_erc20TransferFrom(address(loanToken), repaidAssets));
callbackBundle.push(_erc20TransferFrom(address(loanToken), repaidAssets));

bundle.push(_morphoLiquidate(marketParams, USER, seizedCollateral, 0, type(uint256).max));
bundle.push(_erc20Transfer(address(collateralToken), LIQUIDATOR, seizedCollateral));

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 @@ -256,10 +256,10 @@ abstract contract BaseTest is Test {
uint256 seizedCollateral,
uint256 repaidShares,
uint256 maxRepaidAssets
) internal pure returns (bytes memory) {
) internal view returns (bytes memory) {
return abi.encodeCall(
MorphoBundler.morphoLiquidate,
(marketParams, borrower, seizedCollateral, repaidShares, maxRepaidAssets, hex"")
(marketParams, borrower, seizedCollateral, repaidShares, maxRepaidAssets, abi.encode(callbackBundle))
);
}

Expand Down

0 comments on commit 82f3fe8

Please sign in to comment.