Routing

Candidate generation, cost function, privacy smearing, and selection.

Cost Function

C = λ₁·(price impact) + λ₂·(compute cost) + λ₃·(latency) + λ₄·(privacy cost)

  • Price impact from pool reserves or maker depth.
  • Compute cost approximates Solana CU and tx size.
  • Latency based on historical maker/adapter timings.
  • Privacy cost adds smearing/tie‑break randomness.

Candidate Generation

  • RFQ legs: top‑N makers by past hit‑rate and freshness.
  • AMM legs: k‑shortest paths over pool graph with fee/impact weights.
  • Hybrid: enumerate splits across RFQ and AMM within slice bounds.

Selection Algorithm

for each candidate route r in R:
  score[r] = C(r)
best = argmin(score)
// tie-break with privacy jitter
if |score - score[best]| < ε for some r:
  choose randomly weighted by exp(-score/τ)
        

Constraint Handling

  • Respect minOut, maxSlippage, and maxHops per profile.
  • Reject routes requiring unsupported compute/IX combos.
  • Ensure legs are atomic under router’s state machine.