Skip to main content

encode_cmd_stream

Function encode_cmd_stream 

Source
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