This page describes how third-party providers can create DEX pool
templates, add initial liquidity, build swap or liquidity frontends and
connect external DEX APIs to Cookchain RPC streams.
Explorer v2026.06.30.25Pool deploy RPC: https://rpc.ldbl.net
Concept
A Cookchain DEX pool is a pair of two token contracts plus reserves,
LP ownership and fee settings. The first liquidity operation creates
or initializes the pool state when the target node allows it. Later
liquidity and swap calls update the same pair and emit DEX events.
External providers should treat pool deployment like a Solidity router
workflow: validate token contracts, convert display amounts to raw
units, submit the pool transaction from a backend, then watch the pair
streams until the pool appears in the explorer.
Base URLs
Pool Deploy RPC
https://rpc.ldbl.net
Fullnode / Validator
http://127.0.0.1:9000
Local node
http://127.0.0.1:9000
This explorer proxy
/api/* forwards to the configured node
Public DEX apps should call their own backend first. The backend
validates input, checks balances and slippage, signs or authorizes the
operation, then calls https://rpc.ldbl.net. The fullnode
remains the primary chain data source.
Core Endpoints
Method
Path
Use
GET
/api/dex/pairs
List deployed pools and pair metadata.
GET
/api/dex/pool?token_a=...&token_b=...
Load one pool by token pair.
GET
/api/dex/price
Read current DEX price data.
GET
/api/dex/liquidity
Read liquidity and reserve data.
GET
/api/dex/trades
Read recent trades.
GET
/api/dex/events
Read DEX event history.
POST
/api/dex/liquidity/add
Create or fund a pool by adding liquidity.
POST
/api/dex/liquidity/remove
Remove liquidity from a pool.
POST
/api/dex/swap
Swap one token into another token.
GET
/api/stream/pairs
Server-sent pair and pool updates.
GET
/api/stream/liquidity
Server-sent liquidity updates.
GET
/api/stream/trades
Server-sent trade updates.
GET
/api/stream/prices
Server-sent price updates.
Compatibility paths without /api exist for liquidity and
swap on current nodes: /dex/liquidity/add,
/dex/liquidity/remove and /dex/swap.
Add Initial Liquidity
Amounts are raw token units. Convert display values with
raw = amount * 10^decimals. For a token with 18 decimals,
25.68 display units are submitted as
25680000000000000000 raw units.
When the pool already exists, the node can reject deposits that do not
match the current reserve ratio. Always quote the pool before adding
more liquidity.
External routers should calculate expected output and slippage before
calling the node. Keep the final user confirmation in display units,
but submit only raw units to the RPC.
Use streams for pool cards, prices, candle builders, route refreshes
and explorer-style deploy history without full page reloads.
External DEX API Shape
A hosted DEX provider should expose its own stable public API and keep
Cookchain RPC details behind a service layer. This allows templates,
custody rules, rate limits and future router logic to change without
breaking frontend clients.
GET /v1/tokens
GET /v1/pools?limit=20&page=1
GET /v1/pools/:pairId
POST /v1/pools/quote
POST /v1/pools/deploy
POST /v1/liquidity/add
POST /v1/liquidity/remove
POST /v1/swap/quote
POST /v1/swap/submit
GET /v1/stream/pools
GET /v1/stream/trades
GET /v1/stream/prices
Resolve token contracts through /api/token/info/:contract.
Normalize pair order so the same two tokens always produce one pair id.
Convert every user amount to raw units once and store the conversion.
Check balances, allowance model, pool ratio, fee and slippage server-side.
Submit liquidity or swap calls to https://rpc.ldbl.net.
Persist request id, RPC response, txid, pair id and explorer links.
Subscribe to DEX streams and update your public API cache.
JavaScript Template
function toRaw(amount, decimals) {
const [whole, fraction = ""] = String(amount).split(".");
return BigInt(whole + fraction.padEnd(decimals, "0")).toString();
}
async function deployPool(baseUrl, pool, operatorToken) {
const body = {
token_a: pool.tokenA,
token_b: pool.tokenB,
amount_a: toRaw(pool.amountA, pool.decimalsA),
amount_b: toRaw(pool.amountB, pool.decimalsB),
lp_owner: pool.lpOwner
};
const res = await fetch(`${baseUrl}/api/dex/liquidity/add`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${operatorToken}`
},
body: JSON.stringify(body)
});
if (!res.ok) throw new Error(`pool deploy failed: ${res.status}`);
return res.json();
}
Explorer Links
Pool detail: /explorer/pool/:pairId
Token detail: /explorer/token/:contract
Contract detail: /explorer/contract/:id
Deploy overview: /deploys?tab=pairs&page=1
Pool logo metadata can use normal URLs or IPFS gateway URLs, same as token logos.
Security Checklist
Do not place operator tokens, private keys or admin secrets in browser JavaScript.
Require server-side slippage checks and quote expiry for every swap or pool deploy.
Never mix raw units and display units in the same field.
Use idempotency keys so duplicate browser submissions cannot deploy duplicate pools.
Rate-limit public endpoints and keep an allowlist or risk score for newly deployed tokens.
Persist pair creation, liquidity changes and swap submissions for audit and support.