PluginBench
Skill
Official
Review
Audit score 70

trade

coinbase/agentic-wallet-skills

Swap or trade tokens on Base or Polygon networks via the CDP Swap API.

What is trade?

Execute token swaps and exchanges on Base or Polygon blockchains using the awal CLI. Use this when you need to buy, sell, or convert between tokens like USDC, ETH, and POL.

  • Swap tokens between USDC, ETH, POL, or any contract address
  • Support for multiple amount formats: dollar notation, decimals, whole numbers, and atomic units
  • Configurable slippage tolerance to control price impact
  • Trade on Base (default) or Polygon networks
  • JSON output option for programmatic use
  • Automatic decimal handling for known and custom tokens

How to install trade

npx skills add https://github.com/coinbase/agentic-wallet-skills --skill trade
Prerequisites
  • Must be authenticated with awal (run `awal status` to verify)
  • Wallet must have sufficient balance of the source token
  • Node.js and npm installed to run npx commands
Claude Code
Cursor
Windsurf
Cline

How to use trade

  1. 1.Verify wallet authentication by running `npx awal@2.10.0 status`
  2. 2.Construct the trade command with amount, source token, and destination token
  3. 3.Optionally add `--chain polygon` for Polygon trades or `--slippage <basis-points>` to adjust tolerance
  4. 4.Execute the command and wait for swap confirmation
  5. 5.Check the result or use `--json` flag for structured output

Use cases

Good for
  • Convert USDC to ETH with a simple command
  • Exchange ETH for USDC with custom slippage tolerance
  • Trade POL tokens on the Polygon network
  • Swap arbitrary ERC-20 tokens using contract addresses
  • Get structured JSON output for downstream processing
Who it's for
  • Developers building token trading agents
  • Users managing multi-chain token portfolios
  • Anyone needing programmatic token swaps on Base or Polygon

trade FAQ

What token aliases are supported?

USDC (6 decimals on Base), ETH (18 decimals on Base), and POL (18 decimals on Polygon). You can also use any ERC-20 contract address in 0x format.

How do I specify the amount to swap?

Use dollar notation ('$1.00'), decimal format (0.50), whole numbers (5), or atomic units (500000). Large integers without decimals are auto-detected as atomic units.

Can I trade on Polygon?

Yes, use the `--chain polygon` option. POL tokens are only available on Polygon.

What if I get an authentication error?

Run the authenticate-wallet skill first to log in with your email and set up your wallet.

How do I control slippage?

Use the `--slippage <n>` option where n is in basis points (100 = 1%). Default slippage is applied if not specified.

Full instructions (SKILL.md)

Source of truth, from coinbase/agentic-wallet-skills.


name: trade description: Swap or trade tokens on Base or Polygon. Use when you or the user want to trade, swap, exchange, buy, sell, or convert between tokens like USDC, ETH, and POL. Covers phrases like "buy ETH", "sell ETH for USDC", "convert USDC to ETH", "get some ETH", "buy POL". user-invocable: true disable-model-invocation: false allowed-tools: ["Bash(npx awal@2.10.0 status*)", "Bash(npx awal@2.10.0 trade )", "Bash(npx awal@2.10.0 balance)"]

Trading Tokens

Use the npx awal@2.10.0 trade command to swap tokens on Base or Polygon via the CDP Swap API. You must be authenticated to trade.

Confirm wallet is initialized and authed

npx awal@2.10.0 status

If the wallet is not authenticated, refer to the authenticate-wallet skill.

Command Syntax

npx awal@2.10.0 trade <amount> <from> <to> [options]

The command is also available as npx awal@2.10.0 swap (alias).

Arguments

ArgumentDescription
amountAmount to swap (see Amount Formats below)
fromSource token: alias (usdc, eth, pol) or contract address (0x...)
toDestination token: alias (usdc, eth, pol) or contract address (0x...)

Amount Formats

The amount can be specified in multiple formats:

FormatExampleDescription
Dollar prefix'$1.00', '$0.50'USD notation (decimals based on token)
Decimal1.0, 0.50, 0.001Human-readable with decimal point
Whole number5, 100Interpreted as whole tokens
Atomic units500000Large integers treated as atomic units

Auto-detection: Large integers without a decimal point are treated as atomic units. For example, 500000 for USDC (6 decimals) = $0.50.

Decimals: For known tokens (usdc=6, eth=18, pol=18), decimals are automatic. For arbitrary contract addresses, decimals are read from the token contract.

Options

OptionDescription
-c, --chain <name>Blockchain network: base, polygon (default: base)
-s, --slippage <n>Slippage tolerance in basis points (100 = 1%)
--jsonOutput result as JSON

Token Aliases

AliasTokenDecimalsChain
usdcUSDC6base
ethETH18base
polPOL18polygon

IMPORTANT: Always single-quote amounts that use $ to prevent bash variable expansion (e.g. '$1.00' not $1.00).

Input Validation

Before constructing the command, validate all user-provided values to prevent shell injection:

  • amount: Must match ^\$?[\d.]+$ (digits, optional decimal point, optional $ prefix). Reject if it contains spaces, semicolons, pipes, backticks, or other shell metacharacters.
  • from / to: Must be a known alias (usdc, eth, pol) or a valid 0x hex address (^0x[0-9a-fA-F]{40}$). Reject any other value.
  • slippage: Must be a positive integer (^\d+$).

Do not pass unvalidated user input into the command.

Examples

# Swap $1 USDC for ETH (dollar prefix — note the single quotes)
npx awal@2.10.0 trade '$1' usdc eth

# Swap 0.50 USDC for ETH (decimal format)
npx awal@2.10.0 trade 0.50 usdc eth

# Swap 500000 atomic units of USDC for ETH
npx awal@2.10.0 trade 500000 usdc eth

# Swap 0.01 ETH for USDC
npx awal@2.10.0 trade 0.01 eth usdc

# Swap with custom slippage (2%)
npx awal@2.10.0 trade '$5' usdc eth --slippage 200

# Swap using contract addresses (decimals read from chain)
npx awal@2.10.0 trade 100 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 0x4200000000000000000000000000000000000006

# Get JSON output
npx awal@2.10.0 trade '$1' usdc eth --json

# Swap USDC for POL on Polygon
npx awal@2.10.0 trade '$1' usdc pol --chain polygon

Prerequisites

  • Must be authenticated (awal status to check)
  • Wallet must have sufficient balance of the source token

Error Handling

Common errors:

  • "Not authenticated" - Run awal auth login <email> first
  • "Invalid token" - Use a valid alias (usdc, eth, pol) or 0x address
  • "POL only supported on polygon chain" - Use --chain polygon when trading POL
  • "Cannot swap a token to itself" - From and to must be different
  • "Swap failed: TRANSFER_FROM_FAILED" - Insufficient balance or approval issue
  • "No liquidity" - Try a smaller amount or different token pair
  • "Amount has X decimals but token only supports Y" - Too many decimal places

Related skills

More from coinbase/agentic-wallet-skills and the wider catalog.

x402 logo

x402

Official
coinbase/agentic-wallet-skills

Search and call paid APIs using the x402 payment protocol with automatic USDC payments on Base.

3.0k installs
agentic-wallet logo

agentic-wallet

Official
coinbase/agentic-wallet-skills

Crypto wallet operations via the awal CLI — sign in, check balances, send USDC/ETH/POL/SOL, trade tokens, fund the wallet, and use the x402 payment protocol to discover paid services, pay for API calls, monetize an API, or query onchain data. Use whenever the user mentions signing in, login, authentication, wallet status, balance, address, sending money, paying someone, transferring tokens, ENS names, swapping/trading/converting tokens, funding/topping up/onramp, USDC, ETH, POL, SOL, the x402 bazaar, paid APIs, monetizing an endpoint, or querying onchain data on Base.

617 installs
authenticate-wallet logo

authenticate-wallet

Official
coinbase/agentic-wallet-skills

Sign in to your wallet via email OTP before sending, trading, or funding.

2.4k installs
fund logo

fund

Official
coinbase/agentic-wallet-skills

Add money to your wallet via Coinbase Onramp with multiple payment methods.

2.3k installs
add-lang logo

add-lang

colbymchenry/codegraph

Add tree-sitter language support to codegraph end-to-end — wire the grammar + extractor, write tests, then benchmark extraction quality and retrieval value on 3 popular real-world repos. Use when the user runs /add-lang <language> or asks to add/support a new language (e.g. Lua, Elixir, Zig, OCaml) in codegraph.

651 installs
agent-eval logo

agent-eval

colbymchenry/codegraph

Benchmark CodeGraph retrieval quality on a real codebase by comparing agent behavior with vs without CodeGraph. Use when the user runs /agent-eval or asks to test, benchmark, audit, or validate a codegraph version (the local dev build or a published npm version) against a language's repo.

1.0k installs