-
Notifications
You must be signed in to change notification settings - Fork 578
feat(agentkit): Add Uniswap V3 Action Provider for Base Network #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(agentkit): Add Uniswap V3 Action Provider for Base Network #771
Conversation
🟡 Heimdall Review Status
|
|
Hi @Thedongraphix, thanks for your contribution! Looks pretty good, a few initial comments below.
|
| */ | ||
| export const SwapSchema = z | ||
| .object({ | ||
| tokenIn: z.string().describe("The contract address of the token to swap from"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to use .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format"), for all contract addresses
| import { uniswapActionProvider } from "../uniswapActionProvider"; | ||
|
|
||
| describe("UniswapActionProvider", () => { | ||
| const actionProvider = uniswapActionProvider(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for the logic of each action. As a guide you can have a look at eg https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/action-providers/flaunch/flaunchActionProvider.test.ts that also tests some swap actions
|
It would be good to include the result of some manual end-to-end testing in the PR description. Add the new uniswap action provider to one of the chatbot examples, run it and copy your prompts + output for quote and swap queries here. Please keep changes to the chatbot examples local and do not commit them. |
| /** | ||
| * Uniswap V3 contract addresses for Base networks | ||
| */ | ||
| export const UNISWAP_ADDRESSES: Record<string, Record<string, string>> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: could be extended to a few more chains like ethereum, optimism, arbitrum, polygon (https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/network/network.ts)
You can find the contract addresses here:
https://docs.uniswap.org/contracts/v3/reference/deployments/
Summary
This PR introduces a new Uniswap V3 Action Provider for the Base network, enabling AI agents to perform token swaps on one of the most popular DEXs. This addresses a fundamental need for onchain agents and directly responds to functionality mentioned in the project's WISHLIST.md.
Motivation
Token swaps are a core primitive for DeFi operations. Every onchain agent needs the ability to exchange tokens, whether for:
This provider makes it simple for agents to get quotes and execute swaps with a single tool call.
Key Features
🔄 Two Core Actions
get_quote: Get swap quotes without executing (for planning & price discovery)swap: Execute token swaps with comprehensive safety features🛡️ Built-in Safety & UX
🌐 Network Support
Implementation Details
Files Added
typescript/agentkit/src/action-providers/uniswap/
├── constants.ts # Contract addresses & ABIs
├── schemas.ts # Input validation schemas
├── uniswapActionProvider.ts # Main implementation
├── index.ts # Exports
└── tests/
└── uniswapActionProvider.test.ts # Unit tests
Architecture
Usage Example
Testing
npm run build)Value Proposition
This provider:
Breaking Changes
None - this is a purely additive change.
Additional Context
This implementation focuses on the most commonly used Uniswap V3 functionality while maintaining simplicity and safety. Future enhancements could include:
Ready to empower AI agents with seamless token swapping on Base!