TaxBasedLocker
TaxBasedLocker
Inherits: Initializable, Ownable, ITaxBasedLocker
Locks tokens for a specified period and applies a burn penalty for early withdrawals.
Provides functions for initializing the contract, withdrawing tokens, and calculating the withdrawable amount.
State Variables
startTime
Start time of the lockup period
lockedAmount
Amount that is locked in MONT
token
Address of the MONT token
lockPeriod
The duration of the lockup
Functions
constructor
Constructs the TaxBasedLocker contract.
Initializes the contract with the ERC20 token address and the lock period.
Parameters
_token
IMONT
The address of the ERC20 token to be locked.
_lockPeriod
uint256
The period for which the tokens will be locked, in seconds. Requirements: - _token
must be a valid ERC20 token address. - _lockPeriod
must be greater than zero.
initialize
Initializes the contract with a specified amount of tokens to lock.
Transfers the specified amount of tokens from the caller to the contract.
Parameters
_lockedAmount
uint256
The amount of tokens to lock. Requirements: - The contract must not be already initialized. - The caller must have approved the contract to spend the specified amount of tokens. - The specified amount of tokens must be greater than zero. - The specified amount of tokens must be available in the caller's balance. Emits an {Initialized} event. Throws: - {AlreadyInitialized} if the contract is already initialized. - {NotEnoughTokens} if the caller does not have enough tokens.
withdraw
Withdraws the withdrawable amount of tokens.
*The withdrawable amount is determined by the time elapsed since initialization. The remaining tokens are burned as a penalty for early withdrawal. Requirements:
The caller must be the owner of the contract. Emits a {Withdrawn} event indicating the amount withdrawn. Emits a {Burnn} event indicating the amount burned.*
calculateWithdrawableAmount
Calculates the amount of tokens that can be withdrawn based on the time elapsed since initialization.
Returns the amount of tokens that can be withdrawn without penalty.
Returns
<none>
uint256
The amount of tokens that can be withdrawn.
Last updated