Ambient

Ambient combines full-range and concentrated liquidity in the same trading pools

Ambient is a decentralized exchange where token swaps use pools combining full-range liquidity and liquidity confined to a chosen price range. Traders exchange assets against those pools, while liquidity providers earn swap fees when their capital participates in trading. Knockout liquidity adds limit-order-style execution within the same market structure.

Shared Liquidity and Price Movement

A swap changes a pool's relative virtual reserves, so its size and the available active liquidity determine price movement. An automated market maker, or AMM, calculates the exchange using those reserves. Full-range positions and active concentrated positions share a constant-product curve between price boundaries, with fees and changes in active liquidity affecting the calculation as a swap moves through the pool. Liquidity outside the current price range does not add depth at that price.

The price at a point on the curve differs from the average rate for a whole trade. Each swap moves along the curve as it exchanges tokens. A larger order relative to available liquidity generally causes greater price impact. Pool reserves are pricing inputs; the main contract also holds assets for other pools and user balances. Its total token holdings therefore do not describe the depth available to one trade.


Wallet Funding and Spending Permissions

An ERC-20 input paid from a wallet requires enough tokens and spending authorization for the exchange contract. An approval sets the amount a contract may draw. Approval alone does not exchange tokens. An existing allowance may already cover the intended debit, and supported tokens can use a permit signature. Authorization must identify the intended token and spender on the selected network.

Direct wallet transactions also need the selected network's native currency to pay gas.

Native-token funding uses transaction value instead of an ERC-20 allowance. That value belongs only on operations involving the native currency; a token-only operation does not refund accidentally attached native value. For position inspection, CrocQuery exposes pool prices and the underlying token quantities belonging to LP positions. These read-only functions help distinguish capital committed to liquidity from tokens available for spending.

From Quote to Settled Swap

For a wallet-funded swap, an acceptable quote becomes a completed exchange only when on-chain execution succeeds. This path pays an ERC-20 input and sends the output to the wallet. A fixed-input quantity defines the proposed spend, while a minimum-output amount bounds acceptable execution.

Swap Stage Execution Condition or Confirmation
Select the pair and funding The selected deployment must have liquidity connecting the input and output assets.
Calculate the quote Estimated token flows use the pool state available at calculation time.
Set the minimum output The fixed-input swap must satisfy the chosen output floor to succeed.
Authorize the input debit An allowance or supported permit must cover the wallet-funded ERC-20 input.
Submit the swap A transaction identifier tracks submission; it does not establish successful execution.
Execute and settle The swap and settlement must satisfy the transaction's encoded constraints.
Reconcile the completed transaction A successful receipt and actual token movements establish the settled input and output.
Illustration: From Quote to Settled Swap (Ambient)

Open full-size image

On the normal path, the successful transaction exchanges tokens and records the actual amounts paid and received. The realized rate is output received divided by input spent, after adjusting each token's raw amount for its decimals. A quote only estimates execution against a particular pool state. Other trading can change that state before the submitted transaction executes.

If the output would fall below the encoded minimum, the transaction reverts and its swap balance changes do not persist. The failed transaction can still consume gas. After a confirmed revert, a retry is a new swap with a fresh quote and an acceptable output boundary. Changing the estimate cannot turn the failed transaction into a completed trade.


Direct Pools and Multihop Routing

A direct pool supports a single-hop swap when it has enough liquidity between the selected tokens. Multihop routing connects pools through intermediate tokens. An off-chain routing service can propose a path, while the contracts execute the predetermined route. Net settlement avoids transferring intermediate tokens to the trader. Additional hops introduce more pool fees and computation, so route quality depends on the complete exchange, including price impact across its pools.


Full-Range Liquidity and Fee Growth

Full-range liquidity stays active across the pool's price domain and automatically compounds the swap fees it earns. This is the protocol's ambient liquidity. It avoids choosing and maintaining narrow price boundaries, although trading still changes the underlying token mixture. Native ambient liquidity also has its own accounting; it differs from extending a concentrated position across a very wide range.

Fees earned by concentrated positions are reinvested into the pool as ambient liquidity. The original concentrated amount and its price boundaries stay separate from those full-range rewards, so compounding fees does not widen the range or move it around the current price. Previously accumulated rewards can continue compounding even while the original range contributes no active liquidity.

Harvesting concentrated fees collects accumulated rewards without removing the range's principal liquidity.


Concentrated Ranges and Token Exposure

A concentrated position supplies trading liquidity inside its selected range and stops earning new trading fees from that contribution when price leaves it.

A narrower range requires less collateral for a given amount of active liquidity. For the same capital, a narrower range can provide more active liquidity and earn a larger fee share while price remains inside it. Narrow boundaries leave less room for price movement before the position becomes inactive. Ordinary concentrated positions remain open outside their range and can participate again when price returns.

Trading changes a position's token mixture as price moves through the range. Beyond either boundary, its principal consists of one token. Which token remains depends on the crossed boundary and the direction used to express the pair's price. Previously accumulated fee rewards are separate from that principal and can contain both tokens.

Impermanent loss describes how a changing LP position can fall behind the value of the same starting tokens held separately, even when the position has collected trading fees. It applies to both full-range and concentrated liquidity. The comparison uses the original token quantities as its baseline.

Burning liquidity returns the underlying token quantities at the pool's prevailing price. Repositioning a range can combine a burn, swap and new mint in one transaction. LP operations also support acceptable pool-price bounds, allowing a call to reject execution after an unwanted price move. A range adjustment changes future exposure without restoring the original deposit's token mixture.

Pool Fees and Network Costs

Pool fees follow the pool's configuration, and dynamic fees allow that setting to change with market conditions. A policy oracle can adjust the liquidity fee without changing the underlying AMM mechanism. The protocol can also configure a share of swap fees for itself. A previously displayed fee does not establish the charge for every future trade.

Gas pays for on-chain computation and settlement separately from the pool's trading fee. Price impact changes the average exchange rate, while slippage tolerance bounds acceptable deterioration from the quote. For native-token trades, wallet balance changes also include gas spending, so the swap's recorded token flows identify the traded quantities.

A larger slippage tolerance widens acceptable execution without increasing pool liquidity or lowering its trading fee.


When Does a Knockout Order Become Irreversible?

A knockout order locks its conversion when the pool price crosses its full configured range in the order's direction. A fully knocked-out position is permanently removed from active pool liquidity. A partial conversion can reverse before the far edge is crossed. Knockout liquidity must be enabled for the pool and follows its configured width. Filled tokens still require a claim or recovery call; crossing the fill boundary does not automatically deliver them to the wallet. A claim also collects accumulated fees, while recovery forfeits them.


Surplus Balances and Settlement Choices

Surplus collateral is a user's token balance inside the exchange, independent of any liquidity pool. Swaps and liquidity operations can debit or credit that balance, avoiding repeated external token transfers. Merely holding surplus collateral does not earn LP trading fees, and its token quantity stays fixed until an operation uses or transfers it, even though the asset's market value can change.

Settlement can mix wallet and surplus balances. A wallet-funded input can produce output credited inside the exchange. That output is available as surplus collateral without increasing the wallet's token balance. Withdrawals move surplus tokens back to a wallet, and internal transfers can move surplus balances between users.

Shared Contract State and Advanced Controls

The core contract, CrocSwapDex, holds pool liquidity and position records together. Supporting execution modules operate against its shared state, while query contracts expose readings. Complex orders can combine swaps, liquidity additions and removals in one transaction and net their token flows. A particular interface may expose only part of that protocol functionality.

Permissionless pool types allow participation without an external access check. Permissioned pools apply their own oracle checks to trading and liquidity operations. Governance can adjust parameters and install execution code through privileged controls. Code upgrades use a timelock and treasury multisig authorization. The installed execution code has access to the main contract's state and funds.

Relayed commands provide another execution route: a third party submits the transaction carrying the user's signed command. Deadlines and nonces constrain its validity. Any relayer tip comes from the user's surplus balance. The relayed transaction reverts if that balance cannot cover the tip. This route requires compatible client and relayer support. The command and its execution conditions use EIP-712 typed signatures.

Ambient - your questions answered

Does an Ambient Liquidity Position Have to Be an NFT?

An Ambient liquidity position can be stored as a native entry in the exchange contract without an NFT. Full-range positions can also be wrapped as ERC-20 LP tokens when a token representation is useful. The representation affects how ownership is tracked; it does not remove the underlying position's liquidity exposure.

Why Can Two Tokens Share the Same Ticker on Ambient?

Token symbols are descriptive labels, so separate token contracts can use the same ticker. The contract address and network identify the asset you select. Matching symbols do not establish shared balances or liquidity. ERC-20 defines an optional symbol method without making it a unique identifier, so a ticker alone cannot establish token identity.

Can an Ambient Swap Fill Only Part of the Requested Quantity?

An Ambient swap can stop with part of its requested quantity unfilled when it reaches an encoded curve-price limit. This limit applies to the pool's marginal price, while the minimum-output or maximum-input constraint governs acceptable token flows. A partial fill can succeed only if those separate settlement constraints also pass.

Is Approval Needed for the Token I Receive From a Swap?

Receiving tokens from the exchange does not require a spending approval for the output token. Approval or a compatible permit concerns ERC-20 tokens the contract collects from your wallet. Spending an existing surplus balance also avoids a new wallet-token approval because those tokens already sit inside the exchange contract.

How Soon Can Newly Added Concentrated Liquidity Be Withdrawn?

A pool's configured minimum holding period can block removal of newly added concentrated liquidity. The timer runs from position creation or its latest liquidity increase. A burn attempted before that period passes reverts. This rule limits just-in-time liquidity withdrawal, and moving out of range does not itself waive the pool's holding requirement.

Can I Initialize a Pool for a Token Pair With No Existing Market?

A permissionless pool type allows users to initialize a previously uncreated pool for a token pair. Initialization sets a starting price and permanently commits seed liquidity under the protocol's configured requirement. The required tokens need valid funding. Creating the pool establishes its market structure; subsequent liquidity determines the depth available for trading.

Updated ยท