// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract PancakePredictionV2 {
uint256 public currentEpoch;
struct Round {
uint256 epoch;
uint256 startTimestamp;
uint256 lockTimestamp;
uint256 closeTimestamp;
int256 lockPrice;
int256 closePrice;
uint256 lockOracleId;
uint256 closeOracleId;
uint256 totalAmount;
uint256 bullAmount;
uint256 bearAmount;
uint256 rewardBaseCalAmount;
uint256 rewardAmount;
bool oracleCalled;
}
mapping(uint256 => Round) public rounds;
event Debug(uint256 value);
function changeEpoch(uint256 num) public {
currentEpoch = currentEpoch + num;
emit Debug(currentEpoch); // Emitting the currentEpoch value for debugging
}
// Add a function to initialize default values for a specific round
function initializeRound(
uint256 epoch_,
uint256 startTimestamp_,
uint256 lockTimestamp_,
uint256 closeTimestamp_,
int256 lockPrice_
) external {
Round storage existingRound = rounds[epoch_];
existingRound.epoch = epoch_;
existingRound.startTimestamp = startTimestamp_;
existingRound.lockTimestamp = lockTimestamp_;
existingRound.closeTimestamp = closeTimestamp_;
existingRound.lockPrice = lockPrice_;
emit Debug(existingRound.lockTimestamp); // Emitting the lockTimestamp value for debugging
}
function initializeRound_2(
uint256 epoch_,
int256 closePrice_,
uint256 lockOracleId_,
uint256 closeOracleId_,
uint256 totalAmount_,
uint256 bullAmount_,
uint256 bearAmount_,
uint256 rewardBaseCalAmount_,
uint256 rewardAmount_,
bool oracleCalled_
) external {
Round storage existingRound = rounds[epoch_];
existingRound.epoch = epoch_;
existingRound.closePrice = closePrice_;
existingRound.lockOracleId = lockOracleId_;
existingRound.closeOracleId = closeOracleId_;
existingRound.totalAmount = totalAmount_;
existingRound.bullAmount = bullAmount_;
existingRound.bearAmount = bearAmount_;
existingRound.rewardBaseCalAmount = rewardBaseCalAmount_;
existingRound.rewardAmount = rewardAmount_;
existingRound.oracleCalled = oracleCalled_;
emit Debug(existingRound.lockOracleId); // Emitting the lockOracleId value for debugging
}
}
I want to read rounds function using the below contract..
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface PancakePredictionV2 {
function rounds(uint256) external view returns (
uint256[14] memory,
bool
);
function currentEpoch() external view returns (uint256);
}
contract MyContract {
address public pancakePredictionContract;
constructor(address _pancakePredictionContract) {
pancakePredictionContract = _pancakePredictionContract;
}
function getCurrentEpoch() public view returns (uint256) {
return PancakePredictionV2(pancakePredictionContract).currentEpoch();
}
function getRoundLockTimestamp(uint256 epoch) external view returns (uint256) {
uint256[14] memory roundData;
bool isValid;
(roundData, isValid) = PancakePredictionV2(pancakePredictionContract).rounds(epoch);
return roundData[2]; // lockTimestamp
}
}
Let me know if anyone can help me.