Skip to content
This repository was archived by the owner on Dec 28, 2019. It is now read-only.
Open
Changes from all 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
12 changes: 11 additions & 1 deletion contracts/Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down