Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/adapters/MorphoMarketV1Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ contract MorphoMarketV1Adapter is IMorphoMarketV1Adapter {
require(data.length == 0, InvalidData());
require(msg.sender == parentVault, NotAuthorized());

uint256 shares;
uint256 mintedShares;
if (assets > 0) {
(, shares) = IMorpho(morpho).supply(marketParams(), assets, 0, address(this), hex"");
(, mintedShares) = IMorpho(morpho).supply(marketParams(), assets, 0, address(this), hex"");
// Safe cast because Market V1 bounds the total shares to uint128.max.
supplyShares += uint128(shares);
supplyShares += uint128(mintedShares);
}

uint256 _newAllocation = newAllocation();
// Safe casts because Market V1 bounds totalSupplyAssets to uint128.max.
int256 change = int256(_newAllocation) - int256(uint256(allocation));
allocation = uint128(_newAllocation);

emit Allocate(shares);
emit Allocate(mintedShares);

return (ids(), change);
}
Expand All @@ -110,19 +110,19 @@ contract MorphoMarketV1Adapter is IMorphoMarketV1Adapter {
require(data.length == 0, InvalidData());
require(msg.sender == parentVault, NotAuthorized());

uint256 shares;
uint256 burnedShares;
if (assets > 0) {
(, shares) = IMorpho(morpho).withdraw(marketParams(), assets, 0, address(this), address(this));
(, burnedShares) = IMorpho(morpho).withdraw(marketParams(), assets, 0, address(this), address(this));
// Safe cast because Market V1 bounds the total shares to uint128.max.
supplyShares -= uint128(shares);
supplyShares -= uint128(burnedShares);
}

uint256 _newAllocation = newAllocation();
// Safe casts because Market V1 bounds totalSupplyAssets to uint128.max.
int256 change = int256(_newAllocation) - int256(uint256(allocation));
allocation = uint128(_newAllocation);

emit Deallocate(shares);
emit Deallocate(burnedShares);

return (ids(), change);
}
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/interfaces/IMorphoMarketV1Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {Id, MarketParams} from "../../../lib/morpho-blue/src/interfaces/IMorpho.
interface IMorphoMarketV1Adapter is IAdapter {
/* EVENTS */

event Allocate(uint256 shares);
event Deallocate(uint256 shares);
event Allocate(uint256 mintedShares);
event Deallocate(uint256 burnedShares);
event SetSkimRecipient(address indexed newSkimRecipient);
event Skim(address indexed token, uint256 assets);

Expand Down
Loading