WrapX Docs
  • Welcome to WrapX
    • Introduction
    • Background
    • Technical Doc
      • Wrap
      • Unwrap
      • Deploying a Wrapper Contract
  • ERC7527
    • Introduction
    • Publications
Powered by GitBook
On this page
  1. Welcome to WrapX
  2. Technical Doc

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

  1. 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.

  2. User Calls the unwrap() Function

    • The user submits a transaction invoking the unwrap() function on the WrapX contract, providing the prepared parameters.

  3. 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.

  4. 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.

  5. System Burns the WToken

    • The WrapX contract permanently removes (burns) the WToken from circulation, making it non-recoverable.

  6. 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.

  7. System Emits an Unwrap Event

    • A 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.

PreviousWrapNextDeploying a Wrapper Contract

Last updated 2 months ago

WrapX - Unwrap