fix(price-estimation): short-circuit native price#4367
Conversation
…d wrapped native token POST /api/v1/quote on mainnet fails with "NativeBuy estimator failed: No liquidity" whenever buy_token = BUY_ETH_ADDRESS (0xeee…eee), because Eip4626 tries to detect vault tokens by calling asset() on a non-contract sentinel. The native token and the ETH-flow sentinel both price at 1 native by definition, so there's no point dispatching them to any downstream estimator. Two short-circuits: - CachingNativePriceEstimator (primary): return Ok(1.0) immediately for either token, bypassing cache, Eip4626 wrapper, and all underlying sources. - Eip4626::estimate_native_price (defence-in-depth): pass BUY_ETH_ADDRESS through to the inner estimator without attempting vault detection RPC calls.
There was a problem hiding this comment.
Code Review
This pull request introduces short-circuiting logic for the native token and the ETH-flow sentinel address in the price estimation service. By returning a fixed price of 1.0 for these addresses, the system avoids unnecessary RPC calls and potential failures in downstream estimators like Eip4626. A high-severity issue was identified where the Eip4626 estimator still delegates the sentinel address to an inner estimator instead of short-circuiting, which could lead to failures in external price sources.
|
Converting this to a draft for now. |
There was a problem hiding this comment.
Code Review
This pull request implements short-circuiting logic for the native token and the ETH-flow sentinel address within the price estimation components. By identifying these tokens in CachingNativePriceEstimator and the Eip4626 estimator, the system now returns a 1:1 price ratio immediately, which prevents unnecessary RPC calls, downstream estimator overhead, and cache pollution. Corresponding tests have been updated to include the required native token configuration and to verify the new short-circuiting behavior. I have no feedback to provide.
POST /api/v1/quotefails with"NativeBuy estimator failed: No liquidity"wheneverbuy_token = BUY_ETH_ADDRESS (0xeee…eee), most likely becauseEip4626tries to detect vault tokens by callingasset()anddecimals()on a non-contract sentinel.The native token and the ETH-flow sentinel both price at 1 native by definition, so there's no point dispatching them to any downstream estimator.
Two short-circuits:
CachingNativePriceEstimator(primary): returnOk(1.0)immediately for either token, bypassing cache,Eip4626wrapper, and all underlying sources.Eip4626::estimate_native_price(secodary, safeguard): passBUY_ETH_ADDRESSthrough to the inner estimator without attempting vault detection RPC calls.