Implement the scheduler and the cron job in any of the previous challenges.
TukTuk is integrated into the escrow-litesvm program as an auto-refund scheduler. When a maker creates an escrow, they can schedule a TukTuk task that automatically refunds the escrowed tokens if no taker fulfills the trade by the expiry time.
auto_refund — Permissionless refund executed by TukTuk crankers
- No maker signature required (TukTuk crankers call this on behalf of the maker)
- Graceful no-op if the escrow was already taken or manually refunded
- Transfers vault tokens back to maker and closes both vault and escrow accounts
schedule_refund — Maker-signed instruction to schedule the auto-refund
- CPIs into TukTuk's
queue_task_v0to register a time-triggered task - Compiles the
auto_refundinstruction into TukTuk's transaction format - Accepts an
expiry_timestampto set when the refund should execute
programs/anchor-escrow/src/instructions/auto_refund.rsprograms/anchor-escrow/src/instructions/schedule_refund.rs
All 7 tests pass including 2 new auto-refund tests:
test_auto_refund_success— make → auto_refund → verify tokens returned, vault + escrow closedtest_auto_refund_already_taken_noop— make → take → auto_refund → verify graceful no-op
cd ../escrow-litesvm
cargo test -p anchor-escrow -- --nocapture