1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! The **Encode** part of an `ExecutionStrategy` (ADR-025 D2) — the
//! `PayloadComposer` seam.
//!
//! A solver result becomes payload `bytes` for ONE execution contract. Rust
//! users implement [`PayloadComposer`] directly; Python users supply a callable
//! that `degenbot-python` lifts into this same trait (`PyPayloadComposer`).
//!
//! **Decoupling note (ADR-025-a).** The canonical `cmd_executor` composer
//! (`encode_cmd_stream` over `degenbot_executor::composers::ComposerInputs`) is
//! the *developer's* adapter — its `ComposerInputs` carries
//! `executor_address` / `pool_manager_address` / `weth_address` + a
//! cmd-specific `opts: EncodeOptions`, all wedged to the Vyper contract. This
//! seam's [`ComposerInputs`] deliberately carries **only the solver-driven
//! amounts** (`optimal_input`, `hop_outputs`, `consumed_inputs`) + a
//! decoupled generic [`ComposeOptions`] — no protocol addresses, no
//! cmd-opcode knobs. A user's Encode part names its own contract; the
//! default-adapter internals (cmd addresses/opts) stay on the other side of
//! the seam.
use ;
use PathInfo;
use Error;
/// Generic, adapter-agnostic encode knobs (ADR-025 D2/D5).
///
/// Deliberately **not** `degenbot_executor::composers::EncodeOptions` (which
/// carries `erc6909_profit` / `use_v4_batch` — cmd_executor-specific opcode
/// toggles). This is an empty, defaulted placeholder a foreign composer may
/// ignore; extend it if a future user contract needs its own encode-time
/// switches. Decoupled from `cmd_executor` opcodes by construction.
;
/// The per-path solver-driven amount bundle handed to [`PayloadComposer::compose`].
///
/// Mirrors the *shape* of `degenbot_executor::composers::ComposerInputs`
/// (the `optimal_input` / `hop_outputs` / `consumed_inputs` / `opts` fields)
/// while dropping the cmd-specific `executor/pool_manager/weth` addresses and
/// the cmd-opcode `EncodeOptions`, per ADR-025 D5.
///
/// Amounts are **integer fixed-point u128** (the `cmd_executor` int128
/// convention) — decimal place matters, so they are never floats. The
/// solve-result view ([`crate::SolveResult`]) carries the same amounts as
/// `U256`; the caller narrows via `fits_int128`-style checks when building
/// these, exactly as the default adapter does today.
/// Failure modes for the Encode part (payload composition).
/// A custom failure factory for user composers.
/// The **Encode** part of an `ExecutionStrategy`: solve result → payload
/// `bytes` for ONE execution contract (ADR-025 D2).
///
/// Rust users implement this trait; Python users supply a callable lifted into
/// it by `degenbot-python` (`PyPayloadComposer`). The canonical `cmd_executor`
/// encoder is the **default adapter** implementing this seam.
// Blanket so a caller can satisfy `&dyn PayloadComposer` with any sized impl.
/// A convenience `U256` → `u128` narrowing for composing payloads from the
/// solve-result view's amounts, mirroring the `cmd_executor` `fits_int128`
/// guard's non-negative acceptance.
///
/// Returns `None` when `value` does not fit in a signed 128-bit integer.