Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

[Under Audit] Add Bucket-Lender #357

Merged
merged 22 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/external/weth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
All contracts in this folder are taken from the official MakerDao GitHub.
They have been upgraded to a more recent Solidity version without changing functionality.
They are only included for testing purposes.
63 changes: 63 additions & 0 deletions contracts/external/weth/WETH9.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
pragma solidity 0.4.24;


contract WETH9 {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;

event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);

mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;

function() public payable {
deposit();
}
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
msg.sender.transfer(wad);
emit Withdrawal(msg.sender, wad);
}

function totalSupply() public view returns (uint) {
return address(this).balance;
}

function approve(address guy, uint wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
emit Approval(msg.sender, guy, wad);
return true;
}

function transfer(address dst, uint wad) public returns (bool) {
return transferFrom(msg.sender, dst, wad);
}

function transferFrom(address src, address dst, uint wad)
public
returns (bool)
{
require(balanceOf[src] >= wad);

if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
require(allowance[src][msg.sender] >= wad);
allowance[src][msg.sender] -= wad;
}

balanceOf[src] -= wad;
balanceOf[dst] += wad;

emit Transfer(src, dst, wad);

return true;
}
}
14 changes: 14 additions & 0 deletions contracts/lib/MathHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ library MathHelpers {
return 2 ** 256 - 1;
}

/**
* Calculates and returns the maximum value for a uint256 in solidity

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit -- Comment needs updating to uint32.

*
* @return The maximum value for uint256

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit -- Comment needs updating to uint32.

*/
function maxUint32(
)
internal
pure
returns (uint32)
{
return 2 ** 32 - 1;
}

/**
* Returns the number of bits in a uint256. That is, the lowest number, x, such that n >> x == 0
*
Expand Down
Loading