CTF思路
点击放大

The contracts in this repository are designed to unify mutually exclusi markets into a single multi-outcome market structure. By mutually exclusi 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 equi amongst certain sets of positions.
Contract Documentation
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 equi 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 con to the equi position of YES tokens plus some amount of USDC.
The underlying binary markets are implemented using Gnosis’s 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 con 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.
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.
The NegRiskOperator and NegRiskAdapter are designed to be used with the UmaCtfAdapter, 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.
It is vital that markets prepared on the NegRiskAdapter ne in a tie or will be unable to be determined. For any gi, once one question is resolved as Yes/True, all other questions must be resolved as No/False. This means that if the chosen oracle returns a second question as Yes/True, the call to reportOutcome will revert, and the market may not be able to fully resolved. Similarly, it is expected that one question will resolve to Yes/True, and it should not be the case that all questions for a gi resolve to No/False. Keep this in mind when preparing markets and questions on the NegRiskAdapter.
开发语言:Solidity
Star 数:89
该项目属于CTF思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕CTF思路相关项目展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | neg-risk-ctf-adapter - CTF思路相关项目 |
| 所属分类 | CTF思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-05 23:57:04 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 261 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |