Zero Day Futures Trading Platform 2023/12/11 Abstract Z-DayFutures is a futures contract trading platform designed for trading of futures deployed on Aptos blockchain. Leveraging the capabilities of the Aptos blockchain, Z-DayFutures builds upon ECONIA to provide fast market data and orderbook for efficient handling of financial assets within the contract. Uti- lizing Aptos’s fast finality time and high transactions per second (tps) handling capabilities, Z-DayFutures ensures accurate and reliable data for settlement after 24 hours, offering traders a robust solution that is less sensitive to market activities, thereby providing the best possible outcomes for the traders. Introduction Z-DayFutures introduces a cutting-edge futures contract trading platform built on the Aptos blockchain. This platform seamlessly integrates with ECONIA to deliver rapid market data and a dynamic order book, streamlining the handling of financial assets within the contract. Leveraging the remarkable capabilities of the Aptos blockchain, including its swift finality time and high transactions per second (tps) handling, Z-DayFutures ensures unparalleled accuracy and reliability in data. Beyond its robust technical foundation, Z-DayFutures extends support through both a user-friendly website and a feature-rich mobile app. Furthermore, it pioneers non-custodial access, empowering traders with control over their assets in their own trading wallet on the blockchain. This commitment to decentralization aligns with the platform’s core philosophy, emphasizing user autonomy and security. Additionally, Z-DayFutures distinguishes itself by providing prices resistant to rapid changes, thanks to its swift settlements and low-latency calculations. The platform employs efficient algorithms to maximize benefits for traders, ensuring that calculations are executed with precision and speed. As we explore the architecture of Z-DayFutures, we uncover its innovative approach to addressing the challenges of the modern trading landscape. 1 System Design 1.1 Contract Interaction via smart contracts Figure 1: Contract Interactions 1 1.2 Contract Specifications 1.2.1 Wallet Contract This contract handles the deposit and withdrawal of user funds that are used for the purpose of trading on Z-DayFutures platform. 1.2.2 Econia Pool Contract This contract handles the fund transfer during settlement and stores the margins and fees collected from various contracts. 1.2.3 Calc Contract This contract handles the user data during order placing and checker intervals for liquidation checks. 1.2.4 Coin Contract This contract deploys the test tokens for demonstration purposes. 2 Architecture 2.1 Margin Calculation The future entry transaction can be formalized mathematically as follows: future entry ( entry price, quantity purchased, leverage ) = ( trade value, margin ) (1) Where: trade value = entry price × quantity purchased (2) margin = trade value leverage (3) Equation (2) calculates the total trade value, which is the product of the entry price and the quantity purchased. Equation (3) computes the margin required for the transaction, determined by dividing the trade value by the leverage. 2.2 PnL calculation for Long position The profit and loss (PnL) calculation for a long position can be formalized mathematically as follows: pnl ( margin, current price, quantity purchased, entry price ) = pnl (4) Where: num = ( current price − entry price ) × quantity purchased (5) pnl = num margin (6) Equation (5) calculates the numerator, which is the product of the difference between the current price and entry price, and the quantity purchased. Equation (6) computes the profit and loss (PnL) for a long position, determined by dividing the numerator by the margin. 2.3 PnL calculation for short position The profit and loss (PnL) calculation for a short position can be formalized mathematically as follows: pnl short ( margin, current price, quantity purchased, entry price ) = pnl (7) Where: num = ( entry price − current price ) × quantity purchased (8) pnl = num margin (9) Equation (8) calculates the numerator, which is the product of the difference between the entry price and current price, and the quantity purchased. Equation (9) computes the profit and loss (PnL) for a short position, determined by dividing the numerator by the margin. 2.4 Liquidation Condition The decision to liquidate or not, based on profit and loss (PnL) calculations, can be formalized mathemat- ically as follows: liquidate or not ( is long, margin, current price, quantity purchased, entry price ) = should liquidate (10) Where: pnl = { pnl long ( margin, current price, quantity purchased, entry price ) if is long pnl short ( margin, current price, quantity purchased, entry price ) otherwise (11) should liquidate = { true if pnl ≥ 1 false otherwise (12) Equation (11) determines the profit and loss (PnL) based on whether the position is long or short. Equation (12) decides whether to liquidate or not, depending on whether the calculated PnL is greater than or equal to 1. 2.5 Long-to-Long Position Aggregation Function The aggregation of two long positions can be formalized mathematically as follows: long to long ( margin 1 , trade value 1 , margin 2 , trade value 2 ) = ( new leverage, new margin, new trade value ) (13) Where: new margin = margin 1 + margin 2 (14) new trade value = trade value 1 + trade value 2 (15) new leverage = new trade value new margin (16) Equation (14) calculates the new margin, which is the sum of the margins of the two long positions. Equation (15) computes the new total trade value, obtained by summing the trade values of the two positions. Equation (16) determines the new leverage based on the updated trade value and margin. 2.6 Long to Short position Aggregation The transformation of two long positions into a single short position can be formalized mathematically as follows: long 2 short ( margin 1 , trade value 1 , margin 2 , trade value 2 ) = ( new leverage, new margin, new trade value, is long ) (17) Where: new margin = { margin 1 − margin 2 if margin 1 > margin 2 margin 2 − margin 1 otherwise (18) new trade value = { trade value 1 − trade value 2 if trade value 1 > trade value 2 trade value 2 − trade value 1 otherwise (19) new leverage = new trade value new margin (20) is long = { true if margin 1 > margin 2 false otherwise (21) Equation (18) calculates the new margin, which is the absolute difference between the margins of the two original positions. Equation (19) computes the new total trade value, obtained by taking the absolute difference between the trade values of the two positions. Equation (20) determines the new leverage based on the updated trade value and margin. Equation (21) determines whether the resulting position is long or short based on the comparison of the original margins. Disclaimer This paper is for general information purposes only. It does not constitute investment advice or a recom- mendation or solicitation to buy or sell any investment and should not be used in the evaluation of the merits of making any investment decision. It should not be relied upon for accounting, legal, or tax advice or investment recommendations.