8. Puppet
https://www.damnvulnerabledefi.xyz/challenges/puppet/
Last updated
https://www.damnvulnerabledefi.xyz/challenges/puppet/
Last updated
The price of dvt tokens is determined by the ratio in the uniswap pool. Calculated as follows:
ETH in pool / dvt in Pool = price of 1 dvt in wei
_computeOraclePrice in PuppetPool.sol does this
However, the pool only allows a user to borrow tokens, if they deposit twice their value in ETH. Essentially, overcollateralized lending.
Hence, the deposit required calculation is as follows:
If user wants to borrow 10 tokens (w/ each token worth 1 ether), he needs to deposit (10*2) ether.
Attacker to sell all of his tokens into Uniswap pool for ether -> skews pools ratio, thereby discounting token price heavily
Calculate collateral required to borrow 1 token from pool at new token prices
Based on collateral required, calculate how much attacker can borrow given his ether balances
In this case, attacker can borrow much more than the pool has to offer, so we would borrow everything the pool has in dvt tokens.
Calculate how much ether is require for this borrow, to send as msg.value
Alternatively, attacker can just send all his ether balances, since the borrow function does return the excess ether.