In this challenge, there’s a pair contract (liquidity pool) between WETH and DVT from where PuppetV2 gets the price of the DVT tokens when some user wants to borrow(), calculating the deposit of WETH required by calling UniswapV2Library (line 89):
The math behind the UniswapV2 liquidity pool contract for calculating the cost of an asset can be found on the quote() function of the UniswapV2Library contract:
Now, since the attacker has a big amount of DVT tokens, he’s able to manipulate the price of the DVT by swapping them all with WETH on the Uniswap exchange of the pair DVT/WETH. To devaluate its price, the attacker has to increase the amount of DVT and decrease the amount of WETH in the pool. So, similar to previous level Puppet, the vulnerability of this challenge lies upon the ability of a singular entity to change an asset’s price drastically.
it uses Uniswap v2 as a price oracle
the assets in the liquidity pool are WETH / DVT
initial:the asset ratio is 10 / 100
attack
1.Swap all of the attacker DVT tokens with WETH in the Uniswap exchange (pair) contract:Approve all attacker’s DVT balance to UniswapRouter contract, and Swap all DVT tokens with WETH using the UniswapRouter contract.