Skip to content

Commit 4d28ebf

Browse files
committedSep 13, 2023
Updates.
1 parent c1c3d0a commit 4d28ebf

33 files changed

+2321
-235
lines changed
 

‎.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"git.ignoreLimitWarning": true
3+
}

‎graphql/README.md ‎README.md

File renamed without changes.

‎backend/contracts/common/Settlement.sol

+13-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ struct Prediction {
2424
interface ITrading {
2525
function concludePrediction_2(uint256, bool) external;
2626

27+
function getNextPredictionId() external view returns (uint256);
28+
2729
function getPrediction(uint256) external view returns (Prediction memory);
2830
}
2931

32+
error PM_InvalidPredictionId();
33+
3034
/// @dev The contract is inherently a data feed reader
3135
contract PM_Settlement is Ownable {
3236
/// @notice The Trading contract that acts as a middle ground for Settlement and MarketHandler
@@ -37,12 +41,20 @@ contract PM_Settlement is Ownable {
3741
tradingContract = ITrading(_trading);
3842
}
3943

44+
modifier isValidPredictionId(uint256 _id) {
45+
uint256 currentUpper = tradingContract.getNextPredictionId();
46+
if (_id >= currentUpper) revert PM_InvalidPredictionId();
47+
_;
48+
}
49+
4050
/// @dev We can add an incentive to whoever calls it get some % of overall protocol fee for a given prediction.
4151
/// Note that this should come out > gas fee to run the txn in the first place. Or we use CRON job, EAC,
4252
/// Cloud-based scheduler.
4353
/// @dev Personally think that the 1st and 3rd options are good candidates.
4454
/// @param _predictionId The unique identifier for the prediction to be concluded.
45-
function concludePrediction_1(uint256 _predictionId) external {
55+
function concludePrediction_1(
56+
uint256 _predictionId
57+
) external isValidPredictionId(_predictionId) {
4658
Prediction memory associatedPrediction = tradingContract.getPrediction(
4759
_predictionId
4860
);

‎backend/contracts/common/Trading.sol

+9
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ contract PredictionMarket is Context, Ownable {
8383
int256 amountNo
8484
);
8585

86+
event PredictionConcluded(uint256 indexed predictionId, uint256 timestamp);
87+
8688
/// @notice The payment token interface
8789
IERC20 immutable I_USDC_CONTRACT;
8890

@@ -207,6 +209,8 @@ contract PredictionMarket is Context, Ownable {
207209
IMarketHandler mhInstance = IMarketHandler(associatedMHAddress);
208210

209211
mhInstance.concludePrediction_3(_vote);
212+
213+
emit PredictionConcluded(_predictionId, block.timestamp);
210214
}
211215

212216
/// @notice Setter functions ------
@@ -223,6 +227,11 @@ contract PredictionMarket is Context, Ownable {
223227
}
224228

225229
/// @notice Getter functions ------
230+
231+
function getNextPredictionId() external view returns (uint256) {
232+
return nextPredictionId.current();
233+
}
234+
226235
function getPrediction(
227236
uint256 _predictionId
228237
) external view returns (Prediction memory) {

‎backend/deploy/0_deploy.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,9 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
1515
});
1616

1717
/// THESE ARE ALL ON POLYGON TESTNET
18-
const assetArray = ["AAVE", "API3", "BTC", "ETH", "MATIC"];
19-
const proxyArray = [
20-
"0x13d1Ed8c24911d88e6155cE32A66908399C97924",
21-
"0xf25b7429406b24da879f0d1a008596b74fcb9c2f",
22-
"0xe5Cf15fED24942E656dBF75165aF1851C89F21B5",
23-
"0x26690F9f17FdC26D419371315bc17950a0FC90eD",
24-
"0x3ACccB328Db79Af1B81a4801DAf9ac8370b9FBF8",
25-
];
26-
const limit = 5;
2718
const Trading = await deploy("PredictionMarket", {
2819
from: deployer,
29-
args: [Mock.address, assetArray, proxyArray, limit],
20+
args: [Mock.address],
3021
});
3122

3223
const Settlement = await deploy("PM_Settlement", {

‎backend/deployments/goerli/.chainId

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5

0 commit comments

Comments
 (0)
Please sign in to comment.