Start typing to search this publication.
BlazePhoenix logo BlazePhoenix
Open menu
BlazePhoenix logo

Subscribe to BlazePhoenix

Get new posts delivered straight to your inbox.

One SDK, two protocol versions: feature detection instead of version guessing

How the BlazePhoenix SDK handles a protocol that is changing under it: a feature table, honest errors, and calldata it will not forward blind.

BlazePhoenix avatar BlazePhoenix
3 min read

Protocols ship new versions. The code that integrates them is usually written once, against the version that existed that week.

The BlazePhoenix SDK treats that as a design problem. Protocol versions are deployments, not SDK versions: 1.0.0 is the generation the SDK resolved to on Base when I tested it, and 2.0.0 is the final Core / Hub / Solver / Quoter / Router set from the contract repository, which is pending. One client has to speak both, without the caller knowing which one answered. This is how it does that, with outputs from running it against Base.

Versions are selected, not assumed

new BlazePhoenix({ rpc, version: 'latest' });   // default: newest version registered on each chain
new BlazePhoenix({ rpc, version: '1' });        // stay on 1.x
await blaze.quote({ ...req, version: '2.0.0' }); // per call

I resolved the default deployment for Base on 29 October 2026:

const r = await blaze.resolveDeployment({ chain: 'base' });
// r.version === '1.0.0', r.source === 'embedded'
// Object.entries(r.features).filter(([, v]) => v)  →  []

No RPC is needed for that call: it only reads the registry. Now ask for the version that is pending:

not_deployed  no BlazePhoenix deployment matching version "2.0.0" on chain 8453 (deployed: 1.0.0)

The SDK says what it knows (the only deployed version is 1.0.0) and does not substitute one version for another silently.

Capabilities come from a function, not a guess

featuresOf(version) returns six booleans. For 1.0.0 all six are false. For 2.0.0 all six are true:

Capability

1.x

2.x

previewAndEncode: preview and Router calldata in one call

the SDK encodes it

the Quoter returns it, verified field by field

nativeEntry: native ETH in, no pre-wrap

wrap first with buildWrapTx

swapExactInNative

swapBest: solve and execute in the same transaction

not available

mode: 'best'

batchQuote: on-chain batch of quotes

parallel previews

chunked on-chain

executionProof: quoted vs realised vs floor on every fill

not available

ExecutionProof event

introspection

not available

available

Calling code branches on features, not on a version string it parsed itself. When a third version appears, the table changes in one place.

Honest refusals

The first place this shows up is native ETH. I tried to build a swap that sends ETH directly on Base:

unsupported_by_version  native ETH input needs a 2.x Router (this deployment is 1.0.0):
                        wrap first with buildWrapTx(chain, amount), then swap WETH

Not a revert and not a transaction that fails after you pay gas. The error names the cause, the version and the workaround. (A quote with tokenIn: 'ETH' does work on 1.x: it reports nativeIn: true. It is the build step that needs the wrap.)

Where the versions really differ: the calldata

On 1.x, the SDK builds the Router calldata itself (encodedBy: 'sdk' in the plan; that is what I got). On 2.x, Quoter.previewAndEncode returns the preview and the exact swapExactIn bytes.

The README is direct about what that is worth. The Quoter's own source says "a compromised Quoter fools the interface", so the SDK never forwards those bytes blind. It decodes them with the Router ABI and throws calldata_mismatch unless the amount, recipient, deadline, the route (identical to the previewed one and connecting tokenIn to tokenOut) and a minimum at least the on-chain floor all match what you asked. Your slippage setting can only tighten that minimum.

A version that gives the SDK more power over the transaction also gives it a stricter check on the result. That is the right direction for a client that holds no keys.

A practical rule

If you integrate any protocol that versions its contracts:

  1. Select the version explicitly in production, and log which one answered.

  2. Branch on capabilities, not on strings.

  3. Make "this version cannot do that" a typed error with the workaround in the message.

  4. Verify what a newer version hands you instead of trusting it because it is newer.

Status

BlazePhoenix is pre-launch. The 2.0.0 deployments are pending, and an independent external audit is scheduled before launch. Nothing here is advice. Read the contracts: the source is public under the Business Source License 1.1.


SDK: npm i @blazephoenix/sdk · blazephoenix.xyz · MCP server: https://blazephoenix.xyz/mcp · docs for models: llms.txt

Subscribe to BlazePhoenix