diff --git a/ethereum/contracts/core/Bench.sol b/ethereum/contracts/core/Bench.sol index 99fa8be..11e2d3f 100644 --- a/ethereum/contracts/core/Bench.sol +++ b/ethereum/contracts/core/Bench.sol @@ -4,13 +4,6 @@ pragma solidity ^0.8.24; import "./DAO.sol"; import "./Forum.sol"; -struct ValidationPoolStake { - uint id; - bool inFavor; - uint amount; - address sender; -} - struct ValidationPoolParams { uint duration; uint[2] quorum; // [ Numerator, Denominator ] @@ -28,19 +21,26 @@ struct ValidationPoolProps { bool outcome; } -struct ValidationPool { - uint id; - address sender; - mapping(uint => ValidationPoolStake) stakes; - uint stakeCount; - ValidationPoolParams params; - ValidationPoolProps props; - bool callbackOnValidate; - bytes callbackData; -} - contract Bench { - mapping(uint => ValidationPool) public validationPools; + struct Stake { + uint id; + bool inFavor; + uint amount; + address sender; + } + + struct Pool { + uint id; + address sender; + mapping(uint => Stake) stakes; + uint stakeCount; + ValidationPoolParams params; + ValidationPoolProps props; + bool callbackOnValidate; + bytes callbackData; + } + + mapping(uint => Pool) public validationPools; uint public validationPoolCount; DAO dao; @@ -67,14 +67,14 @@ contract Bench { msg.sender == address(dao), "Only DAO contract may call stakeOnValidationPool" ); - ValidationPool storage pool = validationPools[poolIndex]; + Pool storage pool = validationPools[poolIndex]; require( block.timestamp <= pool.props.endTime, "Pool end time has passed" ); // We don't call _update here; We defer that until evaluateOutcome. uint stakeIndex = pool.stakeCount++; - ValidationPoolStake storage s = pool.stakes[stakeIndex]; + Stake storage s = pool.stakes[stakeIndex]; s.sender = sender; s.inFavor = inFavor; s.amount = amount; @@ -107,7 +107,7 @@ contract Bench { require(winRatio[0] <= winRatio[1], "Win ratio is greater than one"); require(bindingPercent <= 100, "Binding percent must be <= 100"); poolIndex = validationPoolCount++; - ValidationPool storage pool = validationPools[poolIndex]; + Pool storage pool = validationPools[poolIndex]; pool.id = poolIndex; pool.sender = sender; pool.props.postId = postId; @@ -134,11 +134,11 @@ contract Bench { msg.sender == address(dao), "Only DAO contract may call evaluateOutcome" ); - ValidationPool storage pool = validationPools[poolIndex]; + Pool storage pool = validationPools[poolIndex]; require(pool.props.resolved == false, "Pool is already resolved"); uint stakedFor; uint stakedAgainst; - ValidationPoolStake storage s; + Stake storage s; for (uint i = 0; i < pool.stakeCount; i++) { s = pool.stakes[i]; // Make sure the sender still has the required balance.