You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
Rewards will not be distributed to the vault's rewarder due a malfunction in LiquidationRow::_performLiquidation()
Summary
The LiquidationRow::_performLiquidation() function will not distribute the rewards to the vault's rewarder because the function does not transfer the reward tokens to the AsyncSwapper contract causing the staker will not receive rewards.
The problem is that the LiquidationRow._performLiquidation() does not transfer the amount to sell to the AsyncSwapper and the AsynSwapper does not make a transferFrom call.
I created a test where LiquidationRow::claimsVaultRewards() will be reverted by a InsufficientBalance in the AsyncSwapper contract:
// File: LiquidationRow.t.sol// $ forge test --match-test "test_TransferRewardsToMainRewarderWillFaillUsingTheBaseAsynSwapper" -vvv//import { IAsyncSwapper, SwapParams } from"src/interfaces/liquidation/IAsyncSwapper.sol";
function test_TransferRewardsToMainRewarderWillFaillUsingTheBaseAsynSwapper() public {
// The LiquidationRow::_performLiquidation() does not transfer the rewards to the AsyncSwapper causing a revert of// the transaction.// // Setup the baseAsyncSwapper
BaseAsyncSwapper baseAsyncSwapper =newBaseAsyncSwapper(vm.addr(100));
liquidationRow.addToWhitelist(address(baseAsyncSwapper));
SwapParams memory swapParams =SwapParams(address(rewardToken2), 200, address(targetToken), buyAmount, newbytes(0), newbytes(0));
liquidationRow.setFeeAndReceiver(feeReceiver, feeBps);
_mockComplexScenario(address(testVault));
IDestinationVault[] memory vaults =_initArrayOfOneTestVault();
//// Claims rewards
liquidationRow.claimsVaultRewards(vaults);
//// The liquidateVaultsForToken() will be reverted by InsufficientBalance
vm.expectRevert(abi.encodeWithSelector(IAsyncSwapper.InsufficientBalance.selector, 0, 200));
liquidationRow.liquidateVaultsForToken(address(rewardToken2), address(baseAsyncSwapper), vaults, swapParams);
}
Impact
The collected rewards will not be received by the vault's rewarders. The collected rewards by the LiquidationRow contract will be stuck in the contract.
sherlock-admin
changed the title
Curved Graphite Marmot - Rewards will not be distributed to the vault's rewarder due a malfunction in LiquidationRow::_performLiquidation()
0xbepresent - Rewards will not be distributed to the vault's rewarder due a malfunction in LiquidationRow::_performLiquidation()Oct 3, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
0xbepresent
high
Rewards will not be distributed to the vault's rewarder due a malfunction in
LiquidationRow::_performLiquidation()
Summary
The
LiquidationRow::_performLiquidation()
function will not distribute the rewards to the vault's rewarder because the function does not transfer the reward tokens to theAsyncSwapper
contract causing the staker will not receive rewards.Vulnerability Detail
The LiquidationRow::_performLiquidation() function helps to transfer the collected rewards to the vault's rewarder.
At the beginning of the function, it swap the accumulated rewards tokens to the vault's rewards token (code line 251):
The AsyncSwapper.swap() function will check if the desired amount to sell is in the contract (code line 30):
The problem is that the
LiquidationRow._performLiquidation()
does not transfer the amount to sell to theAsyncSwapper
and theAsynSwapper
does not make atransferFrom
call.I created a test where
LiquidationRow::claimsVaultRewards()
will be reverted by a InsufficientBalance in theAsyncSwapper
contract:Impact
The collected rewards will not be received by the vault's rewarders. The collected rewards by the LiquidationRow contract will be stuck in the contract.
Code Snippet
Tool used
Manual review
Recommendation
Transfer the sell amount to the
AsyncSwapper
contract and make sure the buy token amount is returned to theLiquidationRow
contract:File: BaseAsyncSwapper.sol function swap(SwapParams memory swapParams) public virtual nonReentrant returns (uint256 buyTokenAmountReceived) { if (swapParams.buyTokenAddress == address(0)) revert TokenAddressZero(); if (swapParams.sellTokenAddress == address(0)) revert TokenAddressZero(); if (swapParams.sellAmount == 0) revert InsufficientSellAmount(); if (swapParams.buyAmount == 0) revert InsufficientBuyAmount(); IERC20 sellToken = IERC20(swapParams.sellTokenAddress); IERC20 buyToken = IERC20(swapParams.buyTokenAddress); ++ IERC20(sellToken).safeTransferFrom(msg.sender, address(this), swapParams.sellAmount); uint256 sellTokenBalance = sellToken.balanceOf(address(this)); if (sellTokenBalance < swapParams.sellAmount) { revert InsufficientBalance(sellTokenBalance, swapParams.sellAmount); } ...
Duplicate of #205
The text was updated successfully, but these errors were encountered: