hot
hot

APEX BLOG

Stay at the forefront of decentralization
with regular ApeX Pro news, deals and research.


    AllAnnouncementsNew Partnerships

    How ApeX Buys & Burns $BANA With Pulsar's TWAMM Swaps

    Nov 14, 2022

    DEX

    Order Book

    Apex

    banner

    At ApeX Pro, we're more than thrilled to bring our traders the best tech features, upgrades and partnerships with established teams that drive improvements to existing decentralized exchange (DEX) challenges.

    ICYMI, ApeX Pro is powered by StarkWare's Layer 2 scalability solution StarkEx, which allows us to solve inefficiencies in traditional DEXs such as low liquidity, seemingly irreducible costs, delays in transaction processing and insufficient security and transparency. 

    There's no denying that there is still plenty of room to take the nascent decentralized finance (DeFi) industry further; and specifically DEXs that rely on automated market makers (AMMs).

    This is why we've zoomed into further enhancing liquidity provisions and guaranteeing minimal slippage with Pulsar's Time-Weighted Average Market Maker (TWAMM) protocol under a Buy & Burn Pool (BBP). 

    Why We Need TWAMM on DEXs

    Most might think that DEX order efficiency begins and ends with the integration of AMMs, that facilitate the instantaneous matching and execution of orders without a third party intermediary overseeing the process. A pricing algorithm and the funds available in a liquidity pool determine the overall price of exchange between two assets, and traders interact solely with the smart contract that oversees the asset swap.

    Theoretically, that sounds like a seamless and optimized trading process as gas costs and slippage are reduced while boosting liquidity for all, but while that may be true for smaller orders, all bets are off the table when traders start trading big and bigger.

    Some established AMM archictecture we've seen in the space with DEXs fall into a trilemma: do they ensure reduced slippage, competitive prices or increased liquidity at the inevitable expense of the others when it comes to large orders? When a large order (e.g. $100 million worth of ETH) is made, the inflow and outflow of funds from the available asset pools leads to a temporary liquidity imbalance, which may lead to significant slippage in prices. Other DEXs have designed their platform to guarantee low slippage in all cases, but end up putting limitations on liquidity provided to traders.

    On ApeX Pro, we needed a solution to better optimize large-order execution in the BBP so traders can avoid unnecessary costs arising from slippage or wasting time and effort manually separating and batching large orders into smaller ones.

    Enter TWAMM. 

    How Does TWAMM Work?

    If this trading acronym looks familiar, you've probably heard of Time-Weighted Average Price (TWAP), used commonly in the traditional securities market to improve prices and minimize price volatility when large orders are executed simultaneously.

    Similar to TWAP, Pulsar's TWAMM has been designed to execute large batches of buy and sell orders without significantly impacting prices of the asset(s) involved in crypto DEX order swaps. Pulsar has combined instant swaps with term swaps to process a large number of orders that are split up into small virtual orders, then virtually crossed using an innovative, embedded AMM before they are published for on-chain settlement.

    Breaking it down further, here's what happens to large orders when submitted:

    1. Long-Term Order Placement: Long-term orders are sold through a fixed period of time (i.e. number of blocks), rather than the common AMM, which executes orders instantaneously

    2. Virtual Sub-Order Splits: The TWAMM breaks long-term orders into infinitely many small virtual sub-orders, which trade against the embedded AMM at an even rate over time

    3. Trading Against Embedded AMM: The execution of long-term orders in the form of small virtual sub-orders will push the price of the embedded AMM away from the price in other markets over time.

    4. Arbitrage to Restore Market Price: When embedded AMM’s price is different from prices in other markets, arbitrageurs will trade against the embedded AMM’s price to bring it back in line through instant swap or term swap, ensuring good execution for long-term orders, and the earning profits.

     The end result? Maximally reduced slippage combined with the lowest transaction costs, so any trader can trade bigger and better on DEXs without sacrificing liquidity or competitive pricing.

     All the above, packaged and integrated for a powerful engine boost to process large transactions on ApeX Pro like never before.

    TWAMM in Action on ApeX Pro

    Traders will primarily see TWAMM in action with the Trade-to-Earn event and BBP between ApeX Pro's reward token $BANA and the platform's underlying stable asset, USDC. The BBP allows buyback, swap and arbitrage on Pulsar with the $BANA-USDC pair.

    • Trade-to-Earn: $BANA earned from participation in Trade-to-Earn can be swapped for USDC via the BANA-USDC Pool at any time during the 52-week long event

    • BBP: Filled with 50% of ApeX Pro trading fees in USDC and regular $BANA buybacks in bulk

    In using TWAMM swaps to ensure minimal slippage and price differences, traders trust that the value of $BANA they receive as rewards from trading on ApeX Pro will not be significantly devalued at any point while Trade-to-Earn is live.

    For example, ApeX Pro decides to proceed with the buyback of 10 million $BANA worth of USDC over the next week (i.e. about 50,400 blocks).

    Total Blocks: 7 24 60 * (60/12) = 50,400 where a new block is created on Ethereum every 12 seconds

    • ApeX Pro creates a long-term order in TWAMM to sell 10 million USDC over 50,400 blocks

      • The cost of each block is dependent on the total fees paid per epoch, for e.g., 1,000 USDC is paid in the first week, so each block's buying rate will be equivalent to (1,000 * 50%)/ 50,400 = 0.009920634921 USDC

    • TWAMM will then split the long-term orders into trillions of tiny sub-orders known as virtual orders TWAMM then takes turns executing the virtual orders of buying $BANA against its embedded AMM

    • If the BBP is buying more $BANA than is sold, the price of $BANA in the embedded AMM will see a controlled increase per block

    • After a week, ApeX Pro's long-term order for $BANA will expire and the buyback is completed — Do note that the execution price of this long-term order will also end up being the average price or value of $BANA over this week

    Users who hold onto $BANA for the entire 52-week long Trade-to-Earn event will then get to convert their $BANA to ApeX Protocol's native $APEX token pro-rata.


    In case you missed it, we had Henry from the Pulsar team on the line on Oct. 12, 2022, for our weekly ApeX DEX Talks.

    Check out the recording of our fireside chat here: https://twitter.com/OfficialApeXdex/status/1580195393966469121