剑庭安
首页
黑客安全首页全部安全栏目 黑客技术黑客技术、渗透测试、漏洞利用工具与教程 安全软件安全工具、扫描器、检测与审计软件 病毒分析恶意软件分析、样本、逆向与沙箱 CTF思路CTF 题目、writeup、解题思路与工具 防护思路防御技术、加固、检测响应与蓝队 红蓝攻防红队攻击模拟、蓝队对抗、攻防演练 漏洞知识库漏洞、CVE、PoC、EXP 与安全研究
逆向|反编译
PHP源码PHP 网站源码、程序、系统 APP源码安卓/iOS APP 源码 ASP源码ASP 网站源码与程序 NET源码.NET 网站源码与系统 小程序源码微信/支付宝小程序源码 Dedecms风格模板Dedecms 织梦风格模板 Empirecms风格模板EmpireCMS 帝国风格模板 Discuz商业模板/插件Discuz 商业模板与插件 WordPress主题/插件WordPress 主题与插件 其它源码、模板其它各类源码与模板 游戏源码游戏源码与引擎项目 加密货币源码加密货币、区块链、钱包、USDT/比特币相关源码与工具 手游源码手机游戏源码、服务端、客户端与引擎项目 传奇源码热血传奇、传奇世界、复古传奇等客户端/服务端/引擎源码 页游源码网页游戏、H5 游戏、浏览器游戏源码 端游源码电脑单机游戏、PC 网游客户端/服务端源码
最新万能免驱动支持所有型号打印机下载程序 日历天气老黄历 · 每天同步真实日期与天气
站长工具站长工具 自助开通会员浏览该分类 其他资源qtziy SEO工具SEO工具 站群源码站群源码 泛程序泛程序 蜘蛛模板蜘蛛模板 蜘蛛池蜘蛛池 外链工具外链工具
搜索 自助开通会员🔓 破甲 API
登录 注册
首页 分类列表 CTF思路 ctf-exchange-v2 - Polymarket…
ctf-exchange-v2 - Polymarket CTF Exchange v2 CTF思路 点击放大
作者:admin 发布:2026-10-05

ctf-exchange-v2 - Polymarket CTF Exchange v2

项目说明Polymarket CTF Exchange V2The CTF Exchange V2 is the core smart contract system for trading Conditional Token Framework (CTF) assets on Polymarket…
资源可下载 免费下载 0 条讨论
会员资源
开通会员后即可下载全部资源。
登录后开通会员
会员方案
108浏览量
0讨论
2下载链接
可下载资源状态
内容可验证
更新 2026-10-05
人工审核发布
评论区答疑

ctf-exchange-v2 - Polymarket CTF Exchange v2

项目说明

Polymarket CTF Exchange V2

The CTF Exchange V2 is the core smart contract system for trading Conditional Token Framework (CTF) assets on Polymarket. It implements operator-dri matching with support for multiple settlement types, signature schemes, and a wrapped collateral layer.

Deployed Contracts

Polygon

| Contract | Address |
|----------|---------|
| CollateralToken (impl) | 0x6bBCef9f7ef3B6C592c99e0f206a0DE94Ad0925f |
| CollateralToken (proxy) | 0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB |
| CollateralOnramp | 0x93070a847efEf7F70739046A929D47a521F5B8ee |
| CollateralOfframp | 0x2957922Eb93258b93368531d39fAcCA3B4dC5854 |
| PermissionedRamp | 0xebC2459Ec962869ca4c0bd1E06368272732BCb08 |
| CtfCollateralAdapter | 0xADa100874d00e3331D00F2007a9c336a65009718 |
| NegRiskCtfCollateralAdapter | 0xAdA200001000ef00D07553cEE7006808F895c6F1 |
| CTFExchangeV2 | 0xE111180000d2663C0091e4f400237545B87B996B |
| NegRiskCtfExchangeV2 | 0xe2222d279d744050d28e000310F59 |

Amoy

| Contract | Address |
|----------|---------|
| CollateralToken (impl) | 0x28A4eaD5bD4847d36F6d046A45e827bdf7781C29 |
| CollateralToken (proxy) | 0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB |
| CollateralOnramp | 0x93070a847efEf7F70739046A929D47a521F5B8ee |
| CollateralOfframp | 0x2957922Eb93258b93368531d39fAcCA3B4dC5854 |
| PermissionedRamp | 0xebC2459Ec962869ca4c0bd1E06368272732BCb08 |
| CtfCollateralAdapter | 0xADa100874d00e3331D00F2007a9c336a65009718 |
| NegRiskCtfCollateralAdapter | 0xAdA200001000ef00D07553cEE7006808F895c6F1 |
| CTFExchangeV2 | 0xE111180000d2663C0091e4f400237545B87B996B |
| NegRiskCtfExchangeV2 | 0xe2222d279d744050d28e000310F59 |

Security

Audits

| Auditor | Report |
|---------|--------|
| Quantstamp | CTF Exchange V2 - Quantstamp - March 2026 |
| Cantina | CTF Exchange V2 - Cantina - March 2026 |

Bug Bounty

Security can be reported through the Cantina bug bounty program.

Architecture

The exchange uses a mixin composition pattern, where each concern is isolated into its own abstract contract:

Contracts

Order Lifecycle

1. Users sign EIP-712 typed orders off-chain specifying token, amounts, and side (BUY/SELL)
2. The operator calls matchOrders() with a taker order and array of maker orders
3. The exchange signatures, checks prices cross, and determines the match type
4. Settlement executes based on match type:
- COMPLEMENTARY (BUY vs SELL) — Direct peer-to-peer transfers, no CTF operations
- MINT (both BUY) — Collateral split into outcome tokens via CTF
- MERGE (both SELL) — Outcome tokens merged back into collateral via CTF

Signature Types

| Type | Description |
|------|-------------|
| EOA | Standard ECDSA — signer must equal maker |
| POLY_PROXY | ECDSA + Polymarket proxy wallet ownership |
| POLY_GNOSIS_SAFE | ECDSA + Gnosis Safe ownership |
| POLY_1271 | EIP-1271 smart contract wallet signature |

Orders can also be preapproved by the operator, bypassing signature for subsequent matches.

Collateral System

The exchange trades in PMCT (PolyMarket Collateral Token), an ERC20 wrapper around USDC/USDCe:

  • CollateralOnramp: Wraps supported assets into PMCT

  • CollateralOfframp: Unwraps PMCT back to supported assets

  • CtfCollateralAdapter: Bridges PMCT ↔ CTF operations (split/merge/redeem)
  • Changes from V1

    New Features

  • Order preapproval — Operator can preappro, bypassing signature on match. Supports in.

  • User self-pause — Users can pause their own accounts with a configurable block delay (default 100 blocks), pre order execution as an emergency recovery mechanism.

  • Builder and metadata fields — Orders now carry builder (origin indicator) and metadata (hashed metadata) fields for richer order attribution.

  • Wrapped collateral (PMCT) — New collateral token layer with onramp/offramp, replacing direct USDC usage. Enables the collateral adapter pattern for CTF interactions.

  • Configurable max fee rate — Admin-settable maximum fee rate in basis points (default 500 = 5%), enforced per-order.
  • Remo

  • fillOrder / fillOrders — Removed in favor of the unified matchOrders entry point.

  • NonceManager — Nonce-based order cancellation removed. Orders are tracked by hash with OrderStatus (filled + remaining).

  • Registry — Token registration removed. Any valid CTF token ID can be traded directly.

  • Reentrancy guard — Removed. The operator-only access pattern eliminates reentrancy .

  • Mutable factory addresses — setProxyFactory() / setSafeFactory() removed. Factory addresses are now immutable constructor parameters with address deri computed in pure assembly.
  • Gas Optimizations

    V2 was built with gas efficiency as a primary design goal. The optimizations span every layer of the protocol. All numbers below are from equi matchOrders gas snapshot tests (EOA signatures, no fees).

    #### V1 vs V2 Comparison

    | Operation | Makers | V1 | V2 | Savings | % |
    |-----------|--------|-----|-----|---------|---|
    | Complementary | 1 | 207,402 | 134,594 | 72,808 | -35% |
    | Complementary | 5 | 411,423 | 308,940 | 102,483 | -25% |
    | Complementary | 10 | 666,818 | 527,180 | 139,638 | -21% |
    | Complementary | 20 | 1,178,855 | 964,688 | 214,167 | -18% |
    | Mint | 1 | 297,631 | 278,853 | 18,778 | -6% |
    | Mint | 5 | 724,982 | 458,937 | 266,045 | -37% |
    | Mint | 10 | 1,259,558 | 684,656 | 574,902 | -46% |
    | Mint | 20 | 2,330,028 | 1,138,156 | 1,191,872 | -51% |
    | Merge | 1 | 267,846 | 248,241 | 19,605 | -7% |
    | Merge | 5 | 684,301 | 434,534 | 249,767 | -37% |
    | Merge | 10 | 1,205,260 | 668,014 | 537,246 | -45% |
    | Merge | 20 | 2,248,481 | 1,137,026 | 1,111,455 | -49% |
    | Combo (comp+mint) | 10 | 954,055 | 683,141 | 270,914 | -28% |
    | Combo (comp+mint) | 20 | 1,745,359 | 1,143,608 | 601,751 | -34% |
    | Combo (comp+merge) | 10 | 953,338 | 679,820 | 273,518 | -29% |
    | Combo (comp+merge) | 20 | 1,724,687 | 1,140,733 | 583,954 | -34% |

    The biggest wins are on multi-maker mint/merge (up to 51% savings) where batched CTF operations eliminate per-maker splitPosition/mergePositions calls. Complementary matches see 18-35% savings from the peer-to-peer fast path.

    #### Batched CTF Operations

    For MINT/MERGE matches with multiple makers, V1 called splitPosition / mergePositions once per maker order. V2 accumulates totals across all makers and executes a single CTF call for the entire batch.

    #### Assembly-Optimized Event Emission

    All events (OrderFilled, OrdersMatched, FeeCharged) are emitted log2/log3/log4 assembly instructions with manually packed memory layouts, a Solidity's ABI encoding o.

    #### Storage-Packed Order Status

    OrderStatus packs bool filled (1 byte) and uint248 remaining (31 bytes) into a single 32-byte storage slot. Updates use a single SLOAD + SSTORE with bit operations:

    #### Cross-Multiplication Price

    V1 computed unit prices for crossing checks. V2 uses cross-multiplication for complementary orders, a di entirely:

    #### Branchless Enum Arithmetic

    Match type deri and asset ID computation use arithmetic instead of conditionals:

    #### EIP-712 Hashing with mcopy

    Struct hashing uses the mcopy opcode (EIP-5656) to copy order fields in a single operation instead of field-by-field mstore calls:

    #### Pure Assembly Address Deri

    Proxy and Safe wallet address computes CREATE2 addresses entirely in assembly — constructing bytecode hashes from raw bytes and pre-computed immutables. No intermediate allocations or ABI encoding.

    #### Other Optimizations

  • Custom errors throughout — no revert strings in bytecode

  • Unchecked arithmetic on 11 pro operations (loop counters, post- subtraction)

  • Immutable factory references — all factory addresses and bytecode hashes stored as immutables, eliminating storage reads on every signature

  • Lazy fee — maxFeeRateBps storage is only read when the fee is non-zero

  • XOR conditional swaps in price calculation — eliminates branches using (A xor B xor B) = A in
  • De

    Prerequisites

    Install Foundry.

    Foundry has daily updates, run foundryup to update forge and cast.

    Build

    Testing

    Run all tests:

    Run test functions matching a regex pattern:

    Run tests in contracts matching a regex pattern:

    Set -vvv to see a stack trace for a failed test.

    Gas Snapshots

    Configuration

  • Solidity: 0.8.30

  • Optimizer runs: 1,000,000

  • Fuzz runs: 256 (default), 10,000 (intense profile)
  • 项目信息

    开发语言:Solidity

    Star 数:82

    技术要点

    该项目属于CTF思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Polymarket CTF Exchange v2展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。

    从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。

    使用与学习建议

    1. 下载源码压缩包,解压到本地环境。

    2. 根据项目类型准备对应的运行环境与依赖。

    3. 按照 README 中的步骤完成配置与部署。

    4. 在隔离的测试环境中运行验证,避免影响生产系统。

    免责声明

    本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。

    资源标题ctf-exchange-v2 - Polymarket CTF Exchange v2
    所属分类CTF思路
    发布作者admin
    发布时间2026-10-05 23:58:18
    下载权限 免费下载
    附件数量2 个下载链接
    浏览次数108
    讨论数量0
    主题状态正常讨论中

    本资源免费,登录后即可在本页「下载链接」区域获取全部附件。

    请在评论区留言说明具体链接,或联系作者补档。楼主更新后本页会同步最新的下载地址。

    请先阅读正文中的授权说明;未注明的默认仅限站内学习交流,禁止直接搬运到其他站点二次售卖。
    还没有讨论,快来抢沙发~
    登录 后才能参与讨论
    下载链接
    会员才能下载
    登录后开通会员
    同分类推荐
    暂无同类资源
    免费登录即可下载
    查看会员
    放大预览

    © 2026 剑庭安 - 网站开发定制 SEO 优化蜘蛛池代做 在线看手相算命. 保留所有权利。

    Powered by 酷像SEOv3.0

    网站地图 Sitemap.xml
    首页 全部分类 黑客安全 逆向|反编译 精品源码 站长工具自助开通会员其他资源SEO工具站群源码泛程序蜘蛛模板蜘蛛池外链工具创意乐园 搜索 会员服务 登录 注册