HIP-4 Markets Docs

Contracts

The HIP4Shares contract on Elysium: address, token ids, functions, events and roles.

Addresses

ContractAddress
USDC (Elysium canonical)0xb47c4C8F73F009CC0C0d3f92B388d13E293F0B65

Network: Elysium, chain id 99901, RPC https://rpc.elysium.kinetiq.xyz.

Token ids

HIP4Shares is an ERC-1155 contract. A token id is 10 × outcome + side, the same number Hyperliquid uses for the side's coin (# + id). Side 0 is YES (or the first team, or Long), side 1 is NO. Amounts have 6 decimals: 1000000 is one share. Token metadata is served at https://hip4.markets/api/token/{id}.

User functions

FunctionWhat it does
buy(id, usdcIn, maxPx)Posts a buy of usdcIn USDC at an average price no higher than maxPx (6 decimals, under 1000000). Pulls the USDC into escrow.
sell(id, shares, minPx)Posts a sell of shares at an average no lower than minPx. Takes the shares out of the wallet until the order closes.
cancel(orderId)Cancels your own open order after 5 minutes and returns everything.
redeem(id, shares)After settlement, burns shares and pays yesPayout (YES) or 1 − yesPayout (NO) per share.
fund(amount)Adds USDC to the free balance that pays sells and redemptions. Open to anyone.

Keeper functions

FunctionChecks
fillBuy(orderId, shares, cost)order open; cost ≤ the USDC paid; cost / shares ≤ the order's limit. Mints shares, refunds usdcIn − cost.
fillSell(orderId, sold, proceeds)order open; sold ≤ shares in the order; proceeds / sold ≥ the order's minimum. Pays proceeds, returns unsold shares.
reject(orderId)order open. Returns all USDC or shares.
settle(outcome, yesPayout)not settled before; yesPayout ≤ 1000000. Closes the outcome to new orders.

Owner functions

FunctionLimits
setKeeper(address)changes the keeper
setPaused(bool)stops new orders (owner or keeper); fills, cancels and redemptions keep working
setParams(minOrder, cancelDelay)cancel delay capped at one day
setURI(uri)metadata location
withdraw(to, amount)free USDC only: reverts if it would touch escrow

The owner can't mint shares, move anyone's shares, change an order or touch escrowed USDC.

Events

OrderPlaced(orderId, user, id, isBuy, amount, limitPx), OrderFilled(orderId, user, id, isBuy, shares, usdc), OrderCancelled(orderId, user, byKeeper), Settled(outcome, yesPayout), Redeemed(user, id, shares, usdc), Funded(from, amount), Withdrawn(to, amount), plus the standard ERC-1155 TransferSingle and TransferBatch.

Checking the backing

ReadWhereWhat it shows
totalSupply(id)HIP4Sharesshares outstanding for one side
escrowed()HIP4SharesUSDC in open buy orders
free()HIP4SharesUSDC available for sells and redemptions
spotClearinghouseState for the keeper accountHyperliquid info APIbacking shares, listed as + followed by the token id

Tests

The contract ships with unit tests for every path (fills within and outside limits, partial sells, rejections, self-cancel timing, settlement and redemption, escrow protection on payouts and withdrawals, pause), a fuzz test of buy fills across amounts and prices, and a test of the full buy, settle and redeem path on a fork of Elysium mainnet with its real USDC. The keeper was run end to end against that fork: a buy filled from Hyperliquid's live book with the unused USDC refunded, a sell filled net of the closing fee, and an order outside its limit handed back in full.