Module 0xdee9::clob_v2
- Struct
PoolCreated
- Struct
OrderPlaced
- Struct
OrderCanceled
- Struct
AllOrdersCanceledComponent
- Struct
AllOrdersCanceled
- Struct
OrderFilled
- Struct
DepositAsset
- Struct
WithdrawAsset
- Struct
MatchedOrderMetadata
- Struct
Order
- Struct
TickLevel
- Resource
Pool
- Resource
PoolOwnerCap
- Constants
- Function
usr_open_orders_exist
- Function
usr_open_orders_for_address
- Function
usr_open_orders
- Function
withdraw_fees
- Function
delete_pool_owner_cap
- Function
destroy_empty_level
- Function
create_account
- Function
create_pool_
- Function
create_pool
- Function
create_customized_pool
- Function
create_pool_with_return_
- Function
create_pool_with_return
- Function
create_customized_pool_with_return
- Function
create_customized_pool_v2
- Function
deposit_base
- Function
deposit_quote
- Function
withdraw_base
- Function
withdraw_quote
- Function
swap_exact_base_for_quote
- Function
swap_exact_base_for_quote_with_metadata
- Function
swap_exact_quote_for_base
- Function
swap_exact_quote_for_base_with_metadata
- Function
match_bid_with_quote_quantity
- Function
match_bid
- Function
match_ask
- Function
place_market_order
- Function
place_market_order_with_metadata
- Function
place_market_order_int
- Function
inject_limit_order
- Function
place_limit_order
- Function
place_limit_order_with_metadata
- Function
place_limit_order_int
- Function
order_is_bid
- Function
emit_order_canceled
- Function
emit_order_filled
- Function
cancel_order
- Function
remove_order
- Function
cancel_all_orders
- Function
batch_cancel_order
- Function
clean_up_expired_orders
- Function
list_open_orders
- Function
account_balance
- Function
get_market_price
- Function
get_level2_book_status_bid_side
- Function
get_level2_book_status_ask_side
- Function
get_level2_book_status
- Function
get_order_status
- Function
matched_order_metadata
- Function
matched_order_metadata_info
- Function
asks
- Function
bids
- Function
tick_size
- Function
maker_rebate_rate
- Function
taker_fee_rate
- Function
pool_size
- Function
open_orders
- Function
order_id
- Function
tick_level
- Function
original_quantity
- Function
quantity
- Function
is_bid
- Function
owner
- Function
expire_timestamp
- Function
quote_asset_trading_fees_value
- Function
clone_order
use 0x1::option;
use 0x1::type_name;
use 0x1::vector;
use 0x2::balance;
use 0x2::clock;
use 0x2::coin;
use 0x2::event;
use 0x2::linked_table;
use 0x2::object;
use 0x2::sui;
use 0x2::table;
use 0x2::transfer;
use 0x2::tx_context;
use 0xdee9::critbit;
use 0xdee9::custodian_v2;
use 0xdee9::math;
Struct PoolCreated
Emitted when a new pool is created
struct PoolCreated has copy, drop, store
Fields
- pool_id: object::ID
- object ID of the newly created pool
- base_asset: type_name::TypeName
- quote_asset: type_name::TypeName
- taker_fee_rate: u64
- maker_rebate_rate: u64
- tick_size: u64
- lot_size: u64
Struct OrderPlaced
Emitted when a maker order is injected into the order book.
struct OrderPlaced<BaseAsset, QuoteAsset> has copy, drop, store
Fields
- pool_id: object::ID
- object ID of the pool the order was placed on
- order_id: u64
- ID of the order within the pool
- client_order_id: u64
- ID of the order defined by client
- is_bid: bool
- owner: address
- owner ID of the AccountCap that placed the order
- original_quantity: u64
- base_asset_quantity_placed: u64
- price: u64
- expire_timestamp: u64
Struct OrderCanceled
Emitted when a maker order is canceled.
struct OrderCanceled<BaseAsset, QuoteAsset> has copy, drop, store
Fields
- pool_id: object::ID
- object ID of the pool the order was placed on
- order_id: u64
- ID of the order within the pool
- client_order_id: u64
- ID of the order defined by client
- is_bid: bool
- owner: address
- owner ID of the AccountCap that canceled the order
- original_quantity: u64
- base_asset_quantity_canceled: u64
- price: u64
Struct AllOrdersCanceledComponent
A struct to make all orders canceled a more effifient struct
struct AllOrdersCanceledComponent<BaseAsset, QuoteAsset> has copy, drop, store
Fields
- order_id: u64
- ID of the order within the pool
- client_order_id: u64
- ID of the order defined by client
- is_bid: bool
- owner: address
- owner ID of the AccountCap that canceled the order
- original_quantity: u64
- base_asset_quantity_canceled: u64
- price: u64
Struct AllOrdersCanceled
Emitted when batch of orders are canceled.
struct AllOrdersCanceled<BaseAsset, QuoteAsset> has copy, drop, store
Fields
- pool_id: object::ID
- object ID of the pool the order was placed on
- orders_canceled: vector<clob_v2::AllOrdersCanceledComponent<BaseAsset, QuoteAsset>>
Struct OrderFilled
Emitted only when a maker order is filled.
struct OrderFilled<BaseAsset, QuoteAsset> has copy, drop, store
Fields
- pool_id: object::ID
- object ID of the pool the order was placed on
- order_id: u64
- ID of the order within the pool
- taker_client_order_id: u64
- ID of the order defined by taker client
- maker_client_order_id: u64
- ID of the order defined by maker client
- is_bid: bool
- taker_address: address
- owner ID of the AccountCap that filled the order
- maker_address: address
- owner ID of the AccountCap that placed the order
- original_quantity: u64
- base_asset_quantity_filled: u64
- base_asset_quantity_remaining: u64
- price: u64
- taker_commission: u64
- maker_rebates: u64
Struct DepositAsset
Emitted when user deposit asset to custodian
struct DepositAsset<Asset> has copy, drop, store
Fields
- pool_id: object::ID
- object id of the pool that asset deposit to
- quantity: u64
- quantity of the asset deposited
- owner: address
- owner address of the AccountCap that deposit the asset
Struct WithdrawAsset
Emitted when user withdraw asset from custodian
struct WithdrawAsset<Asset> has copy, drop, store
Fields
- pool_id: object::ID
- object id of the pool that asset withdraw from
- quantity: u64
- quantity of the asset user withdrew
- owner: address
- owner ID of the AccountCap that withdrew the asset
Struct MatchedOrderMetadata
Returned as metadata only when a maker order is filled from place order functions.
struct MatchedOrderMetadata<BaseAsset, QuoteAsset> has copy, drop, store
Fields
- pool_id: object::ID
- object ID of the pool the order was placed on
- order_id: u64
- ID of the order within the pool
- is_bid: bool
- Direction of order.
- taker_address: address
- owner ID of the AccountCap that filled the order
- maker_address: address
- owner ID of the AccountCap that placed the order
- base_asset_quantity_filled: u64
- qty of base asset filled.
- price: u64
- price at which basset asset filled.
- taker_commission: u64
- maker_rebates: u64
Struct Order
struct Order has drop, store
Fields
- order_id: u64
- client_order_id: u64
- price: u64
- original_quantity: u64
- quantity: u64
- is_bid: bool
- owner: address
- Order can only be canceled by the AccountCap with this owner ID
- expire_timestamp: u64
- self_matching_prevention: u8
Struct TickLevel
struct TickLevel has store
Fields
- price: u64
- open_orders: linked_table::LinkedTable<u64, clob_v2::Order>
Resource Pool
struct Pool<BaseAsset, QuoteAsset> has store, key
Fields
- id: object::UID
- bids: critbit::CritbitTree<clob_v2::TickLevel>
- asks: critbit::CritbitTree<clob_v2::TickLevel>
- next_bid_order_id: u64
- next_ask_order_id: u64
- usr_open_orders: table::Table<address, linked_table::LinkedTable<u64, u64>>
- taker_fee_rate: u64
- maker_rebate_rate: u64
- tick_size: u64
- lot_size: u64
- base_custodian: custodian_v2::Custodian<BaseAsset>
- quote_custodian: custodian_v2::Custodian<QuoteAsset>
- creation_fee: balance::Balance<sui::SUI>
- base_asset_trading_fees: balance::Balance<BaseAsset>
- quote_asset_trading_fees: balance::Balance<QuoteAsset>
Resource PoolOwnerCap
Capability granting permission to access an entry in Pool.quote_asset_trading_fees. The pool objects created for older pools do not have a PoolOwnerCap because they were created prior to the addition of this feature. Here is a list of 11 pools on mainnet that do not have this capability: 0x31d1790e617eef7f516555124155b28d663e5c600317c769a75ee6336a54c07f 0x6e417ee1c12ad5f2600a66bc80c7bd52ff3cb7c072d508700d17cf1325324527 0x17625f1a241d34d2da0dc113086f67a2b832e3e8cd8006887c195cd24d3598a3 0x276ff4d99ecb3175091ba4baffa9b07590f84e2344e3f16e95d30d2c1678b84c 0xd1f0a9baacc1864ab19534e2d4c5d6c14f2e071a1f075e8e7f9d51f2c17dc238 0x4405b50d791fd3346754e8171aaab6bc2ed26c2c46efdd033c14b30ae507ac33 0xf0f663cf87f1eb124da2fc9be813e0ce262146f3df60bc2052d738eb41a25899 0xd9e45ab5440d61cc52e3b2bd915cdd643146f7593d587c715bc7bfa48311d826 0x5deafda22b6b86127ea4299503362638bea0ca33bb212ea3a67b029356b8b955 0x7f526b1263c4b91b43c9e646419b5696f424de28dda3c1e6658cc0a54558baa7 0x18d871e3c3da99046dfc0d3de612c5d88859bc03b8f0568bd127d0e70dbc58be
struct PoolOwnerCap has store, key
Fields
- id: object::UID
- owner: address
- The owner of this AccountCap. Note: this is derived from an object ID, not a user address
Constants
const FLOAT_SCALING: u64 = 1000000000;
const EInsufficientBaseCoin: u64 = 7;
const EInsufficientQuoteCoin: u64 = 8;
const EInvalidExpireTimestamp: u64 = 19;
const EInvalidOrderId: u64 = 3;
const EInvalidPrice: u64 = 5;
const EInvalidQuantity: u64 = 6;
const EInvalidRestriction: u64 = 14;
const EInvalidTickPrice: u64 = 11;
const EInvalidUser: u64 = 12;
const EOrderCannotBeFullyFilled: u64 = 9;
const EOrderCannotBeFullyPassive: u64 = 10;
const EUnauthorizedCancel: u64 = 4;
const FILL_OR_KILL: u8 = 2;
const IMMEDIATE_OR_CANCEL: u8 = 1;
const MAX_PRICE: u64 = 9223372036854775808;
const MIN_ASK_ORDER_ID: u64 = 9223372036854775808;
const MIN_PRICE: u64 = 0;
const NO_RESTRICTION: u8 = 0;
const POST_OR_ABORT: u8 = 3;
const CANCEL_OLDEST: u8 = 0;
const EIncorrectPoolOwner: u64 = 1;
const EInvalidFee: u64 = 18;
const EInvalidFeeRateRebateRate: u64 = 2;
const EInvalidPair: u64 = 16;
const EInvalidSelfMatchingPreventionArg: u64 = 21;
const EInvalidTickSizeLotSize: u64 = 20;
const ENotEqual: u64 = 13;
const FEE_AMOUNT_FOR_CREATE_POOL: u64 = 100000000000;
const MIN_BID_ORDER_ID: u64 = 1;
const REFERENCE_MAKER_REBATE_RATE: u64 = 1500000;
const REFERENCE_TAKER_FEE_RATE: u64 = 2500000;