Open sherlock-admin3 opened 1 week ago
smbv-1923
Medium
defiToStablecoinSwap()
ss.stablecoinFeeCurrency
ss.origin
defiToStablecoinSwap() would fail if ss.stablecoinFeeCurrency and ss.origin token are same
https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L144 https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/swap/AmirX.sol#L111
ss.stablecoinFeeSafe
No response
ss.stablecoinFeeCurrency is set as ORIGIN address (i.e USDC)
_defiswap()
_stablecoinSwap()
ERC20PermitUpgradeable(ss.stablecoinFeeCurrency).safeTransferFrom( wallet, ss.stablecoinFeeSafe, ss.feeAmount );
After that USDC gets transferred to liquidity Safe address and amount of USDC transferred = ss.oAmount which is 100 USDC
amount of USDC transferred = ss.oAmount which is 100 USDC
ERC20PermitUpgradeable(ss.origin).safeTransferFrom( wallet, ss.liquiditySafe, ss.oAmount );
defiToStablecoinSwap
Make sure if ss.stablecoinFeeSafe and ss.origin are same then subtract ss.feeAmount from ss.oAmount
ERC20PermitUpgradeable(ss.origin).safeTransferFrom( wallet, ss.liquiditySafe, ss.oAmount - ss.feeAmount );
smbv-1923
Medium
defiToStablecoinSwap()
would fail ifss.stablecoinFeeCurrency
andss.origin
token are sameSummary
defiToStablecoinSwap()
would fail ifss.stablecoinFeeCurrency
andss.origin
token are sameRoot Cause
https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L144 https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/swap/AmirX.sol#L111
Internal pre-conditions
ss.stablecoinFeeSafe
token should be same asss.origin
tokenExternal pre-conditions
No response
Attack Path
ss.stablecoinFeeCurrency is set as ORIGIN address (i.e USDC)
_defiswap()
would happen and after execution user's wallet would be getting approx 100 USDC for swapping 100 AAVE tokens._stablecoinSwap()
_stablecoinSwap()
, fee gets transferred to stablecoinFeeSafe adddress lets assume 5 USDC gets transferred as feeAmount is 5.After that USDC gets transferred to liquidity Safe address and
amount of USDC transferred = ss.oAmount which is 100 USDC
Impact
defiToStablecoinSwap
would fail wheneverss.stablecoinFeeSafe
andss.origin
in defi to stable coin swap is samePoC
No response
Mitigation
Make sure if
ss.stablecoinFeeSafe
andss.origin
are same then subtract ss.feeAmount from ss.oAmount