Skip to main content

ISemiFungiblePositionManager (V2)

Source reference for public revision e3b9d12. For deployed configuration, select the pool's engine on the parameter page.

Git Source

Functions
​

mintTokenizedPosition
​

Create a new position tokenId containing up to 4 legs.

Both V3 and V4 implementations use bytes poolKey to abstract the underlying pool.

function mintTokenizedPosition(
bytes calldata poolKey,
TokenId tokenId,
uint128 positionSize,
int24 slippageTickLimitLow,
int24 slippageTickLimitHigh
) external returns (LeftRightUnsigned[4] memory collectedByLeg, LeftRightSigned totalMoved, int24 finalTick);

Parameters

NameTypeDescription
poolKeybytesThe ABI-encoded pool key (V3: address, V4: PoolKey)
tokenIdTokenIdThe tokenId of the minted position, which encodes information for up to 4 legs
positionSizeuint128The number of contracts minted, expressed in terms of the asset
slippageTickLimitLowint24The lower bound of an acceptable open interval for the ending price
slippageTickLimitHighint24The upper bound of an acceptable open interval for the ending price

Returns

NameTypeDescription
collectedByLegLeftRightUnsigned[4]An array of LeftRight encoded words containing the amount of currency0 and currency1 collected as fees for each leg
totalMovedLeftRightSignedThe net amount of currency0 and currency1 moved to/from the Uniswap V4 pool
finalTickint24The tick at the end of the mint/burn operation

burnTokenizedPosition
​

Burn a new position containing up to 4 legs wrapped in a ERC1155 token.

Auto-collect all accumulated fees.

function burnTokenizedPosition(
bytes calldata poolKey,
TokenId tokenId,
uint128 positionSize,
int24 slippageTickLimitLow,
int24 slippageTickLimitHigh
) external returns (LeftRightUnsigned[4] memory collectedByLeg, LeftRightSigned totalMoved, int24 finalTick);

Parameters

NameTypeDescription
poolKeybytesThe ABI-encoded pool key in which to burn tokenId (V3: Uniswap V3 pool address, V4: Uniswap V4 PoolKey)
tokenIdTokenIdThe tokenId of the minted position, which encodes information about up to 4 legs
positionSizeuint128The number of contracts minted, expressed in terms of the asset
slippageTickLimitLowint24The lower bound of an acceptable open interval for the ending price
slippageTickLimitHighint24The upper bound of an acceptable open interval for the ending price

Returns

NameTypeDescription
collectedByLegLeftRightUnsigned[4]An array of LeftRight encoded words containing the amount of currency0 and currency1 collected as fees for each leg
totalMovedLeftRightSignedThe net amount of currency0 and currency1 moved to/from the Uniswap V4 pool
finalTickint24The tick at the end of the mint/burn operation

getAccountLiquidity
​

Return the liquidity associated with a given liquidity chunk/tokenType for a user on a Uniswap pool.

function getAccountLiquidity(
bytes calldata poolKey,
address owner,
uint256 tokenType,
int24 tickLower,
int24 tickUpper
) external view returns (LeftRightUnsigned accountLiquidities);

Parameters

NameTypeDescription
poolKeybytesThe ABI-encoded pool key (V3: Uniswap V3 pool address, V4: Uniswap V4 PoolKey)
owneraddressThe address of the account that is queried
tokenTypeuint256The tokenType of the position
tickLowerint24The lower end of the tick range for the position
tickUpperint24The upper end of the tick range for the position

Returns

NameTypeDescription
accountLiquiditiesLeftRightUnsignedThe amount of liquidity that held in and removed from Uniswap for that chunk (netLiquidity:removedLiquidity -> rightSlot:leftSlot)

getAccountPremium
​

Return the premium associated with a given position, where premium is an accumulator of feeGrowth for the touched position.

If an atTick parameter is provided that is different from type(int24).max, then it will update the premium up to the current block at the provided atTick value. We do this because this may be called immediately after the Uniswap V4 pool has been touched, so no need to read the feeGrowths from the Uniswap V4 pool.

function getAccountPremium(
bytes calldata poolKey,
address owner,
uint256 tokenType,
int24 tickLower,
int24 tickUpper,
int24 atTick,
uint256 isLong,
uint256 vegoid
) external view returns (uint128 premium0, uint128 premium1);

Parameters

NameTypeDescription
poolKeybytesThe ABI-encoded pool key (V3: Uniswap V3 pool address, V4: Uniswap V4 PoolKey)
owneraddressThe address of the account that is queried
tokenTypeuint256The tokenType of the position
tickLowerint24The lower end of the tick range for the position
tickUpperint24The upper end of the tick range for the position
atTickint24The current tick. Set atTick < (type(int24).max = 8388607) to get latest premium up to the current block
isLonguint256Whether the position is long (=1) or short (=0)
vegoiduint256The vegoid of the position

Returns

NameTypeDescription
premium0uint128The amount of premium (per liquidity X64) for currency0 = sum(feeGrowthLast0X128) over every block where the position has been touched
premium1uint128The amount of premium (per liquidity X64) for currency1 = sum(feeGrowthLast0X128) over every block where the position has been touched

getPoolId
​

Returns the poolId for a given Uniswap pool.

function getPoolId(bytes memory id, uint8 vegoid) external view returns (uint64 poolId);

Parameters

NameTypeDescription
idbytesThe PoolId of the Uniswap V4 Pool
vegoiduint8The vegoid of the pool

Returns

NameTypeDescription
poolIduint64The unique pool identifier corresponding to a idV4

getEnforcedTickLimits
​

Returns the enforced tick limits for a given pool.

function getEnforcedTickLimits(uint64 poolId) external view returns (int24 minTick, int24 maxTick);

Parameters

NameTypeDescription
poolIduint64The poolId to query

Returns

NameTypeDescription
minTickint24The minimum enforced tick
maxTickint24The maximum enforced tick

getCurrentTick
​

Returns the current tick of a given Uniswap V4 pool

function getCurrentTick(bytes memory poolKey) external view returns (int24 currentTick);

Parameters

NameTypeDescription
poolKeybytesThe ABI-encoded pool key (V3: Uniswap V3 pool address, V4: Uniswap V4 PoolKey)

Returns

NameTypeDescription
currentTickint24The current tick of the Uniswap pool

expandEnforcedTickRange
​

Recomputes and decreases minEnforcedTick and/or increases maxEnforcedTick for a given V4 pool key if certain conditions are met.

This function will only have an effect if both conditions are met:

  • The token supply for one of the (non-native) tokens was greater than MIN_ENFORCED_TICKFILL_COST at the last initializeAMMPool or expandEnforcedTickRangeForPool call for poolId
  • The token supply for one of the tokens meeting the first condition has decreased significantly since the last call

This function cannot decrease the absolute value of either enforced tick, i.e., it can only widen the range of possible ticks.

The purpose of this function is to prevent pools created while a large amount of one of the tokens was flash-minted from being stuck in a narrow tick range.

function expandEnforcedTickRange(uint64 poolId) external;

Parameters

NameTypeDescription
poolIduint64The poolId on which to expand the enforced tick range

safeTransferFrom
​

All ERC1155 transfers are disabled.

function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

safeBatchTransferFrom
​

All ERC1155 transfers are disabled.

function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;

Events
​

TokenizedPositionBurnt
​

Emitted when a position is destroyed/burned.

event TokenizedPositionBurnt(address indexed recipient, TokenId indexed tokenId, uint128 positionSize);

TokenizedPositionMinted
​

Emitted when a position is created/minted.

event TokenizedPositionMinted(address indexed caller, TokenId indexed tokenId, uint128 positionSize);