TokenPriceLocker

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

1

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.

2

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.

3

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.

4

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.

5

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

ParameterDescriptionExample
Lock PeriodMinimum time between unlocks30 days
Unlock PercentagePercentage per period5%
Price MultiplierRequired price increase2x
Price WindowTime for avg price30 days
Update IntervalPrice recording frequency24 hours

View the full contract code and documentation:

View Contract on GitHub