@@ -148,7 +148,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
148148 available = available.sub (commitment.stake);
149149 }
150150
151- require (amount > = available, "SPC::withdraw - not enough (unstaked) balance available " );
151+ require (amount < = available, "SPC::withdraw - not enough (unstaked) balance available " );
152152
153153 _changeCommitterBalance (amount, false );
154154
@@ -250,12 +250,13 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
250250 /// @dev Process commitment by lookup based on address, checking metrics, state and updating balances
251251 function processCommitment (address committer ) public {
252252 console.log ("Processing commitment " );
253+ require (commitments[committer].exists, "SPC::processCommitment - commitment does not exist " );
253254 Commitment storage commitment = commitments[committer];
254255
255256 require (commitment.endTime < block .timestamp , "SPC::processCommitment - commitment is still active " );
256257 require (commitment.endTime < commitment.lastActivityUpdate, "SPC::processCommitment - update activity " );
257258
258- commitment.met = commitment.reportedValue > commitment.goalValue;
259+ commitment.met = commitment.reportedValue >= commitment.goalValue;
259260
260261 if (! commitment.met) {
261262 _slashFunds (commitment.stake, committer);
@@ -269,6 +270,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
269270 /// @dev Process commitment by lookup msg.sender, checking metrics, state and updating balances
270271 function processCommitmentUser () public {
271272 console.log ("Processing commitment " );
273+ require (commitments[msg .sender ].exists, "SPC::processCommitmentUser - commitment does not exist " );
272274 Commitment storage commitment = commitments[msg .sender ];
273275
274276 commitment.met = commitment.reportedValue > commitment.goalValue;
@@ -289,8 +291,9 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
289291 console.log ("Received call for owner withdrawal for amount %s " , amount);
290292
291293 require (amount <= slashedBalance, "SPC::ownerWithdraw - not enough available balance " );
294+ slashedBalance = slashedBalance.sub (amount);
295+
292296 require (token.transfer (msg .sender , amount), "SPC::ownerWithdraw - token transfer failed " );
293- slashedBalance -= amount;
294297
295298 return true ;
296299 }
@@ -318,7 +321,7 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
318321 function _slashFunds (uint256 amount , address committer ) internal returns (bool success ) {
319322 require (committerBalances[committer] >= amount, "SPC::_slashFunds - funds not available " );
320323 _changeCommitterBalance (amount, false );
321- slashedBalance += amount;
324+ slashedBalance = slashedBalance. add ( amount) ;
322325 return true ;
323326 }
324327
@@ -337,10 +340,10 @@ contract SinglePlayerCommit is ChainlinkClient, Ownable {
337340 console.log ("All provided activities added " );
338341 }
339342
340- /// @notice Add activity to contract's activityList
343+ /// @notice Add activity to contract's activityKeyList
341344 /// @param _activityName String name of activity
342345 /// @param _oracleAddress Contract address of oracle
343- /// @dev Create key from name, create activity, push to activityList , return key
346+ /// @dev Create key from name, create activity, push to activityKeyList , return key
344347 function _addActivity (string memory _activityName , address _oracleAddress )
345348 internal
346349 returns (bytes32 activityKey )
0 commit comments