Skip to content

Commit

Permalink
Merge pull request #792 from oceanprotocol/issue791-predictoor-update…
Browse files Browse the repository at this point in the history
…-existing-prediction-if-exists

Allow predictoors to update their prediction before epoch closes
  • Loading branch information
trizin authored Aug 4, 2023
2 parents ccd6dcd + fdbf61a commit 9734008
Show file tree
Hide file tree
Showing 2 changed files with 484 additions and 468 deletions.
8 changes: 6 additions & 2 deletions contracts/templates/ERC20Template3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,13 @@ contract ERC20Template3 is
require(toEpochStart(epoch_start) == epoch_start, "invalid epoch");
require(paused == false, "paused");
require(epoch_start >= soonestEpochToPredict(block.timestamp), "too late to submit");
require(!submittedPredval(epoch_start, msg.sender), "already submitted");

emit PredictionSubmitted(msg.sender, epoch_start, stake);
if (submittedPredval(epoch_start, msg.sender)) {
require(predictions[epoch_start][msg.sender].stake == stake, "cannot modify stake amt");
predictions[epoch_start][msg.sender].predictedValue = predictedValue;
return;
}
predictions[epoch_start][msg.sender] = Prediction(
predictedValue,
stake,
Expand All @@ -1005,7 +1010,6 @@ contract ERC20Template3 is
roundSumStakesUp[epoch_start] += stake * (predictedValue ? 1 : 0);
roundSumStakes[epoch_start] += stake;

emit PredictionSubmitted(msg.sender, epoch_start, stake);
// safe transfer stake
IERC20(stakeToken).safeTransferFrom(msg.sender, address(this), stake);
}
Expand Down
Loading

0 comments on commit 9734008

Please sign in to comment.