Vault
Last updated
Last updated
The Vault is a critical component of Torch Finance, responsible for managing user assets and leveraging TON’s sharding mechanism. Each Vault stores and manages specific asset types, safeguarding user funds and executing transfers based on instructions from the Torch contracts.
Before diving into the Vault contract, it’s important to understand the concept of assets.
In Torch, TON and Jetton are treated as distinct asset types:
TON is a unique asset type managed by the TON Vault, which stores and handles users' TON assets.
Jetton represents another asset type managed by Jetton Vaults. Each Jetton has its own dedicated Vault, such as USDT Vault or tsTON Vault.
The Vault contract’s primary function is to store user assets and process deposits, swaps and withdrawals whenever users interact with the system.
Continuing the supermarket analogy, think of Torch as a large supermarket, with each Vault acting as a dedicated checkout counter.
Customers purchasing TON go to the TON checkout counter, which handles all TON-related transactions.
Those buying Jettons (such as USDT or tsTON) head to the Jetton checkout counter, with each Jetton having its own lane (e.g., USDT Vault, tsTON Vault).
This way, even if the line at the TON counter is long, it won’t affect transactions for Jetton or other assets – everyone queues separately, ensuring smooth and uninterrupted operations.
If new asset types (like extra-currency) are introduced in the future, adding a new checkout counter – Extra-currency Vault – is simple and won’t disrupt the existing system.
This design ensures that each asset has a dedicated management and processing lane, significantly enhancing the flexibility and scalability of asset management.
If all assets were managed by a single router contract, every transaction would have to line up at the same checkout counter. When transaction volume surges, the router becomes a bottleneck, causing congestion and slowing down the entire system.
Torch mitigates this by distributing assets across multiple Vaults (parent-child contract architecture):
Each Vault acts as a dedicated checkout counter, independently handling the storage and transfer of a specific asset, fully utilizing TON’s sharding capabilities (contracts can operate on different shards).
Even if the TON Vault experiences congestion, Jetton Vaults continue to operate smoothly, preventing single points of failure.
This distribution mechanism ensures that when the TON network becomes congested and sharding is triggered, each Vault can migrate to a different shard chain to continue processing, avoiding blockages at a single contract. This allows each asset transaction to be completed at the fastest available checkout counter, enhancing user experience.