Skip to main content

Radius AI Agent Toolkit - Uniswap Plugin

This plugin enables AI agents to interact with the Uniswap protocol on Radius, allowing them to get token quotes and perform token swaps.

This package is part of the Radius AI Agent Toolkit, which provides tools for integrating AI agents with the Radius platform.

Installation

# Install this specific package
pip install radius-ai-agent-sdk-plugin-uniswap

# Required dependencies
pip install radius-ai-agent-sdk
pip install radius-ai-agent-sdk-wallet-evm
pip install radius-ai-agent-sdk-wallet-web3
pip install radius-ai-agent-sdk-plugin-erc20

Prerequisites

  • Python >=3.10
  • Uniswap API key - Get it from: Uniswap Hub
  • Radius wallet setup with a funded account

Configuration

Required environment variables:

  • UNISWAP_API_KEY: Your Uniswap API key
    • Format: 32-character string
    • Required for: Accessing Uniswap's API for quotes and swaps
  • UNISWAP_BASE_URL: Uniswap API base URL
    • Format: Full URL with protocol and version
    • Default: https://api.uniswap.org/v1

Usage

from radius_plugins.uniswap import uniswap, UniswapPluginOptions
from radius_wallets.evm import create_evm_wallet_client
from radius.utils.get_tools import get_on_chain_tools

# Create a Radius wallet
wallet = await create_evm_wallet_client({
    "rpc_url": "YOUR_RPC_URL",
    "private_key": "YOUR_PRIVATE_KEY"
})

# Initialize the Uniswap plugin
uniswap_plugin = uniswap(UniswapPluginOptions(
    base_url=os.environ.get("UNISWAP_BASE_URL", "https://api.uniswap.org/v1"),
    api_key=os.environ.get("UNISWAP_API_KEY")
))

# Create AI agent tools with the Uniswap plugin
tools = await get_on_chain_tools(wallet=wallet, plugins=[uniswap_plugin])

API Reference

uniswap(options)

Creates a new Uniswap plugin instance.

Parameters:

  • options.base_url (string): Uniswap API base URL
  • options.api_key (string): Your Uniswap API key

Returns:

  • A UniswapPlugin instance that can be used with AI agent frameworks

Provided Tools

The Uniswap plugin provides the following AI agent tools:

uniswap_check_approval

Checks if a wallet has enough token approval for a swap.

Parameters:

  • token (string): The token address to check approval for
  • amount (string): The amount to approve
  • walletAddress (string): The wallet address to check

Example:

try:
    approval_status = await check_approval_tool.execute({
        "token": "0x51fCe89b9f6D4c530698f181167043e1bB4abf89",  # USDC on Radius testnet
        "amount": "1000000",  # 1 USDC (6 decimals)
        "walletAddress": "0xefbf7a6fa61a1602eb7630c92e79e5b6e63909e1"
    })
    
    print("Approval status:", approval_status)
    # { "status": "approved", "txHash": "0x..." }
except Exception as error:
    print(f"Approval check failed: {error}")

uniswap_get_quote

Gets a quote for swapping tokens.

Parameters:

  • tokenIn (string): The address of the input token
  • tokenOut (string): The address of the output token
  • amount (string): The amount of tokenIn to swap
  • type (string): The type of swap ("EXACT_INPUT" or "EXACT_OUTPUT")
  • protocols (list[string]): The protocols to use for the swap (e.g., ["V3"])

Example:

try:
    quote_params = {
        "tokenIn": "0x9aeEa4f3025940dBdbf6863C7e16a23Ea95272a4",   # RADUSD on Radius testnet
        "tokenOut": "0x51fCe89b9f6D4c530698f181167043e1bB4abf89",  # USDC on Radius testnet
        "amount": "1000000000000000000",  # 1 RADUSD (18 decimals)
        "type": "EXACT_INPUT",
        "protocols": ["V3"]
    }
    
    quote = await get_quote_tool.execute(quote_params)
    print("Swap quote result:", quote)
    # Quote data including estimated gas, output amount, etc.
except Exception as error:
    print(f"Getting quote failed: {error}")

uniswap_swap_tokens

Executes a token swap on Uniswap.

Parameters:

  • tokenIn (string): The address of the input token
  • tokenOut (string): The address of the output token
  • amount (string): The amount of tokenIn to swap
  • type (string): The type of swap ("EXACT_INPUT" or "EXACT_OUTPUT")
  • protocols (list[string]): The protocols to use for the swap (e.g., ["V3"])

Example:

try:
    swap_params = {
        "tokenIn": "0x9aeEa4f3025940dBdbf6863C7e16a23Ea95272a4",   # RADUSD on Radius testnet
        "tokenOut": "0x51fCe89b9f6D4c530698f181167043e1bB4abf89",  # USDC on Radius testnet
        "amount": "1000000000000000000",  # 1 RADUSD (18 decimals)
        "type": "EXACT_INPUT",
        "protocols": ["V3"]
    }
    
    swap_result = await swap_tokens_tool.execute(swap_params)
    print("Swap transaction:", swap_result)
    # { "txHash": "0x..." }
except Exception as error:
    print(f"Swap failed: {error}")

Note on Tool Naming: The Uniswap plugin explicitly prefixes its tool names with uniswap_ in the implementation, which is consistent with the final available tool names.

Integration Examples

For a complete example integrating this plugin with LangChain, see:

Resources

Contributing

Please see the Contributing Guide for detailed information about contributing to this toolkit.

License

This project is licensed under the MIT License

Metadata

Release files for radius-ai-agent-sdk-plugin-uniswap 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for radius-ai-agent-sdk-plugin-uniswap 1.0.0
File Size Uploaded Provenance Actions
radius_ai_agent_sdk_plugin_uniswap-1.0.0.tar.gz 11.5 kB Without provenance Details for radius_ai_agent_sdk_plugin_uniswap-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for radius-ai-agent-sdk-plugin-uniswap 1.0.0
File Interpreter ABI Platform Actions
radius_ai_agent_sdk_plugin_uniswap-1.0.0-py3-none-any.whl Python 3 none any Details for radius_ai_agent_sdk_plugin_uniswap-1.0.0-py3-none-any.whl

Total release size: 19.2 kB

Release files / radius_ai_agent_sdk_plugin_uniswap-1.0.0.tar.gz

Download URL radius_ai_agent_sdk_plugin_uniswap-1.0.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2da54c1795275f7b762479b1f367726c0cfd85a008902765ec23dde08ea8bb3a
BLAKE2b-256 checksum
How to use checksums
ed11eeab82f3232d9f44ac9c01bc5a3d1b79da77f68293ff0d4245f35a842a56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / radius_ai_agent_sdk_plugin_uniswap-1.0.0-py3-none-any.whl

Download URL radius_ai_agent_sdk_plugin_uniswap-1.0.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd50974798154ba037e48370273991fb81ae1005fa0a52632f089121ab2f8a77
BLAKE2b-256 checksum
How to use checksums
2bfcaf7dc963476000f7dcac303cea05e486d256d8d9fd69954a0cb2ee52ecd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Security for radius-ai-agent-sdk-plugin-uniswap 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page