Skip to main content

Module split_primitives

Module split_primitives 

Source
Expand description

Shared machinery for algorithms that divide an order across several paths.

Structs§

HopDescriptor
One leg of a path: the pool, and the direction it trades.
MarketOverrides
Component state overrides for passing degraded states to find_single_route.
PathAllocation
A fully-simulated path allocation.
SimResult
Output of simulating one path at a given input amount.
SimulatedHop
A HopDescriptor paired with its simulation result. Used in PathAllocation::hops where the solving algorithm has already computed per-hop outputs and gas.

Enums§

SplitMathError
Errors from split-routing math utilities.

Functions§

build_post_swap_overrides
Builds post-swap component states after all paths in a split-route solution have been executed.
build_split_route
Assembles a Route from split-route path allocations with shared-hop deduplication.
compute_marginal_price_product
Product of spot prices along a path — approximates the exchange rate at near-zero input.
evaluate_total_output
Simulates all paths at their current fractions and returns (total_amount_out, total_gas). paths[i] corresponds to fractions[i].
fractions_to_amounts
Convert fractions (summing to 1.0) into BigUint amounts summing exactly to total.
golden_section_search
Find the x in [lo, hi] that maximises f(x) using golden-section search.
normalize_fractions
Normalize a slice of fractions so they sum to 1.0.
simulate_path
Simulates a path hop-by-hop, threading output of each hop as input to the next.
split_amount
Split total into (part, remainder) where part ≈ total * fraction.