Skip to content

Commit 5889859

Browse files
committed
Add study notes for 2025-08-15
1 parent bf5bd7d commit 5889859

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

3956ray.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,54 @@ timezone: UTC+8
1515
## Notes
1616

1717
<!-- Content_START -->
18+
# 2025-08-15
19+
20+
# Uniswap
21+
22+
- **v3(2021)**:提出“**集中流动性**”(LP 可把资金只投在自选价区),并配合多费率档、NFT 头寸与内置 TWAP 预言机,显著提升资金效率与可组合性。([Uniswap文档](https://docs.uniswap.org/concepts/protocol/concentrated-liquidity?utm_source=chatgpt.com "Concentrated Liquidity"), [app.uniswap.org](https://app.uniswap.org/whitepaper-v3.pdf?utm_source=chatgpt.com "Uniswap v3 Core"))
23+
24+
- **v4(2025)**:在延续 v3 资金效率的基础上,换成 **Singleton** 架构 + **Flash Accounting**(净额结算)+ **Hooks** 可编程扩展;费用从固定档变为 **0–100% 可配置/可动态**;支持 **原生 ETH**(无需先包成 WETH)。
25+
26+
27+
28+
| | v3 | v4 |
29+
| ----- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30+
| 合约架构 | Factory + 每个池都是独立合约 | **单合约 PoolManager(Singleton)** 管全部池状态,创建/多跳更省 Gas。 |
31+
| 资金效率 | **集中流动性**(LP 指定价区) | 继承 v3 的集中流动性机制。 |
32+
| 费用机制 | 固定档(0.01%、0.05%、0.3%、1%) | **可配置费率(0–100%)**,可静态或由 **Hook 动态**决定。([Uniswap文档](https://docs.uniswap.org/concepts/protocol/fees?utm_source=chatgpt.com "Fees"), [blog.openzeppelin.com](https://blog.openzeppelin.com/uniswap-v4-core-audit?utm_source=chatgpt.com "Uniswap v4 Core Audit")) |
33+
| 结算与转账 | 每跳都真实转账,跨多池成本高 | **Flash Accounting**,交易末尾按净额结算,跨池更省 Gas;附带“**免费闪电贷**”性质。([Uniswap文档](https://docs.uniswap.org/contracts/v4/concepts/flash-accounting?utm_source=chatgpt.com "Flash Accounting"), [Uniswap Labs](https://blog.uniswap.org/uniswap-v4?utm_source=chatgpt.com "Our Vision for Uniswap v4"), [blog.openzeppelin.com](https://blog.openzeppelin.com/uniswap-v4-core-audit?utm_source=chatgpt.com "Uniswap v4 Core Audit")) |
34+
| 原生资产 | 需 WETH/WMATIC 包装 | **原生 ETH 直用**,用户体验更好。 |
35+
| 可编程性 | 协议内置功能为主 | **Hooks**:在建池/加减仓/换汇等生命周期“前/后”插入自定义逻辑(限价单、定制预言机、费用管理、做市策略等)。 |
36+
| 头寸表示 | 每个 LP 头寸是 **ERC-721** | 仍由 **v4 PositionManager 铸造/管理 ERC-721 头寸**;但结算层引入 **ERC-6909** 做内部记账与赎回优化。 |
37+
| 预言机 | **内置 TWAP 预言机**(池可直接出价) | **不再内置预言机**;如需可由 Hook 定制。 |
38+
| 范式/路由 | v3 Router + SDK | **Universal Router + v4 SDK**,支持 v4 的新结算/Hook 语义。( |
39+
40+
> 备注:**Range Orders(区间单)** 在 v3/v4 语义一致,都是用“单边集中流动性 + 价区穿越”来近似限价单。
41+
42+
# v4 的关键技术点(为什么更“灵活+低 Gas”)
43+
44+
1. **Singleton + Flash Accounting**
45+
全池状态集中到 `PoolManager`;一次交易内先用**瞬时状态**记账(受 EIP-1153/Transient Storage 设计启发),最后统一结算,跨多池/多步操作显著省 Gas,并天然形成“**净额结算/免费闪电贷**”特性。([GitHub](https://github.com/Uniswap/v4-core?utm_source=chatgpt.com "Core smart contracts of Uniswap v4"), [Uniswap文档](https://docs.uniswap.org/contracts/v4/concepts/flash-accounting?utm_source=chatgpt.com "Flash Accounting"), [blog.openzeppelin.com](https://blog.openzeppelin.com/uniswap-v4-core-audit?utm_source=chatgpt.com "Uniswap v4 Core Audit"))
46+
2. **Hooks(池级可编程)**
47+
在建池、swap、modifyLiquidity、donate 等前/后插点执行外部合约,实现**动态费率、做市策略、预言机、风控/合规模块**等;是 v4 的可扩展核心。
48+
3. **费用与会计完全可定制**
49+
费率范围 0–100%,静态或由 Hook 每笔动态设定;配合 **Custom Accounting/Return Deltas** 可实现复杂经济模型。([blog.openzeppelin.com](https://blog.openzeppelin.com/uniswap-v4-core-audit?utm_source=chatgpt.com "Uniswap v4 Core Audit"), [Uniswap文档](https://docs.uniswap.org/contracts/v4/guides/custom-accounting?utm_source=chatgpt.com "Custom Accounting | Uniswap"))
50+
4. **原生 ETH 支持**
51+
路由/PoolKey 直接标识 ETH,减少 wrap/unwrap 成本与边界复杂度。
52+
5. **ERC-6909 内部记账**
53+
与 Flash Accounting 协同,允许在 `PoolManager` 内以多 token-id 形式记账、赎回/归还,进一步压低赎回/领取 Gas。
54+
55+
56+
# 2024–2025
57+
58+
- **主网上线 & 多链部署****2025-01-31** v4 正式发布,**以太坊、Polygon、Arbitrum、OP Mainnet、Base、BNB、Blast、World Chain、Avalanche、Zora** 等链可用。([Uniswap Labs](https://blog.uniswap.org/uniswap-v4-is-here?utm_source=chatgpt.com "Uniswap v4 is Here – A New Era of DeFi"))
59+
- **安全与审计**:上线前组织了**多轮审计/竞赛****$15.5M** 赏金;独立审计报告也剖析了 **Flash Accounting“免费闪电贷”****ERC-6909 结算** 的安全注意点。([Uniswap Labs](https://blog.uniswap.org/v4-bug-bounty?utm_source=chatgpt.com "$15.5M Bug Bounty for Uniswap v4: The Largest in History"), [blog.openzeppelin.com](https://blog.openzeppelin.com/uniswap-v4-core-audit?utm_source=chatgpt.com "Uniswap v4 Core Audit"))
60+
- **数据与分析迁移**:因 **Singleton** 与新记账范式,v4 的链上数据抓取/查询方式与 v3 有明显不同(研究者/分析师需更新方法)。([uniswapfoundation.mirror.xyz](https://uniswapfoundation.mirror.xyz/c7LDDTWhC2ry6gp0nGqcSKHvNHosJmhPQ-ZuIxqeB2I?utm_source=chatgpt.com "How to Navigate Uniswap v4 Data"))
61+
- **开发生态**:发布 **v4 SDK****Universal Router** 文档/示例,同时官方/社区给出 Hook 模板与实践指引(如 BaseHook、风控/积分/动态费率 Hook 等)。([Uniswap文档](https://docs.uniswap.org/sdk/v4/overview?utm_source=chatgpt.com "The Uniswap v4 SDK"))
62+
- **许可与合规**
63+
- v3:最初 BUSL,后已转 **GPL**(可自由复刻,遵守 GPL 即可)。([support.uniswap.org](https://support.uniswap.org/hc/en-us/articles/14569783029645-Uniswap-v3-licensing?utm_source=chatgpt.com "Uniswap v3 licensing"))
64+
- v4:**BUSL-1.1/双许可**(部分文件 MIT),随时间转为更宽松许可;DAO 对例外授权/流程有专门讨论。([GitHub](https://github.com/Uniswap/v4-core?utm_source=chatgpt.com "Core smart contracts of Uniswap v4"), [Uniswap Governance](https://gov.uniswap.org/t/establish-uniswap-v4-licensing-process/25443?utm_source=chatgpt.com "Establish Uniswap v4 Licensing Process"))
65+
1866
# 2025-08-14
1967

2068
# OpenZeppelin

0 commit comments

Comments
 (0)