PropSwapRouter Integration Guide

This guide explains how to integrate with the PropSwapRouter contract to get quotes and execute token swaps in the Wasabi Prop AMM system.

Overview

The PropSwapRouter is the main entry point for swapping tokens. It:

  • Routes swaps through underlying PropPool contracts

  • Uses USDC as the common base pair (quote token)

  • Supports both exact-input and exact-output swap modes

  • Provides slippage protection and deadline validation

Contract Addresses

Chain Name
Chain ID
PropSwapRouter
PropPoolFactory

Base Sepolia

84532

0x6bd7186801a50c2158c0c9ac5fd8bebd419212fe

0x877c68779d0fef5458515c98f13355ca3780a486

Base

8453

0xfc81dfde25083a286723b7c9dd7213f8723369fe

0x851fc799c9f1443a2c1e6b966605a80f8a1b1bf2


Discovering Pools

The PropPoolFactory provides functions to discover which tokens are supported and get pool addresses.

getListedTokens

Returns all tokens that have a pool in the system.

getPropPool

Returns the pool address for a given token.

Example (Solidity):

Example (TypeScript/ethers):

Each pool holds reserves of one base token (e.g. WETH) and USDC as the quote token. You can inspect pool state via getReserves(), getBaseToken(), and getQuoteToken() on the IPropPool interface.


Getting Quotes

Quote functions are view functions that estimate swap amounts without executing a transaction. Always call these before swapping to determine expected output or required input.

quoteExactInput

Calculate how much output you'll receive for a given input amount.

Parameters:

Name
Type
Description

tokenIn

address

Token to sell

tokenOut

address

Token to receive

amountIn

uint256

Amount of input token (in base units)

Returns: Expected output amount in base units

Example:

quoteExactOutput

Calculate how much input is needed for a desired output amount.

Parameters:

Name
Type
Description

tokenIn

address

Token to sell

tokenOut

address

Token to receive

amountOut

uint256

Desired output amount (in base units)

Returns: Required input amount in base units

Example:


Executing Swaps

Prerequisites

  1. Approve tokens: The router must be approved to spend your input tokens

  2. Authorization: Your address must be an authorized swapper (check with the factory admin)

  3. Sufficient balance: Ensure you have enough input tokens

swapExactInput

Swap a fixed input amount for variable output (with minimum output protection).

Parameters:

Name
Type
Description

tokenIn

address

Token to sell

tokenOut

address

Token to receive

amountIn

uint256

Amount of input token to swap

minAmountOut

uint256

Minimum acceptable output (slippage protection)

recipient

address

Address to receive output tokens

deadline

uint256

Unix timestamp after which the swap reverts

Returns: Actual amount of output tokens received

Example:

swapExactOutput

Swap variable input for a fixed output amount (with maximum input protection).

Parameters:

Name
Type
Description

tokenIn

address

Token to sell

tokenOut

address

Token to receive

amountOut

uint256

Exact amount of output tokens desired

maxAmountIn

uint256

Maximum input willing to pay (slippage protection)

recipient

address

Address to receive output tokens

deadline

uint256

Unix timestamp after which the swap reverts

Returns: Actual amount of input tokens used (unused tokens are refunded)

Example:


Swap Routing

The router automatically determines the optimal path:

tokenIn
tokenOut
Path

USDC

Token

Single hop: USDC → Token

Token

USDC

Single hop: Token → USDC

Token A

Token B

Two hops: Token A → USDC → Token B

Multi-hop swaps incur fees on each leg.


Error Handling

The router reverts with specific errors:

Handling errors:


Complete Integration Example


TypeScript/Ethers.js Integration


Best Practices

  1. Always get a quote first - Quotes help you set appropriate slippage limits

  2. Use reasonable deadlines - 10-30 minutes for manual swaps, shorter for bots

  3. Set appropriate slippage:

    • 0.5-1% for stable pairs

    • 1-3% for volatile pairs

    • Higher for large trades relative to pool liquidity

  4. Check token decimals - USDC uses 6 decimals, most tokens use 18

  5. Handle refunds - For swapExactOutput, unused input tokens are automatically refunded

  6. Monitor events - Listen for SwapExactInput and SwapExactOutput events for confirmations


Events


Support

For questions or issues, contact Wasabi via Telegram (if we already have a chat open) or open a ticket in our Discord.

Discord: https://discord.gg/A9xZuxdRKP

Last updated