Skip to content
10 changes: 5 additions & 5 deletions solidity/contracts/peripherals/Auction.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNICENSE
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.33;
uint256 constant AUCTION_TIME = 1 weeks;

Expand Down Expand Up @@ -26,7 +26,7 @@ contract Auction {
require(msg.value > 0, 'need to invest with eth!');
require(address(this).balance <= ethAmountToBuy, 'attempting to overfund');
require(totalRepPurchased + repToBuy <= repAvailable, 'attempt to buy too much rep');
purchasedRep[msg.sender] = repToBuy; // todo, currently anyone can buy with any price
purchasedRep[msg.sender] = repToBuy; // TODO, currently anyone can buy with any price
totalRepPurchased += repToBuy;
emit Participated(msg.sender, repToBuy, msg.value, totalRepPurchased);
}
Expand All @@ -39,12 +39,12 @@ contract Auction {
emit AuctionStarted(ethAmountToBuy, repAvailable);
}

function finalizeAuction() public {
function finalizeAuction(address receiver) public {
//require(block.timestamp > auctionStarted + AUCTION_TIME, 'Auction needs to have ended first'); // caller checks
require(msg.sender == owner, 'Only owner can finalize');
require(!finalized, 'Already finalized');
finalized = true;
(bool sent, ) = payable(owner).call{value: address(this).balance}('');
require(sent, 'Failed to send Ether');
(bool sent, ) = payable(receiver).call{value: address(this).balance}('');
require(sent, 'failed to send Ether');
}
}
8 changes: 4 additions & 4 deletions solidity/contracts/peripherals/EscalationGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ contract EscalationGame {
return startBond * series / SCALE;
}

// todo investigate this function more for errors. This can result in weird errors where you fork just before/after escalation game end
// TODO investigate this function more for errors. This can result in weird errors where you fork just before/after escalation game end
function computeTimeSinceStartFromAttritionCost(uint256 attritionCost) public view returns (uint256) {
uint256 low = 0;
uint256 high = escalationTimeLength;
Expand Down Expand Up @@ -171,7 +171,7 @@ contract EscalationGame {
}
}

// todo, this should be calculated against to actual nonDecisionThreshold, not the one set at the start. The actual can be lower than the games treshold but never above
// TODO, this should be calculated against to actual nonDecisionThreshold, not the one set at the start. The actual can be lower than the games treshold but never above
function claimDepositForWinning(uint256 depositIndex, YesNoMarkets.Outcome outcome) public returns (address depositor, uint256 amountToWithdraw) {
require(msg.sender == address(securityPool) || msg.sender == address(securityPool.securityPoolForker()), 'Only Security Pool can withdraw');
Deposit memory deposit = deposits[uint8(outcome)][depositIndex];
Expand All @@ -193,7 +193,7 @@ contract EscalationGame {
}
}

// todo, allow withdrawing after someones elses fork as well (game is canceled)
// TODO, allow withdrawing after someones elses fork as well (game is canceled)
function withdrawDeposit(uint256 depositIndex) public returns (address depositor, uint256 amountToWithdraw) {
require(msg.sender == address(securityPool), 'Only Security Pool can withdraw');
require(nonDecisionTimestamp == 0, 'System has reached non-decision');
Expand All @@ -203,7 +203,7 @@ contract EscalationGame {
emit WithdrawDeposit(depositor, marketResolution, amountToWithdraw, depositIndex);
}

// todo, for the UI, we probably want to retrieve multiple outcomes at once
// TODO, for the UI, we probably want to retrieve multiple outcomes at once
function getDepositsByOutcome(YesNoMarkets.Outcome outcome, uint256 startIndex, uint256 numberOfEntries) external view returns (Deposit[] memory returnDeposits) {
returnDeposits = new Deposit[](numberOfEntries);
uint256 iterateUntil = startIndex + numberOfEntries > deposits[uint8(outcome)].length ? deposits[uint8(outcome)].length : startIndex + numberOfEntries;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNICENSE
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.33;

import { IWeth9 } from './interfaces/IWeth9.sol';
Expand Down Expand Up @@ -37,7 +37,7 @@ contract PriceOracleManagerAndOperatorQueuer {
OpenOracle public immutable openOracle;

event PriceReported(uint256 reportId, uint256 price);
event ExecutetedQueuedOperation(uint256 operationId, OperationType operation, bool success, string errorMessage);
event ExecutedQueuedOperation(uint256 operationId, OperationType operation, bool success, string errorMessage);

// operation queuing
uint256 public previousQueuedOperationId;
Expand All @@ -58,15 +58,15 @@ contract PriceOracleManagerAndOperatorQueuer {
lastPrice = _lastPrice;
}

function getRequestPriceEthCost() public view returns (uint256) {// todo, probably something else
function getRequestPriceEthCost() public view returns (uint256) {// TODO, probably something else
// https://github.com/j0i0m0b0o/openOracleBase/blob/feeTokenChange/src/OpenOracle.sol#L100
uint256 ethCost = block.basefee * 4 * (gasConsumedSettlement + gasConsumedOpenOracleReportPrice); // todo, probably something else
uint256 ethCost = block.basefee * 4 * (gasConsumedSettlement + gasConsumedOpenOracleReportPrice); // TODO, probably something else
return ethCost;
}
function requestPrice() public payable {
require(pendingReportId == 0, 'Already pending request');
// https://github.com/j0i0m0b0o/openOracleBase/blob/feeTokenChange/src/OpenOracle.sol#L100
uint256 ethCost = getRequestPriceEthCost();// todo, probably something else
uint256 ethCost = getRequestPriceEthCost();// TODO, probably something else
require(msg.value >= ethCost, 'not big enough eth bounty');

// TODO, research more on how to set these params
Expand Down Expand Up @@ -100,7 +100,7 @@ contract PriceOracleManagerAndOperatorQueuer {
lastSettlementTimestamp = block.timestamp;
lastPrice = price;
emit PriceReported(reportId, lastPrice);
if (queuedPendingOperationId != 0) { // todo we maybe should allow executing couple operations?
if (queuedPendingOperationId != 0) { // TODO we maybe should allow executing couple operations?
executeQueuedOperation(queuedPendingOperationId);
queuedPendingOperationId = 0;
}
Expand All @@ -125,32 +125,42 @@ contract PriceOracleManagerAndOperatorQueuer {
queuedPendingOperationId = previousQueuedOperationId;
requestPrice();
}
// send rest of the eth back
(bool sent, ) = payable(msg.sender).call{ value: address(this).balance }('');
require(sent, 'failed to return eth');
}

function executeQueuedOperation(uint256 operationId) public {
require(queuedOperations[operationId].amount > 0, 'no such operation or already executed');
require(isPriceValid(), 'price is not valid to execute');
// todo, we should allow these operations here to fail, but solidity try catch doesnt work inside the same contract
uint256 amount = queuedOperations[operationId].amount;
queuedOperations[operationId].amount = 0;
// TODO, we should allow these operations here to fail, but solidity try catch doesnt work inside the same contract
if (queuedOperations[operationId].operation == OperationType.Liquidation) {
try securityPool.performLiquidation(queuedOperations[operationId].initiatorVault, queuedOperations[operationId].targetVault, queuedOperations[operationId].amount) {
emit ExecutetedQueuedOperation(operationId, queuedOperations[operationId].operation, true, '');
try securityPool.performLiquidation(queuedOperations[operationId].initiatorVault, queuedOperations[operationId].targetVault, amount) {
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, true, '');
} catch Error(string memory reason) {
emit ExecutetedQueuedOperation(operationId, queuedOperations[operationId].operation, false, reason);
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, false, reason);
} catch {
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, false, 'Unknown error');
}
} else if(queuedOperations[operationId].operation == OperationType.WithdrawRep) {
try securityPool.performWithdrawRep(queuedOperations[operationId].initiatorVault, queuedOperations[operationId].amount) {
emit ExecutetedQueuedOperation(operationId, queuedOperations[operationId].operation, true, '');
try securityPool.performWithdrawRep(queuedOperations[operationId].initiatorVault, amount) {
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, true, '');
} catch Error(string memory reason) {
emit ExecutetedQueuedOperation(operationId, queuedOperations[operationId].operation, false, reason);
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, false, reason);
} catch {
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, false, 'Unknown error');
}
} else {
try securityPool.performSetSecurityBondsAllowance(queuedOperations[operationId].initiatorVault, queuedOperations[operationId].amount) {
emit ExecutetedQueuedOperation(operationId, queuedOperations[operationId].operation, true, '');
try securityPool.performSetSecurityBondsAllowance(queuedOperations[operationId].initiatorVault, amount) {
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, true, '');
} catch Error(string memory reason) {
emit ExecutetedQueuedOperation(operationId, queuedOperations[operationId].operation, false, reason);
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, false, reason);
} catch {
emit ExecutedQueuedOperation(operationId, queuedOperations[operationId].operation, false, 'Unknown error');
}
}
queuedOperations[operationId].amount = 0;
}

function getQueuedOperation() public view returns (QueuedOperation memory) {
Expand Down
Loading