Router would fail when adding liquidity to index Pool
The TridentRouter does not calculate optimal liquidity parameters for index pools, so users may transfer extra tokens or have transactions fail if the pool price changes before confirmation. An attacker could exploit this by front-running to cause failures or force users to deposit at unfavourable rates.
Submitted by broccoli
Impact
TridentRouter is easy to fail when trying to provide liquidity to an index pool.
Users would not get extra lp if they are not providing lp at the pool’s spot price. It’s the same design as uniswap v2. However, uniswap’s v2 handle’s the dirty part.
Users would not lose tokens if they use the router (UniswapV2Router02.sol L61-L76).
However, the router wouldn’t stop users from transferring extra tokens (TridentRouter.sol L168-L190).
Second, the price would possibly change when the transaction is confirmed. This would be reverted in the index pool.
Users would either transfer extra tokens or fail. I consider this is a medium-risk issue.
Proof of Concept
A possible scenario:
There’s a BTC/USD pool. BTC = 50000 USD.
- A user sends a transaction to transfer 1 BTC and 50000 USD.
- After the user send a transaction, a random bot buying BTC with USD.
- The transaction at step 1 is mined. Since the BTC price is not 50000 USD, the transaction fails.
Recommended Mitigation Steps
Please refer to the uniswap v2 router in UniswapV2Router02.sol L61-L76
The router should calculate the optimal parameters for users.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the router does not compute optimal deposit amounts based on the pool's current reserves, unlike Uniswap V2's router.
Impact
Users could transfer extra tokens or have their transaction fail, and an attacker could front-run to cause failures or unfavourable deposits.
What the attacker needed
User uses TridentRouter to add liquidity; Pool price changes before transaction is mined
How it was found
- User sends a transaction to transfer 1 BTC and 50000 USD to the pool.
- A bot buys BTC with USD, changing the pool price.
- The user's transaction is mined but fails because the price is no longer 50000 USD.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you add money to a liquidity pool, the amounts must match the current price ratio. This router doesn't adjust the amounts for you, so if the price moves before your transaction is processed, you might lose extra tokens or the transaction fails. A front-running bot can make this happen on purpose.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.