Skip to content

Commit

Permalink
Require deposit to be divisible by GWEI (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrChico committed May 13, 2020
1 parent 72ad3a7 commit d12d660
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deposit_contract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface IDepositContract {
contract DepositContract is IDepositContract {
uint constant GWEI = 1e9;

uint constant MIN_DEPOSIT_AMOUNT = 1000000000; // Gwei
uint constant MIN_DEPOSIT_AMOUNT = 1 ether;
uint constant DEPOSIT_CONTRACT_TREE_DEPTH = 32;
// NOTE: this also ensures `deposit_count` will fit into 64-bits
uint constant MAX_DEPOSIT_COUNT = 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1;
Expand Down Expand Up @@ -79,8 +79,9 @@ contract DepositContract is IDepositContract {
require(deposit_count < MAX_DEPOSIT_COUNT);

// Check deposit amount
require(msg.value >= MIN_DEPOSIT_AMOUNT);
require(msg.value % GWEI == 0);
uint deposit_amount = msg.value / GWEI;
require(deposit_amount >= MIN_DEPOSIT_AMOUNT);
require(deposit_amount < 2**64);

// Length checks for safety
Expand Down

0 comments on commit d12d660

Please sign in to comment.