Lockers V3
Technical Reference
Locker V3.1

UNCX_ProofOfReservesV2_UniV3

Functions Write

Lock

function lock(LockParams calldata params) external payable   returns (uint256)

Converts nft to full range and collects fees and sends them back to collector.

Parameters:
TypeDescription
LockParamsAn object that contains: nftPositionManager (address), nft_id (uint256), dustRecipient (address), owner (address), additionalCollector (address), collectAddress (address), unlockDate (uint256), countryCode (string), r (bytes[]), and feeName (string).
Return Values:
TypeDescription
uint256The ID of the newly created lock.

Collects

function collect(
    uint256 _lockId, 
    address _recipient, 
    uint128 _amount0Max, 
    uint128 _amount1Max
) external   
returns (
    uint256 amount0, 
    uint256 amount1, 
    uint256 fee0, 
    uint256 fee1
)

Collect fees to _recipient if msg.sender is the owner of _lockId.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock from which to collect fees.
_recipientaddressThe address to which collected fees will be sent.
_amount0Maxuint128Maximum amount of token0 to collect.
_amount1Maxuint128Maximum amount of token1 to collect.
Return Values:
TypeDescription
uint256Amount of token0 collected.
uint256Amount of token1 collected.
uint256Fee associated with token0.
uint256Fee associated with token1.

IncreaseLiquidity

function increaseLiquidity(
    uint256 _lockId, 
    INonfungiblePositionManager.IncreaseLiquidityParams calldata params
) external payable   
returns (
    uint128 liquidity, 
    uint256 amount0, 
    uint256 amount1
)

Increases liquidity.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock.
paramsINonfungiblePositionManager.IncreaseLiquidityParamsObject containing parameters for increasing liquidity.
Return Values:
NameTypeDescription
liquidityuint128Amount of liquidity added.
amount0uint256Amount of token0 added.
amount1uint256Amount of token1 added.

DecreaseLiquidity

function decreaseLiquidity(
    uint256 _lockId,
    INonfungiblePositionManager.DecreaseLiquidityParams calldata params
) external payable   returns (uint256 amount0, uint256 amount1)

Decrease liquidity if a lock has expired

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock.
paramsINonfungiblePositionManager.DecreaseLiquidityParamsObject containing parameters for decreasing liquidity.
Return Values:
NameTypeDescription
amount0uint256Amount of token0 returned after decreasing liquidity.
amount1uint256Amount of token1 returned after decreasing liquidity.

Relock

function relock(
    uint256 _lockId,
    uint256 _unlockDate
) external  

Set the unlock date further in the future.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock.
_unlockDateuint256The new unlock date timestamp. It must be greater than the current unlock date and the current block timestamp.
Return Values:
NameTypeDescription
_lockIduint256The ID of the lock.
_unlockDateuint256The new unlock date timestamp. It must be greater than the current unlock date and the current block timestamp.

Withdraw

function withdraw(
    uint256 _lockId,
    address _receiver
) external  

Withdraw a UniV3 liquidity NFT and send it to _receiver.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock. The caller must be an admin of this lock.
_receiveraddressThe address to which the UniV3 liquidity NFT will be sent after the withdrawal.

Migrate

function migrate(
    uint256 _lockId
) external  

Migrate a lock to a new amm version (Uniswap V4).

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock. The caller must be an admin of this lock.

SetAdditionalCollector

function setAdditionalCollector(
    uint256 _lockId,
    address _additionalCollector
) external  

Allow a lock owner to add an additional address, usually a contract, to collect fees. Useful for bots.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock. The caller must be an admin of this lock.
_additionalCollectoraddressThe address designated as an additional collector for the fees from the lock.

SetCollectAddress

function setCollectAddress(
    uint256 _lockId,
    address _collectAddress
) external  

Set the adress to which fees are automatically collected.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock. The caller must be an admin of this lock.
_collectAddressaddressThe address to which the fees from the lock are automatically collected.

TransferLockOwnership

function transferLockOwnership(
    uint256 _lockId,
    address _newOwner
) external  

Transfer ownership of a lock to _newOwner.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock. The caller must be an admin of this lock.
_newOwneraddressThe address of the new owner to whom the lock's ownership is being transferred.

AcceptLockOwnership

function acceptLockOwnership(
    uint256 _lockId
) external  
Parameters:
NameTypeDescription
_lockIduint256The ID of the lock for which ownership is being accepted.

Functions View

GetFee

function getFee(string memory _name) public  view returns (FeeStruct memory)

Retrieves the fee details associated with a given name.

Parameters:
TypeDescription
stringThe name used to lookup the associated fee structure.
Return Values:
TypeDescription
FeeStructAn object that contains: name (string), lpFee (uint256), collectFee (uint256), flatFee (uint256), and flatFeeToken (address).

GetFeeOptionAtIndex

function getFeeOptionAtIndex(uint256 _index) external view returns (FeeStruct memory)

Fetches the fee details based on its position.

Parameters:
TypeDescription
uint256Index of the fee option to be retrieved.
Return Values:
TypeDescription
FeeStructAn object that contains: name (string), lpFee (uint256), collectFee (uint256), flatFee (uint256), and flatFeeToken (address).

GetFeeOptionLength

function getFeeOptionLength() external view returns (uint256)

Returns the total amount of fee options available.

Return Values:
TypeDescription
uint256The total amount of fee options available.

GetLock

function getLock(uint256 _lockId) external view  returns (Lock memory _lock)

Returns a Lock struct for _lockId.

Parameters:
NameTypeDescription
_lockIduint256The ID of the lock to be retrieved.
Return Values:
TypeDescription
LockAn object that contains: lock_id (uint256), nftPositionManager (INonfungiblePositionManager), pool (address), nft_id (uint256), owner (address), pendingOwner (address), additionalCollector (address), collectAddress (address), unlockDate (uint256), countryCode (uint16), and ucf (uint256).

GetLocksLength

function getLocksLength() external view  returns (uint256)
Return Values:
TypeDescription
uint256The unique nonce representing the amount of locks in the contract.

GetNumUserLocks

function getNumUserLocks(address _user) external view  returns (uint256)
Parameters:
TypeDescription
addressThe address of the user.
Return Values:
TypeDescription
uint256The number of locks associated with the user.

GetUserLockAtIndex

function getUserLockAtIndex(
    address _user,
    uint256 _index
) external view  returns (Lock memory)
Parameters:
TypeDescription
addressThe address of the user.
uint256The index of the lock for the given user.
Return Values:
TypeDescription
LockA struct that contains details of the lock including lock_id, nftPositionManager, pool, nft_id, owner, pendingOwner, additionalCollector, collectAddress, unlockDate, countryCode, and ucf.

TickSpacingToMaxTick

function tickSpacingToMaxTick(int24 tickSpacing) public pure returns (int24 maxTick)
Parameters:
TypeDescription
int24The tick spacing used to calculate the maximum possible tick.
Return Values:
TypeDescription
int24The maximum tick value calculated for the spacing.

GetAmountsForLiquidity

function getAmountsForLiquidity (
    int24 currentTick, 
    int24 tickLower, 
    int24 tickHigher, 
    uint128 liquidity
) public pure  returns (uint256 amount0, uint256 amount1) {
    return LiquidityAmounts.getAmountsForLiquidity(
        TickMath.getSqrtRatioAtTick(currentTick),
        TickMath.getSqrtRatioAtTick(tickLower),
        TickMath.getSqrtRatioAtTick(tickHigher),
        liquidity
    )
}
Parameters:
TypeDescription
int24The current tick of the liquidity range.
int24The lower tick boundary of the liquidity range.
int24The higher tick boundary of the liquidity range.
uint128The liquidity amount to be used for calculations.
Return Values:
TypeDescription
uint256The amount of token0 calculated based on the provided parameters.
uint256The amount of token1 calculated based on the provided parameters.

OnERC721Received

function onERC721Received(
    address operator,
    address from,
    uint256 tokenId,
    bytes calldata data
) public pure  returns (bytes4) {
    return IERC721Receiver.onERC721Received.selector
}
Parameters:
TypeDescription
addressThe address of the sender invoking this function (the operator).
addressThe address from which the ERC721 token originates.
uint256The unique identifier (ID) of the ERC721 token being transferred.
bytesAdditional calldata sent with the transfer.
Return Values:
TypeDescription
bytes4The function selector for the onERC721Received function.

Events

OnAddFee

event onAddFee(
    bytes32 nameHash, 
    string name, 
    uint256 lpFee, 
    uint256 collectFee, 
    uint256 flatFee, 
    address flatFeeToken
)

Emitted on addOrEditFee.

Parameters:
NameTypeDescription
nameHashbytes32The unique hash representing the name of the fee.
namestringThe name of the fee.
lpFeeuint256The liquidity provider fee amount.
collectFeeuint256The fee amount to be collected.
flatFeeuint256The flat fee amount.
flatFeeTokenaddressThe address of the token in which the flat fee is denominated.

OnEditFee

event onEditFee(
    bytes32 nameHash, 
    string name, 
    uint256 lpFee, 
    uint256 collectFee, 
    uint256 flatFee, 
    address flatFeeToken
)

Emitted on addOrEditFee.

Parameters:
NameTypeDescription
nameHashbytes32The unique hash representing the name of the fee.
namestringThe name of the fee.
lpFeeuint256The liquidity provider fee amount.
collectFeeuint256The fee amount to be collected.
flatFeeuint256The flat fee amount.
flatFeeTokenaddressThe address of the token in which the flat fee is denominated.

OnRemoveFee

event onRemoveFee(
    bytes32 nameHash
)

Emitted on removeFee.

Parameters:
NameTypeDescription
nameHashbytes32The unique hash representing the name of the fee.

OnLock

event onLock(
    uint256 lock_id,
    address nftPositionManager,
    uint256 nft_id,
    address owner,
    address additionalCollector,
    address collectAddress,
    uint256 unlockDate,
    uint16 countryCode,
    uint256 collectFee,
    address poolAddress,
    INonfungiblePositionManager.Position position
)

Emitted ont Lock.

Parameters:
NameTypeDescription
lock_iduint256The unique nonce per lock.
nftPositionManagerINonfungiblePositionManagerThe NFT position manager of the Uniswap fork.
nft_iduint256The NFT token ID of the NFT belonging to the nftPositionManager.
owneraddressThe owner who can collect and withdraw.
additionalCollectoraddressAn additional address allowed to call collect.
collectAddressaddressThe address to which automatic collections are sent.
unlockDateuint256The unlock date of the lock in seconds.
countryCodeuint16The country code of the locker/business.
collectFeeuint256The collect fee.
poolAddressaddressThe pool address.
positionIUniswapV3Pool.PositionRepresents a unique position in a Uniswap V3 Pool. Contains details about the liquidity provided.

OnIncreaseLiquidity

event onIncreaseLiquidity(
    uint256 lockId
)

Emitted on IncreaseLiquidity.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock for which liquidity was increased.

OnDecreaseLiquidity

event onDecreaseLiquidity(
    uint256 lockId
)

Emitted on DecreaseLiquidity.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock for which liquidity was decreased.

OnRelock

event onRelock(
    uint256 lockId, 
    uint256 unlockDate
)

Emitted on Relock.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock that is being relocked.
unlockDateuint256The new unlock date for the relocked lock.

OnWithdraw

event onWithdraw(
    uint256 lock_id, 
    address owner, 
    address receiver
)

Emitted on Withdraw.

Parameters:
NameTypeDescription
lock_iduint256The ID of the lock being withdrawn.
owneraddressThe owner of the lock.
receiveraddressThe address receiving the withdrawal.

OnMigrate

event onMigrate(
    uint256 lockId
)

Emitted on Migrate.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock that is being migrated.

OnSetAdditionalCollector

event onSetAdditionalCollector(
    uint256 lockId, 
    address additionalCollector
)

Emitted on SetAdditionalCollector.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock setting an additional collector.
additionalCollectoraddressThe address being set as the additional collector.

OnSetCollectAddress

event onSetCollectAddress(
    uint256 lockId, 
    address collectAddress
)

Emitted on SetCollectAddress.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock where the collection address is being set.
collectAddressaddressThe new collection address being set.

OnLockOwnershipTransferStarted

event onLockOwnershipTransferStarted(
    uint256 lockId, 
    address currentOwner, 
    address pendingOwner
)

Emitted on TransferLockOwnership.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock initiating ownership transfer.
currentOwneraddressThe current owner initiating the transfer.
pendingOwneraddressThe proposed new owner.

OnTransferLockOwnership

event onTransferLockOwnership(
    uint256 lockId, 
    address oldOwner, 
    address newOwner
)

Emitted on AcceptLockOwnership.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock finalizing ownership transfer.
oldOwneraddressThe address of the previous owner.
newOwneraddressThe address of the new owner.

OnSetMigrator

event onSetMigrator(
    address migrator
)

Emitted on SetMigrator.

Parameters:
NameTypeDescription
migratoraddressThe address of the migrator being set.

OnSetUCF

event onSetUCF(
    uint256 lockId, 
    uint256 ucf
)

Emitted on setUCF.

Parameters:
NameTypeDescription
lockIduint256The ID of the lock where the UCF is being set.
ucfuint256The new UCF value being set.