Appearance
Contracts
All contracts are on Polygon (chain ID 137).
| Contract | Address |
|---|---|
Peerkets escrow (PredexEscrowV3) | Final deployment pending. Test deployment: 0xaBE8c3A4263d440757e11AB57dbb0Cb53aF921c4 |
| pUSD | 0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB |
| Conditional Tokens (older markets) | 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 |
| PositionManager (Protocol V2 markets) | 0x006F54F7f9A22e0000CC2AB60031000000ae9fEF |
Units
Shares and pUSD both use 6 decimals. price is pUSD units per 1e6 share units, so 62¢ is 620000. The cost of shares at price is shares * price / 1e6, rounded down.
Functions
| Function | Who | What |
|---|---|---|
createOrder(ledger, tokenId, side, price, shares, expiry, taker) | maker | Opens an order. side 0 = maker buys, 1 = maker sells. taker = zero address for anyone. |
fill(orderId, shares) | taker | Fills part or all of an order. |
cancel(orderId) | maker | Closes the order and returns the unfilled part. |
reclaimExpired(orderId) | anyone | After expiry, returns the unfilled part to the maker. |
getOrder(orderId) | view | Maker, taker, ledger, side, status, expiry, tokenId, price, shares, filled, pusdLeft. |
Funds are pushed in, not pulled: createOrder and fill succeed only if the escrow's balance already covers what it tracks plus the new amount. Always send the transfer and the call in the same transaction (one Deposit Wallet batch) — untracked funds can be used by whoever calls next.
| Action | Batch |
|---|---|
| Post a sell | ledger.safeTransferFrom(wallet → escrow, tokenId, shares) + createOrder(…, side 1, …) |
| Post a buy | pUSD.transfer(escrow, cost) + createOrder(…, side 0, …) |
| Fill a sell order | pUSD.transfer(escrow, cost) + fill(orderId, shares) |
| Fill a buy order | ledger.safeTransferFrom(wallet → escrow, tokenId, shares) + fill(orderId, shares) |
Events
solidity
event OrderCreated(uint256 indexed orderId, address indexed maker, address taker, address ledger,
uint256 tokenId, uint8 side, uint256 price, uint256 shares, uint48 expiry);
event OrderFilled(uint256 indexed orderId, address indexed taker, uint256 shares, uint256 pusd);
event OrderClosed(uint256 indexed orderId, uint8 status, uint256 sharesReturned, uint256 pusdReturned);OrderClosed.status: 2 = filled, 3 = cancelled (cancel or reclaim).