Agent skill

Uniswap Swap

by Nethereum in Nethereum/Nethereum

Swap tokens on Uniswap V2/V3/V4 using Nethereum (.NET/C). An agent skill from Nethereum/Nethereum.

MITAuto-check passedBusiness, Finance & HR

Install Uniswap Swap

skills CLI
$ npx skills add Nethereum/Nethereum --skill uniswap-swap -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Nethereum/Nethereum uniswap-swap --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Nethereum/Nethereum.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/nethereum-skills/skills/uniswap-swap .claude/skills/uniswap-swap && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
uniswap-swap
GitHub stars
2.3k
Token cost
~2.1k tokens
SKILL.md length
320 words
Files
1
Skills in repo
71
Repo updated
First seen
Licence
MIT

At a glance

Swap tokens on Uniswap V2/V3/V4 using Nethereum (.NET/C). An agent skill from Nethereum/Nethereum.

  • The user asks about token swaps
  • SKILL.md covers Connect to Uniswap V4, Quote a Price, Execute a Swap and Slippage and Price Impact, plus 7 more sections
  • Calls dotnet
  • Uniswap integration

What it does

Uniswap Swap is an agent skill from Nethereum/Nethereum. Swap tokens on Uniswap V2/V3/V4 using Nethereum (.NET/C). Use this skill whenever the user asks about token swaps, DEX trading, Uniswap integration, quoting prices, slippage protection, price impact, Universal Router, Permit2, or any DeFi swap operation with C or .NET.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Business, Finance & HR, covering Crypto and DeFi analysis and Trading and backtesting. It works with Uniswap, C# and .NET. The repository describes itself as: Ethereum .Net cross platform integration library. The licence is MIT.

When your agent uses it

  • The user asks about token swaps
  • Uniswap integration
  • Slippage protection
  • Universal Router

Example prompts

  • “/uniswap-swap”

What it can do on your machine

Read from SKILL.md and the folder at commit 229f278. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.nethereum.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Uniswap Swap loads about 2.1k tokens when it runs. Until then it costs about 71 tokens; SKILL.md has 320 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~71
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Nethereum/Nethereum at commit 229f278, republished under its MIT licence (© Nethereum). 320 words, ~2,073 tokens.

Download SKILL.mdSave it as .claude/skills/uniswap-swap/SKILL.md (or your agent's skills folder).
name
uniswap-swap
description
Swap tokens on Uniswap V2/V3/V4 using Nethereum (.NET/C#). Use this skill whenever the user asks about token swaps, DEX trading, Uniswap integration, quoting prices, slippage protection, price impact, Universal Router, Permit2, or any DeFi swap operation with C# or .NET.
user-invocable
true

Uniswap: Swap Tokens

Nethereum provides a complete Uniswap integration covering V2, V3, and V4. The web3.UniswapV4() extension gives you access to quoting, routing, pool discovery, and swap execution — all through typed C# services. This is the standard way to execute on-chain token swaps from .NET.

NuGet: Nethereum.Uniswap

bash
dotnet add package Nethereum.Uniswap

Connect to Uniswap V4

The UniswapV4() extension on Web3 exposes the full service hierarchy. It defaults to Mainnet addresses but accepts any network's addresses:

csharp
var web3 = new Web3(new Account(privateKey), rpcUrl);
var uniswap = web3.UniswapV4();
// Or for a specific network:
var uniswap = web3.UniswapV4(UniswapV4Addresses.BaseSepolia);

The uniswap object provides: Pools (state, cache, discovery), Pricing (quoter, price calculator, slippage, price impact), Positions (liquidity management), UniversalRouter (swap execution), and Math (tick math).

Quote a Price

Before swapping, simulate the trade with the quoter — this is a read-only call, no gas cost:

csharp
var pathKeys = V4PathEncoder.EncodeMultihopExactInPath(new List<PoolKey> { pool }, eth);
var amountIn = Web3.Convert.ToWei(0.001);

var quoteParams = new QuoteExactParams
{
    Path = pathKeys,
    ExactAmount = amountIn,
    ExactCurrency = eth
};

var quote = await uniswap.Pricing.Quoter.QuoteExactInputQueryAsync(quoteParams);
var quoteAmount = Web3.Convert.FromWei(quote.AmountOut, 6); // USDC = 6 decimals

The V4PathEncoder encodes the swap route. For single-hop, pass one pool key. For multi-hop (e.g., ETH→DAI→USDC), pass multiple pool keys.

Execute a Swap

Swaps go through the Universal Router. The pattern is: build actions (swap + settle input + take output), then execute:

csharp
var v4ActionBuilder = uniswap.GetUniversalRouterV4ActionsBuilder();

v4ActionBuilder.AddCommand(new SwapExactIn
{
    CurrencyIn = eth,
    AmountIn = amountIn,
    AmountOutMinimum = quote.AmountOut * 95 / 100, // 5% slippage
    Path = pathKeys.MapToActionV4()
});

v4ActionBuilder.AddCommand(new SettleAll { Currency = eth, Amount = amountIn });
v4ActionBuilder.AddCommand(new TakeAll { Currency = usdc, MinAmount = 0 });

var routerBuilder = new UniversalRouterBuilder();
routerBuilder.AddCommand(v4ActionBuilder.GetV4SwapCommand());

var executeFunction = routerBuilder.GetExecuteFunction(amountIn);
var receipt = await uniswap.UniversalRouter.ExecuteRequestAndWaitForReceiptAsync(executeFunction);

The three actions form the standard swap pattern: swap exchanges tokens in the pool, settle pays the input, take collects the output. AmountOutMinimum is your slippage protection.

Slippage and Price Impact

Nethereum provides calculators for both:

csharp
var slippage = uniswap.Pricing.SlippageCalculator;

// For exact-input swaps: minimum acceptable output
var tolerance = new BigDecimal(0.5m); // 0.5%
var minAmountOut = slippage.CalculateMinimumAmountOut(expectedAmountOut, tolerance);

// For exact-output swaps: maximum you're willing to pay
var maxAmountIn = slippage.CalculateMaximumAmountIn(expectedAmountIn, tolerance);

// Price impact classification
var impactCalc = uniswap.Pricing.PriceImpactCalculator;
var impact = impactCalc.CalculatePriceImpact(input, output, midPrice);
var level = impactCalc.ClassifyPriceImpact(impact);
// Returns: Low (<1%), Medium (1-3%), High (3-5%), Critical (>5%)
var warning = impactCalc.GetPriceImpactWarning(level);

Price Calculations

Calculate human-readable prices from the pool's raw sqrtPriceX96 value:

csharp
// Get price of token0 in terms of token1 (adjusted for decimals)
var priceToken0InToken1 = uniswap.Pricing.PriceCalculator.CalculatePriceFromSqrtPriceX96(
    sqrtPriceX96, decimals0: 18, decimals1: 6);

// Inverse gives token1 price in terms of token0
var priceToken1InToken0 = priceToken0InToken1 == 0 ? 0 : 1 / priceToken0InToken1;

Tick math conversions for working with price ranges:

csharp
var sqrtPriceX96 = uniswap.Math.Tick.GetSqrtRatioAtTick(tick);
var tick = uniswap.Math.Tick.GetTickAtSqrtRatio(sqrtPriceX96);

Pool Discovery

Find available pools for a token pair using on-chain Initialize events:

csharp
var poolCache = uniswap.Pools.Cache;
var pools = await poolCache.FindPoolsForTokenAsync(token: usdc, fromBlockNumber: start, toBlockNumber: end);

Or fetch a specific pool directly:

csharp
var pool = await poolCache.GetOrFetchPoolAsync(currency0: eth, currency1: usdc, fee: 500, tickSpacing: 10);

Find Best Path

For large trades or exotic pairs, route through intermediate tokens for better prices:

csharp
var pathFinder = uniswap.Pricing.QuotePricePathFinder;
var cachedPools = await poolCache.GetAllCachedPoolsAsync();

// Direct path only
var bestDirect = await pathFinder.FindBestDirectPathAsync(
    tokenIn: eth, tokenOut: usdc,
    amountIn: Web3.Convert.ToWei(1),
    candidatePools: cachedPools);

// Multi-hop through intermediate tokens
var bestPath = await pathFinder.FindBestPathAsync(
    tokenIn: usdc, tokenOut: weth,
    amountIn: Web3.Convert.ToWei(1000, UnitConversion.EthUnit.Mwei),
    intermediateTokens: new[] { dai, eth },
    candidatePools: cachedPools);

Token Approvals

Before swapping ERC-20 tokens (not native ETH), ensure the router has approval:

csharp
await uniswap.Accounts.Approvals.CheckAndApproveIfNeededAsync(
    tokenAddress, owner, spender, requiredAmount);

// Or check and approve separately
var status = await uniswap.Accounts.Approvals.CheckApprovalAsync(
    tokenAddress, owner, spender, requiredAmount);
if (!status.IsApproved)
{
    await uniswap.Accounts.Approvals.ApproveAsync(
        tokenAddress, spender, AccountApprovalService.GetMaxApprovalAmount());
}

Validate Balances

Before executing a swap, verify the sender has enough tokens:

csharp
var balanceResult = await uniswap.Accounts.Balances.ValidateBalanceAsync(
    tokenAddress, owner, requiredAmount);

if (!balanceResult.HasSufficientBalance)
    Console.WriteLine($"Need {balanceResult.Deficit} more tokens");

V3 Swaps with Permit2

For Uniswap V3, swaps use the same Universal Router but with Permit2 for gasless approvals. The flow: approve Permit2 once, then sign off-chain permits per swap:

csharp
// One-time: approve Permit2 to spend your WETH
var weth9Service = web3.Eth.ERC20.GetContractService(weth9);
await weth9Service.ApproveRequestAndWaitForReceiptAsync(permit2Address, IntType.MAX_INT256_VALUE);

// Per-swap: sign a Permit2 authorization
var permit = new PermitSingle
{
    Spender = universalRouterAddress,
    SigDeadline = 2000000000,
    Details = new PermitDetails
    {
        Amount = amountIn * 100000,
        Expiration = 0,
        Nonce = 0,
        Token = weth9
    }
};

var permitService = new Permit2Service(web3, permit2Address);
var signedPermit = await permitService.GetSinglePermitWithSignatureAsync(
    permit, new EthECKey(privateKey));

// Build the swap via Universal Router
var planner = new UniversalRouterBuilder();
planner.AddCommand(new Permit2PermitCommand
{
    Permit = signedPermit.PermitRequest,
    Signature = signedPermit.GetSignatureBytes()
});
planner.AddCommand(new V3SwapExactInCommand
{
    AmountIn = amountIn,
    AmountOutMinimum = quote.AmountOut - 10000,
    Path = path,
    Recipient = account.Address,
    FundsFromPermit2OrUniversalRouter = true
});

var receipt = await universalRouterService.ExecuteRequestAndWaitForReceiptAsync(
    planner.GetExecuteFunction(amountIn));

Error Handling

Uniswap reverts with custom errors that the router service can decode:

csharp
catch (SmartContractCustomErrorRevertException e)
{
    var error = universalRouterService.FindCustomErrorException(e);
    if (error != null) Console.WriteLine($"Uniswap error: {error.Message}");
}

For full documentation, see: https://docs.nethereum.com/docs/defi/guide-uniswap-swap

© Nethereum, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/nethereum-skills/skills/uniswap-swap of Nethereum/Nethereum.

Open the folder on GitHubat commit 229f278

Compare with similar skills

Uniswap Swap next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Uniswap Swap compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Uniswap Swap this skillNethereum/Nethereum2.3k—~2.1kAutomated safety check: PassMIT
Notebook To Strategytradingstrategy-ai/trade-executor160—~1.1kAutomated safety check: PassCustom licence
Stock Indicators Dotnetfacioquo/stock-indicators-dotnet1.2k—~852Automated safety check: PassApache-2.0
Aomi Transactjeremylongshore/tons-of-skills-marketplace2.8k—~2.3kAutomated safety check: PassMIT
Polyclawchainstacklabs/polyclaw3591 repos~2kAutomated safety check: PassApache-2.0
Okx Cex Marketdex-original/okx-agent-trade-kit1101 repos~2.7kAutomated safety check: PassMIT

Similar skills

  • Notebook To Strategy

    tradingstrategy-ai/trade-executor

    Transfer code from a backtesting Jupyter notebook to a Trade Executor strategy module

    160 GitHub stars~1.1k tokensUpdated 2 days ago
    Business, Finance & HRAuto-check passed
  • Stock Indicators Dotnet

    facioquo/stock-indicators-dotnet

    Calculate technical analysis indicators (EMA, RSI, MACD, ADX, Bollinger Bands, and dozens more) from OHLCV price bars, in batch or live from a market feed, in C with the FacioQuo.Stock.Indicators v3…

    1.2k GitHub stars~852 tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Aomi Transact

    jeremylongshore/tons-of-skills-marketplace

    Build natural-language crypto agents, web3 assistants, and trading bots that read and write EVM chain state.

    2.8k GitHub stars~2.3k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Polyclaw

    chainstacklabs/polyclaw

    Trade on Polymarket via split + CLOB execution. An agent skill from chainstacklabs/polyclaw.

    359 GitHub starsUsed in 1 repo~2k tokens
    Business, Finance & HRAuto-check passed
  • Okx Cex Market

    dex-original/okx-agent-trade-kit

    A skill your agent uses when the user asks for: price of any asset, ticker, order book, candles, OHLCV, funding rate, open interest, OI change scanner, market screener (top movers, high-volume…

    110 GitHub starsUsed in 1 repo~2.7k tokens
    Business, Finance & HRAuto-check passed
  • Bitget Wallet

    bitget-wallet-ai-lab/bitget-wallet-skill

    Interact with Bitget Wallet API for crypto market data, token info, swap quotes, RWA (real-world asset) stock trading, and security audits.

    246 GitHub stars~7.6k tokensUpdated 5 mo ago
    Business, Finance & HRAuto-check passed

More from Nethereum/Nethereum

All 71 skills in this repo
  • Aa Batching Paymasters

    Nethereum/Nethereum

    Help users batch multiple calls into a single UserOperation and sponsor gas with paymasters using Nethereum Account Abstraction.

    2.3k GitHub stars~1.5k tokensUpdated 6 days ago
    Auto-check passed
  • Aa Bundler

    Nethereum/Nethereum

    Help users run an ERC-4337 bundler using Nethereum — set up in-process or standalone bundlers with mempool, validation, reputation, and JSON-RPC server.

    2.3k GitHub stars~1.2k tokensUpdated 6 days ago
    Auto-check passed
  • Abi Encoding

    Nethereum/Nethereum

    Encode and decode Ethereum ABI data with Nethereum. An agent skill from Nethereum/Nethereum.

    2.3k GitHub stars~1.3k tokensUpdated 6 days ago
    Auto-check passed
  • Abi Retrieval

    Nethereum/Nethereum

    Fetch contract ABIs from Sourcify, Etherscan, and 4Byte Directory using the composite ABIInfoStorage pattern (.NET/C).

    2.3k GitHub stars~1.5k tokensUpdated 6 days ago
    Auto-check passed
  • Account Abstraction

    Nethereum/Nethereum

    Help users implement ERC-4337 Account Abstraction with Nethereum — send UserOperations, use smart accounts, route contract calls through a bundler, enable gasless transactions, or work with AA in…

    2.3k GitHub stars~1.7k tokensUpdated 6 days ago
    Auto-check passed
  • Address Utils

    Nethereum/Nethereum

    Validate and format Ethereum addresses with Nethereum. An agent skill from Nethereum/Nethereum.

    2.3k GitHub stars~1.2k tokensUpdated 6 days ago
    Auto-check passed

Works with

Questions about Uniswap Swap

What does Uniswap Swap do?

Swap tokens on Uniswap V2/V3/V4 using Nethereum (.NET/C). An agent skill from Nethereum/Nethereum. Uniswap Swap is an agent skill from Nethereum/Nethereum.NET/C).

When should I use Uniswap Swap?

Uniswap Swap fits situations like: the user asks about token swaps; uniswap integration; slippage protection; universal Router.

How do I install Uniswap Swap in Claude Code?

Run `npx skills add Nethereum/Nethereum --skill uniswap-swap -a claude-code`. Or copy the skill folder (plugins/nethereum-skills/skills/uniswap-swap in Nethereum/Nethereum) into .claude/skills/uniswap-swap in your project. Claude Code loads it when a task matches its description.

How do I install Uniswap Swap in Codex?

Run `npx skills add Nethereum/Nethereum --skill uniswap-swap -a codex`. Or copy the skill folder (plugins/nethereum-skills/skills/uniswap-swap in Nethereum/Nethereum) into .agents/skills/uniswap-swap in your project. Codex loads it when a task matches its description.

Can I use Uniswap Swap in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Nethereum/Nethereum --skill uniswap-swap -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/uniswap-swap, .gemini/skills/uniswap-swap, .github/skills/uniswap-swap and .opencode/skills/uniswap-swap in your project.

What does Uniswap Swap need to run?

Going by SKILL.md and its folder, Uniswap Swap needs the command-line tools its instructions call (dotnet).

Does Uniswap Swap access the network?

SKILL.md names 1 domain. As links in the text: docs.nethereum.com. This is read from the text; nothing was executed.

Is Uniswap Swap safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Uniswap Swap use?

Uniswap Swap is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Uniswap Swap use?

About 2.1k tokens (SKILL.md is roughly 8.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Uniswap Swap?

Skills that share tags, products or a category with Uniswap Swap: Notebook To Strategy (tradingstrategy-ai/trade-executor, 160 stars), Stock Indicators Dotnet (facioquo/stock-indicators-dotnet, 1.2k stars), Aomi Transact (jeremylongshore/tons-of-skills-marketplace, 2.8k stars) and Polyclaw (chainstacklabs/polyclaw, 359 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Uniswap Swap?

Nethereum (a GitHub organization) maintains it in Nethereum/Nethereum, which has 2,260 GitHub stars. The repository holds 71 skills in this directory. The repository was last updated on October 5, 2026.

Source: Nethereum/Nethereum on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.