Staking Contract Technical Reference
This is a technical reference for the Media Protocol's Staking
smart contract.
Overview
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.
Inheritance
The Staking
contract inherits Recoverable
, and Open Zeppelin's 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 onlyRole(DEFAULT_ADMIN_ROLE) 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 onlyRole(DEFAULT_ADMIN_ROLE) 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.