Skip to content

Commit

Permalink
feat: ERC4626 take into account totalShares of strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Jul 17, 2024
1 parent a6422cb commit c490ca3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contracts/ERC4626Strategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ contract ERC4626Strategy is BaseStrategy {
* @inheritdoc ERC4626
*/
function maxMint(address) public view override returns (uint256) {
return ERC4626(STRATEGY_ASSET).maxMint(address(this));
// We need to convert the total supply of the strategy asset to the total supply of the strategy
return (ERC4626(STRATEGY_ASSET).maxMint(address(this)) * totalSupply()) / ERC4626(STRATEGY_ASSET).totalSupply();
}

/**
Expand All @@ -72,6 +73,11 @@ contract ERC4626Strategy is BaseStrategy {
* @inheritdoc ERC4626
*/
function maxRedeem(address owner) public view override returns (uint256) {
return Math.min(balanceOf(owner), ERC4626(STRATEGY_ASSET).maxRedeem(address(this)));
return
Math.min(
balanceOf(owner),
(ERC4626(STRATEGY_ASSET).maxRedeem(address(this)) * totalSupply()) /
ERC4626(STRATEGY_ASSET).totalSupply()
);
}
}

0 comments on commit c490ca3

Please sign in to comment.