Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Impose minimum and maximum lot sizes
Browse files Browse the repository at this point in the history
This to avoid signer DoS (for the minimum 0.0005 BTC lot size) and to
avoid putting more funds at risk than reasonable in a single deposit
(for the maximum 10 BTC lot size).
  • Loading branch information
Shadowfiend committed Apr 18, 2020
1 parent b896773 commit ed307d7
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions solidity/contracts/system/TBTCSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,27 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog {
function beginLotSizesUpdate(uint64[] calldata _lotSizes)
external onlyOwner
{
for( uint i = 0; i < _lotSizes.length; i++){
if (_lotSizes[i] == 10**8){
lotSizesSatoshis = _lotSizes;
emit LotSizesUpdateStarted(_lotSizes, block.timestamp);
newLotSizesSatoshis = _lotSizes;
lotSizesChangeInitiated = block.timestamp;
return;
bool hasSingleBitcoin = false;
for (uint i = 0; i < _lotSizes.length; i++) {
if (_lotSizes[i] == 10**8) {
hasSingleBitcoin = true;
} else if (_lotSizes[i] < 50 * 10**3) {
// Failed the minimum requirement, break on out.
revert("Lot sizes less than 0.0005 BTC are not allowed");
} else if (_lotSizes[i] > 10 * 10**8) {
// Failed the maximum requirement, break on out.
revert("Lot sizes greater than 10 BTC are not allowed");
}

newLotSizesSatoshis = _lotSizes[i];
}
revert("Lot size array must always contain 1BTC");

require(hasSingleBitcoin, "Lot size array must always contain 1BTC");

lotSizesSatoshis = _lotSizes;
emit LotSizesUpdateStarted(_lotSizes, block.timestamp);
newLotSizesSatoshis = _lotSizes;
lotSizesChangeInitiated = block.timestamp;
}

/// @notice Set the system collateralization levels
Expand Down

0 comments on commit ed307d7

Please sign in to comment.