Amusing Heather Cottonmouth
Medium
_feeDispersal() could be broken (if (address(feeToken) == address(0)) in _buyBack() )and need to pay for referrer with referralFee > 0
In AmirX.sol, return after checking (address(feeToken) == address(0)) in _buyBack could break the functionality in function _feeDispersal because _buyBack does not buy any token to pay to referrer
In AmirX.sol, the _feeDispersal could revert unexpectedly, if address(feeToken) = address(0) in _buyBack() and the line below is executed:
The function _buyBack will not buy anything to pay to referrers because feeToken = address(0).
- Not buy anything at
function _buyBack(
ERC20 feeToken,
address aggregator,
address safe,
bytes memory swapData
) internal {
if (address(feeToken) == address(0)) return;
- Failed to pay referrer fee at
function _feeDispersal(DefiSwap memory defi) internal {
// must buy into TEL
if (defi.feeToken != TELCOIN)
_buyBack(
defi.feeToken,
defi.aggregator,
defi.defiSafe,
defi.swapData
);
// distribute reward
if (defi.referrer != address(0) && defi.referralFee != 0) {
TELCOIN.forceApprove(address(defi.plugin), 0);
TELCOIN.safeIncreaseAllowance(
address(defi.plugin),
defi.referralFee
);
require(
defi.plugin.increaseClaimableBy(
defi.referrer,
defi.referralFee
),
"AmirX: balance was not adjusted"
);
}
// retain remainder
if (TELCOIN.balanceOf(address(this)) > 0)
TELCOIN.safeTransfer(
defi.defiSafe,
TELCOIN.balanceOf(address(this))
);
}
No response
No response
There are some paths, for example: 1 Call defiSwap() with
- defi.feeToken = address(0)
- defi.referrer != address(0) && defi.referralFee != 0
The transaction reverts unexpectedly
No response
Please update _verifyDefiSwap() this case