From Mini-Games to DeFi: What Does TON Still Need?

TON Ecosystem

In recent months, we’ve witnessed explosive growth in the TON ecosystem, with the launches of Notcoin, Dogs, Hamster Kombat, and Catizen on Binance. This surge has reportedly brought millions of new KYC users to various exchanges, marking one of the largest blockchain applications in recent years. However, the pressing question remains: what’s next?

Despite the significant user base, TON’s total value locked (TVL) remains relatively low, and there hasn’t been a noticeable rise in DeFi protocols. This has sparked concerns and discussions about the low user value on the TON chain and the inadequacies of its infrastructure.

In this article, we will briefly discuss an essential concept behind DeFi—atomic swaps—and how LayerPixel (PixelSwap) is addressing related challenges. On one hand, DeFi’s initial success can be traced back to Ethereum, which became the cornerstone for DeFi applications and smart contracts. On the other hand, the rise of asynchronous blockchains like TON brings new opportunities and challenges, particularly regarding composability.

1. A Brief History of DeFi

The DeFi ecosystem flourished during the “DeFi Summer,” primarily centered around Ethereum. Developers leveraged Ethereum’s ecosystem, where smart contracts serve as fundamental building blocks that can be combined like LEGO pieces. This composability enabled rapid proliferation of decentralized financial applications and services.

Ethereum’s composability paradigm allows various DeFi protocols to interact in innovative ways. Key financial primitives such as atomic swaps, flash loans, and collateralized borrowing demonstrate how different applications can stack together to create complex, multifunctional financial products.

As DeFi matured, the limitations of Ethereum’s synchronous model—particularly regarding scalability and high transaction fees—became increasingly apparent. This spurred interest in exploring new blockchain architectures, like asynchronous blockchains, which promise to overcome some of these inherent constraints.

2. Asynchronous Blockchains: A New Paradigm

Ethereum’s traditional model is synchronous, maintaining a monolithic state where each transaction is processed sequentially. In contrast, asynchronous blockchains like TON adopt an actor model approach, resulting in several fundamental structural differences:

Ethereum – Synchronous Blockchain (Monolithic State):

  • Atomic Operations: Direct atomic transactions are possible because each transaction, even if modifying multiple smart contract states, is treated as a single unit. The Ethereum Virtual Machine (EVM) ensures that all steps in a transaction are isolated, guaranteeing that either all execute or none do.
  • Sequential Processing: Each transaction must wait for the previous one to complete, naturally limiting throughput and scalability.
  • Global State: All transactions operate on a shared global state, simplifying state management but exacerbating contention.

TON – Asynchronous Blockchain (Actor Model):

  • Parallel Processing: Transactions can be processed concurrently across multiple actors or smart contracts, enhancing overall scalability and throughput. For example, smart contracts on TON can operate as independent units or actors, using one-way messaging to update states between actors.
  • Distributed State: Different actors hold isolated states, allowing them to interact without sharing a single global state.
  • Coordination Complexity: Implementing atomic operations in this model is complex due to its distributed nature.

While asynchronous blockchains have significant implications for scalability, the lack of atomic swaps presents a considerable barrier to DeFi development on TON, regardless of the complexities associated with the FunC/Tact language. Without atomic operations and sequential processing, liquidity in borrowing protocols becomes challenging, no matter how inventive the DeFi LEGO may be.

LayerPixel and PixelSwap (which utilizes LayerPixel’s infrastructure as part of its framework) propose a new approach to address this issue, enabling atomic swaps and striving to provide a more secure and efficient solution for exchanges and DeFi.

3. Challenges of Composability on Asynchronous Blockchains

Maintaining composability for DeFi applications on asynchronous blockchains introduces complex challenges, primarily due to the characteristics of distributed states and parallelism:

Transaction Coordination:

  • Synchronization: Achieving a consistent state across multiple actors at a specific time is complex. Unlike a synchronous global state that simplifies atomic operations, synchronizing independent actors presents significant hurdles.
  • Consistency Models: Asynchronous systems often rely on weaker consistency models, such as eventual consistency. Ensuring that all relevant actors reach a common state without divergence becomes a logistical challenge.

State Consistency:

  • Concurrency Control: In a distributed environment, if multiple transactions attempt to update overlapping states, race conditions may occur. This necessitates complex mechanisms to ensure transactions are serialized correctly without becoming bottlenecks.
  • State Reconciliation: Reconciling different states among actors and implementing rollback mechanisms (if part of a transaction fails) must be robust enough to gracefully undo changes without introducing inconsistencies.

Failure Handling:

  • Atomicity: Guaranteeing that all parts of a transaction either succeed or fail in a state-distributed, non-atomic environment is challenging.
  • Rollback Mechanisms: Efficiently rolling back partial transaction state changes without leaving residual inconsistencies requires advanced techniques.

4. Pixelswap: Bridging the Composability Gap

Pixelswap addresses these challenges through an innovative design that introduces a distributed transaction framework tailored for the TON blockchain. This architecture adheres to the BASE principles (an alternative to ACID) and includes two main components: a transaction manager and multiple transaction executors.

Saga Transaction Manager:

Orchestrates complex multi-step transactions and overcomes the limitations of the two-phase commit (2PC) protocol, suitable for long-running distributed transactions.

  • Lifecycle Management: Manages the entire transaction lifecycle by breaking it down into smaller, independently executable steps, each with its own compensation operation in case of failure.
  • Task Allocation: Divides the main transaction into discrete, isolated tasks and assigns them to the appropriate transaction executors.
  • Compensation Operations: Ensures that each saga has corresponding compensation transactions that can be triggered to undo partial changes, maintaining consistency.

Transaction Executors:

Responsible for executing the allocated tasks during the transaction lifecycle.

  • Parallel Processing: Executors operate concurrently to maximize throughput and balance system load.
  • Modular Design: Each transaction executor is designed to be modular, allowing the implementation of various functionalities, such as different swap curves, flash loans, and collateral protocols. This modularity ensures these features can seamlessly coordinate with the Saga transaction manager, upholding the core principle of DeFi composability.
  • Eventual Consistency: Ensures the local state of executors remains synchronized and reconciled with the overall distributed state of the transaction.

Through these features, Pixelswap’s transaction executors enable robust, scalable, and asynchronous transaction execution, making it possible to create complex and composable DeFi applications on TON.

5. Conclusion

In summary, the future of DeFi requires adaptation to the paradigm shift from synchronous to asynchronous blockchains while maintaining and enhancing critical principles like composability. Pixelswap’s emergence on the TON blockchain elegantly combines robustness, scalability, and composability, positioning it as a groundbreaking solution.

By ensuring seamless interaction capabilities and strong transaction management, Pixelswap paves the way for a more dynamic, scalable, and innovative DeFi ecosystem.