V2 Locker
Complete reference for the V2Locker contract, which handles locking of Uniswap V2 LP tokens (ERC-20).
Contract Address
Monad Testnet:
0xe373C89A77dE728D50c7372C8Fe139B292a7DFE2
Overview
The V2 Locker enables users to lock their Uniswap V2 LP tokens (ERC-20) for a specified duration. While locked, users can:
Add more tokens to existing locks
Extend lock duration
View total locked amounts per token
How V2 Fee Accrual Works
Important: V2 LP tokens work differently from V3 positions. There is no separate fee claiming function for V2, and this is by design:
Trading fees automatically accrue to the LP token's value
Fees aren't claimed separately; they're reflected in the increasing value of the LP tokens themselves
When you unlock your V2 LP tokens, you receive the full value including all accrued fees
No protocol fee is charged on V2 locks
Core Functions
lockLP
Locks LP tokens for a specified duration.
Parameters:
lpToken: Address of the LP token contract to lockamount: Amount of LP tokens to lock (in token's decimals)unlockTime: Unix timestamp when tokens can be unlockedpermanent: Whether the lock is permanent (cannot be unlocked)condition: Optional condition contract address (useaddress(0)for time-based only)
Requirements:
Must send
creationFeeasmsg.valueMust have approved LP tokens to this contract
Amount must be > 0
If
conditionis provided, it must be a valid contract
Events Emitted:
Example:
unlock
Unlocks LP tokens after the unlock time.
Parameters:
lockId: The ID of the lock to unlock
Requirements:
Must be the lock owner (
msg.sender == lock.owner)Lock must be active
Cannot unlock permanent locks
Current timestamp must be >= unlock time
If condition is set, condition must return
true
Events Emitted:
Example:
addToLock
Adds more LP tokens to an existing lock.
Parameters:
lockId: The ID of the lock to add tokens toamount: Amount of LP tokens to add
Requirements:
Must be the lock owner
Lock must be active
Amount must be > 0
Must have approved additional tokens
Events Emitted:
Example:
extendLock
Extends the unlock time of an existing lock.
Parameters:
lockId: The ID of the lock to extendnewUnlockTime: New unlock timestamp (must be later than current)
Requirements:
Must be the lock owner
Lock must be active
Cannot extend permanent locks
New unlock time must be > current unlock time
Events Emitted:
Example:
View Functions
getOwnerLockIds
Returns all lock IDs owned by an address.
Example:
getOwnerLockCount
Returns the number of locks owned by an address.
Example:
getOwnerLockId
Returns a specific lock ID for an owner by index.
Parameters:
owner: Address to queryindex: Index in the owner's lock array (0-based)
locks
Returns complete lock details.
Returns:
owner: Current owner of the locklpToken: Address of the locked LP tokenamount: Amount of LP tokens lockedunlockTime: Unlock timestamppermanent: Whether lock is permanentactive: Whether lock is activecondition: Condition contract (if any)
Example:
canUnlock
Checks if a lock can be unlocked now.
Example:
getTotalLocked
Returns the total amount of a specific LP token locked across all locks.
Example:
getOwnerLockedAmount
Returns the total amount of a specific LP token locked by a specific owner.
Example:
State Variables
Events
Complete Usage Example
Locking Workflow
Integration Examples
Web3.js
Ethers.js
Error Reference
Gas Estimates
Approximate gas costs on Monad Testnet:
lockLP()
~180,000
~$0.54
unlock()
~120,000
~$0.36
addToLock()
~100,000
~$0.30
extendLock()
~50,000
~$0.15
Note: Actual costs may vary based on network congestion
Comparison: V2 vs V3
Token Type
ERC-20 LP tokens
ERC-721 NFTs
Fee Collection
No separate claim
Yes - claimFees()
How Fees Accrue
Increases LP token value
Separate from liquidity
When You Get Fees
When you unlock
Anytime via claimFees()
Protocol Fee
None
1% on claimed fees
Add to Lock
Yes
No
Concentrated Liquidity
No
Yes
Position Details
Limited
Full position info
Typical Use
Simple LP locks
Advanced strategies
Gas Costs
Lower
Higher
Related Documentation
Last updated
