diff --git a/contracts/PositionRenderer.sol b/contracts/PositionRenderer.sol index 6a9e382d..b1c371d6 100644 --- a/contracts/PositionRenderer.sol +++ b/contracts/PositionRenderer.sol @@ -3,18 +3,26 @@ pragma solidity ^0.8.4; import "openzeppelin/utils/Base64.sol"; import "solmate/tokens/ERC20.sol"; -import "solmate/utils/SafeCastLib.sol"; import "./libraries/StringsLib.sol"; import "./libraries/AssemblyLib.sol"; import "./interfaces/IPortfolio.sol"; -import "./interfaces/IStrategy.sol"; import "./strategies/NormalStrategy.sol"; -/// @dev Contract to render a position. +/** + * @title + * PositionRenderer + * + * @author + * Primitiveā¢ + * + * @dev + * Prepares the metadata and generates the visual representation of the + * liquidity pool tokens. + * This contract is not meant to be called directly. + */ contract PositionRenderer { using StringsLib for *; - using SafeCastLib for *; struct Pair { address asset; @@ -61,6 +69,12 @@ contract PositionRenderer { string private constant STYLE_1 = ");animation:r 10s linear infinite;background-size:200% 200%;will-change:background-position;width:100vw;height:100vh;position:absolute;top:0;left:0;z-index:-2}#n{height:100vh;width:100vw;position:absolute;top:0;right:0;z-index:-1}@keyframes r{0%,100%{background-position:left top}50%{background-position:right bottom}}#t{font-size:6vh}.s{border-spacing:0 1rem}.s td{font-size:5vh}#i{height:15vh}.l{font-size:3.25vh;opacity:.5}.f{background-color:#00000020;padding:1rem;border-radius:8px}.f p{font-size:3vh;margin:0}"; + /** + * @dev Returns the metadata of the required liquidity pool token, following + * the ERC-1155 standard. + * @param id Id of the required pool. + * @return Minified Base64-encoded JSON containing the metadata. + */ function uri(uint256 id) external view returns (string memory) { Properties memory properties = _getProperties(id); @@ -90,6 +104,10 @@ contract PositionRenderer { ); } + /** + * @dev Returns the data associated with the asset / quote pair. + * @param id Id of the required pool. + */ function _getPair(uint256 id) internal view returns (Pair memory) { ( address tokenAsset, @@ -110,6 +128,10 @@ contract PositionRenderer { }); } + /** + * @dev Returns the data associated with the current pool. + * @param id Id of the required pool. + */ function _getPool(uint256 id) internal view returns (Pool memory) { ( uint128 virtualX, @@ -138,6 +160,10 @@ contract PositionRenderer { }); } + /** + * @dev Returns the data associated with the current pool config. + * @param id Id of the required pool. + */ function _getConfig( uint256 id, address strategy @@ -159,6 +185,11 @@ contract PositionRenderer { }); } + /** + * @dev Returns all data associated with the current pool packed within a + * struct. + * @param id Id of the required pool. + */ function _getProperties(uint256 id) private view @@ -171,6 +202,9 @@ contract PositionRenderer { return Properties({ pair: pair, pool: pool, config: config }); } + /** + * @dev Generates the name of the NFT. + */ function _generateName(Properties memory properties) private pure @@ -184,6 +218,9 @@ contract PositionRenderer { ); } + /** + * @dev Outputs all the data associated with the current pair in JSON format. + */ function _generatePair(Properties memory properties) private pure @@ -211,6 +248,9 @@ contract PositionRenderer { ); } + /** + * @dev Outputs all the data associated with the current pool in JSON format. + */ function _generatePool(Properties memory properties) private pure @@ -241,6 +281,10 @@ contract PositionRenderer { ); } + /** + * @dev Outputs all the data associated with the current pool config in JSON + * format. + */ function _generateConfig(Properties memory properties) private pure @@ -264,6 +308,9 @@ contract PositionRenderer { ); } + /** + * @dev Generates the visual representation of the NFT in HTML. + */ function _generateHTML(Properties memory properties) private view @@ -298,11 +345,18 @@ contract PositionRenderer { '
', '', _generateStats(properties), - _generateHTMLFooter(properties), + _generateFooter(properties), "