Skip to main content
Helpful?

Descriptor

Git Source - Generated with forge doc

Describes NFT token positions

Reference: https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/NFTDescriptor.sol

State Variables

sqrt10X128

uint256 constant sqrt10X128 = 1076067327063303206878105757264492625226;

Functions

constructTokenURI

Constructs the token URI for a Uniswap v4 NFT

function constructTokenURI(ConstructTokenURIParams memory params) internal pure returns (string memory);

Parameters

NameTypeDescription
paramsConstructTokenURIParamsParameters needed to construct the token URI

Returns

NameTypeDescription
<none>stringThe token URI as a string

escapeSpecialCharacters

Escapes special characters in a string if they are present

function escapeSpecialCharacters(string memory symbol) internal pure returns (string memory);

generateDescriptionPartOne

Generates the first part of the description for a Uniswap v4 NFT

function generateDescriptionPartOne(
string memory quoteCurrencySymbol,
string memory baseCurrencySymbol,
string memory poolManager
) private pure returns (string memory);

Parameters

NameTypeDescription
quoteCurrencySymbolstringThe symbol of the quote currency
baseCurrencySymbolstringThe symbol of the base currency
poolManagerstringThe address of the pool manager

Returns

NameTypeDescription
<none>stringThe first part of the description

generateDescriptionPartTwo

Generates the second part of the description for a Uniswap v4 NFTs

function generateDescriptionPartTwo(
string memory tokenId,
string memory baseCurrencySymbol,
string memory quoteCurrency,
string memory baseCurrency,
string memory hooks,
string memory feeTier
) private pure returns (string memory);

Parameters

NameTypeDescription
tokenIdstringThe token ID
baseCurrencySymbolstringThe symbol of the base currency
quoteCurrencystringThe address of the quote currency
baseCurrencystringThe address of the base currency
hooksstringThe address of the hooks contract
feeTierstringThe fee tier of the pool

Returns

NameTypeDescription
<none>stringThe second part of the description

generateName

Generates the name for a Uniswap v4 NFT

function generateName(ConstructTokenURIParams memory params, string memory feeTier)
private
pure
returns (string memory);

Parameters

NameTypeDescription
paramsConstructTokenURIParamsParameters needed to generate the name
feeTierstringThe fee tier of the pool

Returns

NameTypeDescription
<none>stringThe name of the NFT

generateDecimalString

function generateDecimalString(DecimalStringParams memory params) private pure returns (string memory);

tickToDecimalString

Gets the price (quote/base) at a specific tick in decimal form MIN or MAX are returned if tick is at the bottom or top of the price curve

function tickToDecimalString(
int24 tick,
int24 tickSpacing,
uint8 baseCurrencyDecimals,
uint8 quoteCurrencyDecimals,
bool flipRatio
) internal pure returns (string memory);

Parameters

NameTypeDescription
tickint24The tick (either tickLower or tickUpper)
tickSpacingint24The tick spacing of the pool
baseCurrencyDecimalsuint8The decimals of the base currency
quoteCurrencyDecimalsuint8The decimals of the quote currency
flipRatioboolTrue if the ratio was flipped

Returns

NameTypeDescription
<none>stringThe ratio value as a string

sigfigsRounded

function sigfigsRounded(uint256 value, uint8 digits) private pure returns (uint256, bool);

adjustForDecimalPrecision

Adjusts the sqrt price for different currencies with different decimals

function adjustForDecimalPrecision(uint160 sqrtRatioX96, uint8 baseCurrencyDecimals, uint8 quoteCurrencyDecimals)
private
pure
returns (uint256 adjustedSqrtRatioX96);

Parameters

NameTypeDescription
sqrtRatioX96uint160The sqrt price at a specific tick
baseCurrencyDecimalsuint8The decimals of the base currency
quoteCurrencyDecimalsuint8The decimals of the quote currency

Returns

NameTypeDescription
adjustedSqrtRatioX96uint256The adjusted sqrt price

abs

Absolute value of a signed integer

function abs(int256 x) private pure returns (uint256);

Parameters

NameTypeDescription
xint256The signed integer

Returns

NameTypeDescription
<none>uint256The absolute value of x

fixedPointToDecimalString

function fixedPointToDecimalString(uint160 sqrtRatioX96, uint8 baseCurrencyDecimals, uint8 quoteCurrencyDecimals)
internal
pure
returns (string memory);

feeToPercentString

Converts fee amount in pips to decimal string with percent sign

function feeToPercentString(uint24 fee) internal pure returns (string memory);

Parameters

NameTypeDescription
feeuint24fee amount

Returns

NameTypeDescription
<none>stringfee as a decimal string with percent sign

addressToString

function addressToString(address addr) internal pure returns (string memory);

generateSVGImage

Generates the SVG image for a Uniswap v4 NFT

function generateSVGImage(ConstructTokenURIParams memory params) internal pure returns (string memory svg);

Parameters

NameTypeDescription
paramsConstructTokenURIParamsParameters needed to generate the SVG image

Returns

NameTypeDescription
svgstringThe SVG image as a string

overRange

Checks if the current price is within your position range, above, or below

function overRange(int24 tickLower, int24 tickUpper, int24 tickCurrent) private pure returns (int8);

Parameters

NameTypeDescription
tickLowerint24The lower tick
tickUpperint24The upper tick
tickCurrentint24The current tick

Returns

NameTypeDescription
<none>int80 if the current price is within the position range, -1 if below, 1 if above

isSpecialCharacter

function isSpecialCharacter(bytes1 b) private pure returns (bool);

scale

function scale(uint256 n, uint256 inMn, uint256 inMx, uint256 outMn, uint256 outMx)
private
pure
returns (string memory);

currencyToColorHex

function currencyToColorHex(uint256 currency, uint256 offset) internal pure returns (string memory str);

getCircleCoord

function getCircleCoord(uint256 currency, uint256 offset, uint256 tokenId) internal pure returns (uint256);

sliceCurrencyHex

function sliceCurrencyHex(uint256 currency, uint256 offset) internal pure returns (uint256);

Structs

ConstructTokenURIParams

struct ConstructTokenURIParams {
uint256 tokenId;
address quoteCurrency;
address baseCurrency;
string quoteCurrencySymbol;
string baseCurrencySymbol;
uint8 quoteCurrencyDecimals;
uint8 baseCurrencyDecimals;
bool flipRatio;
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
int24 tickSpacing;
uint24 fee;
address poolManager;
address hooks;
}

DecimalStringParams

struct DecimalStringParams {
uint256 sigfigs;
uint8 bufferLength;
uint8 sigfigIndex;
uint8 decimalIndex;
uint8 zerosStartIndex;
uint8 zerosEndIndex;
bool isLessThanOne;
bool isPercent;
}
Helpful?