⁉️How Tokenwrap Works
Technical Breakdown: Token Wrapping, Wormhole Protocol, and Liquidity Pool Integration
Last updated
Was this helpful?
Technical Breakdown: Token Wrapping, Wormhole Protocol, and Liquidity Pool Integration
Last updated
Was this helpful?
Tokenwrap leverages a series of decentralized protocols and mechanisms to enable seamless cross-chain token wrapping and unwrapping. This section provides a technical deep dive into the process, focusing on the underlying architecture, the role of the Wormhole protocol, and integration with decentralized exchanges (DEXs) to manage liquidity pools.
Token Wrapping Process: Step-by-Step Breakdown
The wrapping process is fully decentralized, utilizing smart contracts deployed on both the source and destination chains. Below is the step-by-step breakdown of the wrapping and unwrapping process, detailing the smart contract interactions and security mechanisms in place.
Wrapping Tokens
User Initiation:
The user initiates a wrap request by calling the WrapToken function in the Tokenwrap smart contract on the source chain. The parameters include:
Token address (source chain)
Amount of tokens to wrap
Target blockchain identifier (e.g., Ethereum, Solana)
Token Locking on the Source Chain:
Upon the initiation of the wrapping request, the LockTokens function in the source chain's smart contract is triggered. The user’s tokens are transferred to a locking smart contract on the source chain, effectively removing them from circulation.
This contract follows an ERC-20 or SPL standard, depending on the source chain, ensuring full compatibility with existing token standards.
The tokens are held in the smart contract until the corresponding wrapped tokens are minted on the destination chain. The contract is fully collateralized 1:1, meaning each wrapped token minted on the destination chain is backed by an equivalent token locked on the source chain.
The lock event triggers an on-chain message to Wormhole, containing a proof of the lock event, which is validated by the Guardian Network.
Cross-Chain Messaging via Wormhole:
The Wormhole Protocol acts as the bridge between the two blockchain networks. Wormhole uses a cross-chain messaging layer, whereby the lock event on the source chain is notarized and relayed to the destination chain by the Guardian Network.
The Guardian Network consists of decentralized nodes that verify the authenticity of the locking event. Upon successful validation, the Guardians submit a signed VAA (Validator Action Approval) to the destination chain, triggering the minting of wrapped tokens.
The VAA includes:
Source chain identifier
Transaction hash of the lock event
Token address on the source chain
Amount of tokens to be minted
User’s destination chain address
Minting Wrapped Tokens on the Destination Chain:
On the destination chain, the VAA is received by the MintWrappedToken function, which mints the wrapped tokens (e.g., wETH or wSOL) in the user’s wallet.
The wrapped tokens follow the ERC-20 standard on Ethereum or the SPL standard on Solana, ensuring full compatibility with DEXs and other DeFi protocols.
Each wrapped token is fully collateralized, backed 1:1 by the locked tokens on the source chain, ensuring trustlessness and security in the cross-chain transfer.
Unwrapping Tokens
The unwrapping process mirrors the wrapping process, reversing the steps to return the tokens to the original chain.
Unwrap Request Initiation:
The user initiates an unwrap request by calling the UnwrapToken function on the destination chain. The user specifies the amount of wrapped tokens to burn and the original token address on the source chain.
Burning Wrapped Tokens on the Destination Chain:
The wrapped tokens (e.g., wSOL) are burned on the destination chain by the BurnWrappedToken function. This triggers a burn event, which is recorded on-chain and notarized by Wormhole.
The burn event is relayed back to the Guardian Network, where it undergoes the same validation process as during the wrapping.
Token Release on the Source Chain:
Once the burn event is verified, the ReleaseTokens function is called on the source chain’s smart contract. The locked tokens are released from the smart contract and transferred back to the user’s address.
The unwrapping process ensures that the total supply of wrapped tokens on the destination chain is always matched by the equivalent collateral locked on the source chain, maintaining security and decentralization throughout.
The Role of the Wormhole Protocol in Cross-Chain Communication
Tokenwrap’s cross-chain token transfers are enabled by the Wormhole Protocol, which serves as a decentralized bridge between blockchain networks. Wormhole facilitates cross-chain messaging by allowing smart contracts on different chains to communicate with one another securely and efficiently.
Guardian Network: The Wormhole Guardian Network consists of decentralized nodes that act as validators. These nodes observe token locking or burning events on one chain and generate VAAs (Validator Action Approvals) that are relayed to the destination chain. Each VAA is cryptographically signed by a quorum of Guardians, ensuring that only valid and secure messages are transmitted across chains.
Cross-Chain Message Integrity: Wormhole guarantees the integrity of messages sent between chains, ensuring that token locking on the source chain results in the minting of wrapped tokens on the destination chain, and vice versa during unwrapping. The Wormhole bridge operates without the need for centralized custody of assets, making it fully decentralized and trustless.
Message Relayers: In addition to the Guardian Network, Wormhole employs relayers that handle the transmission of messages across blockchains. Relayers do not have control over the assets; they simply ensure the swift delivery of VAAs between the source and destination chains.
Integration with Decentralized Exchanges (DEXs) for Liquidity Pools
Tokenwrap integrates seamlessly with major decentralized exchanges (DEXs) such as Uniswap, SushiSwap, and Solana-based DEXs to provide liquidity for wrapped tokens. Once a token is wrapped on the destination chain, it can be added to liquidity pools on supported DEXs, allowing users to trade or provide liquidity to earn rewards.
Automated Liquidity Pool Creation: Developers and liquidity providers can easily create liquidity pools by depositing an equal value of wrapped tokens (e.g., wSOL) and native tokens (e.g., ETH) into a DEX liquidity pool. This pool allows users to swap between wrapped and native tokens without requiring centralized exchanges.
AMM Protocols: Tokenwrap leverages Automated Market Maker (AMM) protocols, where liquidity is provided by users and pricing is determined algorithmically based on the ratio of tokens in the pool. This decentralized liquidity model ensures continuous trading availability and reduces the reliance on order books or market makers.
Liquidity Provider Rewards: Users who add liquidity to Tokenwrap-enabled pools earn a share of the trading fees generated on the DEX. These rewards are distributed automatically, and users can claim them directly from the DEX interface. The more liquidity a user provides, the larger their share of the rewards.