Commit 99532fd1 authored by Conner Fromknecht's avatar Conner Fromknecht

feat: add minDepositAmount to TeleportrDeposit.sol

parent 60a04f3c
......@@ -9,11 +9,13 @@ pragma solidity >=0.8.9;
*/
contract TeleportrDeposit {
address public owner;
uint256 public minDepositAmount;
uint256 public maxDepositAmount;
uint256 public maxBalance;
// Events
event OwnerSet(address indexed oldOwner, address indexed newOwner);
event MinDepositAmountSet(uint256 previousAmount, uint256 newAmount);
event MaxDepositAmountSet(uint256 previousAmount, uint256 newAmount);
event MaxBalanceSet(uint256 previousBalance, uint256 newBalance);
event BalanceWithdrawn(address indexed owner, uint256 balance);
......@@ -25,19 +27,26 @@ contract TeleportrDeposit {
_;
}
constructor(uint256 _maxDepositAmount, uint256 _maxBalance) {
constructor(
uint256 _minDepositAmount,
uint256 _maxDepositAmount,
uint256 _maxBalance
) {
owner = msg.sender;
minDepositAmount = _minDepositAmount;
maxDepositAmount = _maxDepositAmount;
maxBalance = _maxBalance;
emit OwnerSet(address(0), msg.sender);
emit MinDepositAmountSet(0, _minDepositAmount);
emit MaxDepositAmountSet(0, _maxDepositAmount);
emit MaxBalanceSet(0, _maxBalance);
}
// Receive function which reverts if the amount is greater than
// maxDepositAmount, or the amount would put the contract over its
// maxBalance.
// Receive function which reverts if the amount is outside the range
// [minDepositAmount, maxDepositAmount], or the amount would put the
// contract over its maxBalance.
receive() external payable {
require(msg.value >= minDepositAmount, "Deposit amount is too small");
require(msg.value <= maxDepositAmount, "Deposit amount is too big");
require(address(this).balance <= maxBalance, "Contract max balance exceeded");
......@@ -52,6 +61,11 @@ contract TeleportrDeposit {
}
// Setters
function setMinAmount(uint256 _minDepositAmount) external isOwner {
emit MinDepositAmountSet(minDepositAmount, _minDepositAmount);
minDepositAmount = _minDepositAmount;
}
function setMaxAmount(uint256 _maxDepositAmount) external isOwner {
emit MaxDepositAmountSet(maxDepositAmount, _maxDepositAmount);
maxDepositAmount = _maxDepositAmount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment