Skip to main content
intent-router is a thin coordinator. It does not execute trades, it records each step the user performs across delta-vault, split-engine, and yield-amm, and verifies the end-to-end achieved rate meets the user’s target.

Accounts

IntentSession

["session", owner, session_id_le].

Instructions

Rate formula (record_step3)

Given pt_sold and underlying_received from the AMM swap: discount=pt_soldunderlying_received\text{discount} = \text{pt\_sold} - \text{underlying\_received} achieved_rate=discount×ONE×SECONDS_PER_YEARunderlying_received×duration\text{achieved\_rate} = \frac{\text{discount} \times \text{ONE} \times \text{SECONDS\_PER\_YEAR}}{\text{underlying\_received} \times \text{duration}} If achieved_rate < target_rate, the instruction errors with TargetRateNotAchievable and the session stays at Step2Complete. The user’s PT and YT tokens are untouched, they can unwind manually.

Events

Only IntentFulfilled is emitted as an Anchor #[event] (at record_step3, carrying owner, session_id, amount, target_rate, achieved_rate, pt_received, yt_received). Session creation and the interim steps log progress via msg! and by advancing the session account’s state field.

Errors

InvalidSessionState, TargetRateNotAchievable, TargetRateNotAchieved, SessionCompleted, NotSessionOwner, MathOverflow, ZeroAmount, NoSharesReceived, NoTokensReceived, SlippageExceeded, PtBalanceMismatch, UnderlyingBalanceInsufficient, NoSwapPerformed, NegativeDiscount, InvalidDuration.

Fixed-rate intents

Why the session exists.

Lock a fixed rate

Full code walkthrough.