This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
//import "@openzeppelin/contracts/utils/Address.sol"; | |
interface ISideEntranceLenderPool { | |
function deposit() external payable; | |
function withdraw() external; | |
function flashLoan(uint256 amount) external ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "@openzeppelin/contracts/utils/Address.sol"; | |
interface IFlashLoanEtherReceiver { | |
function execute() external payable; | |
} | |
contract SideEntranceLenderPool { | |
using Address for address payable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after(async function () { | |
/** SUCCESS CONDITIONS */ | |
// // Attacker has stolen all tokens from the pool | |
expect( | |
await this.token.balanceOf(attacker) | |
).to.be.bignumber.gte(POOL_INITIAL_TOKEN_BALANCE); | |
expect( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after(async function () { | |
/** SUCCESS CONDITIONS */ | |
expect( | |
await this.token.balanceOf(attacker) | |
).to.be.bignumber.equal(TOKENS_IN_POOL); | |
expect( | |
await this.token.balanceOf(this.pool.address) | |
).to.be.bignumber.equal('0'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "./SimpleGovernance.sol"; | |
import "./SelfiePool.sol"; | |
import "../DamnValuableTokenSnapshot.sol"; | |
contract AttackerContract{ | |
address public attackerAddress; | |
SelfiePool public selfiePool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ether } = require('@openzeppelin/test-helpers'); | |
const { accounts, contract } = require('@openzeppelin/test-environment'); | |
const DamnValuableToken = contract.fromArtifact('DamnValuableToken'); | |
const TrusterLenderPool = contract.fromArtifact('TrusterLenderPool'); | |
const AttackContract = contract.fromArtifact('AttackerContract'); | |
var Web3 = require("web3"); | |
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "./TrusterLenderPool.sol"; | |
contract AttackerContract{ | |
uint256 public totalTokens = 1000000 ether; | |
address public attackerAddress; | |
// DamnValuableToken public dvTokenContract; | |
address public dvTokenContract; | |
TrusterLenderPool public poolContract; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; | |
contract TrusterLenderPool is ReentrancyGuard { | |
IERC20 public damnValuableToken; | |
constructor (address tokenAddress) public { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flashLoan( | |
uint256 borrowAmount, | |
address borrower, | |
address target, | |
bytes calldata data | |
) | |
external | |
nonReentrant | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
contract AttackContract { | |
address payable pool; | |
address payable target; | |
constructor(address payable poolAddress,address payable targetAddress) public { | |
pool = poolAddress; | |
target = targetAddress; | |
} |
NewerOlder