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
contractWJUisIWJU{stringpublicconstantoverride name ="Wrapped JU";stringpublicconstantoverride symbol ="WJU";uint8publicconstantoverride decimals =18;uintpublicoverride totalSupply;mapping(address=>uint)publicoverride balanceOf;mapping(address=>mapping(address=>uint))publicoverride 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:
User sends JU tokens to the contract
Contract increases user's WJU balance
Increases WJU total supply
Triggers Deposit event
Unwrapping Function (Withdraw)
Users can convert WJU tokens back to JU tokens:
Unwrapping Process:
Check if user has sufficient WJU balance
Decrease user's WJU balance
Transfer corresponding amount of JU tokens to user
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:
User sends JU tokens
Router wraps JU into WJU
Transfer WJU to trading pair
Execute swap logic
User receives target tokens
Sell Tokens for JU
Trading Flow:
User approves and transfers tokens
Execute swap to get WJU
Router unwraps WJU into JU
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
Simple Design: WJU contract logic is simple, reducing security risks
No Admin: Contract has no admin functions, completely decentralized
1:1 Exchange: Strict 1:1 exchange ratio that cannot be manipulated
Usage Security
Balance Checks: All operations check if balance is sufficient
Standard Compliance: Fully compliant with ERC-20 standard
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.