Skip to main content

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


Write Functions

setMarketplace

Sets the marketplace contract address.

function setMarketplace(address _marketplaceAddress) external onlyRole(DEFAULT_ADMIN_ROLE) returns (bool)

Parameters:

NameType
_marketplaceAddressaddressThe address of the marketplace contract.

Return values:

Type
boolWhether the setting was successful or not.

setMediaToken

Sets the MEDIA token address.

function setMediaToken(address _tokenAddress) external onlyRole(DEFAULT_ADMIN_ROLE) returns (bool)

Parameters:

NameType
_tokenAddressaddressThe address of the MEDIA token.

Return values:

Type
boolWhether the setting was successful or not.

Read Functions

getMarketplace

Retrieves the marketplace contract address.

function getMarketplace() public view returns(address addr)

Return values:

NameType
addraddressThe 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:

NameType
marketplaceIduintThe id of the marketplace where you are registered.
provideraddressThe address of the provider.

Return values:

NameType
nftIduint256The 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:

NameType
marketplaceIduintThe id of the marketplace where you are registered.
provideraddressThe address of the provider.

Return values:

NameType
liquidityuint256The stake amount.

note

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.