Skip to content

Commit

Permalink
fix: payments with yield reverting in token without vault
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChin committed Oct 17, 2024
1 parent 7353ca8 commit 3584501
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/contracts/Grateful.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ contract Grateful is IGrateful, Ownable2Step {
return _amount - feeAmount;
}

/// @inheritdoc IGrateful
function owner() public view override(IGrateful, Ownable) returns (address) {
return super.owner();
}
Expand Down Expand Up @@ -359,10 +360,13 @@ contract Grateful is IGrateful, Ownable2Step {
if (yieldingFunds[recipient]) {
AaveV3ERC4626 vault = vaults[_token];
if (address(vault) == address(0)) {
revert Grateful_VaultNotSet();
if (!IERC20(_token).transfer(recipient, recipientShare)) {
revert Grateful_TransferFailed();
}
} else {
uint256 _shares = vault.deposit(recipientShare, address(this));
shares[recipient][_token] += _shares;

Check warning on line 368 in src/contracts/Grateful.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Possible reentrancy vulnerabilities. Avoid state changes after transfer
}
uint256 _shares = vault.deposit(recipientShare, address(this));
shares[recipient][_token] += _shares;
} else {
// Transfer tokens to recipient
if (!IERC20(_token).transfer(recipient, recipientShare)) {
Expand All @@ -375,10 +379,13 @@ contract Grateful is IGrateful, Ownable2Step {
if (yieldingFunds[_merchant]) {
AaveV3ERC4626 vault = vaults[_token];
if (address(vault) == address(0)) {
revert Grateful_VaultNotSet();
if (!IERC20(_token).transfer(_merchant, amountWithFee)) {
revert Grateful_TransferFailed();
}
} else {
uint256 _shares = vault.deposit(amountWithFee, address(this));
shares[_merchant][_token] += _shares;

Check warning on line 387 in src/contracts/Grateful.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Possible reentrancy vulnerabilities. Avoid state changes after transfer
}
uint256 _shares = vault.deposit(amountWithFee, address(this));
shares[_merchant][_token] += _shares;
} else {
// Transfer tokens to merchant
if (!IERC20(_token).transfer(_merchant, amountWithFee)) {
Expand Down

0 comments on commit 3584501

Please sign in to comment.