feat(agentkit): Add Uniswap V3 Action Provider for Base Network#771
feat(agentkit): Add Uniswap V3 Action Provider for Base Network#771Thedongraphix wants to merge 1 commit intocoinbase:mainfrom
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.
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.
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.
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!