Finalizing Orders

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

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

Finalising orders using the GUI

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:

Updated Balances visible on GUI

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

Last updated