Market Creation
A market is defined by the following parameters:
| name | type | description | mutable |
|---|---|---|---|
| market id | bytes32 | The market ID, defined below. | ❌ |
| outboundToken | address | The token that is sold by the makers, bought by the takers. | ❌ |
| inboundToken | address | The token that is bought by the makers, sold by the takers. | ❌ |
| outboundUnits | uint64 | The units of the outbound token. | ❌ |
| inboundUnits | uint64 | The units of the inbound token. | ❌ |
| tickSpacing | uint16 | The number of ticks (1 tick = 0.1 bps) between each price level. | ❌ |
| fees | uint16 | The fees for the market where 100% is 1e6. | ✅ |
| minOutboundUnits | uint32 | The minimum outbound units. | ✅ |
Market creation occurs when a semi-market is defined for the first time. Subsequent activations or deactivations are handled via the SetActive event. A market ID is defined as the hash of the tokens, the units, and the tick spacing.
bytes32 marketId = keccak256(abi.encode(
outboundToken,
outboundUnits,
inboundToken,
inboundUnits,
tickSpacing
));- Outbound tokens are the tokens that are sold by the makers, bought by the takers.
- Inbound tokens are the tokens that are bought by the makers, sold by the takers.
- Tick spacing is the number of ticks (1 tick = 0.1 bps) between each price level.
- Units are the multiplier to go from raw amount to the stored amount. Prices does not take units into account but rather the raw amounts.
The market creation is defined by the following event:
/// @notice Emitted when a new market is created.
/// @param market The market id.
/// @param outboundToken The outbound token address.
/// @param inboundToken The inbound token address.
/// @param outboundUnits The outbound units.
/// @param minOutboundUnits The minimum outbound units.
/// @param inboundUnits The inbound units.
/// @param fees The fees.
/// @dev when this event is emitted, it implies that the market is active by default.
event NewMarket(
bytes32 indexed market,
address indexed outboundToken,
address indexed inboundToken,
uint64 outboundUnits,
uint32 minOutboundUnits,
uint64 inboundUnits,
uint16 tickSpacing,
uint16 fees
);Market parameters changes
The market has a handful of mutable parameters that can be changed after market creation:
- Fees are the fees for the market where the 100% is 1e6.
- Minimum outbound units is the minimum amount an offer shuold give to be active (defined in the outbound units).
- Active is the active status of the market.
/// @notice Emitted when the fees are set for a market.
/// @param market The market id.
/// @param fees The fees.
event SetFees(bytes32 indexed market, uint16 fees);
/// @notice Emitted when the minimum outbound units are set for a market.
/// @param market The market id.
/// @param minOutboundUnits The minimum outbound units.
event SetMinOutboundUnits(bytes32 indexed market, uint32 minOutboundUnits);
/// @notice Emitted when the active status is set for a market.
/// @param market The market id.
/// @param active The active status.
event SetActive(bytes32 indexed market, bool active);