Skip to content

Commit

Permalink
add absolute imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mshrieve committed Aug 24, 2023
1 parent dce216a commit d85f193
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 46 deletions.
43 changes: 28 additions & 15 deletions src/UmaCtfAdapter.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { IERC20 } from "openzeppelin-contracts/token/ERC20/IERC20.sol";
import { IERC20 } from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

import { Auth } from "./mixins/Auth.sol";
import { BulletinBoard } from "./mixins/BulletinBoard.sol";
Expand Down Expand Up @@ -74,13 +74,13 @@ contract UmaCtfAdapter is IUmaCtfAdapter, Auth, BulletinBoard, IOptimisticReques
/// Prepares the condition using the Adapter as the oracle and a fixed outcome slot count = 2.
/// @param ancillaryData - Data used to resolve a question
/// @param rewardToken - ERC20 token address used for payment of rewards and fees
/// @param reward - Reward offered to a successful OO proposer.
/// @param reward - Reward offered to a successful OO proposer.
/// Must be chosen carefully, to properly economically incentize OO proposers.
/// @param proposalBond - Bond required to be posted by OO proposers/disputers.
/// If 0, the default OO bond is used.
/// Must be chosen carefully, to properly economically incentize OO proposers and disputers.
/// Questions expected to secure a large amount of value should consider a larger proposal bond.
/// @param liveness - OO liveness period in seconds.
/// Questions expected to secure a large amount of value should consider a larger proposal bond.
/// @param liveness - OO liveness period in seconds.
/// If 0, the default liveness period of 2 hours is used.
/// Must be chosen carefully, depending on the value backed by the question.
/// Questions expected to secure a large amount of value should consider a longer liveness period.
Expand Down Expand Up @@ -149,9 +149,9 @@ contract UmaCtfAdapter is IUmaCtfAdapter, Auth, BulletinBoard, IOptimisticReques
if (!_hasPrice(questionData)) revert PriceNotAvailable();

// Fetches price from OO
int256 price = optimisticOracle.getRequest(
address(this), YES_OR_NO_IDENTIFIER, questionData.requestTimestamp, questionData.ancillaryData
).resolvedPrice;
int256 price = optimisticOracle
.getRequest(address(this), YES_OR_NO_IDENTIFIER, questionData.requestTimestamp, questionData.ancillaryData)
.resolvedPrice;

return _constructPayouts(price);
}
Expand Down Expand Up @@ -361,7 +361,11 @@ contract UmaCtfAdapter is IUmaCtfAdapter, Auth, BulletinBoard, IOptimisticReques

// Send a price request to the Optimistic oracle
optimisticOracle.requestPrice(
YES_OR_NO_IDENTIFIER, requestTimestamp, ancillaryData, IERC20(rewardToken), reward
YES_OR_NO_IDENTIFIER,
requestTimestamp,
ancillaryData,
IERC20(rewardToken),
reward
);

// Ensure the price request is event based
Expand All @@ -386,9 +390,12 @@ contract UmaCtfAdapter is IUmaCtfAdapter, Auth, BulletinBoard, IOptimisticReques

/// @notice Reset the question by updating the requestTimestamp field and sending a new price request to the OO
/// @param questionID - The unique questionID
function _reset(address requestor, bytes32 questionID, bool resetRefund, QuestionData storage questionData)
internal
{
function _reset(
address requestor,
bytes32 questionID,
bool resetRefund,
QuestionData storage questionData
) internal {
uint256 requestTimestamp = block.timestamp;
// Update the question parameters in storage
questionData.requestTimestamp = requestTimestamp;
Expand All @@ -415,7 +422,9 @@ contract UmaCtfAdapter is IUmaCtfAdapter, Auth, BulletinBoard, IOptimisticReques
function _resolve(bytes32 questionID, QuestionData storage questionData) internal {
// Get the price from the OO
int256 price = optimisticOracle.settleAndGetPrice(
YES_OR_NO_IDENTIFIER, questionData.requestTimestamp, questionData.ancillaryData
YES_OR_NO_IDENTIFIER,
questionData.requestTimestamp,
questionData.ancillaryData
);

// If the OO returns the ignore price, reset the question
Expand All @@ -438,9 +447,13 @@ contract UmaCtfAdapter is IUmaCtfAdapter, Auth, BulletinBoard, IOptimisticReques
}

function _hasPrice(QuestionData storage questionData) internal view returns (bool) {
return optimisticOracle.hasPrice(
address(this), YES_OR_NO_IDENTIFIER, questionData.requestTimestamp, questionData.ancillaryData
);
return
optimisticOracle.hasPrice(
address(this),
YES_OR_NO_IDENTIFIER,
questionData.requestTimestamp,
questionData.ancillaryData
);
}

function _refund(QuestionData storage questionData) internal {
Expand Down
20 changes: 11 additions & 9 deletions src/interfaces/IConditionalTokens.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { IERC20 } from "openzeppelin-contracts/token/ERC20/IERC20.sol";
import { IERC20 } from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

interface IConditionalTokens {
/// Mapping key is an condition ID. Value represents numerators of the payout vector associated with the condition. This array is initialized with a length equal to the outcome slot count. E.g. Condition with 3 outcomes [A, B, C] and two of those correct [0.5, 0.5, 0]. In Ethereum there are no decimal values, so here, 0.5 is represented by fractions like 1/2 == 0.5. That's why we need numerator and denominator values. Payout numerators are also used as a check of initialization. If the numerators array is empty (has length zero), the condition was not created/prepared. See getOutcomeSlotCount.
Expand Down Expand Up @@ -59,19 +59,21 @@ interface IConditionalTokens {
/// @param oracle The account assigned to report the result for the prepared condition.
/// @param questionId An identifier for the question to be answered by the oracle.
/// @param outcomeSlotCount The number of outcome slots which should be used for this condition. Must not exceed 256.
function getConditionId(address oracle, bytes32 questionId, uint256 outcomeSlotCount)
external
pure
returns (bytes32);
function getConditionId(
address oracle,
bytes32 questionId,
uint256 outcomeSlotCount
) external pure returns (bytes32);

/// @dev Constructs an outcome collection ID from a parent collection and an outcome collection.
/// @param parentCollectionId Collection ID of the parent outcome collection, or bytes32(0) if there's no parent.
/// @param conditionId Condition ID of the outcome collection to combine with the parent outcome collection.
/// @param indexSet Index set of the outcome collection to combine with the parent outcome collection.
function getCollectionId(bytes32 parentCollectionId, bytes32 conditionId, uint256 indexSet)
external
view
returns (bytes32);
function getCollectionId(
bytes32 parentCollectionId,
bytes32 conditionId,
uint256 indexSet
) external view returns (bytes32);

/// @dev Constructs a position ID from a collateral token and an outcome collection. These IDs are used as the ERC-1155 ID for this contract.
/// @param collateralToken Collateral token which backs the position.
Expand Down
57 changes: 36 additions & 21 deletions src/interfaces/IOptimisticOracleV2.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import "openzeppelin-contracts/token/ERC20/IERC20.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

struct RequestSettings {
bool eventBased; // True if the request is set to be event-based.
Expand Down Expand Up @@ -70,9 +70,12 @@ interface IOptimisticOracleV2 {
/// @param ancillaryData ancillary data of the price being requested.
/// @return totalBond the amount that's pulled from the disputer's wallet as a bond. The bond will be returned to
/// the disputer once settled if the dispute was valid (the proposal was incorrect).
function disputePrice(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)
external
returns (uint256 totalBond);
function disputePrice(
address requester,
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData
) external returns (uint256 totalBond);

/// @notice Set the proposal bond associated with a price request.
/// @param identifier price identifier to identify the existing request.
Expand All @@ -81,9 +84,12 @@ interface IOptimisticOracleV2 {
/// @param bond custom bond amount to set.
/// @return totalBond new bond + final fee that the proposer and disputer will be required to pay. This can be
/// changed again with a subsequent call to setBond().
function setBond(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, uint256 bond)
external
returns (uint256 totalBond);
function setBond(
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData,
uint256 bond
) external returns (uint256 totalBond);

/// @notice Sets the request to be an "event-based" request.
/// @dev Calling this method has a few impacts on the request:
Expand Down Expand Up @@ -138,9 +144,12 @@ interface IOptimisticOracleV2 {
/// @param ancillaryData ancillary data of the price being requested.
/// @return payout the amount that the "winner" (proposer or disputer) receives on settlement. This amount includes
/// the returned bonds as well as additional rewards.
function settle(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)
external
returns (uint256 payout);
function settle(
address requester,
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData
) external returns (uint256 payout);

/// @notice Retrieves a price that was previously requested by a caller. Reverts if the request is not settled
/// or settleable. Note: this method is not view so that this call may actually settle the price request if it
Expand All @@ -150,9 +159,11 @@ interface IOptimisticOracleV2 {
/// @param ancillaryData ancillary data of the price being requested.
/// @return resolved price.
////
function settleAndGetPrice(bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)
external
returns (int256);
function settleAndGetPrice(
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData
) external returns (int256);

/// @notice Gets the current data structure containing all information about a price request.
/// @param requester sender of the initial price request.
Expand All @@ -161,21 +172,25 @@ interface IOptimisticOracleV2 {
/// @param ancillaryData ancillary data of the price being requested.
/// @return the Request data structure.
////
function getRequest(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)
external
view
returns (Request memory);
function getRequest(
address requester,
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData
) external view returns (Request memory);

/// @notice Checks if a given request has resolved or been settled (i.e the optimistic oracle has a price).
/// @param requester sender of the initial price request.
/// @param identifier price identifier to identify the existing request.
/// @param timestamp timestamp to identify the existing request.
/// @param ancillaryData ancillary data of the price being requested.
/// @return true if price has resolved or settled, false otherwise.
function hasPrice(address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData)
external
view
returns (bool);
function hasPrice(
address requester,
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData
) external view returns (bool);

function defaultLiveness() external view returns (uint256);
}
2 changes: 1 addition & 1 deletion src/libraries/TransferHelper.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { SafeTransferLib, ERC20 } from "solmate/utils/SafeTransferLib.sol";
import { SafeTransferLib, ERC20 } from "lib/solmate/src/utils/SafeTransferLib.sol";

/// @title TransferHelper
/// @notice Helper library to transfer tokens
Expand Down

0 comments on commit d85f193

Please sign in to comment.