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].
| Field | Type | Notes |
|---|---|---|
owner | Pubkey | User |
state | SessionState | Created, Step1Complete, Step2Complete, Completed |
session_id | u64 | Client-supplied nonce |
target_rate | u64 | Minimum APY (9-decimal fixed point) |
duration | i64 | Lock duration in seconds |
amount | u64 | USDC deposited |
vault_shares | u64 | After Step 1 |
pt_received | u64 | After Step 2 |
yt_received | u64 | After Step 2 |
market, pool | Pubkey | The split-engine market + yield-AMM pool used |
bump | u8 |
Instructions
| Instruction | Purpose |
|---|---|
create_session | Open session (Created); stores target_rate, duration, amount, market, pool |
record_step1 | Verify vault_shares delivered; advance to Step1Complete |
record_step2 | Verify pt_received, yt_received; advance to Step2Complete |
record_step3 | Verify swap; compute achieved_rate; require achieved_rate ≥ target_rate; advance to Completed |
close_session | Close account, refund rent (any state) |
Rate formula (record_step3)
Givenpt_sold and underlying_received from the AMM swap:
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
OnlyIntentFulfilled 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.
Read next
Fixed-rate intents
Why the session exists.
Lock a fixed rate
Full code walkthrough.

