feat: AI agent trade confinement via slippage oracle + ProgramExec - #142
Draft
zmanian wants to merge 8 commits into
Draft
feat: AI agent trade confinement via slippage oracle + ProgramExec#142zmanian wants to merge 8 commits into
zmanian wants to merge 8 commits into
Conversation
Add a new on-chain Solana program for validating trade parameters (slippage ratios) as part of AI agent confinement. Uses pinocchio 0.9 consistent with the rest of the workspace. Includes stub processor with VALIDATE_TRADE discriminator and error types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unit tests for the existing new_program_exec, new_program_exec_with_ix_index, and build_program_exec_authority_payload functions. Tests verify that the instructions sysvar account is correctly included in the transaction accounts and that the authority payload is correctly formatted for both the default (current_index - 1) and explicit target instruction index cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Exec + limits Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a high-level builder that produces ProgramExec/ProgramExecSession authority data and ClientAction permissions for trade-confined agent roles with SOL/token spending limits and program access controls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add comment explaining why oracle doesn't validate Swig accounts - Document reserved InvalidSwigAccount error variant - Clarify session_max_length is not encoded in authority_data - Add edge case tests: min_bps=0 and input_amount=0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
slippage-oracleon-chain program that validates trade input/output ratios using basis points, enabling ratio-based slippage enforcement before SwigSignV2executionAgentRoleConfigSDK helper that composes ProgramExec authority + spending limits + program permissions into a single builder for confined AI agent rolesSignV2Instruction::new_program_execunit tests for the interface constructorDesign
Three-layer confinement for AI agents doing trades:
min_output_amount >= (input_amount * min_bps) / 10000before Swig executesTokenLimit/SolLimitcaps absolute lossThe agent holds a
ProgramExecauthority bound to the oracle. It must call the oracle first (which validates trade parameters), and that successful call authenticates the subsequentSignV2.Test Plan
cargo build-sbf)🤖 Generated with Claude Code