Skip to main content
Solidity: ^0.8.4 Inherits: Ownable (OpenZeppelin), ITokifyLock Uses: Address (OpenZeppelin), EnumerableSet (OpenZeppelin), SafeERC20 (OpenZeppelin), IERC20 (OpenZeppelin), FullMath, Uniswap-v2 interfaces

State Variables

NameTypeDescription
lockFeeuint256eth fee per lock in wei
feeReceiveraddress payableaddress receiving lock fees
_locksLock[]append only list of all locks
_userLpLockIdsmapping(address ⇒ Set)lp lock ids for user
_userNormalLockIdsmapping(address ⇒ Set)normal token lock ids for user
_lpLockedTokensAddressSetunique lp tokens with active locks
_normalLockedTokensAddressSetunique normal tokens with active locks
cumulativeLockInfomapping(address ⇒ Info)totals per token and factory reference
_tokenToLockIdsmapping(address ⇒ Set)all lock ids tied to a specific token

Structs

Lock

FieldTypeDescription
iduint256external id (index plus 1000000)
tokenaddresstoken contract address
owneraddressunlock caller
amountuint256total locked amount
lockDateuint256timestamp when created
tgeDateuint256tge time for vesting, unlock time for normal
tgeBpsuint256release basis points at tge, 0 for normal
cycleuint256seconds per cycle, 0 for normal
cycleBpsuint256release basis points per cycle, 0 for normal
unlockedAmountuint256total withdrawn
descriptionstringuser note

CumulativeLockInfo

FieldTypeDescription
tokenaddresstoken address
factoryaddressuniswap v2 factory, zero for normal token
amountuint256active total locked amount

Functions

lock

function lock(
    address owner,
    address token,
    bool isLpToken,
    uint256 amount,
    uint256 unlockDate,
    string memory description
) external payable returns (uint256 id)
Reverts: insufficient fee, zero amount, unlock date not in future. Emits: LockAdded

vestingLock

function vestingLock(
    address owner,
    address token,
    bool isLpToken,
    uint256 amount,
    uint256 tgeDate,
    uint256 tgeBps,
    uint256 cycle,
    uint256 cycleBps,
    string memory description
) external payable returns (uint256 id)
Reverts: bad bps sums, zero cycle, etc. Emits: LockAdded

multipleVestingLock

function multipleVestingLock(
    address[] calldata owners,
    uint256[] calldata amounts,
    address token,
    bool isLpToken,
    uint256 tgeDate,
    uint256 tgeBps,
    uint256 cycle,
    uint256 cycleBps,
    string memory description
) external payable returns (uint256[] memory ids)
Reverts: length mismatch, bad bps, insufficient fee Emits: LockAdded (per lock)

unlock

function unlock(uint256 lockId) external
Reverts: not owner, nothing releasable. Emits: LockRemoved / LockVested

editLock

function editLock(
    uint256 lockId,
    uint256 newAmount,
    uint256 newUnlockDate
) external
Reverts: not owner, lock already unlocked, new values invalid. Emits: LockUpdated

editLockDescription

function editLockDescription(uint256 lockId, string memory description) external
Reverts: not owner. Emits: LockDescriptionChanged

transferLockOwnership

function transferLockOwnership(uint256 lockId, address newOwner) external
Reverts: not owner. Emits: LockOwnerChanged

renounceLockOwnership

function renounceLockOwnership(uint256 lockId) external
Reverts: not owner. Emits: LockOwnerChanged

View Helpers

SignatureReturns
getTotalLockCount()uint256
getLockAt(uint256 index)Lock memory
getLockById(uint256 lockId)Lock memory
withdrawableTokens(uint256 lockId)uint256
allLpTokenLockedCount()uint256
allNormalTokenLockedCount()uint256
totalTokenLockedCount()uint256
getCumulativeNormalTokenLockInfoAt(uint256 index)CumulativeLockInfo memory
getCumulativeNormalTokenLockInfo(uint256 start, uint256 end)CumulativeLockInfo[] memory
getCumulativeLpTokenLockInfoAt(uint256 index)CumulativeLockInfo memory
getCumulativeLpTokenLockInfo(uint256 start, uint256 end)CumulativeLockInfo[] memory
lpLockCountForUser(address user)uint256
lpLocksForUser(address user)Lock[] memory
lpLockForUserAtIndex(address user, uint256 index)Lock memory
normalLockCountForUser(address user)uint256
normalLocksForUser(address user)Lock[] memory
normalLockForUserAtIndex(address user, uint256 index)Lock memory
totalLockCountForUser(address user)uint256
totalLockCountForToken(address token)uint256
getLocksForToken(address token ,uint256 start, uint256 end)Lock[] memory
cumulativeLockInfo(address token)CumulativeLockInfo memory

Events

NameSignature
LockAddedevent LockAdded(uint256 id, address token, address owner, uint256 amount, uint256 unlockDate)
LockUpdatedevent LockUpdated(uint256 id, address token, address owner, uint256 newAmount, uint256 newUnlockDate)
LockRemovedevent LockRemoved(uint256 id, address token, address owner, uint256 amount, uint256 unlockedAt)
LockVestedevent LockVested(uint256 id, address token, address owner, uint256 amount, uint256 remaining, uint256 timestamp)
LockDescriptionChangedevent LockDescriptionChanged(uint256 lockId)
LockOwnerChangedevent LockOwnerChanged(uint256 lockId, address owner, address newOwner)