Crystal
All asset balances, markets, and trading functionality are accessible through a single central contract featuring swap endpoints across the orderbook, AMM, and launchpad.
Functions
feeRecipient
function feeRecipient() external view returns (address)Recipient address of protocol fees.
Return Values
address
address
Address that receives the fee
feeCommission
function feeCommission() external view returns (uint8)Referrer’s commission rate
Return Values
feeCommission
uint8
Global referrer commission rate in percent
userIdToAddress
function userIdToAddress(uint256) external view returns (address)Retrieves the wallet address associated with a specific user ID.
Parameters
userId
uint256
The userId
Return Values
user
address
The address associated with the given userId
addressToUserId
Retrieves the numeric user ID that corresponds to a given wallet address.
Parameters
user
address
The address for which to retrieve the userId
Return Values
userId
uint256
The numeric user ID corresponding to user
claimableRewards
Returns accrued rewards for (token, user); claim via claimFees
Parameters
token
address
ERC-20 token (WETH for native) in which rewards accrue.
user
address
Account whose claimable balance is queried.
Return Values
amount
uint256
Accrued but unclaimed rewards for (token, user)
latestUserId
Returns the most recently issued userId.
Return Values
latestUserId
uint256
Numeric result
gov
Returns the current governance address.
Return Values
gov
address
Current governance/admin address.
feeClaimDuration
Seconds to wait before an expired-fees queue can be executed.
Return Values
duration
uint256
Delay (in seconds) required between queuing and executing expired fee claims.
getMarketByTokens
Looks up market address given an asset pair. May return a placeholder address for launchpad tokens before graduation; not routable until migrated.
Parameters
assetIn
address
Input asset (WETH for native)
assetOut
address
Output asset (WETH for native)
Return Values
market
address
Market contract for the pair, placeholder for launchpad pairs pre-graduation, or zero if none.
marketToMarketId
Returns the numeric marketId for a market address.
Parameters
market
address
Address parameter
Return Values
marketId
uint256
Numeric result
marketIdToMarket
Returns the market address for a numeric marketId.
Parameters
marketId
uint256
Numeric market ID.
Return Values
market
address
Market contract address.
isCanonicalDeployer
Flag: address is allowed to deploy canonical markets.
Parameters
deployer
address
Address to check
Return Values
allowed
bool
True if address qualifies
allMarkets
Paging accessor over all market addresses.
Parameters
index
uint256
Zero-based index into the markets array.
Return Values
market
address
Market address at index.
parameters
Returns global Parameters tuple (quote/base, market id/type, scale, tick, max price).
Return Values
quoteAsset
address
Quote token for the market under construction.
baseAsset
address
Base token for the market under construction.
marketId
uint256
Numeric ID assigned for deterministic deployment.
marketType
uint256
Pricing mode (e.g., linear/decimal/tiered).
scaleFactor
uint256
Decimal scaling for price math.
tickSize
uint256
Minimum price increment.
maxPrice
uint256
Upper bound used to seed tick bitmaps.
launchpadParams
Returns global LaunchpadParams tuple (initial supply, fees/splits, graduated params).
Return Values
launchpadInitialNativeSupply
uint112
Initial virtual native liquidity.
launchpadFee
uint256
Fee factor (scaled base 100_000) on launchpad trades.
launchpadCreatorFeeSplit
uint256
Creator share of launchpad fees (percent)
graduatedMinSize
uint256
Min order size for the graduated market.
graduatedTakerFee
uint256
Taker fee after graduation
graduatedMakerRebate
uint256
Maker rebate after graduation
graduatedCreatorFeeSplit
uint256
Creator fee split post-graduation (percent)
launchpadTokenToMarket
Returns the LaunchpadMarket tuple bound to a token (virtual reserves, k, creator/market addresses, timestamp).
Parameters
token
address
Launchpad token to query.
Return Values
virtualNativeReserve
uint112
Simulated native-side reserve.
virtualTokenReserve
uint112
Simulated token-side reserve.
k
uint256
Constant product used for bonding curve.
creator
address
Token creator entitled to fee split.
market
address
Spot market address to migrate into on graduation.
createTimestamp
uint88
Launch time used for inactivity windows.
allTokens
Paging accessor over all launchpad-created tokens.
Parameters
index
uint256
Zero-based index into launchpad-created tokens.
Return Values
token
address
oken address at index
weth
Returns the canonical WETH address used by the router.
Return Values
weth
address
Canonical WETH contract used for wrapping/unwrapping.
eth
Returns the placeholder/native ETH address constant.
Return Values
eth
address
Sentinel constant representing native ETH (0xEeee…EEeE).
allMarketsLength
Returns the number of deployed markets.
Return Values
length
uint256
Total number of deployed markets stored in the registry.
getMarket
Retrieves stored market data (book top, fees, reserves, etc.).
Parameters
market
address
Market address
Return Values
info
MarketInfo
Struct containing live market data (quote/base, price bounds, fees, reserves, AMM state).
getDepositedBalance
Returns balances held by protocol for user in asset.
Parameters
user
address
Account whose balances are queried.
asset
address
Token address (use WETH sentinel for ETH).
Return Values
total
uint256
Total tokens held in protocol custody.
available
uint256
Portion free for withdrawal or new orders.
locked
uint256
Portion reserved for active orders or liquidity.
getAllOrdersByCloid
Returns batched packed ids and decoded Order[] for a user’s CLOID bucket (windowed by range).
Parameters
user
address
Wallet to inspect
range
uint256
Maximum CLOID window to scan (up to 1023).
Return Values
cloids
uint256[]
Array of client order IDs found.
userOrders
Order[]
Decoded order data matching each CLOID.
getOrderByCloid
Returns a single Order stored under composite CLOID for that user.
Parameters
userId
uint256
User identifier
cloid
uint256
Client order ID
Return Values
order
Order
Full order struct stored under that composite key.
getOrder
Returns a specific Order by (market, price level, native id).
Parameters
market
address
Market address
price
uint256
Order price
id
uint256
Order identifier
Return Values
order
Order
Order details.
getPriceLevel
Returns PriceLevel aggregate for a specific price.
Parameters
market
address
Market address
price
uint256
Order price
Return Values
priceLevel
PriceLevel
Aggregate liquidity and internal pointers for that level.
getPriceLevels
Returns encoded order-book data for initialized price levels starting from a given price and direction.
Parameters
market
address
Market address
isAscending
bool
If true, search for price levels in the space above startPrice, otherwise search below
startPrice
uint256
Start price, inclusive
distance
uint256
How many price increments to check
interval
uint256
Step between prices
max
uint256
Maximum number of entries
Return Values
priceLevels
bytes
Byte string containing 32 byte chunks, with the first 16 bytes the price and last 16 bytes the sum of all order sizes at the price level
getPriceLevelsFromMid
Returns the best bid and ask along with encoded order-book data for price levels around the mid-price.
Parameters
market
address
Target market
distance
uint256
How many price increments to check each way
interval
uint256
Step size between ticks.
max
uint256
Maximum number of entries
Return Values
highestBid
uint256
The price of the highest buy order
lowestAsk
uint256
The price of the lowest sell order
bids
bytes
Byte string representing all buy orders within distance of the bid-ask spread
asks
bytes
Byte string representing all sell orders within distance of the bid-ask spread
getPrice
Returns price, highestBid, lowestAsk given a market address.
Delegated to market via delegatecall; non-view.
Parameters
market
address
Market address
Return Values
price
uint256
Mid Price
highestBid
uint256
Best bid price
lowestAsk
uint256
Best ask price
getQuote
Simulates a trade to calculate the expected input and output amounts given trade direction, size, and worst acceptable price.
Parameters
market
address
Market address
isBuy
bool
True for buy orders, false for sell
isExactInput
bool
True for exact input mode, false for exact output
isCompleteFill
bool
Whether to require complete fill
size
uint256
Order size
worstPrice
uint256
Worst acceptable execution price
Return Values
amountIn
uint256
Input tokens required
amountOut
uint256
Output tokens required
deploy
Deploys a new order-book market with the provided parameters; returns the market address.
Parameters
isCanonical
bool
Determines if market is canonical
quoteAsset
address
Quote token address
baseAsset
address
Base token address
marketType
uint256
Market type identifier
scaleFactor
uint256
Price scaling factor
tickSize
uint256
Minimum price increment
maxPrice
uint256
Maximum allowed price
minSize
uint256
Minimum order size
takerFee
uint24
Taker fee in basis points
makerRebate
uint24
Maker rebate in basis points
Return Values
market
address
Newly deployed market contract.
registerUser
Registers a wallet to enable limit-order placement; this is automatically handled when routing through the main contract.
Parameters
caller
address
Address of the user
Return Values
userId
uint256
Newly assigned numeric user identifier.
deposit
Deposits ERC-20 or native (if msg.value) into protocol custody; returns credited amount (post-wrap/scale).
Parameters
token
address
Token contract address
amount
uint256
Quantity to deposit
Return Values
userId
uint256
Depositing user’s ID (auto-created if new)
withdraw
Withdraws user custody balance to to
Parameters
to
address
Recipient address
token
address
Token contract address
amount
uint256
Amount of tokens
routerDeposit
Router-privileged path to deposit on behalf of a user (supports msg.value).
Parameters
token
address
Token contract address
amount
uint256
Deposit quantity
routerWithdraw
Router-privileged withdrawal on behalf of a user.
Parameters
to
address
Recipient address
token
address
Token contract address
amount
uint256
Amount of tokens
claimFees
Claims accumulated maker rebates or referral fees owed to the caller.
Parameters
to
address
Recipient address
tokens
address[]
Array of token addresses
Return Values
amounts
uint256[]
Claimed amount per token.
queueClaimExpiredFees
Schedules recovery of expired, unclaimed fees for user.
Parameters
user
address
Address of the user
tokens
address[]
Array of token addresses
executeClaimExpiredFees
Executes the queued expired-fee claim and returns recovered amounts.
Parameters
user
address
Address of the user
Return Values
amounts
uint256[]
Amounts successfully recovered per token.
changeGov
Updates configuration parameters.
Parameters
newGov
address
Address of new governance controller
changeFeeRecipient
Updates configuration parameters.
Parameters
newFeeRecipient
address
New wallet to receive protocol fees.
changeFeeClaimDuration
Claims accumulated fees or rewards.
Parameters
newFeeClaimDuration
uint256
New delay (seconds) between queue + execute expired-fee claim.
changeRefFeeStructure
Updates configuration parameters.
Parameters
newFeeCommission
uint8
Proposed new referrer commission rate (%).
newFeeRebate
uint8
Proposed maker rebate (%).
changeMarketParams
Updates configuration parameters.
Parameters
market
address
Target market to update.
newMinSize
uint256
Updated minimum order size.
newTakerFee
uint24
Updated taker fee (scaled bps).
newMakerRebate
uint24
Updated maker rebate (scaled bps).
isAMMEnabled
bool
Toggle AMM hybrid mode.
isCanonical
bool
Toggle canonical-routing flag.
changeMarketCreatorFee
Updates configuration parameters.
Parameters
market
address
Market address
newCreator
address
Updated creator address.
newCreatorFee
uint256
Creator fee split
changeLaunchpadParams
Updates configuration parameters.
Parameters
newLaunchpadParams
LaunchpadParams
Struct containing updated launchpad global settings.
addCanonicalDeployer
Grant canonical-deployer status.
Parameters
deployer
address
Address parameter
removeCanonicalDeployer
Revoke canonical-deployer status.
Parameters
deployer
address
Address parameter
approveForwarder
Approves an address to place and cancel orders on a user's behalf. This is equivalent to giving the forwarder full control of your account including the ability to spend your tokens to their sole discretion, therefore this method should be used with extreme caution.
Parameters
forwarder
address
Contract or EOA allowed to place and cancel orders on caller’s behalf.
removeForwarder
Removes an address from authorization.
Parameters
forwarder
address
Address parameter
clearCloidSlots
Clears stored data.
Parameters
userId
uint256
User whose order slots to clear.
ids
uint256[]
CLOID identifiers being reset.
getReserves
Returns current reserve balances.
Parameters
market
address
Market address
Return Values
reserveQuote
uint112
Current quote-token reserve.
reserveBase
uint112
Current base-token reserve.
addLiquidity
Adds liquidity to a market.
Parameters
market
address
Market address to supply liquidity to.
to
address
Recipient address of LP position.
amountQuoteDesired
uint256
Intended quote deposit.
amountBaseDesired
uint256
Intended base deposit.
amountQuoteMin
uint256
Minimum acceptable quote.
amountBaseMin
uint256
Minimum acceptable base.
Return Values
liquidity
uint256
Minted liquidity amount.
removeLiquidity
Removes liquidity from a market.
Parameters
market
address
Market address
to
address
Recipient address
liquidity
uint256
LP tokens to burn.
amountQuoteMin
uint256
Minimum quote token amount
amountBaseMin
uint256
Minimum base token amount
Return Values
amountQuote
uint256
Quote tokens returned.
amountBase
uint256
Base tokens returned.
removeLiquidityETH
Removes liquidity from a market.
Parameters
market
address
Market address
to
address
Recipient address
liquidity
uint256
Liquidity amount
amountQuoteMin
uint256
Minimum quote token amount
amountBaseMin
uint256
Minimum base token amount
Return Values
amountQuote
uint256
Quote token amount
amountBase
uint256
Base token amount
marketOrder
Executes a market order.
Parameters
market
address
Market address
isBuy
bool
True = buy False = sell.
isExactInput
bool
Indicates whether size is input or output.
options
uint256
Bit-flags for ETH handling and mode
orderType
uint256
Internal order execution type.
size
uint256
Trade amount.
worstPrice
uint256
Maximum slippage or price limit.
referrer
address
Optional referral address.
user
address
Account placing the order
Return Values
amountIn
uint256
Tokens spent
amountOut
uint256
Tokens received
id
uint256
Residual order ID if partially filled
limitOrder
Places a limit order.
Parameters
market
address
Market address
isBuy
bool
True = buy False = sell.
options
uint256
Execution flags.
price
uint256
Limit price.
size
uint256
Order size
user
address
Address of the user
Return Values
id
uint256
Created order ID.
cancelOrder
Cancels an existing order.
Parameters
market
address
Market address
options
uint256
Execution flags
price
uint256
Price level
id
uint256
Order ID
user
address
Address of the user
Return Values
size
uint256
Amount canceled and released.
replaceOrder
Places a limit order.
Parameters
market
address
Market address
options
uint256
Flags for mode
price
uint256
Old price level
id
uint256
Order ID
newPrice
uint256
New price level
size
uint256
New Order size
referrer
address
Referrer address for fee sharing
user
address
Address of the user
Return Values
id
uint256
New or current order ID.
batchOrders
Executes multiple limit or market order in a single transaction.
Parameters
market
address
Market address
actions
Action[]
Array of actions to execute
options
uint256
Bitfield of execution options
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
user
address
Address of the user
getAmountsOut
Calculates token amounts for routing. (eth sentinel auto-mapped to WETH at each hop; reverts on unresolved market or placeholder)
Parameters
amountIn
uint256
Input token amount
path
address[]
Token swap path
Return Values
amounts
uint256[]
Expect Output per hop, final element is total output
getAmountsIn
Calculates token amounts for routing. (eth sentinel auto-mapped to WETH at each hop; reverts on unresolved market or placeholder)
Parameters
amountOut
uint256
Output token amount
path
address[]
Token swap path
Return Values
amounts
uint256[]
Required input per hop, final element is total input
swapExactETHForTokens
Swaps tokens via routing.
Parameters
amountOutMin
uint256
Minimum acceptable output amount
path
address[]
Token swap path
to
address
Recipient address
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
amounts
uint256[]
Numeric result
swapExactTokensForETH
Swaps tokens via routing.
Parameters
amountIn
uint256
Input token amount
amountOutMin
uint256
Minimum acceptable output amount
path
address[]
Token swap path
to
address
Recipient address
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
uint256[]
Numeric result
swapExactTokensForTokens
Swaps tokens via routing.
Parameters
amountIn
uint256
Input token amount
amountOutMin
uint256
Minimum acceptable output amount
path
address[]
Token swap path
to
address
Recipient address
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
uint256[]
Numeric result
swapETHForExactTokens
Swaps tokens via routing.
Parameters
amountOut
uint256
Output token amount
path
address[]
Token swap path
to
address
Recipient address
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
uint256[]
Numeric result
swapTokensForExactETH
Swaps tokens via routing.
Parameters
amountOut
uint256
Output token amount
amountInMax
uint256
Maximum input amount willing to pay
path
address[]
Token swap path
to
address
Recipient address
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
uint256[]
Numeric result
swapTokensForExactTokens
Swaps tokens via routing.
Parameters
amountOut
uint256
Output token amount
amountInMax
uint256
Maximum input amount willing to pay
path
address[]
Token swap path
to
address
Recipient address
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
uint256[]
Numeric result
swap
Swaps tokens via a single market with the option for advanced order types (Partial fill, MTL).
Parameters
exactInput
bool
Boolean flag
tokenIn
address
Input token address
tokenOut
address
Output token address
orderType
uint256
Type of order
size
uint256
Order size
worstPrice
uint256
Worst acceptable execution price
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
Return Values
userId
uint256
Numeric result
balanceOrOut
uint256
Numeric result
id
uint256
Numeric result
placeLimitOrder
Places a limit order.
Parameters
tokenIn
address
Input token address
tokenOut
address
Output token address
price
uint256
Order price
size
uint256
Order size
deadline
uint256
Expiry
Return Values
id
uint256
Created order identifier
cancelLimitOrder
Cancels an existing order.
Parameters
tokenIn
address
Input token address
tokenOut
address
Output token address
price
uint256
Order price
id
uint256
Order identifier
deadline
uint256
Expiry
Return Values
size
uint256
Order size
replaceLimitOrder
Replaces a limit order.
Parameters
isPostOnly
bool
Prevent immediate fills if true
isDecrease
bool
True if reducing size
tokenIn
address
Input token address
tokenOut
address
Output token address
price
uint256
Order price
id
uint256
Order ID
newPrice
uint256
New order price
newSize
uint256
New order size
deadline
uint256
Expiry
referrer
address
Referrer address
Return Values
id
uint256
New/Current Order ID
multiBatchOrders
Executes cross-market batches atomically. (ETH handling: “Wraps ETH to WETH for in-call usage; refunds residual WETH as ETH at end.)
Parameters
batches
Batch[]
Array of batches to execute
deadline
uint256
Transaction deadline timestamp
referrer
address
Referrer address for fee sharing
createToken
Creates a new launchpad token with the option for an initial buy.
Parameters
name
string
Token name
symbol
string
Token symbol
metadataCID
string
IPFS metadata CID
description
string
Text description
social1
string
Social media link
social2
string
Social media link
social3
string
Social media link
social4
string
Social media link
Return Values
token
address
Deployed token address
buy
Buys tokens on the launchpad.
Parameters
isExactInput
bool
True for exact input mode, false for exact output
token
address
Token contract address
amountIn
uint256
Input token amount
amountOut
uint256
Output token amount
Return Values
inputAmount
uint256
ETH spent
outputAmount
uint256
Tokens received
graduated
bool
True = market auto-graduated
sell
Sells tokens on the launchpad.
Parameters
isExactInput
bool
True for exact input mode, false for exact output
token
address
Launchpad token
amountIn
uint256
Tokens sold
amountOut
uint256
Expected WETH/ETH output
Return Values
inputAmount
uint256
Tokens sold
outputAmount
uint256
ETH received
getVirtualReserves
Returns current launchpad bonding curve reserve balances. Empty return values indicate a token has already graduated.
Parameters
token
address
Launchpad token address
Return Values
virtualNativeReserve
uint256
Virtual native-side liquidity.
virtualTokenReserve
uint256
Virtual token-side liquidity.
Fallback
The fallback function is gas-optimized and intended for use by market makers and other high frequency automated trading strategies. Calldata is in 32-byte chunks, with each chunk either representing a batch header or action. By default, msg.sender is used in place of all address parameters for each action.
Top-Level Layout
Crystal.sol fallback calldata is a sequence of market batches:
Each batch is:
There is no function selector.
Batch Header
Each batch starts with one 32-byte word.
0..159
market
address
target market
160..171
actionCount
uint12
number of 32-byte action words that follow
172..251
bid
uint80
optional priority bid sent to block.coinbase
252..255
balanceMode
uint4
currently expected to be 0 or 1
Batch Header Formula
Balance Modes
0: external settlement1: internal settlement
When Crystal.sol delegates into CrystalMarket.sol, it automatically rebuilds the inner header as:
So when calling Crystal.sol fallback, you do not encode userId yourself in calldata. Crystal.sol loads the caller's userId from storage and injects it.
Action Word
Each action is still one 32-byte word.
0..111
param2
uint112
meaning depends on action
112..191
param1
uint80
meaning depends on action
192..201
cloid
uint10
client order id
202..247
unused
-
set to 0
248
isRequireSuccess
uint1
1 reverts whole batch on failure
249..251
unused
-
set to 0
252..255
action
uint4
action code
Generic Action Formula
Action Codes
1
cancel order
2
limit buy
3
limit sell
4
market-to-limit buy
5
market-to-limit sell
6
partial buy
7
partial sell
8
partial buy, gas-aware
9
partial sell, gas-aware
10
complete buy
11
complete sell
12
decrease order
Per-Action Encoding
1 Cancel Order
Cancel by native order id:
param1
price
param2
id
cloid
0
Cancel by cloid:
param1
0
param2
0
cloid
client order id
2 Limit Buy
param1
price
param2
size
cloid
optional client order id
3 Limit Sell
param1
price
param2
size
cloid
optional client order id
4 to 11 Market-Style Orders
param1
worstPrice
param2
size
cloid
optional client order id
Meanings:
4
market-to-limit buy
5
market-to-limit sell
6
partial buy
7
partial sell
8
partial buy, gas-aware
9
partial sell, gas-aware
10
complete buy
11
complete sell
12 Decrease Order
Decrease by native order id:
param1
price
bits 192..232
native order id (uint41)
param2
decreaseAmount
Decrease by cloid:
param1
0
bits 192..201
cloid
param2
decreaseAmount
Limits
actionCount
uint12
bid
uint80
cloid
uint10
param1
uint80
param2
uint112
native order id
uint41
All unused bits should be zeroed.
Events
MarketCreated
Deployed new market with its assets and setup details.
Parameters
isCanonical
indexed bool
Determines if market is canonical.
quoteAsset
indexed address
Quote token address
baseAsset
indexed address
Base token address
market
address
Market address
quoteInfo
ICrystal.TokenMetadata
Parameter value
baseInfo
ICrystal.TokenMetadata
Parameter value
marketInfo
ICrystal.MarketDetails
Parameter value
MarketParamsChanged
A market’s key settings (like fees or minimum size) were updated.
Parameters
market
indexed address
Market address
minSize
uint256
Minimum order size
takerFee
uint24
Taker fee in basis points
makerRebate
uint24
Maker rebate in basis points
isAMMEnabled
bool
True = AMM backstop is enabled
GovChanged
Protocol governance address changed.
Parameters
prev
address
Prev gov address
gov
address
New gov address
UserRegistered
Emitted when a new user is registered.
Parameters
isMargin
indexed bool
Account Type, right now its false for spot
user
indexed address
REgistered wallet address
userId
indexed uint256
User identifier
Deposit
Emitted when user deposits a token into protocol custody.
Parameters
user
indexed address
Depositor's address
userId
indexed uint256
Depositor's user ID
token
indexed address
Token deposited
amount
uint256
Amount of tokens
Withdraw
Emitted when user deposits a token from protocol custody.
Parameters
user
indexed address
Recipient wallet
userId
indexed uint256
Recipient's user ID
token
indexed address
Token contract address
amount
uint256
Amount sent out
RewardsClaimed
Emitted when rewards or fees are claimed.
Parameters
user
indexed address
Address of the user
tokens
address[]
Tokens claimed
amounts
uint256[]
Amounts per token
Trade
Emitted when a trade is executed.
Parameters
market
indexed address
Market address
user
indexed address
Trader wallet
isBuy
bool
True if buy, false if sell
amountIn
uint256
Spent amount
amountOut
uint256
Received amount
startPrice
uint256
Price when order is placed
endPrice
uint256
Price when order is filled
OrdersUpdated
Represents a limit order’s key data — price, size, order type, user ID, and partial-fill progress indicators.
Parameters
market
indexed address
Market address
user
indexed address
Order owner address
orderData
bytes
Compact batch of placed/changed/canceled orders.
Fill
Emitted when an order is filled.
Parameters
market
indexed address
Market address
user
indexed address
Order owner address
fillInfo
uint256
Bit 255 is set to 1 if the aggressing fill is a sell order, 0 if buy. Bits 168-248 is the price, 112-168 is the order id, and 0-112 is the remaining size
fillAmount
uint256
Size of fill
TokenCreated
Emitted when a new entity is created.
Parameters
token
indexed address
Token contract address
creator
indexed address
Token creator address
name
string
Token name
symbol
string
Token symbol
metadataCID
string
IPFS metadata CID
description
string
Description text
social1
string
Social media link
social2
string
Social media link
social3
string
Social media link
social4
string
Social media link
Migrated
Emitted when migration occurs (e.g., to market)
Parameters
token
indexed address
Token contract address
LaunchpadTrade
Launchpad swap executed with updated virtual reserves.
Parameters
token
indexed address
Token contract address
user
indexed address
Address of the user
isBuy
bool
True for buy orders, false for sell
amountIn
uint256
Input token amount
amountOut
uint256
Output token amount
virtualNativeReserve
uint256
Post-swap native token reserve
virtualTokenReserve
uint256
Post-swap launchpad token reserve
Mint
Emitted when liquidity is added to a market pair with actual amounts.
Parameters
market
indexed address
Market address
sender
indexed address
Address parameter
amountQuote
uint
Quote token amount
amountBase
uint
Base token amount
Burn
Liquidity removed from a market pair with actual amounts and recipient.
Parameters
market
indexed address
Market address
sender
indexed address
Address parameter
amountQuote
uint
Quote token amount
amountBase
uint
Base token amount
to
indexed address
Recipient address
Sync
Emitted when reserves are synchronized.
Parameters
market
indexed address
Market address
reserve0
uint112
Numeric value
reserve1
uint112
Numeric value
Structs
InternalOrder
Compact internal storage format for an order, tracking size, type, user, and partial-fill progress.
Parameters
size
uint256
Order size
orderType
uint256
Type of order
userId
uint256
User identifier
fillBefore
uint256
Fill before timestamp
fillAfter
uint256
Fill after timestamp
Order
Order showing side, market, price, size, user, and how much of it is filled.
Parameters
isBuy
bool
True for buy orders, false for sell
market
address
Market address
price
uint256
Order price
size
uint256
Order size
orderType
uint256
Type of order
userId
uint256
User identifier
fillBefore
uint256
Fill before timestamp
fillAfter
uint256
Fill after timestamp
PriceLevel
Aggregates all orders at a single price level, tracking total size and sequencing identifiers for fill order.
Parameters
size
uint256
Order size
latestNativeId
uint256
Numeric value
latest
uint256
Numeric value
fillNext
uint256
Numeric value
Market
Canonical on-chain market config and state: quotes/base assets, fees, size/tick/price bounds, AMM toggle, reserves, creator info, ids, and creation time.
Parameters
highestBid
uint80
Best bid
lowestAsk
uint80
Best ask
minSize
uint40
Minimum order size
takerFee
uint24
Taker fee in basis points
makerRebate
uint24
Maker rebate in basis points
isAMMEnabled
bool
Whether AMM is enabled
reserveQuote
uint112
Quote reserve (LP)
reserveBase
uint112
Base reserve (LP)
quoteAsset
address
Quote token address
baseAsset
address
Base token address
marketId
uint256
Market identifier
marketType
uint256
Market type identifier
scaleFactor
uint256
Decimal scale for price math.
tickSize
uint256
Minimum price increment
maxPrice
uint256
Upper price bound
creator
address
Address parameter
createTimestamp
uint88
Numeric value
creatorFeeSplit
uint8
Numeric value
MarketInfo
Market’s key info for UIs, like top prices, fees, reserves, and settings.
Parameters
quoteAsset
address
Quote token address
baseAsset
address
Base token address
marketType
uint256
Market type identifier
highestBid
uint256
Best bid (widened)
lowestAsk
uint256
Best ask (widened)
scaleFactor
uint256
Price scaling factor
tickSize
uint256
Price tick size
maxPrice
uint256
Max price boundary
minSize
uint256
Minimum order size
takerFee
uint256
Taker fee (scaled)
makerRebate
uint256
Maker rebate (scaled)
reserveQuote
uint256
Quote LP reserve
reserveBase
uint256
Base LP reserve
isAMMEnabled
bool
Whether AMM is enabled
TokenMetadata
Token metadata including address, decimals, ticker, and name.
Parameters
token
address
Token address
decimals
uint256
Decimal precision
ticker
string
String value
name
string
Name string
MarketDetails
Set parameters for a market: ids, scale/tick/max price, min size, and fee schedule.
Parameters
marketId
uint256
Market identifier
marketType
uint256
Market type identifier
scaleFactor
uint256
Price scaling factor
tickSize
uint256
Minimum tick
maxPrice
uint256
Upper price bound
minSize
uint256
Minimum order size
takerFee
uint256
Taker fee (scaled)
makerRebate
uint256
Maker rebate (scaled)
Action
Single instruction inside a batch (e.g., place/cancel/replace); isRequireSuccess gates revert behavior, action op-code with up to three numeric params.
Parameters
isRequireSuccess
bool
If true, revert batch on sub-action failure
action
uint256
Opcode (e.g., place/cancel/replace/market)
param1
uint256
First numeric parameter
param2
uint256
Second numeric parameter.
param3
uint256
Third numeric parameter.
Batch
Collection of Action to execute atomically on one market, with an options bitfield for execution flags.
Parameters
market
address
Target market for all actions in the batch.
actions
Action[]
Ordered list of sub-operations.
options
uint256
Bitfield flags
Parameters
Holds market-level configuration such as quote/base asset addresses, market ID, scaling factor, tick size, and maximum price
Parameters
quoteAsset
address
Quote token address
baseAsset
address
Base token address
marketId
uint256
Market identifier
marketType
uint256
Market type identifier
scaleFactor
uint256
Price scaling factor
tickSize
uint256
Minimum price increment
maxPrice
uint256
Upper bound for ticks
LaunchpadMarket
State of a launchpad token market.
Parameters
virtualNativeReserve
uint112
Bonding-curve native reserve
virtualTokenReserve
uint112
Bonding-curve token reserve
k
uint256
Constant product
creator
address
Creator address (for fee split)
market
address
Market address after graduation
createTimestamp
uint88
Creation time
LaunchpadParams
Launchpad settings: initial native supply, fees/splits, and “graduated” market params after launch.
Parameters
launchpadInitialNativeSupply
uint112
Initial virtual native liquidity.
launchpadFee
uint256
Fee factor (base 100_000)
launchpadCreatorFeeSplit
uint256
Creator share of fees
graduatedMinSize
uint256
Post-graduation min size
graduatedTakerFee
uint256
Post-graduation taker fee (scaled)
graduatedMakerRebate
uint256
Post-graduation maker rebate
graduatedCreatorFeeSplit
uint256
Creator fee split after graduation
PendingExpiredFeeClaim
Queued claim of expired fees for a user: deadline plus token list and amounts.
Parameters
deadline
uint256
Earliest time this claim can be executed.
tokens
address[]
Tokens included in the claim.
amounts
uint256[]
Snapshotted amounts at queue time.
Last updated