UniswapV2Locker
Functions Write
LockLPToken
function lockLPToken (
address _lpToken,
uint256 _amount,
uint256 _unlock_date,
address payable _referral,
bool _fee_in_eth,
address payable _withdrawer,
uint16 _countryCode
) external payable
Creates a new lock.
Parameters:
Name | Type | Description |
---|---|---|
_lpToken | address | The univ2 token address. |
_amount | uint256 | Amount of LP tokens to lock. |
_unlock_date | uint256 | The unix timestamp (in seconds) until unlock. |
_referral | address | The referrer address if any or address(0) for none. |
_fee_in_eth | bool | Fees can be paid in eth or in a secondary token such as UNCX with a discount on univ2 tokens. |
_withdrawer | address | The user who can withdraw liquidity once the lock expires. |
_countryCode | uint16 | The code of the country from which the lock user account/business is from. |
Relock
function relock (
uint256 _lockID,
uint256 _unlock_date
) external
Extends a lock with a new unlock date.
Parameters:
Name | Type | Description |
---|---|---|
_lockID | uint256 | The ID of the lock to be extended. |
_unlock_date | uint256 | The new unix timestamp (in seconds) until unlock. This must be greater than the current one. |
Withdraw
function withdraw (
uint256 _lockID,
uint256 _amount
) external
Withdraws a specified amount from a lock.
Parameters:
Name | Type | Description |
---|---|---|
_lockID | uint256 | ID associated with the specific locked tokens. |
_amount | uint256 | Amount of tokens the user wishes to withdraw. |
IncrementLock
function incrementLock (
uint256 _lockID,
uint256 _amount
) external
Increases the amount of tokens per a specific lock.
Parameters:
Name | Type | Description |
---|---|---|
_lockID | uint256 | ID associated with the specific locked tokens. |
_amount | uint256 | Amount of tokens the contract or user wishes to lock/add. |
SplitLock
function splitLock (
uint256 _lockID,
uint256 _amount
) external payable
Splits a lock into two seperate locks.
Parameters:
Name | Type | Description |
---|---|---|
_lockID | uint256 | ID associated with the specific locked tokens. |
_amount | uint256 | Amount of tokens the user wishes to split. |
TransferLockOwnership
function transferLockOwnership (
uint256 _lockID,
address payable _newOwner
) external
Transfers a lock to a new owner.
Parameters:
Name | Type | Description |
---|---|---|
_lockID | uint256 | ID associated with the specific locked tokens. |
_newOwner | address | The new owner's address to transfer the lock to. |
Migrate
function migrate (
uint256 _lockID,
uint256 _amount,
uint256 _migration_option
) external
Migrates liquidity to the next release of an AMM
Parameters:
Name | Type | Description |
---|---|---|
_lockID | uint256 | ID associated with the specific locked tokens. |
_amount | uint256 | Amount of tokens the user wishes to migrate. |
_migration_option | uint256 | Option to be used as an AMM selector during migration. |
Functions View
GetNumLocksForToken
function getNumLocksForToken (address _lpToken) external view returns (uint256)
Parameters:
Name | Type | Description |
---|---|---|
_lpToken | address | Address of the LP token. |
Return Values:
Type | Description |
---|---|
uint256 | Number of locks for the specified LP token. |
GetNumLockedTokens
function getNumLockedTokens () external view returns (uint256)
Return Values:
Type | Description |
---|---|
uint256 | Number of unique locked tokens. |
GetLockedTokenAtIndex
function getLockedTokenAtIndex (uint256 _index) external view returns (address)
Parameters:
Name | Type | Description |
---|---|---|
_index | uint256 | Index of the locked token. |
Return Values:
Type | Description |
---|---|
address | Address of the locked token at the specified index. |
GetUserNumLockedTokens
function getUserNumLockedTokens (address _user) external view returns (uint256)
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user. |
Return Values:
Type | Description |
---|---|
uint256 | Number of unique tokens locked by the user. |
GetUserLockedTokenAtIndex
function getUserLockedTokenAtIndex (address _user, uint256 _index) external view returns (address)
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user. |
_index | uint256 | Index of the locked token. |
Return Values:
Type | Description |
---|---|
address | Address of the locked token at the specified index for the user. |
GetUserNumLocksForToken
function getUserNumLocksForToken (address _user, address _lpToken) external view returns (uint256)
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user. |
Return Values:
Type | Description |
---|---|
uint256 | Number of unique tokens locked by the user. |
GetUserLockForTokenAtIndex
function getUserLockForTokenAtIndex (
address _user,
address _lpToken,
uint256 _index) external view
returns (TokenLock memory)
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user. |
_index | uint256 | Index of the locked token. |
Return Values:
Type | Description |
---|---|
address | Address of the locked token at the specified index for the user. |
GetWhitelistedUsersLength
function getWhitelistedUsersLength () external view returns (uint256)
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user. |
_lpToken | address | Address of the LP token. |
Return Values:
Type | Description |
---|---|
uint256 | Number of locks for the specified LP token for the user. |
GetWhitelistedUserAtIndex
function getWhitelistedUserAtIndex (uint256 _index) external view returns (address)
Parameters:
Name | Type | Description |
---|---|---|
_user | address | Address of the user. |
_lpToken | address | Address of the LP token. |
_index | uint256 | Index of the locked token. |
Return Values:
Type | Description |
---|---|
TokenLock | An object that contains: lpToken (address), lockDate (uint256), amount (uint256), initialAmount (uint256), unlockDate (uint256), lockID (uint256), owner (address), and countryCode (uint16). |
GetUserWhitelistStatus
function getUserWhitelistStatus (address _user) external view returns (bool)
Return Values:
Type | Description |
---|---|
uint256 | Number of users on the whitelist. |
Events
OnNewLock
event onNewLock(
uint256 indexed lockID,
address indexed lpToken,
address indexed owner,
uint256 amount,
uint256 lockDate,
uint256 unlockDate,
uint16 countryCode
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the new lock. |
lpToken | address | The LP token involved in the lock. |
owner | address | Address of the lock owner. |
amount | uint256 | Amount of tokens in the lock. |
lockDate | uint256 | Date when the tokens were locked. |
unlockDate | uint256 | Date when the tokens can be withdrawn. |
countryCode | uint16 | The country code of the locker or business. |
OnRelock
event onRelock(
uint256 indexed lockID,
address indexed lpToken,
address indexed owner,
uint256 amountRemainingInLock,
uint256 liquidityFee,
uint256 unlockDate
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the relocked token. |
lpToken | address | The LP token involved in the relock. |
owner | address | Address of the lock owner. |
amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
liquidityFee | uint256 | Fee associated with the liquidity. |
unlockDate | uint256 | Date when the tokens can be withdrawn. |
OnWithdraw
event onWithdraw(
uint256 indexed lockID,
address indexed lpToken,
address indexed owner,
uint256 amountRemainingInLock,
uint256 amountRemoved
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the withdrawn lock. |
lpToken | address | The LP token involved in the withdrawal. |
owner | address | Address of the lock owner. |
amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
amountRemoved | uint256 | Amount of tokens removed from the lock. |
OnIncrementLock
event onIncrementLock(
uint256 indexed lockID,
address indexed lpToken,
address indexed owner,
address payer,
uint256 amountRemainingInLock,
uint256 amountAdded,
uint256 liquidityFee
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the incremented lock. |
lpToken | address | The LP token involved in the increment. |
owner | address | Address of the lock owner. |
payer | address | Address of the one who paid for the increment. |
amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
amountAdded | uint256 | Amount of tokens added to the lock. |
liquidityFee | uint256 | Fee associated with the liquidity. |
OnSplitLock
event onSplitLock(
uint256 indexed lockID,
address indexed lpToken,
address indexed owner,
uint256 amountRemainingInLock,
uint256 amountRemoved
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the split lock. |
lpToken | address | The LP token involved in the split. |
owner | address | Address of the lock owner. |
amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
amountRemoved | uint256 | Amount of tokens removed during the split. |
OnTransferLockOwnership
event onTransferLockOwnership(
uint256 indexed lockID,
address indexed lpToken,
address indexed oldOwner,
address newOwner
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the lock whose ownership is transferred. |
lpToken | address | The LP token involved in the transfer. |
oldOwner | address | Address of the previous lock owner. |
newOwner | address | Address of the new lock owner. |
OnMigrate
event OnMigrate(
uint256 indexed lockID,
address indexed lpToken,
address indexed owner,
uint256 amountRemainingInLock,
uint256 amountMigrated,
uint256 migrationOption
)
Parameters:
Name | Type | Description |
---|---|---|
lockID | uint256 | ID of the migrated lock. |
lpToken | address | The LP token involved in the migration. |
owner | address | Address of the lock owner. |
amountRemainingInLock | uint256 | Amount of tokens remaining in the lock. |
amountMigrated | uint256 | Amount of tokens migrated. |
migrationOption | uint256 | Option selected for migration. |