In this case, oAmount is 100 but wallet has only 95 USDC (100 - 5 fees).
Because of that this function will revert and user cannot do stablecoinSwap.
Also, this will happen when defiToStablecoinSwap is used. For example - AAVE to USDC to eUSD (10-10-10) swap, first defi swap happens and wallet will get 10 USDC and now stablecoin swap of USDC-eUSD happens in which fee transfers first and then oAmount of 10 will transfer but actually wallet will have less USDC (10-fees) so it will revert.
Root Cause
In stablecoinSwap, there is a transfer of origin token from wallet to liquiditySafe in which the amount will be oAmount but before that fees are transfered so wallet will have less balance.
Abhan1041
High
Functionality of
stablecoinSwap
will not work when feeToken is origin tokenSummary
When feeToken is origin token,
stablecoinSwap
function will revert due to wrong origin amount transfer.For example, user wants to swap 100 USDC for 100 eUSD with
stablecoinSwap
function and feeToken is USDC.Now fees will be calculated from 100 USDC so lets suppose fees will be 5 USDC.
So firstly, feeAmount will be transferFrom wallet to stablecoinFeeSafe (i.e. 5).
After that USDC will be transferFrom wallet to liquiditySafe (i.e. oAmount).
In this case, oAmount is 100 but wallet has only 95 USDC (100 - 5 fees).
Because of that this function will revert and user cannot do
stablecoinSwap
.Also, this will happen when
defiToStablecoinSwap
is used. For example - AAVE to USDC to eUSD (10-10-10) swap, first defi swap happens and wallet will get 10 USDC and now stablecoin swap of USDC-eUSD happens in which fee transfers first and then oAmount of 10 will transfer but actually wallet will have less USDC (10-fees) so it will revert.Root Cause
stablecoinSwap
, there is a transfer of origin token from wallet to liquiditySafe in which the amount will be oAmount but before that fees are transfered so wallet will have less balance.https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L163C7-L167C15
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
stablecoinSwap
function will not work and always revert when feeToken is origin token.PoC
No response
Mitigation