pub enum PlanStep {
Show 18 variants
FlashSwap {Show 14 fields
pool_idx: u8,
pool_addr: Address,
protocol: Prot,
zfo: bool,
fee: u16,
out_currency: Address,
out_amount: u128,
in_currency: Address,
in_amount: u128,
recipient_idx: u8,
recipient_pool_addr: Option<Address>,
recipient_pool_repays: bool,
auto_repay: bool,
callback: Plan,
},
Erc20Transfer {
token_idx: u8,
token_addr: Address,
recipient_idx: u8,
amount: u128,
seeds_pool: Option<Address>,
repays_flash: Option<Address>,
},
V2SwapCalc {
pool_idx: u8,
pool_addr: Address,
zfo: bool,
recipient_idx: u8,
fee: u16,
out_currency: Address,
out_amount: u128,
recipient_pool_addr: Option<Address>,
recipient_repays: bool,
},
V2SwapDirect {
pool_idx: u8,
pool_addr: Address,
zfo: bool,
out_amount: u128,
recipient_idx: u8,
out_currency: Address,
recipient_pool_addr: Option<Address>,
recipient_repays: bool,
},
SelfFund {
currency: Address,
amount: u128,
},
V4Unlock {
inner: Plan,
pool_manager_idx: u8,
},
V4Swap {
c0_idx: u8,
c1_idx: u8,
fee: u16,
tick_spacing: i16,
hooks_idx: u8,
zfo: bool,
amount: u128,
in_currency: Address,
in_amount: u128,
out_currency: Address,
out_amount: u128,
},
V4TakeDelta {
currency_idx: u8,
currency_addr: Address,
recipient_idx: u8,
seeds_pool: Option<Address>,
},
V4SettleAll,
V4TakeCompact {
currency_idx: u8,
currency_addr: Address,
recipient_idx: u8,
amount: u128,
seeds_pool: Option<Address>,
repays_flash: Option<Address>,
},
V4SettleDelta {
currency_idx: u8,
currency_addr: Address,
},
V4Sync {
currency_idx: u8,
currency_addr: Address,
},
V4Settle {
currency_addr: Address,
amount: u128,
},
NativeTransfer {
amount: u128,
},
WethWithdraw {
weth_idx: u8,
weth_addr: Address,
amount: u128,
},
WethDeposit {
weth_idx: u8,
weth_addr: Address,
amount: u128,
},
V4Batch {
entries: Vec<V4BatchSwap>,
open_weth: bool,
},
V4Mint {
currency_idx: u8,
currency_addr: Address,
recipient_idx: u8,
amount: u128,
},
}Expand description
A single node of the execution-ordered, callback-nested command Plan. The
nesting IS execution order: a FlashSwap’s callback fires when the swap
runs (depth-first); a V4Unlock’s inner runs in the unlock callback.
Each leaf carries BOTH the resolved address-table index (for the byte
encoder) and the currency/pool address (for the LedgerOp projection) —
Checkpoint 1 keeps this minimal; a later refactor may separate
address-collection from emission if it clarifies (see BP7KIR body).
Variants§
FlashSwap
A V2 or V3 *_SWAP_COMPACT flash — the pool credits out_currency to
the executor and is owed in_currency within callback (the bytes the
flash’s callback payload carries, fired when the swap runs).
Fields
recipient_pool_addr: Option<Address>The recipient pool’s address when the flash’s OUTPUT directly seeds
a pool (e.g. a V3 flash paying the terminal V2 — v4_v3_v2).
None for a →SELF output. Bytes encode recipient_idx; this is
ledger-only (the output seeds the pool’s pair-handoff instead of
crediting the executor).
recipient_pool_repays: boolWhether a pool-recipient flash output REPAYS that pool’s flash debt
(a V3→V3 repayment — v4_v3_v3) vs seeds it (a V3 flash feeding the
terminal V2 — v4_v3_v2).
Erc20Transfer
An ERC20_TRANSFER(token→recipient, amount) from the executor. Doubles
as flash-repayment and pair-seed by recipient role (DS4OQD finding 5):
when the recipient is a V2 pair being pre-funded, seeds_pool carries
that pair’s address so the projection also credits the pair-handoff
ledger (a following V2SwapCalc consumes it).
Fields
V2SwapCalc
A V2_SWAP_CALC(pool, zfo, recipient, fee) — the terminal-V2 pre-fund
rule (2PT5HH): swap from whatever the feeder delivered to the pair,
never an exact-out V2_SWAP_COMPACT (over-drains 1 wei → UniswapV2: K).
Consumes the pair-handoff credit seeded by a prior Erc20Transfer.
Fields
out_currency: AddressThe swap’s output currency + amount credited to the executor (the profit / downstream repayment source). Option (B): swaps credit their output so the executor ledger fully accounts.
recipient_pool_addr: Option<Address>The recipient pool’s address when the calc pays a mid pool
(ledger-only — the bytes encode recipient_idx). The projection
routes the output: Some(pool) seeds that pool’s pair-handoff (no
executor credit); None + recipient = SELF keeps the executor
credit; None + recipient = PM pays into the PM. 2-hop families
always pass None (SELF recipients) — the byte-identical case.
V2SwapDirect
An exact-out V2_SWAP_DIRECT(pool, zfo, out_amount, recipient) — the
V2 handoff that pays a specific out_amount to recipient (a next
pool or the executor). Distinct from PlanStep::V2SwapCalc
(exact-in) and PlanStep::FlashSwap (credit-the-executor). Ledger:
consumes the donor pool’s seeded H[pool]; the output goes to the
recipient — SELF credits the executor, a pool seeds that pool
(recipient_pool_addr, ledger-only).
Fields
SelfFund
A self-fund seed (ADR-029 FundingSource::SelfFund) — the executor holds
amount of currency as entry capital before the stream. Not a command;
a stream precondition the validator credits so SelfFund families’ flash
repayments validate. The encoder emits nothing for it.
V4Unlock
A V4_UNLOCK(inner) — the PM callback scope. inner runs inside the
unlock; at its end the master V4 invariant fires: every touched PM delta
must net to zero (V4UnlockEnd).
V4Swap
A V4_SWAP_COMPACT(c0, c1, fee, ts, hooks, zfo, amount) — creates
PM[in] debt and PM[out] credit (both legs modeled so net-zero is
checkable).
Fields
V4TakeDelta
V4_TAKE_DELTA(cur→rcp) — takes the entire positive PM[cur] delta to
rcp (the profit capture; debits PM credit). When the recipient is a
V2 pool (seeds_pool), the taken credit seeds that pool’s pair-handoff
(the 2PT5HH terminal-V2 rule across the V4 boundary — v3_v4_v2).
Fields
V4SettleAll
V4_SETTLE_ALL — auto-settle every touched PM currency to 0.
V4TakeCompact
V4_TAKE_COMPACT(cur→rcp, amount) — take a specific amount of cur’s
PM credit to rcp (the boundary-take: V4 output leaves the PM to feed
a V2/V3 hop or to capture profit). Debits PM (D0 credit-before-debit).
The recipient role determines the second ledger effect (the
cross-ledger move, mirroring Erc20Transfer’s seeds_pool/repays_flash):
recipient_idx == SENTINEL_SELF credits the executor Erc20[cur]
(the token arrives at the executor); seeds_pool = Some(pool) credits
PairHandoff[pool] (the token seeds a V2 pair directly, PM→pool, never
touching executor Erc20).
Fields
V4SettleDelta
V4_SETTLE_DELTA(cur) — auto-settle one currency’s PM delta to 0.
V4Sync
V4_SYNC(cur) — sync the PM’s internal balance for cur (a balance-sync
primitive, delta-neutral: it carries no PM-delta effect; the actual
delta application comes from a following V4Settle). Used in the
boundary-seed pattern (executor pays cur into the PM via an
Erc20Transfer(cur→PM) then V4Settle) to settle a V4 input debt.
V4Settle
V4_SETTLE — the executor pays amount of currency into the PM,
cancelling debt (PM[currency] += amount; the executor’s Erc20
debit happens at the preceding Erc20Transfer(cur→PM)). Used after a
V4Sync + Erc20Transfer boundary-seed. The byte form is the no-arg
V4_SETTLE; the IR carries currency/amount explicitly so the
validator knows which delta to apply.
NativeTransfer
NATIVE_TRANSFER(amount) — the executor→PM native pay-in leg of a
native settle. Ledger-only (encodes to nothing, like
SelfFund): on-chain the native flows as msg.value on the
V4_SETTLE* call, so there is no separate byte instruction. Modeled
explicitly so the executor’s native debit is a separate observable op
(a missing settle half is caught by PM-net-zero, not absorbed).
WethWithdraw
WETH_WITHDRAW(amount) — unwrap WETH to native (the source of native
for a NativeTransfer PM pay-in, or to seed a native V4 input).
WethDeposit
WETH_DEPOSIT(amount) — wrap native to WETH (the native came from a
V4TakeCompact(native→SELF)).
V4Batch
V4_BATCH (0x42) / V4_BATCH_OPEN_WETH (0x43) — a bundled PM extcall
of up to 8 swaps (encoders::enc_v4_batch /
encoders::enc_v4_batch_open_weth). Ledger-equivalent to the constituent
V4Swaps: each entry applies the same PM[in] debt / PM[out]
credit. Asymmetry vs a plain V4Swap sequence: the 0x42 contract
auto-settles any positive native ETH and WETH delta at the batch’s end
(an implicit V4_TAKE_DELTA(→SELF) for those two currencies). For the
WETH-only slice (the executor’s proven path) the derive therefore omits
the terminal V4TakeDelta when use_v4_batch is set — the batch already
captured the WETH profit. The Plan mirrors this: the per-entry ledger
deltas leave a positive PM[weth] that the trailing V4SettleAll
zeroes (the gate’s master invariant fires at V4UnlockEnd — the profit
capture is modelled by the contract, not by a Take op here).
open_weth: false = 0x42 (full tail-settle); true = 0x43 — the
WETH tail-settle is SKIPPED, so the positive PM[weth] delta is left
OPEN for a trailing V4Mint (ERC6909 capture, TGUZCT/SW42JA). The 0x43
projection additionally emits the LedgerOp::OpenWethPairing gate op,
which requires a WETH Mint before V4UnlockEnd.
V4Mint
V4_MINT_COMPACT(cur→rcp, amount) — convert a positive PM[cur]
delta into an ERC6909 claim for rcp (BP7KIR erc6909_profit opt).
Ledger-equivalent to PlanStep::V4TakeDelta: debits PM[cur] by
amount (requires credit-before-debit, D0). The asset stays inside
the PM as a claim rather than a physical transfer — distinct from
V4TakeDelta on-chain, identical for the gate’s safety invariants.
Trait Implementations§
impl StructuralPartialEq for PlanStep
Auto Trait Implementations§
impl Freeze for PlanStep
impl RefUnwindSafe for PlanStep
impl Send for PlanStep
impl Sync for PlanStep
impl Unpin for PlanStep
impl UnsafeUnpin for PlanStep
impl UnwindSafe for PlanStep
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more