Late Hotpink Dinosaur
Medium
Fixed Target Amount in Sequential DeFi-Stablecoin Swaps Leads to Value Loss and Unfair Protocol Gains
Protocol will unfairly gain excess value from favorable price movements in defi-to-stablecoin swaps as it controls the wallet that receives the DeFi swap proceeds while only committing to deliver a fixed target amount to the user.
The choice to use a fixed target amount (tAmount) in AmirX.sol in swap and defiToStablecoinSwap at https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/swap/AmirX.sol#L127 is a mistake as it prevents users from capturing upside in favorable market movements during the sequential swap process.
function defiToStablecoinSwap(
address wallet,
StablecoinSwap memory ss,
DefiSwap memory defi
) external payable onlyRole(SWAPPER_ROLE) whenNotPaused {
_verifyDefiSwap(wallet, defi);
_verifyStablecoinSwap(wallet, ss);
uint256 iBalance = ERC20(ss.origin).balanceOf(wallet);
_defiSwap(wallet, defi);
uint256 fBalance = ERC20(ss.origin).balanceOf(wallet);
ss.oAmount = fBalance - iBalance;
_stablecoinSwap(wallet, ss); // user receives tAmount originally specified
}
Standard DEX swaps typically implement:
struct SwapParams {
uint256 amountIn;
uint256 minAmountOut; // Floor protection, not ceiling
// ...
}
Key issues:
- Standard swaps set minimum output but no maximum
- Users capture all upside from favorable price movements
- In AmirX, similarly, user anyways has paid the fee and should not be limited to target amount
No response
No response
Initial Setup: 1 ETH = $3,000 Expected: 1 ETH → 3,000 USDC → 3,000 USDe
When ETH price increases to $3,300: What Should Happen: 1 ETH → 3,300 USDC → ~3,000 USDe
What Actually Happens: 1 ETH → 3,300 USDC → only 3,000 USDe (fixed amount) Protocol keeps: ~300 USDC excess
The issue is:
- Higher ETH price gets more USDC in first swap
- But fixed
tAmount
in contract means user still only gets 3,000 USDe - Protocol keeps the extra USDC (~300) from favorable ETH price
- User loses out on ~300 USDe they should have received
This is unfair because users don't benefit from favorable ETH price movements, while the protocol captures the excess value.
No response
No response
No response