Overview v0.2 (DEPRECATED)
[DEPRECATED - ONLY FOR REFERENCE] Capturing the core logic behind order placement, matching, finalisation, and settlement in Fermi DEX v0.2
1. Order placement
Adding to Bids/Asks PDA
let insert_result = self.bids.insert(Order {
order_id,
qty: max_coin_qty,
owner,
owner_slot,
});let insert_result = self.asks.insert(Order {
order_id,
qty: max_pc_qty,
owner,
owner_slot,
});Approving tokens
```rust
```rust
Side::Bid => {
let lock_qty_native = max_native_pc_qty;
native_pc_qty_locked = Some(lock_qty_native);
let free_qty_to_lock = lock_qty_native.min(open_orders.native_pc_free);
let total_deposit_amount = lock_qty_native - free_qty_to_lock;
//deposit_amount = total_deposit_amount * 2/100; //marginal deposit up front
deposit_amount = total_deposit_amount; //for test with matching, L1044
deposit_vault = pc_vault;
```rust
Side::Ask => {
native_pc_qty_locked = None;
let lock_qty_native = max_coin_qty
.checked_mul(market.coin_lot_size)
.ok_or(error!(ErrorCode::InsufficientFunds))?;
let free_qty_to_lock = lock_qty_native.min(open_orders.native_coin_free);
let total_deposit_amount = lock_qty_native - free_qty_to_lock;
//deposit_amount = total_deposit_amount * 2/100; //marginal deposit up front
deposit_amount = total_deposit_amount; //for test with matching, L1044
deposit_vault = coin_vault;
```

2. Matching
Events tracking matched orders
3. Finalisation
Finalize Events


4. Settlement
Last updated