Skip to main content
Single-contract DEX (formerly CrocSwap) with ambient (full-range) and concentrated liquidity in one unified pool. All liquidity lives in one contract.

What it offers

  • swap: Swap tokens via the CrocSwapDex contract with base/quote pair addressing

Notes

  • Single contract holds ALL liquidity (similar to Balancer V2 Vault and Uniswap V4 PoolManager)
  • The contract address differs on Ethereum and Scroll
  • poolIdx identifies the pool type: different pool indices have different fee rates and tick spacing
  • Common pool indices: 420 (standard on Ethereum), 36000 (stable pairs on Scroll)
  • Exact-input: isBuy: true, inBaseQty: true specifies base paid; isBuy: false, inBaseQty: false specifies quote paid
  • Exact-output: isBuy: true, inBaseQty: false specifies quote received; isBuy: false, inBaseQty: true specifies base received
  • tip: Optional tip in basis points for priority execution (usually 0)
  • limitPrice: Price limit as sqrt price Q64.64 fixed-point (0 is no limit, which leaves minOut as the only bound)
  • reserveFlags: Bitmask for using surplus collateral (set to 0 for standard swaps)
  • userCmd is the universal command interface for all non-swap operations (adding/removing liquidity, etc.)
  • callpath 1 = liquidity operations, 3 = warm path operations
  • Gas-efficient for simple swaps; more complex for LP operations via userCmd
  • Input token must be ERC20-approved to the CrocSwapDex contract

Its names in a program

On Ethereum, Ambient is a namespace: its contracts need no import.

Deployments

ABI

CrocSwapDexABI

import CrocSwapDexABI from "./protocols/ambient/CrocSwapDexABI.json"; Speaks for: crocSwapDex.
  • swap(address base, address quote, uint256 poolIdx, bool isBuy, bool inBaseQty, uint128 qty, uint16 tip, uint128 limitPrice, uint128 minOut, uint8 reserveFlags) payable returns (int128 baseFlow, int128 quoteFlow)
  • userCmd(uint16 callpath, bytes cmd) payable returns (bytes result)

Next steps