P2P
Documentation

How P2P works.

One contract, four functions that move tokens, and no oracle. This page describes exactly what the code does and what it does not.

What P2P is

P2P is a peer-to-peer exchange for ERC-20 tokens. One party locks tokens in the P2POTC contract and states the exact amount of another token they want. A second party pays that amount and receives the locked tokens in the same transaction.

It is not a DEX, an aggregator, or an order book. There is no pool, no matching engine and no price feed.

Why OTC exists

An automated market maker prices each token of a trade worse than the previous one. In a deep pool that is negligible. In a shallow pool a large order can receive far less than its quoted value, and it moves the pool's price for everyone else.

If a buyer for the whole position exists, the two sides can simply agree a price. The only thing missing is a way to swap without one side having to send first. That is all P2P provides.

A direct exchange does not consume pool liquidity. It does not make the trade invisible, and it does not stop the buyer from selling into the pool later.

How a funded offer works

Makeroffers TOKENP2POTCescrow · terms · feeall-or-nothingTakerpays HYPE1 · escrow2 · payment3 · ask − fee3 · TOKENSteps 2 and 3 are one transaction. If any transfer fails, all of it reverts.
  1. Create. The maker approves the exact amount and calls createOrder. The contract pulls the tokens, checks that it received exactly that amount, and records the order with the current fee rate.
  2. Discover. The OrderCreated event is indexed. Listed offers appear in the marketplace; every offer has a link of the form /deal/<chainId>/<orderId>.
  3. Fill. The taker approves the exact asking amount and calls fillOrder(id, termsHash). The hash commits to the terms the taker reviewed.
  4. Settle. In that call the contract marks the order filled, pulls the payment, forwards it to the maker minus the fee, and releases the escrow to the taker.

Public, unlisted, restricted

ModeOn-chainEffect
Publiclisted = true, no takerShown in the marketplace. Anyone can fill.
Unlistedlisted = false, no takerHidden from the marketplace. Anyone with the id can fill.
One walletallowedTaker setOnly that address can fill. Enforced by the contract.

None of these is private. listed is a hint to indexers. Every offer, its amounts and its addresses are readable by anyone on the chain.

Escrow and atomic settlement

Offered tokens are held by the contract, not by a person or a team wallet. The contract tracks the total owed back per token (totalEscrowed) separately from fees it has earned (accruedFees); the test suite checks after every random action that the token balance equals the sum of the two.

fillOrder updates state first and transfers afterwards, behind a reentrancy guard. If the payment, the payout or the escrow release fails, the whole transaction reverts and nobody's balance changes. An order can be filled once.

Offers are full-fill only in this version. Partial fills are planned and deliberately not included yet.

Fees

P2P charges no fee. The taker pays exactly the asking amount, the maker receives all of it, and the taker receives the full escrow. The only cost is network gas, paid in HYPE by whoever sends each transaction.

  • The contract does have a fee setting, currently 0. Its owner could raise it for future offers, never above 1% (MAX_FEE_BPS = 100, a constant).
  • The rate is stored on each offer when it is created, so a later change can never touch an existing offer.
  • The review step and the deal page always show the rate that applies to that offer, read from the contract.

Expiry, cancellation, recovery

  • Every offer has an expiry timestamp, at most 365 days out. Expiry is a condition, not a transaction: once the time passes, fillOrder reverts even though the stored status still says open.
  • cancelOrder: the maker withdraws the escrow at any time before a fill, including after expiry.
  • reclaimExpiredOrder: after expiry anyone may trigger the refund. The tokens go only to the maker.
  • Both keep working while the protocol is paused.

Supported assets

Both sides must be ERC-20 contracts. Native HYPE is not accepted directly; it needs a wrapped HYPE token, and a canonical one has not been verified for Elysium yet.

  • Transfer-tax tokens are rejected. Every inbound transfer is checked by balance difference and reverts if less arrives than was sent.
  • Tokens that return nothing from transfer (USDT-style) work.
  • Rebasing tokens are not supported. A negative rebase would leave the escrow short.
  • Pausable, blacklisting or upgradeable tokens can block a fill or a refund. That risk is the token's, and P2P cannot remove it.
  • An optional on-chain allowlist can restrict which tokens new offers may use. On Elysium it is currently off, so any ERC-20 can be offered; the owner can turn it back on. It never blocks filling, cancelling or reclaiming an existing offer.

Reviewed tokens configured for this build (Elysium):

SymbolAddressDecimals
WHYPE0xbA876237B0F021A6c6D852d6c26E107997cC5E8118
USDC0xb47c4C8F73F009CC0C0d3f92B388d13E293F0B656
kHYPE0x248888D396A546A69A188f3Deb476964e581E9d018
KNTQ0xe45a355d9e9cAd2aD85F2d03E3eE3102A036acF018
UBTC0xE9C29585EAe4B9a55b02a9605AEa892B40d972E88
UETH0x7A66A75fe41Bc26867C17fe1bc7D1C076EBd4eCd18
M100xB97b1A77C2039Addc78b594300C4f69EBBCbA3e218
VOID0xD31B21Cb80E431AC996269deC31A40fCf048B77f18
AGI0x74F811F35134D73221E5491135E4C8f96331695318
ELYSIAN0xb96EcE0Cfa2C9DFeD18e26A2F16D60a1be48075518
EGG0xCb0Bb01149163AfEB8E1a80787A265F87634b6b518
PERP0x231e303Fc99f8Ff35fb089c707981e3767d4E6B718
SYMB0x6668AA70A1F1a9E6e096Ae73eFe21Fe87685579918
JELLY0xC6673922B09570711675873F9dbd3B389117163b18
HYPEPE0x5dCFb191f0cDB853BAc3A6A4385e160E779e377F18
CITIZEN0x7b40B1999E1227aDd159AdA58C11C3Af3d84F64c18
QUOTED0x66f46517D0C2CFa489bcBf776D127D59c79fA49918
GRASS0x2b2Ffc9435c470f4C96eAf3b9a51Fe212b8c048418
RAM0x2ea9E66Adb86b0Ed71f79ab2e81a31147eDc321518
CLU0x4888cd903c91Da581C82147Ff3C80aDDBc7c2eC818
SMOOR0x0C4CB3d13067BD5D86A857F3344A47ECC7160C0218
LUMI0xD564380a0e9752D25e4E8305E796A0a58d0456bf18
TREMOR0x5b601A07748cE9868dD46012EbC7F7ecFb64087118
INDEX0xBDF7119C6Fa191Ea0576792910c8db8ca3f0e80118
PANTHEON0x892723Bf41F2E1af70ADb1fF19036810888473a318
HELIOS0xa698ddceaD546AC40ae09D3f9fbC235Cf623679718
TANGENT0x5bc7c1F1afC2d1c51A0bdFC241Cb525Bc4b02Fc918
MAXIMUS0xEb8bCC0fdE0e76D26F1FBcB38BF476C837b9292718
burn0x5A614150bdB6eE403b3F002cbCd3621a7240AdC418
AGORA0x5e5Df82d563FCF36b6f853c4D09f89e2d18825B418
CORPUS0xA0D3C65d7DE62931C1A0cf62FB9BbDAC7af2921518
CHAMELEON0xd662D66eC991A3eae4EcBdA34327264c53d4cF3818
LEASH0x0d442948A8748F0296aF853c85EC054D875c010f18
Troy0x597E37295E8Ee74d55969def5007dD5Afb3A6b2a18
TAIL0xC6333959D096f151dee397AC56c9259a1127B87018
PORTED0x21436b58f67724025A53c396f796DCd50C6D4f4418
ELO0xe107e5D99910F544f88ef961E3cA6d88F06f29DD18
EVERMOR0x7f4f3b9770648262fe5133B9CB8A2155173be0d418
EACCAT0x32193Afd14c53f12c45A4c04ECA9F7Ba98e3ec7118
MONTRA0x063F7Cc5339f92a5FD7BaF3D22233044FdA1F32718
BLOB0x69E58778c986a036cdF7EE93A18e173BFd47B10B18
ICE0x49c08C6Bb912f512A467a2973FB93Cb2c91436dE18
POCKET0xF0394d1E25BE152C9746791f5DA3B287743f0E5218
LiquidV0xd12609Ddb1CD18280C7C14fB2CB5091CFEa37f2D18
HI0xC75f783646739542C1E3680FD64424A0c4088D6918
LONGCAT0xbb5629257e6A28Fe3dbd8f9eB032129FE238d7b618
UNSEEN0x6d1523348ad84210eE51d08676618fF5DD2B281918
e/acc0x8df4f39d592de2aAee15838B265C2392d19A412818
HYDE0x594267928A0e4Aa76e34aC441B116E01ff231dF518
KM0xCdA74aC622378106582102CE6Cd8599F3BA0d76918
YTR0x5eBd8EfB0ff0387702365Ec0BACcDA20621F54eb18
NUM0xE9C952CD198Ff412113a465D34Ff2C233F6F4ca118
VOLTA0x0f79931689Af199e7CF868ed1107bBA2C83c68f718

AMM comparison method

Where a pool is configured for a token pair, P2P reads its live reserves and computes what the same size would fetch there, using constant-product math in integers:

in'  = amountIn × (10 000 − feeBps)
out  = in' × reserveOut / (reserveIn × 10 000 + in')
spot = amountIn × reserveOut / reserveIn
  • Seller view: pool proceeds versus what the deal pays.
  • Buyer view: pool cost to acquire the same amount versus the deal's asking amount.
  • The source, pool fee and age of the reserves are shown. Gas is excluded.
  • If no verified pool exists the comparison says so. P2P does not estimate.

This math is exact only for x·y=k pools. Montra's pools on Elysium are Uniswap v4 pools with a hook, which need the v4 quoter, not this formula. That integration is not built, so on Elysium the comparison is unavailable until a verified adapter exists. The number is never used for settlement.

Pools configured for this build: none.

Contract architecture

A single immutable contract, P2POTC, Solidity 0.8.26, OpenZeppelin 5 (SafeERC20, ReentrancyGuard, Ownable2Step). No proxy, no upgrade path: a new version is a new address.

FunctionCallerDoes
createOrdermakerEscrows tokens, opens an order
fillOrdertakerPays and receives, atomically
cancelOrdermakerRefunds an unfilled order
reclaimExpiredOrderanyoneRefunds the maker after expiry
withdrawFeesanyoneSends accrued fees to the fee recipient
getOrder, effectiveStatus, isOrderFillable, calculateSettlement, getRemainingAmounts, orderTermsHashviewsRead state

Orders live in a mapping keyed by an incrementing id. Nothing on-chain iterates over orders; discovery is by events.

Admin permissions

The owner (intended to be a multisig) can:

  • set the fee rate for future offers, up to 1%;
  • change the fee recipient;
  • pause creating offers and/or filling them;
  • enable the token allowlist and add or remove tokens.

The owner cannot, because no function exists to do it:

  • move, seize or redirect escrow;
  • change an offer's amounts, tokens, counterparty, expiry or fee;
  • stop a maker cancelling or reclaiming;
  • withdraw anything other than accrued fees, and those only to the fee recipient.

Security limits

  • Not audited. 62 unit and fuzz tests and 5 invariant tests pass. That is evidence, not proof.
  • No privacy. All offers and settlements are public.
  • No ordering protection. On a public offer the first confirmed fill wins. Others revert and lose only gas.
  • Token risk is not removed. See supported assets.
  • Simulation is a hint. The interface simulates before asking for a signature; a passing simulation can still fail on-chain if state changes first.
  • EVM target. Bytecode is compiled for the paris EVM so it does not depend on newer opcodes, because Elysium's fork level could not be confirmed.

Indexer and API

The indexer reads P2POTC events, keys each by transaction hash and log index, re-reads the most recent 12 blocks on every pass to absorb reorganisations, and rebuilds from the deployment block if its checkpoint no longer matches the chain. It holds no keys and cannot affect settlement. Deal pages read the contract directly and work without it.

GET /api/orders?status=open|filled|cancelled|expired|all
               &maker=0x… &taker=0x… &token=0x… &offered=0x… &requested=0x…
               &sort=newest|oldest|expiring|size &limit=1..200 &offset=
GET /api/orders/:id
GET /api/activity?type=created|filled|cancelled|reclaimed&limit=&offset=
GET /api/stats
GET /api/tokens/:address

All inputs are validated, responses are paginated, and requests are rate limited per client.

Deployment status

This build targetsElysium, chain ID 99901
P2POTC address0x5FaBF29765132f800880EdD88f114AF172871ed7
RPC configuredYes
Elysium mainnet (99901)Deployed at 0x5FaBF29765132f800880EdD88f114AF172871ed7 (block 16621591). Unaudited.
AuditNone

Open items before a mainnet deployment:

  • A general-purpose Elysium RPC. The Montra RPC only relays Montra's own transactions and refuses everything else, so it cannot deploy or call P2P.
  • Confirmation of the chain's EVM fork level, a block explorer and its verification API.
  • Verified addresses for wrapped HYPE and any stablecoin, added to the token config.
  • A v4 quoter adapter if pool comparisons are wanted for Montra pools.
  • An independent audit and a multisig owner.

FAQ

Does the P2P team hold my tokens?

No. They sit in the contract, and the contract has no function that lets an admin move them.

Can I get a better price than the pool?

Sometimes. For large size in thin liquidity, often. For small size in deep liquidity, usually not. The comparison shows both honestly when a pool is available.

What if nobody takes my offer?

Cancel whenever you like, or let it expire and reclaim. You pay gas, no fee.

Is there a P2P token?

No. The protocol does not need one.

Can I counter-offer?

Not in the contract. Create your own wallet-restricted offer with the terms you want and send the other side the link.

Read the risk disclosure