Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uma Oracle Provider #168

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e532c79
feat: cvi and deployment scripts for providers
0xnyxos Jun 22, 2023
abd1fbf
feat: Chainlink interface variables added to providers
0xnyxos Jun 29, 2023
08130a7
feat: uma assertion implementation
0xnyxos Sep 1, 2023
9f7d3c8
tests: wip
0xnyxos Sep 1, 2023
d89fc73
feat: tests completed
0xnyxos Sep 5, 2023
fbba657
tests: comments removed and balance check
0xnyxos Sep 6, 2023
dbcf670
fix: removed unused price functions
0xnyxos Sep 20, 2023
7a4f6c1
feat: uma deploy script added
0xnyxos Sep 21, 2023
bcc78db
feat: uma split into v1(true at timestamp) and v2 (true after timesta…
0xnyxos Sep 22, 2023
27138a1
feat: dynamic bond function added
0xnyxos Sep 29, 2023
da4fbe4
fix: umaV3 naming and pyth tests fixed
0xnyxos Oct 9, 2023
f910091
feat: umaV2 price provider
0xnyxos Oct 9, 2023
683b208
feat: UmaV2 assertion provider
0xnyxos Oct 9, 2023
2f3ea19
feat: info for config added
0xnyxos Oct 10, 2023
df71ceb
fix: removed custom bond config
0xnyxos Oct 10, 2023
57bdb5c
feat: dynamic data assertion v3
0xnyxos Oct 12, 2023
2d4a93c
feat: deploy scripts UmaV2
0xnyxos Oct 17, 2023
15535b8
feat: whitelist added for assertionFetch
0xnyxos Oct 20, 2023
605b535
fix: RedstoneUniversal tests
0xnyxos Oct 25, 2023
c17b4d5
feat: pyth deploy script
0xnyxos Oct 25, 2023
9e526e2
feat: umaV2 fetchAssert pulls funds
0xnyxos Oct 27, 2023
54a9339
feat: uma storage and pending approach optimised
0xnyxos Nov 1, 2023
a1600c9
feat: refactored UmaV3
0xnyxos Dec 13, 2023
42f3559
fix: additional checks and bond logic
0xnyxos Dec 21, 2023
1142507
feat: refactored UmaV3 providers
0xnyxos Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions getRedstonePayload.js

This file was deleted.

89 changes: 86 additions & 3 deletions script/v2/V2DeployContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import "../../src/v2/oracles/individual/RedstonePriceProvider.sol";
import "../../src/v2/oracles/individual/DIAPriceProvider.sol";
import "../../src/v2/oracles/individual/CVIPriceProvider.sol";
import "../../src/v2/oracles/individual/GdaiPriceProvider.sol";
import "../../src/v2/oracles/individual/UmaV2PriceProvider.sol";
import "../../src/v2/oracles/individual/UmaV2AssertionProvider.sol";
import "../../src/v2/oracles/individual/UmaV3PriceProvider.sol";
import "../../src/v2/oracles/individual/UmaV3AssertionProvider.sol";
import "../../src/v2/oracles/individual/PythPriceProvider.sol";
import "../../src/v2/TimeLock.sol";
import "./V2Helper.sol";
import {
Expand Down Expand Up @@ -112,8 +117,8 @@ contract V2DeployContracts is Script, HelperV2 {
// timeOut
// );

address gdaiVault = 0xd85E038593d7A098614721EaE955EC2022B9B91B;
GdaiPriceProvider gdaiPriceProvider = new GdaiPriceProvider(gdaiVault);
// address gdaiVault = 0xd85E038593d7A098614721EaE955EC2022B9B91B;
// GdaiPriceProvider gdaiPriceProvider = new GdaiPriceProvider(gdaiVault);

// address cviOracle = 0x649813B6dc6111D67484BaDeDd377D32e4505F85;
// uint256 cviDecimals = 0;
Expand All @@ -126,6 +131,77 @@ contract V2DeployContracts is Script, HelperV2 {
// address diaOracleV2 = 0xd041478644048d9281f88558E6088e9da97df624;
// DIAPriceProvider diaPriceProvider = new DIAPriceProvider(diaOracleV2);

uint256 timeOut = 2 hours;
// address umaCurrency = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8;
// address umaV2Finder = 0xB0b9f73B424AD8dc58156C2AE0D7A1115D1EcCd1;
// uint128 reward = 5e6;

// uint256 umaDecimals = 18;
// string memory umaDescription = "FUSD/USD";
// string
// memory ancillaryData = 'base:FDUSD,baseAddress:0xc5f0f7b66764F6ec8C8Dff7BA683102295E16409,baseChain: 1,quote:USD,quoteDetails:United States Dollar,rounding:18,fallback:"https://www.coingecko.com/en/coins/first-digital-usd",configuration:{"type": "medianizer","minTimeBetweenUpdates": 60,"twapLength": 600,"medianizedFeeds":[{ "type": "cryptowatch", "exchange": "binance", "pair": "fdusdusdt" }]}';

// UmaV2PriceProvider umaV2PriceProvider = new UmaV2PriceProvider(
// timeOut,
// umaDecimals,
// umaDescription,
// umaV2Finder,
// umaCurrency,
// ancillaryData,
// reward
// );

// string memory umaDescription = "AAVE aUSDC Hack Market";
// string
// memory ancillaryData = "q: Aave USDC.e pool (address: 0x625E7708f30cA75bfd92586e17077590C60eb4cD) on Arbitrum One was hacked or compromised leading to locked funds or >25% loss in TVL value after the timestamp of: ";
// UmaV2AssertionProvider umaV2AssertionProvider = new UmaV2AssertionProvider(
// timeOut,
// umaDescription,
// umaV2Finder,
// umaCurrency,
// ancillaryData,
// reward
// );

// uint256 umaDecimals = 18;
// string memory umaDescription = "USDC";
// uint256 requiredBond = 1e6;
// bytes32 defaultIdentifier = bytes32("abc");
// bytes
// memory assertionDescription = "The USDC/USD exchange is above 0.997";
// address currency = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1; // WETH_ADDRESS
// UmaV3PriceProvider umaPriceProvider = new UmaV3PriceProvider(
// umaDecimals,
// umaDescription,
// timeOut,
// umaOOV3,
// defaultIdentifier,
// currency,
// assertionDescription,
// requiredBond
// );

address umaOOV3 = 0xa6147867264374F324524E30C02C331cF28aa879;
string memory marketDescription = "ETH Volatility";
uint256 requiredBond = 501e6;
address currency = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8; // USDC.e
UmaV3AssertionProvider umaV3Provider = new UmaV3AssertionProvider(
marketDescription,
timeOut,
umaOOV3,
currency,
requiredBond
);

// address pythContract = 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C;
// // bytes32 fdUsdFeedId = 0xccdc1a08923e2e4f4b1e6ea89de6acbc5fe1948e9706f5604b8cb50bc1ed3979;
// bytes32 cUsdFeedId = 0x8f218655050a1476b780185e89f19d2b1e1f49e9bd629efad6ac547a946bf6ab;
// PythPriceProvider pythProvider = new PythPriceProvider(
// pythContract,
// cUsdFeedId,
// timeOut
// );

// vaultFactory.whitelistController(address(controller));
// KeeperV2 resolveKeeper = new KeeperV2(
// payable(addresses.gelatoOpsV2),
Expand Down Expand Up @@ -164,9 +240,16 @@ contract V2DeployContracts is Script, HelperV2 {
// address(chainlinkPriceProviderMAI)
// );
// console2.log("Redstone Price Provider", address(redstoneProvider));
console2.log("Gdai Price Provider", address(gdaiPriceProvider));
// console2.log("Gdai Price Provider", address(gdaiPriceProvider));
// console2.log("CVI Price Provider", address(cviPriceProvider));
// console2.log("Dia Price Provider", address(diaPriceProvider));
// console.log("Pyth Price Provider", address(pythProvider));
// console2.log("Uma V2 Price Provider", address(umaV2PriceProvider));
// console2.log(
// "Uma V2 Assertion Provider",
// address(umaV2AssertionProvider)
// );
console2.log("Uma V3 Provider", address(umaV3Provider));

// console2.log("resolveKeeper address", address(resolveKeeper));
// console2.log("resolveKeeperGenericController address", address(resolveKeeperGenericController));
Expand Down
13 changes: 13 additions & 0 deletions src/v2/interfaces/IFinder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IFinder {
/**
* @notice Gets the address of the contract that implements the given `interfaceName`.
* @param interfaceName queried interface.
* @return implementationAddress address of the deployed contract that implements the interface.
*/
function getImplementationAddress(
bytes32 interfaceName
) external view returns (address);
}
22 changes: 22 additions & 0 deletions src/v2/interfaces/IOptimisticOracleV3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

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

interface IOptimisticOracleV3 {
function assertTruth(
bytes calldata claim,
address asserter,
address callBackAddress,
address sovereignSecurity,
uint64 assertionLiveness,
IERC20 currency,
uint256 bond,
bytes32 defaultIdentifier,
bytes32 domain
) external payable returns (bytes32 assertionId);

function getMinimumBond(address currency) external returns (uint256);

function defaultIdentifier() external returns (bytes32);
}
75 changes: 75 additions & 0 deletions src/v2/interfaces/IUmaV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

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

interface IUmaV2 {
/**
* @notice Requests a new price.
* @param identifier price identifier being requested.
* @param timestamp timestamp of the price being requested.
* @param ancillaryData ancillary data representing additional args being passed with the price request.
* @param currency ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM.
* @param reward reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0,
* which could make sense if the contract requests and proposes the value in the same call or
* provides its own reward system.
* @return totalBond default bond (final fee) + final fee that the proposer and disputer will be required to pay.
* This can be changed with a subsequent call to setBond().
*/
function requestPrice(
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData,
IERC20 currency,
uint256 reward
) external returns (uint256 totalBond);

/**
* @notice Set the proposal bond associated with a 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.
* @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);

/**
* @notice Sets a custom liveness value for the request. Liveness is the amount of time a proposal must wait before
* being auto-resolved.
* @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.
* @param customLiveness new custom liveness.
*/
function setCustomLiveness(
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData,
uint256 customLiveness
) external;

/**
* @notice Sets which callbacks should be enabled for the 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.
* @param callbackOnPriceProposed whether to enable the callback onPriceProposed.
* @param callbackOnPriceDisputed whether to enable the callback onPriceDisputed.
* @param callbackOnPriceSettled whether to enable the callback onPriceSettled.
*/
function setCallbacks(
bytes32 identifier,
uint256 timestamp,
bytes memory ancillaryData,
bool callbackOnPriceProposed,
bool callbackOnPriceDisputed,
bool callbackOnPriceSettled
) external;
}
2 changes: 1 addition & 1 deletion src/v2/oracles/individual/PythPriceProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract PythPriceProvider is Ownable, IConditionProvider {
function getLatestPrice() public view virtual returns (int256) {
PythStructs.Price memory answer = pyth.getPriceNoOlderThan(
priceFeedId,
timeOut
block.timestamp - timeOut
);
if (answer.price <= 0) revert OraclePriceNegative();

Expand Down
1 change: 0 additions & 1 deletion src/v2/oracles/individual/RedstonePriceProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,4 @@ contract RedstonePriceProvider is Ownable, IConditionProvider {
error RoundIdOutdated();
error PriceTimedOut();
error ConditionTypeNotSet();
error ConditionTypeSet();
}
Loading