Catalog PyPI
Back to packageRELEASE DETAILS

0.1.1

PyPI

a2a-swap-langchain

LangChain and CrewAI tools for A2A-Swap — autonomous token swaps and liquidity on Solana

agentaiammautonomouscrewaidefilangchainsolanaswap
Published23 Feb 2026
Direct dependencies6
Transitive dependenciesNot calculated

README

Version 0.1.1 documentation

a2a-swap-langchain

LangChain and CrewAI tools for A2A-Swap — the constant-product AMM built for autonomous AI agents on Solana.

Installation

pip install a2a-swap-langchain          # LangChain only
pip install "a2a-swap-langchain[crewai]" # + CrewAI support

Also install the CLI (required — tools call it as a subprocess):

cargo install a2a-swap-cli

Configuration

Set environment variables (or pass them to get_tools()):

export A2A_KEYPAIR=~/.config/solana/id.json
export A2A_RPC_URL=https://api.mainnet-beta.solana.com  # optional, mainnet is default

LangChain

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from a2a_swap_langchain import get_tools

tools = get_tools()  # reads A2A_KEYPAIR / A2A_RPC_URL from env
llm   = ChatOpenAI(model="gpt-4o")

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a DeFi agent on Solana. Use A2A-Swap to trade and manage liquidity."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

agent    = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

executor.invoke({"input": "What is the current SOL/USDC price on A2A-Swap?"})
executor.invoke({"input": "Simulate swapping 1 SOL for USDC and show the fee breakdown."})
executor.invoke({"input": "How much fees have I earned on my LP positions?"})

CrewAI

from crewai import Agent, Crew, Task
from a2a_swap_langchain import get_tools, A2ASimulateTool, A2APoolInfoTool

# All tools work in CrewAI without any wrapping
trader = Agent(
    role="DeFi Trader",
    goal="Execute optimal swaps on A2A-Swap",
    backstory="Autonomous Solana trading agent.",
    tools=get_tools(),
)

task = Task(
    description="Simulate selling 0.5 SOL for USDC, then execute if price impact < 1%.",
    expected_output="Simulation result and optional transaction signature.",
    agent=trader,
)

Crew(agents=[trader], tasks=[task]).kickoff()

Available Tools

ToolNameWallet needed?Description
A2ASimulateToola2a_simulate_swapNoPreview a swap: fees, estimated out, price impact
A2ASwapToola2a_swapYesExecute an atomic token swap
A2AProvideLiquidityToola2a_provide_liquidityYesDeposit tokens, earn LP shares and fees
A2APoolInfoToola2a_pool_infoNoRead pool reserves, spot price, fee rate
A2AMyFeesToola2a_my_feesYes (for identity)Check accrued trading fees across all positions

Individual tool usage

from a2a_swap_langchain import A2ASimulateTool, A2ASwapTool

# Read-only — no wallet
sim = A2ASimulateTool()
print(sim.run({"mint_in": "SOL", "mint_out": "USDC", "amount_in": 1_000_000_000}))

# Write — needs keypair
swap = A2ASwapTool(keypair="~/.config/solana/id.json")
print(swap.run({"mint_in": "SOL", "mint_out": "USDC", "amount_in": 500_000_000}))

Token shortcuts

Use SOL, USDC, or USDT as shorthand, or any base-58 mint address:

# Shorthand
sim.run({"mint_in": "SOL", "mint_out": "USDC", "amount_in": 1_000_000_000})

# Full mint address
sim.run({
    "mint_in":  "So11111111111111111111111111111111111111112",
    "mint_out": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount_in": 1_000_000_000,
})

Live pools (mainnet)

PoolAddress
SOL/USDC (30 bps)BtBL5wpMbmabFimeUmLtjZAAeh4xWWf76NSpefMXb4TC

Pools are permissionless — any agent can create a new pair via a2a-swap create-pool.

  • Program: 8XJfG4mHqRZjByAd7HxHdEALfB8jVtJVQsdhGEmysTFq (mainnet-beta)
  • CLI: cargo install a2a-swap-cli
  • TypeScript SDK: npm install @liqdlad/a2a-swap-sdk
  • Rust SDK: cargo add a2a-swap-sdk
  • ElizaOS plugin: elizaos plugins add plugin-a2a-swap
  • GitHub: liqdlad-rgb/a2a-swap

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
langchain-core
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langchain-core>=0.2.0runtime
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pydantic>=2.0runtime
crewai
Environment
{
  "extras": "",
  "marker": "extra == \"crewai\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
crewai>=0.30.0; extra == "crewai"runtime
langchain-openai
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langchain-openai; extra == "dev"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "dev"runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio; extra == "dev"runtime

Distribution files

2 collected
a2a_swap_langchain-0.1.1-py3-none-any.whl

bdist_wheel · 9.48 KB · Python py3

Source file
a2a_swap_langchain-0.1.1.tar.gz

sdist · 9.23 KB · Python source

Source file

Repository

PENDING
liqdlad-rgb/a2a-swap

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 16:30 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:c055a17b02c8d7786422617897c0074b3bbd4ece0586e9e9c7ea2cee40e71de4

Other collected versions

View all collected versions →