From 5ba159dd9bb162634c385a567cc04c5c634ee823 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sun, 28 Oct 2018 14:58:39 +0100 Subject: [PATCH] Limit the amount the beneficiary receives (rest goes into the owner's multisig) --- contracts/Market.sol | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/contracts/Market.sol b/contracts/Market.sol index abf79d0..bfe1d2a 100644 --- a/contracts/Market.sol +++ b/contracts/Market.sol @@ -9,6 +9,8 @@ import "./IProperty.sol"; // @title Radical Bodies market. contract Market is IMarket, Ownable, Pausable { + uint256 private constant beneficiaryLimit = 42 ether; + // 6 digits precision uint256 private constant _taxPrecision = 1000000; @@ -21,6 +23,8 @@ contract Market is IMarket, Ownable, Pausable { mapping (uint256 => uint256) private tokenPrice; mapping (uint256 => uint256) private tokenTaxedUntil; + uint256 private totalWithdrawn = 0; + constructor( IProperty token, uint256 interval, @@ -70,7 +74,13 @@ contract Market is IMarket, Ownable, Pausable { // The beneficiary can retrieve already released funds via this. function withdrawAvailableFunds() external payable { - _beneficiary.transfer(this.balance); + if (totalWithdrawn >= beneficiaryLimit) + owner().transfer(this.balance); + else { + uint256 amount = Math.min(this.balance, beneficiaryLimit); + totalWithdrawn += amount; + _beneficiary.transfer(amount); + } } // The current price of the given token.