Ambient (formerly CrocSwap) is a decentralized trading protocol that allows two-way AMMs that combine centralized and ambient constant product liquidity on any pair of blockchain assets. Ambient runs the entire DEX within a single smart contract, where a single AMM pool is a lightweight data structure rather than an independent smart contract. This design makes Ambient the most efficient Ethereum-based DEX currently.

Mechanism Analysis
Automated Market Maker (AMM)
In Ambient, liquidity is provided through an automated market maker (AMM) mechanism. Unlike traditional limit order books (LOBs), liquidity is not provided by individual orders, but by the overall liquidity of the liquidity pool composed of funds provided by liquidity providers (LPs).
Each liquidity pool in Ambient represents a two-way market between a pair of interchangeable assets or tokens. At any given time, each liquidity pool has a single exchange rate determined by the ratio of virtual reserves committed to the pool. End users can exchange one token in the pair for another according to a deterministic formula.
The Ambient liquidity pool uses a constant product market maker (CPMM) algorithm. Regardless of the size or direction of the exchange, the product of the two aspects of the virtual reserve will remain constant. (In addition to the fees collected and the increase in concentrated liquidity). When an exchanger sends a certain amount of the base token to the pool, the liquidity pool will return a certain amount of the quote token based on this constant product relationship. Therefore, the exchange rate of the liquidity pool will rise to increase the exchange rate of the quote token relative to the base token.
The mechanism balances supply and demand by re-adjusting prices proportionally based on the size and direction of the swap. So instead of getting an instant exchange rate, swappers get a slightly worse price based on the size of their trade relative to the liquidity in the pool. This difference is called a price bump.
In addition, swappers pay liquidity fees based on the notional amount of their trades. Liquidity fees are redistributed to LPs based on their proportional contribution of active liquidity in the liquidity pool. Rates vary based on the specific liquidity pool and may be adjusted based on market conditions, but are typically in the range of 0-1%.
Centralized Liquidity
Pooled liquidity allows users to provide liquidity within any predefined price range on a single AMM curve. This is in stark contrast to Ambient liquidity, where liquidity remains active at all possible prices from zero to infinity.
The advantage of pooled liquidity is primarily capital efficiency. Liquidity providers (LPs) only need to commit the collateral required to support a limited range of liquidity. For example, a stablecoin pair trading between $0.99 and $1.01 would require significantly less capital to provide centralized liquidity.
The downside of pooled liquidity is that if the curve price is outside the order range, the liquidity provider will no longer accrue fees. Therefore, pooled liquidity providers must either determine their price ranges wisely or periodically "rebalance" the order book to move it back into range.
Ambient also supports native Ambient liquidity, which is different from "full scope centralized liquidity". The first advantage is that, unlike fees accumulating in separate side pockets, Ambient Liquidity Provider fees automatically compound back to their original position without any manual management. The second advantage is that the gas cost required to mint and burn the positions of Ambient liquidity providers is significantly lower. The third advantage is that the positions of all Ambient liquidity providers on a given curve are naturally interchangeable and can be easily packaged into "LP tokens".
Eliminate liquidity
Elimination of liquidity behaves the same as range-based concentrated liquidity, except that any time the curve price exceeds the edge of the range, liquidity is permanently removed from the AMM curve. Elimination of liquidity can be set when the curve price falls below the bid price or when the curve price rises to the ask price.
The behavior of Knockout Liquidity is somewhat similar to an “irreversible limit order” in a traditional centralized limit order book. Users who want to achieve directional execution at a better price than the current market price can buy (sell) in the pool by bidding (selling) below (above) the current price. As long as the price at a certain point exceeds that point, the user's order will be executed. Unlike the original centralized liquidity range order, the tokens purchased by the user will not be converted back even if the price rises back above the fill price. For this reason, Knockout Liquidity is a useful tool for users who want directional execution but want to obtain more favorable prices than traditional swaps.
Eliminating liquidity orders provides better prices
Waiting for cheaper prices
Receive rather than pay swaps
Avoiding price slippage on AMM curves
In practice, elimination of liquidity is often subject to some restrictions by users
Unlike typical pooled liquidity, the width of range orders is fixed (usually narrower) for all knock-out orders across the entire pool.
The knockout bid must always be below the current curve price, and the knockout bid must always be above the current curve price.
In order to be fully knocked out, the price must move completely through the range. If the curve moves to the middle of the range, the order may be "partially filled". If the price moves back into the range without reaching the knockout price, it switches back.

User Level
Token Swap
Ambient's core functionality is to allow users to exchange one type of token for another at a fair market price. If there is liquidity for a given currency pair in the DEX contract, then users will be able to swap between tokens. In addition, the front-end web application provides an interface for general-purpose exchanges.

Remaining Collateral
Users can deposit a certain amount of tokens directly into the DEX contract as a static balance. Excess collateral can be used as lightweight working capital, so the overhead and transaction costs are lower than processing ERC20 token transfers in each swap, minting and destruction operation. Excess collateral can be deposited by users directly by sending tokens directly to the DEX contract. Or it can be received as an output of a swap, destruction or harvesting operation. In addition, excess collateral can also be withdrawn directly, so that the user's wallet will receive the corresponding base tokens.
Governance & Policy
The governance of the Ambient Protocol is ultimately controlled by the DAO multisig. There are two main multisigs, the operational multisig and the financial multisig.
Multi-signature action capabilities include:
Set and modify pool parameters (e.g. liquidity fees, tick intervals, JIT thresholds, etc.)
Initialize a new pool type template
Set, turn on or off agreement fees
Set sub-price size improvement token size threshold
Sets a minimum liquidity commitment for newly initialized pool types.
Install the policy oracle pipeline with any functionality to operate multi-signature.
Treasury multisig is reserved for more serious executive actions. However, this requires a higher degree of commitment and longer delays. Treasury multisig combines Gnosis Vault with a 5-day time lock. In addition to standard operational multisig permissions, Treasury multisig can:
Upgrading the code in the DEX contract
Transfer DEX permissions to a new policy controller contract
Collecting Accumulated Protocol Fees in DEX
Force uninstallation of policy oracle before it expires
Force conversion of permissioned pools to permissionless pools (in case of misbehaving permission oracles)
System Overview

Governance fills the traditional role of a DAO. It has full authority over the protocol and is controlled by M-of-N multi-signature and time-lock solutions.
Policy is an intermediary layer that sits between DAO governance and the DEX contract itself. It can either directly pass on solutions from the governance layer, or delegate limited management control of the DEX to an external smart contract policy oracle that is explicitly installed by the DAO governance.
The mechanism is the underlying DEX contract itself. CrocSwapDex (the core smart contract that holds decentralized liquidity and positions) is built with adjustable parameters that can be dynamically adjusted by external policy oracles. This allows the protocol to improve and try new features in a safer and more controlled way than directly upgrading the underlying DEX smart contract.
Advantage
As a brand new code base, Ambient takes into account the best engineering practices and innovative smart contract architecture choices. This gives it some core advantages over other DEXs:
Significantly save gas fees.
Combine concentrated ("UniV3 style"), ambient ("UniV3 style"), and knockout liquidity (behaving like limit orders that atomically fill and lock positions in a single direction) on the same liquidity curve.
Dynamically adjusted pool fees that maximize returns to liquidity providers relative to market conditions and demand for liquidity.
Since fees from pooled liquidity providers are automatically reinvested into ambient liquidity, users can earn compound interest even if they do not harvest manually.
Instant liquidity attacks are prevented by using minimal TTL parameters on concentrated liquidity positions. As a result, regular liquidity providers can earn higher fees.
Users can pre-fund tokens on the DEX in the form of “residual collateral.” By delaying token transfers until net settlement, active traders are more efficient.
Through the EIP-712 off-chain standard, users can conduct “gas-free” transactions with exchanged tokens.
Unique support for a “Limited Permissioned Pool” primitive, which offloads the ability to manage and limit pools to general-purpose smart contract oracles running inside or outside the protocol.
Summary

The model for providing liquidity in Ambient combines the features of decentralized exchanges and centralized exchanges. And unlike other AMMs, liquidity is not decentralized for trading pairs. Ambient can also run the entire DEX system in a single smart contract, thus achieving lower fee transactions, greater liquidity rewards, and a fairer trading experience. As a trading protocol that combines the features of CEX and DEX, Ambient introduces novel DeFi native features to bring users a first-class experience.