uniswap-swap

Executes token swaps on Uniswap V2, V3, and V4 using Nethereum in .NET.

2.3k|744|Updated Nov 23, 2015
One-click install
npx skills add https://github.com/Nethereum/Nethereum --skill uniswap-swap
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: uniswap-swap
Source: https://github.com/Nethereum/Nethereum/tree/main/plugins/nethereum-skills/skills/uniswap-swap
Command: npx skills add https://github.com/Nethereum/Nethereum --skill uniswap-swap

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Nethereum.Uniswap.

What problem does it solve?

Executing decentralized exchange trades from .NET applications requires handling quoting, routing, slippage protection, token approvals, and Permit2 signatures across multiple Uniswap protocol versions, which is complex to implement from scratch.

Core Features & Use Cases

  • Quoting and Routing: Simulate trades with the V4 quoter, discover pools on-chain, and find optimal direct or multi-hop swap paths.
  • Swap Execution: Build and submit swaps through the Universal Router with settle/take actions and configurable slippage tolerance.
  • Risk Controls: Calculate slippage bounds, classify price impact, validate balances, and manage ERC-20 approvals including Permit2 gasless permits for V3.
  • Use Case: A C# backend service needs to swap ETH for USDC on Base; it quotes the trade, applies 0.5% slippage protection, and executes through the Universal Router in a few typed calls.

Quick Start

Use the uniswap-swap skill to quote and execute a swap of 0.001 ETH for USDC on Uniswap V4 with 5% slippage protection in C#.

Frequently Asked Questions about uniswap-swap

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I swap tokens on Uniswap using C#?

Install the Nethereum.Uniswap NuGet package, create a Web3 instance with your account and RPC URL, then call web3.UniswapV4(). Quote the trade with the quoter, build swap, settle, and take actions via the Universal Router builder, and execute the transaction.

How to get a Uniswap price quote before swapping in .NET?

Use uniswap.Pricing.Quoter.QuoteExactInputQueryAsync with an encoded path from V4PathEncoder and the input amount. This is a read-only simulation that costs no gas and returns the expected output amount.

Does Nethereum support Uniswap V3 and Permit2?

Yes, V3 swaps use the Universal Router with Permit2 for gasless approvals. Approve Permit2 once for the token, then sign off-chain PermitSingle authorizations per swap and include them as a Permit2PermitCommand in the router plan.

How do I add slippage protection to a Uniswap swap?

Use uniswap.Pricing.SlippageCalculator to compute a minimum output amount from your tolerance, such as 0.5 percent, and set it as AmountOutMinimum in the swap command. The transaction reverts if the actual output falls below this threshold.

Why does my Uniswap swap transaction revert?

Common causes include insufficient token approval for the router, output below the slippage minimum, or inadequate balance. Catch SmartContractCustomErrorRevertException and call FindCustomErrorException on the router service to decode the specific Uniswap error.