22pragma solidity = 0.7.6 ;
33pragma abicoder v2;
44
5+ import 'lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol ' ;
6+ import 'lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721MetadataUpgradeable.sol ' ;
7+ import 'lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721Upgradeable.sol ' ;
8+
59import 'src/core/interfaces/IListaV3Pool.sol ' ;
610import 'src/core/libraries/FixedPoint128.sol ' ;
711import 'src/core/libraries/FullMath.sol ' ;
@@ -13,17 +17,18 @@ import './libraries/PoolAddress.sol';
1317import './base/LiquidityManagement.sol ' ;
1418import './base/PeripheryImmutableState.sol ' ;
1519import './base/Multicall.sol ' ;
16- import './base/ERC721Permit .sol ' ;
20+ import './base/ERC721PermitUpgradeable .sol ' ;
1721import './base/PeripheryValidation.sol ' ;
1822import './base/SelfPermit.sol ' ;
1923import './base/PoolInitializer.sol ' ;
2024
2125/// @title NFT positions
2226/// @notice Wraps Lista V3 positions in the ERC721 non-fungible token interface
27+ /// @dev Deployed behind a TransparentUpgradeableProxy; initialize() replaces the constructor.
2328contract NonfungiblePositionManager is
2429 INonfungiblePositionManager ,
2530 Multicall ,
26- ERC721Permit ,
31+ ERC721PermitUpgradeable ,
2732 PeripheryImmutableState ,
2833 PoolInitializer ,
2934 LiquidityManagement ,
@@ -60,20 +65,23 @@ contract NonfungiblePositionManager is
6065 /// @dev The token ID position data
6166 mapping (uint256 => Position) private _positions;
6267
63- /// @dev The ID of the next token that will be minted. Skips 0
64- uint176 private _nextId = 1 ;
65- /// @dev The ID of the next pool that is used for the first time. Skips 0
66- uint80 private _nextPoolId = 1 ;
68+ /// @dev The ID of the next token that will be minted. Skips 0. Set in initialize().
69+ uint176 private _nextId;
70+ /// @dev The ID of the next pool that is used for the first time. Skips 0. Set in initialize().
71+ uint80 private _nextPoolId;
6772
6873 /// @dev The address of the token descriptor contract, which handles generating token URIs for position tokens
69- address private immutable _tokenDescriptor;
74+ address private _tokenDescriptor;
75+
76+ uint256 [45 ] private __gap;
7077
71- constructor (
72- address _factory ,
73- address _WETH9 ,
74- address _tokenDescriptor_
75- ) ERC721Permit ('Lista V3 Positions NFT-V1 ' , 'LIS-V3-POS ' , '1 ' ) PeripheryImmutableState (_factory, _WETH9) {
78+ constructor (address _factory , address _WETH9 ) PeripheryImmutableState (_factory, _WETH9) {}
79+
80+ function initialize (address _tokenDescriptor_ ) external initializer {
81+ __ERC721Permit_init ('Lista V3 Positions NFT-V1 ' , 'LIS-V3-POS ' , '1 ' );
7682 _tokenDescriptor = _tokenDescriptor_;
83+ _nextId = 1 ;
84+ _nextPoolId = 1 ;
7785 }
7886
7987 /// @inheritdoc INonfungiblePositionManager
@@ -186,7 +194,12 @@ contract NonfungiblePositionManager is
186194 _;
187195 }
188196
189- function tokenURI (uint256 tokenId ) public view override (ERC721 , IERC721Metadata ) returns (string memory ) {
197+ function tokenURI (uint256 tokenId )
198+ public
199+ view
200+ override (ERC721Upgradeable , IERC721MetadataUpgradeable )
201+ returns (string memory )
202+ {
190203 require (_exists (tokenId));
191204 return INonfungibleTokenPositionDescriptor (_tokenDescriptor).tokenURI (this , tokenId);
192205 }
@@ -385,15 +398,20 @@ contract NonfungiblePositionManager is
385398 return uint256 (_positions[tokenId].nonce++ );
386399 }
387400
388- /// @inheritdoc IERC721
389- function getApproved (uint256 tokenId ) public view override (ERC721 , IERC721 ) returns (address ) {
401+ /// @inheritdoc IERC721Upgradeable
402+ function getApproved (uint256 tokenId )
403+ public
404+ view
405+ override (ERC721Upgradeable , IERC721Upgradeable )
406+ returns (address )
407+ {
390408 require (_exists (tokenId), 'ERC721: approved query for nonexistent token ' );
391409
392410 return _positions[tokenId].operator;
393411 }
394412
395413 /// @dev Overrides _approve to use the operator in the position, which is packed with the position permit nonce
396- function _approve (address to , uint256 tokenId ) internal override (ERC721 ) {
414+ function _approve (address to , uint256 tokenId ) internal override (ERC721Upgradeable ) {
397415 _positions[tokenId].operator = to;
398416 emit Approval (ownerOf (tokenId), to, tokenId);
399417 }
0 commit comments