DEVOXPAD
Documentation

DevoxSwap

A constant-product AMM built to price a token whose balances are encrypted.

Why DEVOXPAD ships its own DEX

COTI has no Uniswap deployment. More importantly, a stock one could not work here even if it did.

Uniswap V2 works out what a pair holds by calling balanceOf on itself. A COTI PrivateERC20 answers that with a ctUint256 ciphertext handle rather than a number, so a stock pair would compute nonsense reserves and be drained on the first trade. This is not a gap in the port. It is what encryption means.

PrivateERC20.sol
function balanceOf(address account)
    public view virtual override
    returns (ctUint256 memory)   // ciphertext, not a number
{
    return _balances[account].userCiphertext;
}

Internal reserve accounting

A DevoxSwapPair never reads a balance. It pulls tokens itself with transferFrom and credits its own reserve0 and reserve1, so the amount is known because the pair moved it. Everything else is the V2 design: x times y equals k, 0.3% to liquidity providers, and a minimum liquidity burned forever so a pool can never be fully emptied.

The honest cost

Because reserves are internal, a raw transfer into a pair is a donation nobody can claim, and fee-on-transfer tokens are unsupported. Both are acceptable. Reading an encrypted balance is not possible at all.

Model
Constant product, x * y = k
Fee
0.3% to liquidity providers
Minimum liquidity
1000 units, burned on the first mint
Pair discovery
CREATE2, so an address is derivable before it exists
LP token
A public ERC-20 on every pair

LP shares are deliberately public. They must be transferable and readable for a pool to function, so no privacy is claimed for them.

Swapping tokens DevoxSwap has no pool for

DevoxSwap only has pools for tokens launched here. That used to mean every other token on COTI - gCOTI, WETH, wADA, the stablecoins, anything bridged - simply could not be traded in this app, even though the chain has depth for all of them. The swap page now routes to whichever venue can actually fill the trade.

  1. 1
    DevoxSwap first

    If a pool exists, it wins. A constant-product pool prices continuously, fills in one hop, and cannot run out partway through a trade.

  2. 2
    Otherwise the order book

    COTI's order book holds posted orders for most tokens on the chain. If it has depth for the pair, the trade fills there instead - same page, same two clicks.

Why the venue is shown

A pool and an order book are not interchangeable. An order book can fill part of a trade and then run out of orders, and a pool cannot. When that happens the quote says so and prices only the part that can actually be filled, rather than quoting an amount and reverting on send.

How an order-book route is built

An order-book trade is not a path through pools. The contract takes a list of specific orders and how much of the input each one receives, and fills exactly what it is told - so the matching a DEX router would do on chain has to happen before the transaction is sent. DEVOXPAD reads every order on the pair, works out each one's price and how much it can absorb, and fills the cheapest first.

The contract's own curve, re-derived. A and B are compressed floats: mantissa in the low 48 bits, exponent above.
marginal price   ((A·y + B·z) / (z · 2^48))²      target per source
capacity         y·z·2^96 / ((A·y + B·z)·B)       source needed to drain it
Two ways to get this subtly wrong

The marginal price is the SQUARE of that ratio - using it unsquared still sorts the book by a monotonic function of price, so the route looks fine while filling in the wrong order. And the order book charges a 0.2% fee out of the target amount, so a locally computed quote comes out high by exactly 1/(1 - fee) and reads like a rounding error. Both were caught by checking against the contract's own calculateTradeTargetAmount before any of it shipped.

The contract has the last word

This code picks which orders to fill. It never decides what you are told you will receive: the final number comes from the venue itself, and if the venue will not price the route, no quote is offered at all rather than one this app invented.

The router

Pairs pull their own tokens, which leaves the router with a narrow job: wrap and unwrap native COTI around a swap, apply a deadline, and expose quotes. It holds no funds between calls and has no admin.

Two signatures to sell

Selling needs an approval and then the swap. That is the ERC-20 dance, not something DEVOXPAD adds. COTI's PrivateERC20 additionally refuses to overwrite a non-zero allowance with another non-zero value, so the interface resets the allowance to zero first.

DevoxSwap · DEVOXPAD