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.
Type | Description |
---|---|
LockParams | An 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). |
Type | Description |
---|---|
uint256 | The 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.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock from which to collect fees. |
_recipient | address | The address to which collected fees will be sent. |
_amount0Max | uint128 | Maximum amount of token0 to collect. |
_amount1Max | uint128 | Maximum amount of token1 to collect. |
Type | Description |
---|---|
uint256 | Amount of token0 collected. |
uint256 | Amount of token1 collected. |
uint256 | Fee associated with token0. |
uint256 | Fee associated with token1. |
IncreaseLiquidity
function increaseLiquidity(
uint256 _lockId,
INonfungiblePositionManager.IncreaseLiquidityParams calldata params
) external payable
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
)
Increases liquidity.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. |
params | INonfungiblePositionManager.IncreaseLiquidityParams | Object containing parameters for increasing liquidity. |
Name | Type | Description |
---|---|---|
liquidity | uint128 | Amount of liquidity added. |
amount0 | uint256 | Amount of token0 added. |
amount1 | uint256 | Amount 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
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. |
params | INonfungiblePositionManager.DecreaseLiquidityParams | Object containing parameters for decreasing liquidity. |
Name | Type | Description |
---|---|---|
amount0 | uint256 | Amount of token0 returned after decreasing liquidity. |
amount1 | uint256 | Amount of token1 returned after decreasing liquidity. |
Relock
function relock(
uint256 _lockId,
uint256 _unlockDate
) external
Set the unlock date further in the future.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. |
_unlockDate | uint256 | The new unlock date timestamp. It must be greater than the current unlock date and the current block timestamp. |
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. |
_unlockDate | uint256 | The 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.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. The caller must be an admin of this lock. |
_receiver | address | The 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).
Name | Type | Description |
---|---|---|
_lockId | uint256 | The 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.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. The caller must be an admin of this lock. |
_additionalCollector | address | The 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.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. The caller must be an admin of this lock. |
_collectAddress | address | The 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.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock. The caller must be an admin of this lock. |
_newOwner | address | The address of the new owner to whom the lock's ownership is being transferred. |
AcceptLockOwnership
function acceptLockOwnership(
uint256 _lockId
) external
Name | Type | Description |
---|---|---|
_lockId | uint256 | The 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.
Type | Description |
---|---|
string | The name used to lookup the associated fee structure. |
Type | Description |
---|---|
FeeStruct | An 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.
Type | Description |
---|---|
uint256 | Index of the fee option to be retrieved. |
Type | Description |
---|---|
FeeStruct | An 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.
Type | Description |
---|---|
uint256 | The total amount of fee options available. |
GetLock
function getLock(uint256 _lockId) external view returns (Lock memory _lock)
Returns a Lock struct for _lockId.
Name | Type | Description |
---|---|---|
_lockId | uint256 | The ID of the lock to be retrieved. |
Type | Description |
---|---|
Lock | An 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)
Type | Description |
---|---|
uint256 | The unique nonce representing the amount of locks in the contract. |
GetNumUserLocks
function getNumUserLocks(address _user) external view returns (uint256)
Type | Description |
---|---|
address | The address of the user. |
Type | Description |
---|---|
uint256 | The number of locks associated with the user. |
GetUserLockAtIndex
function getUserLockAtIndex(
address _user,
uint256 _index
) external view returns (Lock memory)
Type | Description |
---|---|
address | The address of the user. |
uint256 | The index of the lock for the given user. |
Type | Description |
---|---|
Lock | A 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)
Type | Description |
---|---|
int24 | The tick spacing used to calculate the maximum possible tick. |
Type | Description |
---|---|
int24 | The 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
)
}
Type | Description |
---|---|
int24 | The current tick of the liquidity range. |
int24 | The lower tick boundary of the liquidity range. |
int24 | The higher tick boundary of the liquidity range. |
uint128 | The liquidity amount to be used for calculations. |
Type | Description |
---|---|
uint256 | The amount of token0 calculated based on the provided parameters. |
uint256 | The 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
}
Type | Description |
---|---|
address | The address of the sender invoking this function (the operator). |
address | The address from which the ERC721 token originates. |
uint256 | The unique identifier (ID) of the ERC721 token being transferred. |
bytes | Additional calldata sent with the transfer. |
Type | Description |
---|---|
bytes4 | The 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.
Name | Type | Description |
---|---|---|
nameHash | bytes32 | The unique hash representing the name of the fee. |
name | string | The name of the fee. |
lpFee | uint256 | The liquidity provider fee amount. |
collectFee | uint256 | The fee amount to be collected. |
flatFee | uint256 | The flat fee amount. |
flatFeeToken | address | The 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.
Name | Type | Description |
---|---|---|
nameHash | bytes32 | The unique hash representing the name of the fee. |
name | string | The name of the fee. |
lpFee | uint256 | The liquidity provider fee amount. |
collectFee | uint256 | The fee amount to be collected. |
flatFee | uint256 | The flat fee amount. |
flatFeeToken | address | The address of the token in which the flat fee is denominated. |
OnRemoveFee
event onRemoveFee(
bytes32 nameHash
)
Emitted on removeFee.
Name | Type | Description |
---|---|---|
nameHash | bytes32 | The 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.
Name | Type | Description |
---|---|---|
lock_id | uint256 | The unique nonce per lock. |
nftPositionManager | INonfungiblePositionManager | The NFT position manager of the Uniswap fork. |
nft_id | uint256 | The NFT token ID of the NFT belonging to the nftPositionManager. |
owner | address | The owner who can collect and withdraw. |
additionalCollector | address | An additional address allowed to call collect. |
collectAddress | address | The address to which automatic collections are sent. |
unlockDate | uint256 | The unlock date of the lock in seconds. |
countryCode | uint16 | The country code of the locker/business. |
collectFee | uint256 | The collect fee. |
poolAddress | address | The pool address. |
position | IUniswapV3Pool.Position | Represents a unique position in a Uniswap V3 Pool. Contains details about the liquidity provided. |
OnIncreaseLiquidity
event onIncreaseLiquidity(
uint256 lockId
)
Emitted on IncreaseLiquidity.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock for which liquidity was increased. |
OnDecreaseLiquidity
event onDecreaseLiquidity(
uint256 lockId
)
Emitted on DecreaseLiquidity.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock for which liquidity was decreased. |
OnRelock
event onRelock(
uint256 lockId,
uint256 unlockDate
)
Emitted on Relock.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock that is being relocked. |
unlockDate | uint256 | The new unlock date for the relocked lock. |
OnWithdraw
event onWithdraw(
uint256 lock_id,
address owner,
address receiver
)
Emitted on Withdraw.
Name | Type | Description |
---|---|---|
lock_id | uint256 | The ID of the lock being withdrawn. |
owner | address | The owner of the lock. |
receiver | address | The address receiving the withdrawal. |
OnMigrate
event onMigrate(
uint256 lockId
)
Emitted on Migrate.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock that is being migrated. |
OnSetAdditionalCollector
event onSetAdditionalCollector(
uint256 lockId,
address additionalCollector
)
Emitted on SetAdditionalCollector.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock setting an additional collector. |
additionalCollector | address | The address being set as the additional collector. |
OnSetCollectAddress
event onSetCollectAddress(
uint256 lockId,
address collectAddress
)
Emitted on SetCollectAddress.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock where the collection address is being set. |
collectAddress | address | The new collection address being set. |
OnLockOwnershipTransferStarted
event onLockOwnershipTransferStarted(
uint256 lockId,
address currentOwner,
address pendingOwner
)
Emitted on TransferLockOwnership.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock initiating ownership transfer. |
currentOwner | address | The current owner initiating the transfer. |
pendingOwner | address | The proposed new owner. |
OnTransferLockOwnership
event onTransferLockOwnership(
uint256 lockId,
address oldOwner,
address newOwner
)
Emitted on AcceptLockOwnership.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock finalizing ownership transfer. |
oldOwner | address | The address of the previous owner. |
newOwner | address | The address of the new owner. |
OnSetMigrator
event onSetMigrator(
address migrator
)
Emitted on SetMigrator.
Name | Type | Description |
---|---|---|
migrator | address | The address of the migrator being set. |
OnSetUCF
event onSetUCF(
uint256 lockId,
uint256 ucf
)
Emitted on setUCF.
Name | Type | Description |
---|---|---|
lockId | uint256 | The ID of the lock where the UCF is being set. |
ucf | uint256 | The new UCF value being set. |