WJU Wrapped Token

Overview

WJU (Wrapped JU) is the ERC-20 wrapped version of JuChain's native token JU. Since AMM systems require all tokens to follow the ERC-20 standard, the WJU contract provides seamless conversion functionality between JU tokens and ERC-20 tokens, enabling JU tokens to participate in all JAMM DEX trading activities.

Contract Implementation

Basic Information

contract WJU is IWJU {
    string public constant override name = "Wrapped JU";
    string public constant override symbol = "WJU";
    uint8 public constant override decimals = 18;
    uint public override totalSupply;
    mapping(address => uint) public override balanceOf;
    mapping(address => mapping(address => uint)) public override allowance;
}

The WJU contract fully implements the ERC-20 standard with the following characteristics:

  • Name: "Wrapped JU"

  • Symbol: "WJU"

  • Decimals: 18 decimal places

  • 1:1 Exchange: 1 JU = 1 WJU

Core Functions

Wrapping Function (Deposit)

Users can wrap JU tokens into WJU through two methods:

Method 1: Direct JU Transfer

Users directly send JU tokens to the WJU contract address, and the contract automatically calls the deposit() function.

Method 2: Call deposit Function

Wrapping Process:

  1. User sends JU tokens to the contract

  2. Contract increases user's WJU balance

  3. Increases WJU total supply

  4. Triggers Deposit event

Unwrapping Function (Withdraw)

Users can convert WJU tokens back to JU tokens:

Unwrapping Process:

  1. Check if user has sufficient WJU balance

  2. Decrease user's WJU balance

  3. Transfer corresponding amount of JU tokens to user

  4. Trigger Withdrawal event

ERC-20 Standard Implementation

Transfer Function

Authorized Transfer Function

Approval Function

Event System

Deposit Event

Records JU token wrapping into WJU operations.

Withdrawal Event

Records WJU token unwrapping into JU operations.

ERC-20 Standard Events

Application in JAMM DEX

Router Integration

The JAMMRouter contract is deeply integrated with WJU, providing convenient JU token trading functionality:

JU Token Trading

Buy Tokens with JU

Trading Flow:

  1. User sends JU tokens

  2. Router wraps JU into WJU

  3. Transfer WJU to trading pair

  4. Execute swap logic

  5. User receives target tokens

Sell Tokens for JU

Trading Flow:

  1. User approves and transfers tokens

  2. Execute swap to get WJU

  3. Router unwraps WJU into JU

  4. Transfer JU tokens to user

Liquidity Management

Add JU Liquidity

Remove JU Liquidity

Usage Examples

Basic Wrapping/Unwrapping

Query Balances

Listen to Events

Security Considerations

Contract Security

  1. Simple Design: WJU contract logic is simple, reducing security risks

  2. No Admin: Contract has no admin functions, completely decentralized

  3. 1:1 Exchange: Strict 1:1 exchange ratio that cannot be manipulated

Usage Security

  1. Balance Checks: All operations check if balance is sufficient

  2. Overflow Protection: Uses Solidity 0.8.21's built-in overflow protection

  3. Event Logging: All operations have corresponding event records

Best Practices

For Users

  1. Timely Unwrapping: If not needed for DEX use, promptly unwrap WJU to JU

  2. Balance Management: Maintain appropriate WJU balance for trading

  3. Gas Optimization: Batch operations to save gas fees

For Developers

  1. Path Validation: In JU-related trades, ensure path correctly includes WJU

  2. Balance Display: Show both JU and WJU balances in UI

  3. Auto Wrapping: Provide automatic wrapping/unwrapping functionality for users

Summary

WJU wrapped token is an important component of the JAMM DEX ecosystem:

  1. Seamless Integration: Enables JU tokens to participate in all DEX functions

  2. 1:1 Exchange: Guarantees complete value parity

  3. Automation: Router contract automatically handles wrapping/unwrapping

  4. Standard Compliance: Fully compliant with ERC-20 standard

  5. Decentralization: No need to trust third parties, completely managed by smart contracts

The existence of WJU enables JuChain users to conveniently use native tokens to participate in DeFi activities. In the next section, we will explore LP Token Mechanisms.