From 77487ff3896178877bebd3d04911010405388a8d Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 7 Aug 2023 10:20:41 +0100 Subject: [PATCH 1/2] adjust readme, adjust test --- README.md | 6 ++++++ src/test/NegRiskOperator.t.sol | 2 ++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 3f7b61a..3d1cffc 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,9 @@ The underlying binary markets are implemented using Gnosis’s Conditional Token The NegRiskOperator is designed to allow admin accounts to prepare questions and markets, as well as to integrate with resolution sources. The Vault holds USDC and Yes tokens which are collected as fees from users who choose to convert NO positions, given a positive fee rate. + +## Use with the UmaCtfAdapter + +The NegRiskOperator and NegRiskAdapter are designed to be used with the [UmaCtfAdapter](https://github.com/Polymarket/uma-ctf-adapter), or any oracle with the same interface. +A dedicated UmaCtfAdapter will need to be deployed with the UmaCtfAdapter's `ctf` set to the address of the NegRiskAdapter, and the NegRiskOperator's `oracle` set to the address of the UmaCtfAdapter. +Note that the UmaCtfAdapter can return `[1,1]` as a possible outcome, which is not a valid outcome for the NegRiskAdapter. The NegRiskAdapter will revert if it receives this outcome. It is important that markets/questions are chosen carefully so that this outcome is not possible. diff --git a/src/test/NegRiskOperator.t.sol b/src/test/NegRiskOperator.t.sol index 2d21241..a9f5258 100644 --- a/src/test/NegRiskOperator.t.sol +++ b/src/test/NegRiskOperator.t.sol @@ -56,6 +56,8 @@ contract NegRiskOperatorTest is TestHelper, INegRiskOperatorEE { } function test_revert_setOracle_oracleAlreadyIntialized(address _oracle1, address _oracle2) public { + vm.assume(_oracle1 != address(0)); + vm.startPrank(alice); NegRiskOperator nro = new NegRiskOperator(address(0)); nro.setOracle(_oracle1); From 2f7b27f3f27d2d44163fa5a2b44fc8cf8c93ecb9 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 8 Aug 2023 11:12:06 +0200 Subject: [PATCH 2/2] update README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d1cffc..0d3a59d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Polymarket Multi-Outcome Markets -The contracts in this repository are designed to unify mutually exclusive binary markets into a single multi-outcome market structure. By mutually exclusive binary markets, we mean a set of binary YES/NO of which one and only one will resolve true. The canonical example is a set of markets each representing a candidate in a particular political election, where only one can win. Each component binary market is a YES/NO market for a particular candidate. The fact that only one candidate can win guarantees that there are certain equivalancies amongst certain sets of positions. +The contracts in this repository are designed to unify mutually exclusive binary markets into a single multi-outcome market structure. By mutually exclusive binary markets, we mean a set of binary YES/NO markets of which one and only one will resolve true. The canonical example is a set of markets each representing a candidate in a particular political election, where only one can win. Each component binary market is a YES/NO market for a particular candidate. The fact that only one candidate can win guarantees that there are certain equivalancies amongst certain sets of positions. As an example, consider an election with candidates A, B, and C. For each candidate there is a binary YES/NO market, and exactly one candidate will win, i.e., exactly one market will resolve YES, and the rest NO. Consider a position consisting of 1 NO A and 1 NO B. If A wins, the position is worth 1 USDC. If B wins, the position is again worth 1 USDC. If C wins, the position is worth 2 USDC, as both NO tokens are redeemable for 1 USDC each. We can see that the position is equivalent to 1 USDC and 1 YES C, as the value of the two positions is equal in all three cases. The NegRiskAdapter is designed precisely to allow a position of 1 or more NO tokens to be converted to the equivalent position of YES tokens plus some amount of USDC. -The underlying binary markets are implemented using Gnosis’s Conditional Tokens contracts: https://github.com/gnosis/conditional-tokens-contracts. Once collateral is split into position tokens, there are only two ways to recover it, either by merging complete sets, or by redeeming positions after resolution. So, in order to allow USDC to be released as part of a conversion from a NO position to a YES position, we wrap USDC into WrappedCollateral, which is then used to collateralize all underlying markets. This enables the NegRiskAdapter to manage USDC separately from the ConditionalTokens contract. +The underlying binary markets are implemented using Gnosis’s [Conditional Tokens contracts](https://github.com/gnosis/conditional-tokens-contracts). Once collateral is split into position tokens, there are only two ways to recover it, either by merging complete sets, or by redeeming positions after resolution. So, in order to allow USDC to be released as part of a conversion from a NO position to a YES position, we wrap USDC into WrappedCollateral, which is then used to collateralize all underlying markets. This enables the NegRiskAdapter to manage USDC separately from the ConditionalTokens contract. The NegRiskOperator is designed to allow admin accounts to prepare questions and markets, as well as to integrate with resolution sources. @@ -15,4 +15,7 @@ The Vault holds USDC and Yes tokens which are collected as fees from users who c The NegRiskOperator and NegRiskAdapter are designed to be used with the [UmaCtfAdapter](https://github.com/Polymarket/uma-ctf-adapter), or any oracle with the same interface. A dedicated UmaCtfAdapter will need to be deployed with the UmaCtfAdapter's `ctf` set to the address of the NegRiskAdapter, and the NegRiskOperator's `oracle` set to the address of the UmaCtfAdapter. + +In order to prepare a question for a market using the NegRiskOperator, the question must be initialized on the UmaCtfAdapter first. Then, the question may be prepared on the NegRiskOperator where the `_requestId` parameter is the `questionID` returned by the UmaCtfAdapter. + Note that the UmaCtfAdapter can return `[1,1]` as a possible outcome, which is not a valid outcome for the NegRiskAdapter. The NegRiskAdapter will revert if it receives this outcome. It is important that markets/questions are chosen carefully so that this outcome is not possible.