Skip to main content

FactoryNFT

Git Source

Inherits: MetadataStore, ERC721

Author: Axicon Labs Limited

Constructs dynamic SVG art and metadata for Panoptic Factory NFTs from a set of building blocks.

Pointers to metadata are provided at deployment time.

Functions

constructor

Initialize metadata pointers and token name/symbol.

constructor(bytes32[] memory properties, uint256[][] memory indices, Pointer[][] memory pointers)
MetadataStore(properties, indices, pointers)
ERC721("Panoptic V1.1 Factory Deployer NFTs", "PANOPTIC-NFT");

Parameters

NameTypeDescription
propertiesbytes32[]An array of identifiers for different categories of metadata
indicesuint256[][]A nested array of keys for K-V metadata pairs for each property in properties
pointersPointer[][]Contains pointers to the metadata values stored in contract data slices for each index in indices

tokenURI

Returns the metadata URI for a given tokenId.

The metadata is dynamically generated from the characteristics of the PanopticPool encoded in tokenId.

The first 160 bits of tokenId are the address of a Panoptic Pool.

function tokenURI(uint256 tokenId) public view override returns (string memory);

Parameters

NameTypeDescription
tokenIduint256The token ID (encoded pool address) to get the metadata URI for

Returns

NameTypeDescription
<none>stringThe metadata URI for the token ID

constructMetadata

Returns the metadata URI for a given set of characteristics.

function constructMetadata(address panopticPool, string memory symbol0, string memory symbol1, uint256 fee)
public
view
returns (string memory);

Parameters

NameTypeDescription
panopticPooladdressThe displayed address used to determine the rarity (leading zeros) and lastCharVal (last 4 bits)
symbol0stringThe symbol of currency0 in the Uniswap pool
symbol1stringThe symbol of currency1 in the Uniswap pool
feeuint256The fee of the Uniswap pool (in hundredths of basis points)

Returns

NameTypeDescription
<none>stringThe metadata URI for the given characteristics

generateSVGArt

Generate the artwork component of the SVG for a given rarity and last character value.

function generateSVGArt(uint256 lastCharVal, uint256 rarity) internal view returns (string memory svgOut);

Parameters

NameTypeDescription
lastCharValuint256The last character of the pool address
rarityuint256The rarity of the NFT

Returns

NameTypeDescription
svgOutstringThe SVG artwork for the NFT

generateSVGInfo

Fill in the pool/rarity specific text fields on the SVG artwork.

function generateSVGInfo(
string memory svgIn,
address panopticPool,
uint256 rarity,
string memory symbol0,
string memory symbol1
) internal view returns (string memory);

Parameters

NameTypeDescription
svgInstringThe SVG artwork to complete
panopticPooladdressThe address of the Panoptic Pool
rarityuint256The rarity of the NFT
symbol0stringThe symbol of currency0 in the Uniswap pool
symbol1stringThe symbol of currency1 in the Uniswap pool

Returns

NameTypeDescription
<none>stringThe final SVG artwork with the pool/rarity specific text fields filled in

getChainName

Get the name of the current chain.

function getChainName() internal view returns (string memory);

Returns

NameTypeDescription
<none>stringThe name of the current chain, or the chain ID if not recognized

write

Get a group of paths representing chars written in a certain font at a default size.

function write(string memory chars) internal view returns (string memory);

Parameters

NameTypeDescription
charsstringThe characters to write

Returns

NameTypeDescription
<none>stringThe group of paths representing the characters written in the font

write

Get a group of paths representing chars written in a certain font, scaled to a maximum width.

function write(string memory chars, uint256 maxWidth) internal view returns (string memory fontGroup);

Parameters

NameTypeDescription
charsstringThe characters to write
maxWidthuint256The maximum width (in SVG units) of the group of paths

Returns

NameTypeDescription
fontGroupstringThe group of paths representing the characters written in the font

maxSymbolWidth

Get the maximum SVG unit width for the token symbols at the bottom left/right corners for a given rarity.

This is to ensure the text fits within its section on the frame. There are 6 frames, and each rarity is assigned one of the six.

function maxSymbolWidth(uint256 rarity) internal pure returns (uint256 width);

Parameters

NameTypeDescription
rarityuint256The rarity of the NFT

Returns

NameTypeDescription
widthuint256The maximum SVG unit width for the token symbols

maxRarityLabelWidth

Get the maximum SVG unit width for the rarity name at the top for a given rarity (frame).

This is to ensure the text fits within its section on the frame. There are 6 frames, and each rarity is assigned one of the six.

function maxRarityLabelWidth(uint256 rarity) internal pure returns (uint256 width);

Parameters

NameTypeDescription
rarityuint256The rarity of the NFT

Returns

NameTypeDescription
widthuint256The maximum SVG unit width for the rarity name

maxStrategyLabelWidth

Get the maximum SVG unit width for the strategy name label in the center for a given rarity (frame).

This is to ensure the text fits within its section on the frame. There are 6 frames, and each rarity is assigned one of the six.

function maxStrategyLabelWidth(uint256 rarity) internal pure returns (uint256 width);

Parameters

NameTypeDescription
rarityuint256The rarity of the NFT

Returns

NameTypeDescription
widthuint256The maximum SVG unit width for the strategy name label