Gorgeous Jade Falcon
High
The incorrect usage of msg.value
in the _buyBack
function will cause a potential loss for the protocol as the SWAPPER_ROLE
user cannot provide POL
directly, leading to swap failures or possible mismanagement of POL
funds.
In AmirX.sol: 232, msg.value
is used to conduct swaps for POL
tokens, which should instead use address(this).balance
.
SWAPPER_ROLE
calls_buyBack
for a fee buyback operation usingPOL
.- The protocol holds a
POL
balance from previous transactions or collected fees.
- The aggregator expects a non-zero POL amount to execute the swap successfully.
SWAPPER_ROLE
is unable to sendmsg.value
as part of the contract transaction, causing failure.
- The
SWAPPER_ROLE
initiates_buyBack
withPOL
selected as feeToken. _buyBack
calls the aggregator usingmsg.value
, which will be zero from the caller (SWAPPER_ROLE
).- The transaction fails or completes without using the
POL
balance on the contract, causing a failed buyback or remainingPOL
in the contract.
The protocol suffers a potential loss of POL due to failed swaps or inconsistent buyback behavior, as SWAPPER_ROLE
cannot complete swaps correctly.
No response
Use address(this).balance
instead of msg.value
for POL transactions within _buyBack
.
function _buyBack(ERC20 feeToken, address aggregator, address safe, bytes memory swapData) internal {
if (address(feeToken) == POL) {
uint256 polBalance = address(this).balance; <<<<@
(bool polSwap, ) = aggregator.call{value: polBalance}(swapData); <<<<@ remove msg.value
require(polSwap, "AmirX: POL swap transaction failed");
}
}