TaxBasedLocker

TaxBasedLocker

Git Source

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

uint256 public startTime;

lockedAmount

Amount that is locked in MONT

uint256 public lockedAmount;

token

Address of the MONT token

IMONT public immutable token;

lockPeriod

The duration of the lockup

uint256 public immutable lockPeriod;

Functions

constructor

Constructs the TaxBasedLocker contract.

Initializes the contract with the ERC20 token address and the lock period.

constructor(IMONT _token, uint256 _lockPeriod) Ownable(msg.sender);

Parameters

Name
Type
Description

_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.

function initialize(uint256 _lockedAmount) external onlyNotInitialized onlyOwner;

Parameters

Name
Type
Description

_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.*

function withdraw() external onlyOwner onlyInitialized;

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.

function calculateWithdrawableAmount() public view returns (uint256);

Returns

Name
Type
Description

<none>

uint256

The amount of tokens that can be withdrawn.

Last updated