About TokenPriceLocker
A smart contract for locking BEP20 tokens with time and price-based unlocking conditions.
Contract Overview
TokenPriceLocker is a Solidity smart contract that allows users to lock their BEP20 tokens and unlock them gradually based on both time and price conditions. This mechanism encourages long-term holding and rewards users when the token price increases.
Locking Mechanism
Users can lock their tokens in the contract. Once locked, tokens can only be unlocked when specific time and price conditions are met. This prevents panic selling and encourages long-term holding.
Price Conditions
The contract monitors token price through a Pancake trading pair. For each unlock period, the price must increase by a specified multiplier (e.g., 2x) compared to the previous unlock price.
Time Conditions
Each unlock period has a minimum time requirement. Users must wait for this period to pass before they can unlock their tokens, even if the price condition is already met.
Gradual Unlocking
Tokens are unlocked gradually in small percentages (e.g., 5% at a time). This prevents large dumps and maintains price stability while still allowing users to realize gains.
How It Works
Lock Your Tokens
Users deposit their BEP20 tokens into the contract. The contract records the lock time, amount, and current token price from the Pancake trading pair.
Wait for Unlock Conditions
The contract calculates the next unlock time (current time + lock period) and the required price (last unlock price × price multiplier). Users must wait until both conditions are met.
Price Monitoring
The contract regularly updates and stores price data from the trading pair. It calculates the average price over a specified window to prevent price manipulation.
Unlock Tokens
When both time and price conditions are met, users can unlock a percentage of their total locked tokens. The contract updates the last unlock time, price, and next unlock time.
Repeat Until Fully Unlocked
The process repeats for each unlock period until all tokens are unlocked. With a 5% unlock percentage, it would take 20 successful unlock periods to fully unlock all tokens.
Contract Parameters
| Parameter | Description | Example |
|---|---|---|
| Lock Period | Minimum time between unlocks | 30 days |
| Unlock Percentage | Percentage per period | 5% |
| Price Multiplier | Required price increase | 2x |
| Price Window | Time for avg price | 30 days |
| Update Interval | Price recording frequency | 24 hours |
View the full contract code and documentation:
View Contract on GitHub