Documentation
Lockers V2
Technical Reference
UniswapV2Locker (2.1)

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:
NameTypeDescription
_lpTokenaddressThe univ2 token address.
_amountuint256Amount of LP tokens to lock.
_unlock_dateuint256The unix timestamp (in seconds) until unlock.
_referraladdressThe referrer address if any or address(0) for none.
_fee_in_ethboolFees can be paid in eth or in a secondary token such as UNCX with a discount on univ2 tokens.
_withdraweraddressThe user who can withdraw liquidity once the lock expires.
_countryCodeuint16The 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:
NameTypeDescription
_lockIDuint256The ID of the lock to be extended.
_unlock_dateuint256The 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:
NameTypeDescription
_lockIDuint256ID associated with the specific locked tokens.
_amountuint256Amount 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:
NameTypeDescription
_lockIDuint256ID associated with the specific locked tokens.
_amountuint256Amount 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:
NameTypeDescription
_lockIDuint256ID associated with the specific locked tokens.
_amountuint256Amount of tokens the user wishes to split.

TransferLockOwnership

function transferLockOwnership (
    uint256 _lockID, 
    address payable _newOwner
) external

Transfers a lock to a new owner.

Parameters:
NameTypeDescription
_lockIDuint256ID associated with the specific locked tokens.
_newOwneraddressThe 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:
NameTypeDescription
_lockIDuint256ID associated with the specific locked tokens.
_amountuint256Amount of tokens the user wishes to migrate.
_migration_optionuint256Option to be used as an AMM selector during migration.

Functions View

GetNumLocksForToken

function getNumLocksForToken (address _lpToken) external view returns (uint256)
Parameters:
NameTypeDescription
_lpTokenaddressAddress of the LP token.
Return Values:
TypeDescription
uint256Number of locks for the specified LP token.

GetNumLockedTokens

function getNumLockedTokens () external view returns (uint256)
Return Values:
TypeDescription
uint256Number of unique locked tokens.

GetLockedTokenAtIndex

function getLockedTokenAtIndex (uint256 _index) external view returns (address)
Parameters:
NameTypeDescription
_indexuint256Index of the locked token.
Return Values:
TypeDescription
addressAddress of the locked token at the specified index.

GetUserNumLockedTokens

function getUserNumLockedTokens (address _user) external view returns (uint256)
Parameters:
NameTypeDescription
_useraddressAddress of the user.
Return Values:
TypeDescription
uint256Number of unique tokens locked by the user.

GetUserLockedTokenAtIndex

function getUserLockedTokenAtIndex (address _user, uint256 _index) external view returns (address)
Parameters:
NameTypeDescription
_useraddressAddress of the user.
_indexuint256Index of the locked token.
Return Values:
TypeDescription
addressAddress of the locked token at the specified index for the user.

GetUserNumLocksForToken

function getUserNumLocksForToken (address _user, address _lpToken) external view returns (uint256)
Parameters:
NameTypeDescription
_useraddressAddress of the user.
Return Values:
TypeDescription
uint256Number of unique tokens locked by the user.

GetUserLockForTokenAtIndex

function getUserLockForTokenAtIndex (
    address _user, 
    address _lpToken, 
    uint256 _index) external view 
  returns (TokenLock memory)
Parameters:
NameTypeDescription
_useraddressAddress of the user.
_indexuint256Index of the locked token.
Return Values:
TypeDescription
addressAddress of the locked token at the specified index for the user.

GetWhitelistedUsersLength

function getWhitelistedUsersLength () external view returns (uint256)
Parameters:
NameTypeDescription
_useraddressAddress of the user.
_lpTokenaddressAddress of the LP token.
Return Values:
TypeDescription
uint256Number of locks for the specified LP token for the user.

GetWhitelistedUserAtIndex

function getWhitelistedUserAtIndex (uint256 _index) external view returns (address)
Parameters:
NameTypeDescription
_useraddressAddress of the user.
_lpTokenaddressAddress of the LP token.
_indexuint256Index of the locked token.
Return Values:
TypeDescription
TokenLockAn 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:
TypeDescription
uint256Number 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:
NameTypeDescription
lockIDuint256ID of the new lock.
lpTokenaddressThe LP token involved in the lock.
owneraddressAddress of the lock owner.
amountuint256Amount of tokens in the lock.
lockDateuint256Date when the tokens were locked.
unlockDateuint256Date when the tokens can be withdrawn.
countryCodeuint16The 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:
NameTypeDescription
lockIDuint256ID of the relocked token.
lpTokenaddressThe LP token involved in the relock.
owneraddressAddress of the lock owner.
amountRemainingInLockuint256Amount of tokens remaining in the lock.
liquidityFeeuint256Fee associated with the liquidity.
unlockDateuint256Date when the tokens can be withdrawn.

OnWithdraw

event onWithdraw(
    uint256 indexed lockID, 
    address indexed lpToken, 
    address indexed owner, 
    uint256 amountRemainingInLock, 
    uint256 amountRemoved
)
Parameters:
NameTypeDescription
lockIDuint256ID of the withdrawn lock.
lpTokenaddressThe LP token involved in the withdrawal.
owneraddressAddress of the lock owner.
amountRemainingInLockuint256Amount of tokens remaining in the lock.
amountRemoveduint256Amount 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:
NameTypeDescription
lockIDuint256ID of the incremented lock.
lpTokenaddressThe LP token involved in the increment.
owneraddressAddress of the lock owner.
payeraddressAddress of the one who paid for the increment.
amountRemainingInLockuint256Amount of tokens remaining in the lock.
amountAddeduint256Amount of tokens added to the lock.
liquidityFeeuint256Fee associated with the liquidity.

OnSplitLock

event onSplitLock(
    uint256 indexed lockID, 
    address indexed lpToken, 
    address indexed owner, 
    uint256 amountRemainingInLock, 
    uint256 amountRemoved
)
Parameters:
NameTypeDescription
lockIDuint256ID of the split lock.
lpTokenaddressThe LP token involved in the split.
owneraddressAddress of the lock owner.
amountRemainingInLockuint256Amount of tokens remaining in the lock.
amountRemoveduint256Amount of tokens removed during the split.

OnTransferLockOwnership

event onTransferLockOwnership(
    uint256 indexed lockID, 
    address indexed lpToken, 
    address indexed oldOwner, 
    address newOwner
)
Parameters:
NameTypeDescription
lockIDuint256ID of the lock whose ownership is transferred.
lpTokenaddressThe LP token involved in the transfer.
oldOwneraddressAddress of the previous lock owner.
newOwneraddressAddress of the new lock owner.

OnMigrate

event OnMigrate(
    uint256 indexed lockID, 
    address indexed lpToken, 
    address indexed owner, 
    uint256 amountRemainingInLock, 
    uint256 amountMigrated, 
    uint256 migrationOption
)
Parameters:
NameTypeDescription
lockIDuint256ID of the migrated lock.
lpTokenaddressThe LP token involved in the migration.
owneraddressAddress of the lock owner.
amountRemainingInLockuint256Amount of tokens remaining in the lock.
amountMigrateduint256Amount of tokens migrated.
migrationOptionuint256Option selected for migration.