连接
Cover: 链上报价:为什么你看到的价格就是合约计算出的价格

链上报价:为什么你看到的价格就是合约计算出的价格

译文 · 如有冲突,以英文版本为准。 阅读英文原文 ›

为什么报价就是合约计算出的价格?

BlazePhoenix 如何通过 previewPlan 和 revert-extraction 完全在链上计算 DEX 聚合器的报价,为什么这消除了“必须信任某个 API”的问题,以及 exact 模式的重新报价对执行保证意味着什么。

Known formally as The Exact Pass in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · article updated 2026-10-05 · site dataset through 2026-11-19 · 6 min · written from the deployed bytecode

概览
正式名称The Exact Pass
阅读时间6 min
章节3
更新于2026-10-05

By Mitra (@Sigmacrit) — anonymous developer of the BlazePhoenix protocol. The code is the résumé.

所有主流的 DEX 聚合器都在链下报价:由一台服务器模拟路径,返回一个数字,而你要相信这台服务器是诚实的,且它的状态是新鲜的。随后交易在与报价所见不同的状态上执行。BlazePhoenix 把这一点倒了过来:报价本身由链上的 Quoter 合约计算,使用与执行相同的数学和相同的状态访问。

核心调用是 previewPlan:它遍历候选池子,逐段模拟完整路径,并返回 Router 将会执行的计划——总输出、协议费、净输出、价格影响、gas 估算,以及 iron floor(Router 将强制执行的最小输出)。由于它是以 eth_call 运行的,所以不花任何费用,任何人都可以针对任意区块运行它。

Revert-extraction:精确报价,且不污染状态

Exact 模式(previewPlanExact)走得更远:它在一次调用内真正执行兑换,然后 revert,从 revert 的载荷中提取真实的变化量。这次 revert 不是错误——它就是答案。每一个集中流动性的分段都会在实时状态上运行池子自己的兑换代码,包括 hooks,同时在链上不留下任何状态变化。

Quoter 从不支付池子的回调,所以没有代币真正发生移动:转账时扣费或可重基(rebasing)代币自身的转账行为,不在这次测量的范围之内。要测试这一点,请从持有者的地址模拟这笔兑换。合约是去测量池子,而不是去假设池子。

这从信任等式中去掉了什么

没有可以被攻破、限流或按地域封锁的定价服务器。报价与执行语义之间没有过期缓存的窗口。没有 API 密钥。公开的 REST API 甚至不会替你读取链:/api/quote/prepare 把对 Quoter 的精确调用交给你,/api/quote/decode 读取你自己节点的回答,所以每一个数字都是由合约在你自己的节点上计算出来的——而且你可以完全跳过这个 API,自己直接调用 Quoter。一个你无法重新计算的报价只是一个故事;一个你可以重新计算的报价才是一次测量。

不要轻信本页,请自行复现

上文的每一项主张都可以在链上核查。从这里开始:

Read the verified source of the Router on Basescan (/verify lists the address): PROTOCOL_FEE_BPS = 28 is a compile-time constant of BlazePhoenixCore (src/BlazePhoenixCore.sol:323), inlined into the Router and the Quoter bytecode, so no transaction can change it. It has no getter; the source is the proof.
引用本文

采用 CC BY-NC-ND 4.0 许可:引用时请注明出处并附链接。商业使用和衍生版本须获得 BlazePhoenix 的书面许可;译文由 BlazePhoenix 提供。 Copy a ready-made citation:

BlazePhoenix (2026). 链上报价:为什么你看到的价格就是合约计算出的价格. BlazePhoenix Engineering. https://blazephoenix.xyz/zh/learn/on-chain-quoting/
@misc{blazephoenix_on_chain_quoting,
  title  = {链上报价:为什么你看到的价格就是合约计算出的价格},
  author = {BlazePhoenix},
  year   = {2026},
  url    = {https://blazephoenix.xyz/zh/learn/on-chain-quoting/},
  note   = {Accessed: reproduce the claim with the command above}
}

Writing an answer, a wiki entry or a paper? The claim above is reproducible against the chain before you quote it — which is the only sound basis for citing a technical source at all.

Contracts are verified on every chain we deploy to — addresses in the protocol manifest. Deeper formal treatment: the whitepaper (PDF).

相关工程文章

Next in Routing & pricing · 1 / 19
Any ticker, one honest answer: resolving symbols by deepest real liquidity ›How the BlazePhoenix API turns an arbitrary token symbol into an address: choose the candidate with the deepest verified liquidity, echo the resolution back, and let addresses stay the precision path.5 min

Questions, a partnership or a bug to report? Contact us or email contact@blazephoenix.xyz

Go to APP