MarketManager (AMM)
CreateMarket
CreateMarket
Initialises a new market, defined over a unique combination of:
Base token: contract address for the base token (e.g.
ETH
) of the market pairQuote token: contract address for the quote token (e.g.
USDC
) of the market pairWidth: market width which defines the precision of limit price increments (min. 1.00001 intervals)
Strategy: address of the strategy contract used for managing liquidity on the market (or 0 if none)
Swap fee rate: the fee rate paid by swappers to LPs, applied on amounts paid in to the pool
Fee controller: address of the fee controller contract that returns the variable swap fee rate for the market (or 0 if none)
Controller: address of the market controller that can define access control for various market features (e.g. enabling or disabling swaps, limit orders and strategies)
The market_id
is generated from the Poseidon hash of the above variables, ensuring their uniqueness. The event also emits the start limit / tick and sqrt price of the market at initialisation.
ModifyPosition
ModifyPosition
Modifies liquidity position, either adding or removing liquidity, or collecting accrued fees. The event is also emitted for limit order updates, such that indexing all ModifyPosition
events yields an accurate 1:1 view of available liquidity.
Caller: position owner
Market ID: market id (see above)
Lower limit: shifted limit at which position starts
Upper limit: shifted limit at which position ends
Is Limit Order: true if event is emitted as part of a limit order update, false otherwise
Liquidity Delta: change in liquidity applied by position update, or 0 if collecting fees only
Base Amount: amount of base assets added or removed from position
Quote Amount: amount of quote assets added or removed from position
Base Amount: amount of base fees collected from position
Quote Amount: amount of quote fees collected from position
CreateOrder
CreateOrder
Creates a new limit order.
Caller: position owner
Market ID: market id (see above)
Order ID: assigned unique order id
Limit: shifted (lower) limit at which order is placed, i.e. the position spans
limit
tolimit
+width
)Batch ID: ID of order batch to which order belongs (orders are batched for efficient filling)
Is Bid: true if order is a bid limit order
Amount: order amount
Note that this event also emits a ModifyPosition
event (see explanation above).
CollectOrder
CollectOrder
Collects an existing limit order, withdrawing both filled and unfilled amounts.
Caller: position owner
Market ID: market id (see above)
Order ID: assigned unique order id
Limit: shifted (lower) limit at which order is placed, i.e. the position spans
limit
tolimit
+width
)Batch ID: ID of order batch to which order belongs (orders are batched for efficient filling)
Is Bid: true if order is a bid limit order
Base amount: base amount collected
Quote amount: quote amount collected
Swap
Swap
Executes a swap through a single market.
Caller: swap caller
Market ID: market id (see above)
Is Buy: true if swapping from quote to base asset, false otherwise
Exact Input: true if amount specified is in terms of input asset, false if in terms of output asset
Swap ID: assigned unique swap id
Amount In: amount swapped in (in quote tokens for buys, base tokens for sells)
Amount Out: amount swapped out (in base tokens for buys, quote tokens for sells)
Fees: amount swapped in (in quote tokens for buys, base tokens for sells)
End Limit: shifted limit of the market after the swap
End Sqrt Price: square root price of the market after the swap
Market Liquidity: active market liquidity after the swap
MultiSwap
A swap over multiple markets.
Caller: swap caller
Swap ID: assigned unique swap id (used for identifying each leg of the multi-swap)
In Token: token swapped in
Out Token: token swapped out
Amount In: amount swapped in
Amount Out: amount swapped out
Note that individual Swap
events are also emitted for every leg of the swap, in addition to the MultiSwap
event.
Last updated