Fermi DEX- Docs
  • ๐Ÿ‘‹Intro to Fermi
  • Overview
    • ๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธVision
    • ๐Ÿ’กWhat we do
    • โœจFermi DEX: Features
    • ๐Ÿˆโ€โฌ›Background
  • Fermi DEX Usage Guide
    • Fermi DEX: How it works
      • ๐Ÿ“ชPosting a Limit Order
      • โœ…Finalizing Orders
      • ๐Ÿ”„Withdrawing Funds
    • ๐Ÿ› ๏ธGetting set up
      • ๐Ÿ“Getting tokens
      • ๐Ÿ”ซTrobleshooting
    • ๐ŸชTransfer Hooks Redefined
    • Custom settlement periods
  • Technical Overview
    • Overview v0.2 (DEPRECATED)
    • Technical Overview v1
      • Market Addresses (Devnet)
      • Key Structs
      • Instructions
      • Events
      • SDK
    • ๐ŸšงArchitecture
      • ๐Ÿ‘ฝJust In Time Liquidity
      • ๐ŸคMatching Logic
      • ๐Ÿ›ธLiquidity Abstraction
      • ๐ŸŒŠLiquidity Management Programs
    • ๐ŸงชTesting Locally
    • ๐Ÿ•น๏ธDemo - Fermi v0.2
    • ๐Ÿ“ฝ๏ธDemo - Fermi v1
    • ๐Ÿ“‡Github, Devnet Programs and PDAs
    • ๐Ÿ‘ฉโ€๐ŸŽคActors and Incentives
  • Use cases & Benefits
    • ๐Ÿ–‡๏ธLower Slippage than traditional DEXes
    • โ›๏ธPortfolio Margining Strategies
    • ๐ŸMarket Making on Fermi DEX
  • About us
    • ๐Ÿ‘‹Meet the Team
    • ๐Ÿ›ฃ๏ธRoadmap
    • ๐Ÿš“Next Steps
Powered by GitBook
On this page
  1. Fermi DEX Usage Guide
  2. Fermi DEX: How it works

Finalizing Orders

This is the step that makes the actual transfers & accounting changes to the counterparties' balances

PreviousPosting a Limit OrderNextWithdrawing Funds

Last updated 1 year ago

Once a trade has been matched, the finalise button will become visible on the UX for both the counterparties to the trade, like so:

Similarly, users of the SDK will find that the "EventQListener" will detect when an order has been filled, and provide template transactions for "FinaliseBid" and "FinaliseAsk". Either user may then proceed to finalize the order. Upon clicking Finalize, the program logic checks that both the counterparties to the trade have enough tokens in their openorders accounts. If not, it attempts to transfer the appropriate amount of funds from the party to the program owned "vault". Once th If so, it proceeds with modifying the balances according to the trade terms, and then marks the trade as finalized (to prevent double spends). After finalization is completed, the user can instantly see their updated balances from their OpenOrdersPDA:

These funds will then available for withdrawal at any time. For a deeper dive into the logic executed at the finalizeOrders step, please see Just In Time Liquidity. Example Finalise Transaction:

โœ…
https://solscan.io/tx/2bSohxq73L9gouc4dmuQnkkd1uctNxMuNw2xmJms1RntvUNb5cdWt7NqMmpujhjPTGLZFMZxzFqVEJcyAzLGx1uH?cluster=devnet
Finalising orders using the GUI
Updated Balances visible on GUI