Staking Contract Technical Reference
The Staking
contract allows the Marketplace
contract to stake Uniswap V3 Positions NFTs in name of users to become providers, and also provides a way to retrieve the NFT ID of a provider and the stake amount.
Details:
Inheritance
The Staking
contract inherits Recoverable
, IERC721Receiver
, and ReentrancyGuard
contracts.
State Variables
token
: The staking ERC20 Token.WETH9
: The WETH9 contract address.marketplace
: The address of the marketplace contract.nftIds
: A mapping of provider addresses to NFT IDs.positionManager
: The Uniswap V3 position manager contract.factory
: The Uniswap V3 factory contract.
Functions
setMarketplace
: Sets the marketplace contract address.setMediaToken
: Sets the MEDIA token address.getMarketplace
: Retrieves the marketplace contract address.getNftId
: Retrieves the NFT ID of a provider.getStakeAmount
: Retrieves the stake amount of a provider.
Write Functions
setMarketplace
Sets the marketplace contract address.
function setMarketplace(address _marketplaceAddress) external onlyOwner returns (bool)
Parameters:
Name | Type | |
---|---|---|
_marketplaceAddress | address | The address of the marketplace contract. |
Return values:
Type | |
---|---|
bool | Whether the setting was successful or not. |
setMediaToken
Sets the MEDIA token address.
function setMediaToken(address _tokenAddress) external onlyOwner returns (bool)
Parameters:
Name | Type | |
---|---|---|
_tokenAddress | address | The address of the MEDIA token. |
Return values:
Type | |
---|---|
bool | Whether the setting was successful or not. |
Read Functions
getMarketplace
Retrieves the marketplace contract address.
function getMarketplace() public view returns(address addr)
Return values:
Name | Type | |
---|---|---|
addr | address | The address of the marketplace contract. |
getNftId
Retrieves the Uniswap V3 NFT ID of a provider.
function getNftId(uint marketplaceId, address provider) public view returns (uint256 nftId)
Parameters:
Name | Type | |
---|---|---|
marketplaceId | uint | The id of the marketplace where you are registered. |
provider | address | The address of the provider. |
Return values:
Name | Type | |
---|---|---|
nftId | uint256 | The NFT ID of the provider. |
getStakeAmount
Retrieves the stake amount of a provider.
function getStakeAmount(uint marketplaceId, address provider) public view returns (uint256 liquidity)
Parameters:
Name | Type | |
---|---|---|
marketplaceId | uint | The id of the marketplace where you are registered. |
provider | address | The address of the provider. |
Return values:
Name | Type | |
---|---|---|
liquidity | uint256 | The stake amount. |
This is a high-level technical breakdown. For a deep understanding of each function's inner workings and logic, refer to the smart contract's actual implementation.