Function: lock(uint256 shares, uint256 endTime)
This locks a specified amount of shares until a specified end time.
Inputs
sharesControl: Fully controlled by the caller.
Constraints: Should be greater than zero.
Impact: The number of shares to lock.
endTimeControl: Fully controlled by the caller.
Constraints: The
endTime - block.timestampshould be between the rangegetMinLockTime()andgetMaxLockTime().Impact: The time until which the shares will be locked.
Branches and code coverage
Intended branches
The
endTime - block.timestampshould be between the rangegetMinLockTime()andgetMaxLockTime().Check if
balanceOfcaller is greater than the value ofshares.Mint NFT to the caller and increment the
nextTokenIdcounter.
Negative behavior
The
endTime - block.timestampis outside the expected range.The
sharesamount is equal to zero.The
balanceOfcaller is less than thesharesamount.
Function call analysis
this.getMaxLockTime() -> this.vaultManager.maxLockTime()What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? N/A.
this.getMinLockTime() -> this.vaultManager.minLockTime()What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? N/A.
this.tranche.balanceOf(msg.sender)What is controllable?
msg.sender.If the return value is controllable, how is it used and how can it go wrong? It is the balance of
msg.sender— should be greater thansharesfor a successful call.What happens if it reverts, reenters or does other unusual control flow? If it reverts, the entire call will revert — no reentrancy scenarios.
Counters.current(this.tokenIds)What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? N/A.
this.tranche.transferFrom(msg.sender, address(this), shares)What is controllable?
msg.senderandshares.If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? If it reverts, the entire call will revert — no reentrancy scenarios.
Counters.increment(this.tokenIds)What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? N/A.