Skip to content

Commit

Permalink
Merge pull request #85 from GenerationSoftware/gen-1220-h-59-yield-fe…
Browse files Browse the repository at this point in the history
…e-balance-share-subtraction-bug

subtract only the amount of shares claimed from the yield fee balance
  • Loading branch information
trmid committed Mar 18, 2024
2 parents 94b0c03 + 582f5b8 commit cc9e119
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/PrizeVault.sol
Expand Up @@ -610,11 +610,9 @@ contract PrizeVault is TwabERC20, Claimable, IERC4626, ILiquidationSource, Ownab
/// @dev Will revert if the caller is not the yield fee recipient or if zero shares are withdrawn
function claimYieldFeeShares(uint256 _shares) external onlyYieldFeeRecipient {
if (_shares == 0) revert MintZeroShares();
if (_shares > yieldFeeBalance) revert SharesExceedsYieldFeeBalance(_shares, yieldFeeBalance);

uint256 _yieldFeeBalance = yieldFeeBalance;
if (_shares > _yieldFeeBalance) revert SharesExceedsYieldFeeBalance(_shares, _yieldFeeBalance);

yieldFeeBalance -= _yieldFeeBalance;
yieldFeeBalance -= _shares;

_mint(msg.sender, _shares);

Expand Down
11 changes: 11 additions & 0 deletions test/unit/PrizeVault/Liquidate.t.sol
Expand Up @@ -371,6 +371,17 @@ contract PrizeVaultLiquidationTest is UnitBaseSetup {
vm.stopPrank();

assertEq(vault.balanceOf(bob), yieldFeeBalance / 3);

// test a claim of the rest of the fees:
vm.startPrank(bob);
vm.expectEmit();
emit Transfer(address(0), bob, (2 * yieldFeeBalance) / 3);
vm.expectEmit();
emit ClaimYieldFeeShares(bob, (2 * yieldFeeBalance) / 3);
vault.claimYieldFeeShares((2 * yieldFeeBalance) / 3);
vm.stopPrank();

assertEq(vault.balanceOf(bob), yieldFeeBalance);
}

}

0 comments on commit cc9e119

Please sign in to comment.