Skip to content

Commit

Permalink
Merge pull request #87 from GenerationSoftware/gen-1211-qa-237-l-11-q…
Browse files Browse the repository at this point in the history
…a-212-l-03

Replace double approval with OZ forceApprove
  • Loading branch information
trmid committed Mar 18, 2024
2 parents 843a7b7 + 1b73128 commit cc7fb67
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/PrizeVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -857,15 +857,11 @@ contract PrizeVault is TwabERC20, Claimable, IERC4626, ILiquidationSource, Ownab

// Previously accumulated dust is swept into the yield vault along with the deposit.
uint256 _assetsWithDust = _asset.balanceOf(address(this));
_asset.approve(address(yieldVault), _assetsWithDust);
_asset.forceApprove(address(yieldVault), _assetsWithDust);

// The shares are calculated and then minted directly to mitigate rounding error loss.
uint256 _yieldVaultShares = yieldVault.previewDeposit(_assetsWithDust);
uint256 _assetsUsed = yieldVault.mint(_yieldVaultShares, address(this));
if (_assetsUsed != _assetsWithDust) {
// If some latent balance remains, the approval is set back to zero for weird tokens like USDT.
_asset.approve(address(yieldVault), 0);
}

_mint(_receiver, _shares);

Expand Down

0 comments on commit cc7fb67

Please sign in to comment.