Skip to main content

Swapping

You can swap between XYZ and any graduated token on the AMM. Swaps execute instantly against the pool’s reserves using the constant-product formula.

Swap XYZ for Tokens

To buy tokens with XYZ:
  1. Navigate to the token’s trading page
  2. Enter the amount of XYZ you want to spend
  3. Review the estimated tokens you’ll receive and price impact
  4. Click Swap and confirm in your wallet

Contract Message

Funds: [{ "denom": "uxyz", "amount": "<xyz_to_swap>" }] The min_output parameter protects against slippage — the transaction reverts if you’d receive fewer tokens than specified.

Swap Tokens for XYZ

To sell tokens for XYZ, the AMM uses the CW20 Send pattern. Instead of calling the AMM directly, you send tokens to the AMM contract with an encoded swap message:
The inner message (before base64 encoding):
The TypeScript SDK handles the CW20 Send encoding automatically:

Simulating Swaps

Preview any swap before executing:
Set offer_xyz: true for XYZ to Token, false for Token to XYZ. Response:

Understanding Price Impact

Price impact is the difference between the current market price and the effective price of your trade. It depends on trade size relative to pool depth:
Large trades relative to pool size will have significant price impact. Consider splitting large orders into smaller trades.

Fees

Fees are deducted from your input before the swap calculation.

Next Steps

Liquidity

How LP tokens and pool mechanics work

AMM Overview

Constant-product formula and pool basics