Documentation Index
Fetch the complete documentation index at: https://prophet.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Prophet’s AMM is a binary YES/NO automated market maker built around complete-set accounting. Unlike Uniswap-style constant-product AMMs that trade two existing tokens, Prophet’s AMM creates and destroys matched pairs of YES and NO shares to maintain solvency at all times. The invariant is simple: for every YES share outstanding, there is exactly one NO share outstanding. This means the pool can always pay $1.00 per winning share, regardless of which side wins.Complete-Set Accounting
The fundamental building block is the complete set: one YES share + one NO share = $1.00 USDT (always). When liquidity enters the pool:- $1.00 USDT creates one YES share AND one NO share
- The pool holds both — these are the reserves
- Each YES share redeems for $1.00
- Each NO share is worth $0.00
- The total USDT in the pool exactly covers all YES share redemptions, because every YES share was matched with a NO share at creation
Pool State
The AMM tracks three values for each market:Seeding: How Liquidity Enters the Pool
When the market-maker agent callsseedLiquidity(collateralAmount):
collateralAmountUSDT enters the pool- An equal number of YES shares and NO shares are minted and added to reserves
- Initial price is 50/50 — YES at 0.50
Buying YES Shares
When a trader callsbuyShares(true, collateralAmount, minSharesOut):
collateralAmountUSDT enters the pool- The same amount of YES shares AND NO shares are minted (complete-set creation)
- The newly minted YES shares are given to the trader
- The newly minted NO shares are added to the pool’s NO reserve
- A trading fee is taken from the collateral before share calculation
Buying NO Shares
The mirror image:buyShares(false, collateralAmount, minSharesOut).
collateralAmountUSDT enters the pool- YES and NO shares are minted
- The newly minted NO shares go to the trader
- The newly minted YES shares are added to the pool’s YES reserve
Selling Shares Back to the Pool
Selling is more complex because it is the reverse operation — shares re-enter the pool and USDT exits. The pool must ensure it remains solvent after the sale. The sell equation that governssellShares(isYes, sharesIn, minCollateralOut):
sameReserve= reserve of the share type being sold (e.g.,yesReservewhen selling YES)oppositeReserve= reserve of the other share type (e.g.,noReservewhen selling YES)sharesIn= number of shares being soldcollateralOut= USDT to be returned to the seller (the unknown — solver must find this)
collateralOut such that the pool remains solvent.
A trading fee is deducted from collateralOut.
Slippage protection: The minCollateralOut parameter lets sellers specify the minimum USDT they accept. The transaction reverts if the AMM would return less — protecting against sandwich attacks and large price movements between tx submission and execution.
Price Discovery in Practice
The AMM price at any moment reflects the current buy/sell pressure. As traders buy YES, the YES price rises, attracting sellers and NO buyers — pushing it back toward equilibrium. This continuous process means the AMM price tracks the market consensus of probability in real time.| Action | YES Reserve | NO Reserve | YES Price |
|---|---|---|---|
| Initial seed (1000 USDT) | 1000 | 1000 | $0.500 |
| Buy YES (100 USDT) | 1000 | 1099 | $0.523 |
| Buy YES (100 USDT) | 1000 | 1198 | $0.545 |
| Buy NO (200 USDT) | 1198 | 1198 | $0.500 |
| Buy NO (500 USDT) | 1693 | 1198 | $0.414 |
Trading Fees
Every buy and sell incurs a fee that accrues to the protocol. Fees are taken from the collateral input (for buys) or output (for sells). The fee breakdown:- Oracle fee: funds the AI oracle agent’s 0G Compute usage
- Market-maker fee: compensates the LiquidityPool for providing initial liquidity
- Protocol fee: goes to the treasury address
View Functions
These read-only functions let the frontend display current state without a transaction:getBuyAmount and getSellAmount before every trade to show the user exactly what they will receive, including the slippage from their specific trade size.
Slippage Protection
All trade functions accept a minimum output parameter:AMM Security Properties
- Non-zero check: Trades with zero input revert immediately
- ReentrancyGuard: All state-changing functions are protected against reentrancy attacks
- SafeERC20: All token transfers use OpenZeppelin’s SafeERC20 — no raw
transfer()calls - Solvency invariant: The sell equation is derived to maintain pool solvency — the pool can never be drained to insolvency by a single trade
- 6-decimal USDT: All amounts use
parseUnits("X", 6)— the contracts assume 6-decimal USDT throughout