pub fn encode_cmd_stream(
ctx: &EncodeContext,
req: &EncodeRequest,
) -> Option<Vec<u8>>Expand description
Encode an arbitrage path as a cmd_executor command stream.
Produces a bytes payload for execute(commands) on the cmd_executor
contract. Uses compact command encoding (V2_SWAP_COMPACT, V2_SWAP_CALC,
V4_SWAP_COMPACT, …) with an address table for minimal calldata size.
The intake contract is the pair EncodeContext (session-scoped
deployment addresses) + EncodeRequest (per path: the path + the
solver’s amount triple + the declared axes — ADR-033). The CL
overfeed-clamp invariant attaches to the request (consumed_inputs[i]
is the executable input to hop i) — it is owned where the request is
built, not re-derived here. Bribes never ride the stream: the caller
passes them through pack_config at the call site.
Returns None if encoding declines for this path type. A validator
Reject (a Plan was built but violated the ledger invariants) is fatal
by contract (ADR-030) — it panics rather than folding into None.
§Path-type routing
- all-V2 hops (≥2):
crate::grammar_shape::derive_all_v2— the Plan + validator path (KO5NNB cutover) - every other 2/3-hop mix: the shape-class walker
(
crate::grammar_shape::derive_shape)