Liquidity Source Integration Proposal
Title
Baseline Integration
Author
- Discord: 0xzx
- Telegram: @zaqk1
- Email: zeezdev0@gmail.com
Simple Summary
Baseline Mercury is an on-chain power-law AMM. Each market is a single-sided bonding-curve pool that prices one token (the bToken) against a configured reserve asset (e.g. WETH, USDC, or native ETH via a wrapped reserve).
The protocol is fully on-chain and accessed through a single router contract.
Motivation
- Capturable existing flow. CoW Swap already settles a meaningful stream of REPPO trades today — but routes them to less efficient venues (Aerodrome, Uniswap) that don’t reflect Baseline’s curve. Those same orders would execute at better
prices against the Baseline REPPO pool. - Supported pairs/assets. Each pool is
bToken / reserve; the reserve is configured per pool. Baseline has many live markets. The highest-priority one for this integration is REPPO / VIRTUAL on Base. - Existing integrations. Baseline liquidity is already integrated with major aggregators including 0x and KyberSwap.
- Liquidity depth. Depth is the pool’s reserve balance, readable live on-chain as
totalReserves(bToken). For the REPPO pool this is ~514,800 VIRTUAL (~$317k).
Examples
Below are a few examples of CoW Swap transactions that solvers could have routed to Baseline for better execution.
- Buy — Base tx
0x90870a0bf5fc0c698851b20505a0468f32d359be4ed663b53f8fdacc46f7be96:
0.2 WETH → REPPO, split across two external pools.
The same order routed WETH→VIRTUAL→Baseline yields about +40 bps. - Sell — Base tx
0xfd357d037b29803804c0098f5e241500023f12ba7f8925993aa331966b8e8475:
2,916 REPPO → USDC, routed REPPO→WETH across three external pools.
Routed REPPO→VIRTUAL→Baseline instead, the proceeds are about +31 bps higher.
Technical Specification
Architecture
All calls, quotes, and swaps go to a single Relay router address (a delegatecall proxy that dispatches by function selector).
- A market is identified by its bToken address (an ERC-20). Every function takes the bToken as its first argument.
- The reserve asset for a pool is discoverable via
reserve(bToken) → ERC20. - All amounts are in each token’s native decimals.
- bTokens and reserves are standard ERC-20s. If the reserve is wrapped-native (e.g. WETH), the
payablebuy path also accepts native ETH (msg.value), refunding any overpayment.
Deployment. The Relay is deployed at the same address on every chain:
0xc81Fd894C0acE037d133aF4886550aC8133568E8
Supported chains: Eth mainnet, Base
Contract interfaces & ABIs. All functions below are reached on the Relay address. ABIs and reference docs: baseline.markets/docs/contracts
Price Discovery
| Function | Returns |
|---|---|
quoteBuyExactIn(BToken bToken, uint256 reservesIn) |
(uint256 tokensOut, uint256 fee, uint256 slippage) |
quoteSellExactIn(BToken bToken, uint256 tokensIn) |
(uint256 reservesOut, uint256 fee, uint256 slippage) |
quoteBuyExactOut(BToken bToken, uint256 tokensOut) |
(uint256 reservesIn, uint256 fee, uint256 slippage) |
quoteSellExactOut(BToken bToken, uint256 reservesOut) |
(uint256 tokensIn, uint256 fee, uint256 slippage) |
feeis the swap fee in reserve units;slippageis price impact in WAD (1e18 = 100%), measured against the block snapshot.
Optional — local quoting. A getQuoteState view returns a full pool snapshot that lets a solver reproduce quotes off-chain and price unlimited candidate sizes locally, without an eth_call per quote. It’s an advanced path with extra
integration work, so we’ve left the details out here — solvers interested in using it should reach out and we’re happy to walk through it.
Recommended (lowest gas):
| Function | Semantics | limitAmount | Gas (typical / range) |
|---|---|---|---|
buyTokensExactOut(BToken bToken, uint256 tokensOut, uint256 limitAmount) |
pay reserve for exactly tokensOut bTokens |
max reserves to spend | ~172k / 170k–310k |
sellTokensExactIn(BToken bToken, uint256 tokensIn, uint256 limitAmount) |
sell exactly tokensIn bTokens for reserve |
min reserves to receive | ~176k / 175k–290k |
buyTokensExactOut is payable (accepts native ETH when the reserve is wrapped-native).
Supported but more expensive. These run an on-chain binary-search solver and cost ~2–2.4× more gas; use only when the counter-side amount must be exact:
| Function | Semantics | limitAmount | Gas (typical / range) |
|---|---|---|---|
buyTokensExactIn(BToken bToken, uint256 reservesIn, uint256 limitAmount) |
spend exactly reservesIn reserve for bTokens |
min tokens to receive | ~418k / 390k–550k |
sellTokensExactOut(BToken bToken, uint256 reservesOut, uint256 limitAmount) |
sell bTokens for exactly reservesOut reserve |
max tokens to spend | ~376k / 375k–450k |
buyTokensExactIn accepts ERC-20 reserve only (no payable path).
Example: buy
// 1. Size the fill (view).
(uint256 reservesIn,,) = relay.quoteBuyExactOut(bToken, tokensWanted);
// 2. Approve the Relay to pull reserve (or send native ETH as msg.value).
reserveToken.approve(address(relay), reservesIn);
// 3. Swap
relay.buyTokensExactOut(bToken, tokensWanted, reservesIn);
Example: sell
// 1. Size the fill (view).
(uint256 reservesOut,,) = relay.quoteSellExactIn(bToken, tokensToSell);
// 2. Approve the Relay to pull the bTokens.
bToken.approve(address(relay), tokensToSell);
// 3. Swap (reservesOut is the minimum reserve to receive).
relay.sellTokensExactIn(bToken, tokensToSell, reservesOut);
Integration Incentives
Not at this time.
Additional Information
Security audits
Baseline has completed multiple independent review and remediation rounds. Audit reports and security documentation: baseline.markets/docs/contracts/security
Contact Information
- discord: 0xzx
- telegram: @zaqk1
- email: zeezdev0@gmail.com
- Response time expectations: 1-2 hours