Quoting the Solidly curve on-chain: Newton's method where the naive seed lies

Known formally as The Solidly Solver in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · updated 2026-07-27 · 8 min · written from the deployed bytecode

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

Abstract in 15 languages · resumo · resumen · 摘要 · 要旨 · ملخص

EnglishThe Solidly stable curve k = x3y + xy3 has no clean closed form, so its output is found by iteration. The naive constant-sum seed silently saturates on lopsided pools; a Newton method seeded at the opposite reserve with a half-step clamp matches the pool's own getAmountOut within 0.5%, computed on-chain.

PortuguêsA curva estável Solidly k = x3y + xy3 não tem forma fechada limpa, por isso a saída é encontrada por iteração. A semente ingénua de soma-constante satura em silêncio em pools desequilibradas; um método de Newton semeado na reserva oposta com meio-passo limitado iguala o getAmountOut da própria pool a 0,5%, calculado on-chain.

EspañolLa curva estable Solidly k = x3y + xy3 no tiene forma cerrada limpia, así que su salida se halla por iteración. La semilla ingenua de suma constante se satura en silencio en pools desequilibradas; un método de Newton sembrado en la reserva opuesta con medio paso acotado iguala el getAmountOut de la propia pool al 0,5%, calculado on-chain.

FrançaisLa courbe stable Solidly k = x3y + xy3 n'a pas de forme close nette ; sa sortie se trouve par itération. La graine naïve à somme constante sature en silence sur les pools déséquilibrées ; une méthode de Newton amorcée sur la réserve opposée avec demi-pas borné égale le getAmountOut de la pool à 0,5 %, calculé on-chain.

DeutschDie Solidly-Stable-Kurve k = x3y + xy3 hat keine saubere geschlossene Form, ihr Output wird iterativ gefunden. Der naive Konstant-Summen-Seed saturiert bei schiefen Pools still; ein Newton-Verfahren, an der Gegenreserve geseedet mit Halbschritt-Klemme, trifft das getAmountOut des Pools auf 0,5 %, on-chain berechnet.

РусскийУ стабильной кривой Solidly k = x3y + xy3 нет чистой замкнутой формы, поэтому вывод ищут итерацией. Наивный старт с постоянной суммой молча насыщается на перекошенных пулах; метод Ньютона со стартом на противоположном резерве и полушаговым зажимом совпадает с собственным getAmountOut пула в пределах 0,5%, вычислено он-чейн.

TürkçeSolidly stabil eğrisi k = x3y + xy3 temiz kapalı forma sahip değildir; çıktısı iterasyonla bulunur. Naif sabit-toplam tohumu dengesiz havuzlarda sessizce doyar; karşı rezervde tohumlanan ve yarım adım kıskacı olan Newton yöntemi, havuzun kendi getAmountOut'una %0,5 içinde uyar, zincir üstünde hesaplanır.

العربيةمنحنى Solidly المستقر k = x3y + xy3 ليس له صيغة مغلقة نظيفة، فيُوجد ناتجه بالتكرار. البذرة الساذجة ذات المجموع الثابت تتشبّع بصمت في المجمّعات غير المتوازنة؛ طريقة نيوتن المبذورة عند الاحتياطي المقابل مع تقييد نصف الخطوة تطابق getAmountOut للمجمّع ضمن 0.5%، محسوبة على السلسلة.

हिन्दीSolidly स्थिर वक्र k = x3y + xy3 का साफ बंद-रूप नहीं है, इसलिए इसका आउटपुट पुनरावृत्ति से निकाला जाता है। भोला स्थिर-योग बीज असंतुलित पूल पर चुपचाप संतृप्त हो जाता है; विपरीत रिज़र्व पर बीजित और आधे-कदम की सीमा वाला न्यूटन तरीका पूल के अपने getAmountOut से 0.5% के भीतर मिलता है, ऑन-चेन गणना।

日本語Solidlyの安定曲線 k = x3y + xy3 にはきれいな閉形式がなく、出力は反復で求めます。素朴な定和シードは偏ったプールで静かに飽和します。反対側リザーブで初期化し半ステップでクランプするニュートン法は、プール自身のgetAmountOutに0.5%以内で一致し、オンチェーンで計算されます。

中文Solidly 稳定曲线 k = x3y + xy3 没有干净的闭式解,其输出靠迭代求得。朴素的恒和初值在失衡池上会悄然饱和;以对侧储备为初值、带半步钳制的牛顿法与池自身的 getAmountOut 相差不超过 0.5%,且在链上计算。

한국어Solidly 안정 곡선 k = x3y + xy3 은 깔끔한 닫힌 형태가 없어 출력은 반복으로 구합니다. 순진한 상수합 시드는 치우친 풀에서 조용히 포화됩니다. 반대 예비금에서 시드하고 반보 클램프를 둔 뉴턴 방법은 풀 자체의 getAmountOut과 0.5% 이내로 일치하며, 온체인에서 계산됩니다.

Bahasa IndonesiaKurva stabil Solidly k = x3y + xy3 tak punya bentuk tertutup rapi, jadi keluarannya dicari lewat iterasi. Benih naif jumlah-konstan diam-diam jenuh pada pool timpang; metode Newton yang dibenihkan di cadangan berlawanan dengan klem setengah langkah cocok dengan getAmountOut pool dalam 0,5%, dihitung on-chain.

বাংলাSolidly স্থিতিশীল বক্ররেখা k = x3y + xy3-এর পরিষ্কার বদ্ধ রূপ নেই, তাই এর আউটপুট পুনরাবৃত্তিতে বের করা হয়। সরল ধ্রুব-যোগ বীজ ভারসাম্যহীন পুলে নীরবে সম্পৃক্ত হয়; বিপরীত রিজার্ভে বীজিত ও অর্ধ-ধাপ ক্ল্যাম্পযুক্ত নিউটন পদ্ধতি পুলের নিজের getAmountOut-এর ০.৫% এর মধ্যে মেলে, অন-চেইনে গণিত।

FilipinoAng Solidly stable curve k = x3y + xy3 ay walang malinis na closed form, kaya ang output ay hinahanap sa iterasyon. Ang naive constant-sum seed ay tahimik na nasa-saturate sa hindi-balanseng pool; ang Newton method na sinimulan sa kabilang reserve na may half-step clamp ay tumutugma sa getAmountOut ng pool sa loob ng 0.5%, kinakalkula on-chain.

Most automated market makers have a clean closed form: put an amount in, a single expression gives the amount out. Constant-product pools do (x*y = k). Concentrated-liquidity pools do, per tick. The Solidly family — the ve(3,3) stable curve behind Velodrome, Aerodrome and their forks — does not. Its invariant is a quartic, k = x3y + xy3, chosen because it stays nearly flat for assets that should trade near parity and only bends sharply at the extremes. That shape is exactly what a stablecoin pair wants, and exactly what has no tidy inverse.

So the output has to be found by iteration: guess an answer, measure how wrong the invariant is, correct, repeat. Do that carelessly and you get a number that looks plausible and is quietly wrong — which, for a quote that must equal execution, is the one outcome we cannot ship.

Why the obvious starting guess fails

The intuitive way to seed the iteration is to treat the pool as a constant-sum swap — assume one token in gives roughly one token out, since the whole point of a stable pair is near-parity — and refine from there. On a balanced pool near the middle of the curve, that seed is close and the iteration converges in a step or two.

The trap is at the edges. When the pool is lopsided, or the trade is large relative to depth, the constant-sum seed lands in a region where the curve has bent hard, and the naive iteration SILENTLY SATURATES: it stops moving toward the true answer and returns a value that is confidently, invisibly off. Nothing errors. The quote is simply wrong, and it is wrong in exactly the situation — a large or imbalanced trade — where being wrong costs the most.

The fix: seed at the opposite reserve, clamp the step

BlazePhoenix seeds Newton's method at the OPPOSITE reserve rather than at the constant-sum guess. That places the first estimate on the correct side of the curve's bend, so the iteration walks toward the true root instead of away from it, even when the pool is far from balance.

Newton's method can also overshoot — a step too large jumps past the root and oscillates. So each step is governed by a bidirectional half-step clamp: the correction is bounded in both directions, which trades a little speed for the guarantee that the iteration tightens monotonically rather than ringing. The result is an output that matches the pool's own live getAmountOut within 0.5%, across the whole curve, including the lopsided region where the naive seed gave up.

Two supporting disciplines make that robust in production: decimals are normalised before the maths so a 6-decimal token and an 18-decimal token are compared on the same scale, and the final figure is validated with an explicit under-quote margin — when the numerical answer is uncertain, the protocol quotes slightly LOW rather than slightly high, so the realised fill can only beat the quote, never miss it. That is the Fail-Closed rule applied to arithmetic: when unsure, promise less.

Why solve it on-chain at all

An off-chain aggregator would compute this on a server and send you the result. The reason to do it inside the contract is the same reason it runs everywhere else in this protocol: the number you are quoted and the number the trade realises are then produced by the same code over the same block. A server's Solidly solver can drift from the pool's actual behaviour — different rounding, a stale reserve read, a subtly different iteration — and you would have no way to prove the gap. On-chain, the quote is a simulation of the very computation that will settle.

And where the venue's own contract exposes the truth directly, the protocol asks it rather than reproducing it: Curve's get_dy and a Solidly pool's own getAmountOut are called on the read path, because the same bytecode that will enforce the invariant at execution is the most honest source of the number. The solver above is for the cases where that call is unavailable or too costly on the scoring path — and even then, it is validated against the pool's own answer.

Do not trust this page — reproduce it

Every claim above is checkable against the chain. Start here:

Call a Solidly/Aerodrome pool's own getAmountOut for a given input, then compare it against the quote our Quoter returns for the same pair and size — the two match within the under-quote margin, which is the claim of this article

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

Share this article · join the discussion

Related engineering