contract Rubixi { uint private balance = 0; uint private collectedFees = 0; uint private feePercent = 10; uint private pyramidMultiplier = 300; uint private payoutOrder = 0; address private creator; function DynamicPyramid() { creator = msg.sender; } struct Participant { address etherAddress; uint payout; } Participant[] private participants; function() { addPayout (); } function addPayout(uint _fee) private { participants.push(Participant(msg.sender, (msg.value * pyramidMultiplier) / 100)); if (participants.length == 10) pyramidMultiplier = 200; else if (participants.length == 25) pyramidMultiplier = 150; balance += (msg.value * (100 - _fee)) / 100; collectedFees += (msg.value * _fee) / 100; while (balance > participants[payoutOrder].payout) { uint payoutToSend = participants[payoutOrder].payout; participants[payoutOrder].etherAddress.send(payoutToSend); balance -= participants[payoutOrder].payout; payoutOrder += 1; } } function collectAllFees() { if (collectedFees == 0) throw; creator.send(collectedFees); collectedFees = 0; } }
0.4.18