On-Chain Execution

Shielding Users from Centralized Risks

Evo Exchange uses a non-custodial deposit vault, which underscores the commitment to security and user empowerment. Unlike centralized exchanges that pose inherent risks due to the custody of user funds, Evo Exchange's non-custodial approach ensures that users maintain control over their assets throughout the entire trading process. The vault acts as a secure repository, shielding users from the vulnerabilities associated with centralized custody.

Once a trade has been placed on the UI, then verified and matched through the Matching Engine, it is passed into the Exchange smart contract. This smart contract is what allows Evo Exchange to be a completely non-custodial, decentralized, central limit orderbook exchange. The Exchange smart contract has many different functions. It is responsible for user deposits, balance tracking, traditional spot trade execution, margin and short trade logic and execution, and withdrawals.

Deposits

When a deposit is approved and submitted through the front end, the asset then moves into the Evo Exchange smart contract where it is mapped and tracked by user.

Trades

After the batch of spot trades has been matched in the Matching Engine, the matching engine then requests the "taker" of the trade to sign the transaction. Once signed, the order details of all of the trades are passed into the smart contract for the smart contract to execute the trade and update all user balances.

When the order details are received in the smart contract, the smart contract then places each user's trade balances for their specific order within the trade into a "Pending Balances" state. By doing this, users are able to place continuous trades without waiting for their prior trades to execute.

The smart contract then checks what type of order each trade in the batch is trying to make. If it is a spot order it will go through the spot order balance check functionality, which only needs to check the asset balance for the trade that user is trying to make. If it is a margin or a short order then it goes through the margin/short balance check functionality, which also checks the users Liabilities (assets borrowed), Total Portfolio Value (the net value of their portfolio including all assets, and liabilities), and Aggregate Maintenance Margin Requirement (the minimum required Total Portfolio Value the user needs in order to avoid being liquidated).

Once all of the details are verified and confirmed, the smart contract then calls on the Oracle to verify that this trade is an order that has been matched in the Orderbook. After getting this final confirmation, the order is now ready to be executed.

Once all order and user details are reviewed and confirmed, the smart contract goes through the Transfer Balances functionality, which completes the trade. This executes the trades by moving the mapped assets between each user's holdings in the smart contract. For margin and shorts, this also involves modifying all of the above mentioned values by their appropriate amounts as well.

Withdrawals

When users choose to withdraw from the exchange they will also need to go through several security checks before the withdrawal functions lets them transfer their balances back to their wallets.

Before processing a withdrawal, the withdraw function first checks the user's balance for that asset. This also discounts the "pending" balances from any trades that might be in the processing stage of a trade. For users that have margin or short positions, the withdrawal function will not let them withdraw any amount higher than their Total Portfolio Balance minus Aggregate Initial Margin Requirement.

Last updated