Unwrap
Converting WToken back to tokens
The unwrapping process allows an WToken holder to exchange their WToken for its underlying asset through the WrapX contract. The following steps outline the technical flow for this operation.
TLDR: What is Unwrap?
WToken is burned
Receives ERC20/ETH fungible tokens
Transaction is logged on-chain
Flow Breakdown
User Prepares Unwrapping Parameters The user initiates the process by defining the necessary parameters:
Recipient Address: Specifies who will receive the unwrapped assets.
Token ID: Identifies the WToken to be unwrapped.
Minimum Expected Output: Ensures slippage protection by setting a threshold for the unwrapped value.
User Calls the
unwrap()
FunctionThe user submits a transaction invoking the
unwrap()
function on the WrapX contract, providing the prepared parameters.
System Validates the Request Upon receiving the transaction, the smart contract performs the following checks:
Ownership Verification: Confirms that the caller either owns the WToken or has been granted approval.
Minimum Output Check: Ensures that the unwrapped asset's expected value meets or exceeds the specified threshold.
System Calculates the Unwrap Value The system determines the output amount based on predefined rules:
The FOAMM (Fractional Ownership Automated Market Maker) model calculates the base amount.
A 1% fee is deducted from the calculated value and transferred to the designated fee recipient.
System Burns the WToken
The WrapX contract permanently removes (burns) the WToken from circulation, making it non-recoverable.
System Transfers the Unwrapped Asset to the Recipient Based on the type of WToken being unwrapped, the system executes one of the following transfers:
For WrapXNative WTokens → ETH is sent to the recipient.
For WrapXToken WTokens → The corresponding ERC20 tokens are transferred.
System Emits an
Unwrap
EventA blockchain event is emitted, containing transaction details such as:
The WToken’s token ID
The recipient’s address
The amount of unwrapped assets received
The applied fee
Outcome
The WToken is burned and removed from circulation.
The user receives the underlying asset minus the transaction fee.
The transaction is recorded on-chain, ensuring transparency and traceability.
Last updated