DragonSwap
  • Getting Started
    • 👋Welcome to DragonSwap
    • 💰How to Create & Connect a Wallet
    • 🪙Approving Tokens
    • 🔴Sei V2 EVM
  • Guides
    • Trading
      • 💱How to Swap
      • 🎁How to Wrap SEI
      • 🎀How to Unwrap SEI
    • Liqudity Providers
      • 🌊How to Add Liquidity
      • ☔How to Remove Liquidity
      • 🏊How to Deploy New Pools
      • 📉Understanding Impermanent Loss
      • 🫗V2: Concentrated Liquidity Pools
      • 🤖Automated Liquidity Managers (ALM)
    • Farms
      • 🥕Depositing to Farm
      • 🧑‍🌾Withdrawing from Farm
      • 🪙Claiming Rewards
      • 🚀Boosted Farms
    • Predictions
      • 🔮How to use Predictions
      • 🧞How Predictions work?
      • ❓Predictions FAQ
    • Analytics
      • 🏊Pools
      • 🥕Farms
      • 🪙Tokens
  • DragonSwap Token
    • Token & Tokenomics
    • How to Stake
    • DragonSwap Points
    • Protocol Rewards
  • Resources
    • 💻Developer Resources
      • 📄Smart Contracts
        • DragonswapV1
          • Factory
          • Pair
          • Pair(ERC-20)
          • Library
          • Router
          • Audit
        • DragonswapV2
          • Core
            • DragonswapV2Factory
            • DragonswapV2Pool
            • DragonswapV2PoolDeployer
            • Interfaces
              • IERC20Minimal
              • IDragonswapV2Factory
              • IDragonswapV2Pool
              • IDragonswapV2PoolDeployer
              • Callbacks
                • IDragonswapV2FlashCallback
                • IDragonswapV2MintCallback
                • IDragonswapV2SwapCallback
              • Pool
                • IDragonswapV2PoolActions
                • IDragonswapV2PoolDerivedState
                • IDragonswapV2PoolEvents
                • IDragonswapV2PoolImmutables
                • IDragonswapV2PoolOwnerActions
                • IDragonswapV2PoolState
            • Libraries
              • BitMath
              • FixedPoint128
              • FixedPoint96
              • FullMath
              • LiquidityMath
              • LowGasSafeMath
              • Oracle
              • Position
              • SafeCast
              • SecondsOutside
              • SqrtPriceMath
              • SwapMath
              • Tick
              • TickBitmap
              • TickMath
              • TransferHelper
              • UnsafeMath
          • Periphery
            • Base
              • BlockTimestamp
              • ERC721Permit
              • LiquidityManagement
              • Multicall
              • PeripheryImmutableState
              • PeripheryPayments
              • PeripheryPaymentsWithFee
              • PoolInitializer
              • SelfPermit
            • Interfaces
              • IERC20Metadata
              • IERC721Permit
              • IMulticall
              • INonfungiblePositionManager
              • INonfungibleTokenPositionDescriptor
              • IPeripheryImmutableState
              • IPeripheryPayments
              • IPeripheryPaymentsWithFee
              • IPoolInitializer
              • IQuoter
              • IQuoterV2
              • ISelfPermit
              • ISwapRouter
              • ITickLens
              • IV2Migrator
              • External
                • IERC1271
                • IERC20PermitAllowed
                • IWSEI
            • Lens
              • Quoter
              • QuoterV2
              • TickLens
            • Libraries
              • Base64
              • BytesLib
              • CallbackValidation
              • ChainId
              • HexStrings
              • LiquidityAmounts
              • NFTDescriptor
              • NFTSVG
              • OracleLibrary
              • Path
              • PoolAddress
              • PoolTicksCounter
              • PositionKey
              • TransferHelper
            • NonfungiblePositionManager
            • NonfungibleTokenPositionDescriptor
            • SwapRouter
            • V2Migrator
            • Error Codes
          • Staker
            • Overview
            • DragonswapV2Staker
            • Interfaces
              • IDragonswapV2Staker
            • Libraries
              • IncentiveId
              • NFTPositionInfo
              • RewardMath
          • Smart Router
            • Base
              • ApproveAndCall
              • ImmutableState
              • MulticallExtended
              • OracleSlippage
              • PeripheryPaymentsExtended
              • PeripheryPaymentsWithFeeExtended
              • PeripheryValidationExtended
            • Interfaces
              • IApproveAndCall
              • IImmutableState
              • IMixedRouteQuoterV1
              • IMulticallExtended
              • IOracleSlippage
              • IPeripheryPaymentsExtended
              • IPeripheryPaymentsWithFeeExtended
              • IQuoter
              • IQuoterV2
              • ISwapRouter02
              • ITokenValidator
              • IV1SwapRouter
              • IV2SwapRouter
            • Lens
              • MixedRouteQuoterV1
              • Quoter
              • QuoterV2
              • TokenValidator
            • Libraries
              • Constants
              • DragonswapLibrary
              • PoolTicksCounter
            • V1SwapRouter
            • V2SwapRouter
            • SwapRouter02
          • Audit
    • ❣️Marketing Resources
      • 🚩Brand Guidelines
      • 😂Meme Library
      • 🤗DragonSwap Ambassador Program
  • FAQ
    • 📲Official Links
    • 📄Contract Addresses
      • DragonswapV1
      • DragonswapV2
      • Predictions
    • ✨Roadmap
    • 📄 Token Listing Policy
    • 🏛️ToS
Powered by GitBook
On this page
  1. Resources
  2. Developer Resources
  3. Smart Contracts
  4. DragonswapV2
  5. Staker

DragonswapV2Staker

PreviousOverviewNextInterfaces

Last updated 9 months ago

Below is the technical reference for the staker contract, . A technical guide for interacting with this staking contract will be released soon.

Functions

stakes

  function stakes(
    uint256 tokenId,
    bytes32 incentiveId
  ) public view override returns (uint160 secondsPerLiquidityInsideInitialX128, uint128 liquidity)

Returns information about a staked liquidity NFT

Parameters:

Name
Type
Description

tokenId

uint256

The ID of the staked token

incentiveId

bytes32

The ID of the incentive for which the token is staked

Return Values:

Name
Type
Description

secondsPerLiquidityInsideInitialX128

uint160

secondsPerLiquidity represented as a UQ32.128

liquidity

bytes32

The amount of liquidity in the NFT as of the last time the rewards were computed

constructor

  function constructor(
    contract IDragonswapV2Factory _factory,
    contract INonfungiblePositionManager _nonfungiblePositionManager,
    uint256 _maxIncentiveStartLeadTime,
    uint256 _maxIncentiveDuration
  ) public
Name
Type
Description

_factory

contract IDragonswapV2Factory

the DragonswapV2 factory

_nonfungiblePositionManager

contract INonfungiblePositionManager

the NFT position manager contract address

_maxIncentiveStartLeadTime

uint256

the max duration of an incentive in seconds

_maxIncentiveDuration

uint256

the max amount of seconds into the future the incentive startTime can be set

  function createIncentive(
    struct IDragonswapV2Staker.IncentiveKey key,
    uint256 reward
  ) external

Creates a new liquidity mining incentive program

Name
Type
Description

key

struct IDragonswapV2Staker.IncentiveKey

Details of the incentive to create

reward

uint256

The amount of reward tokens to be distributed

  function endIncentive(
    struct IDragonswapV2Staker.IncentiveKey key
  ) external returns (uint256 refund)

Ends an incentive after the incentive end time has passed and all stakes have been withdrawn

Name
Type
Description

key

struct IDragonswapV2Staker.IncentiveKey

Details of the incentive to end

Name
Type
Description

refund

uint256

The remaining reward tokens when the incentive is ended

  function onERC721Received(
  ) external returns (bytes4)

Upon receiving a DragonswapV2 ERC721, creates the token deposit setting owner to from. Also stakes token in one or more incentives if properly formatted data has a length > 0.

Whenever an {IERC721} tokenId token is transferred to this contract via {IERC721-safeTransferFrom} by operator from from, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721.onERC721Received.selector.

  function transferDeposit(
    uint256 tokenId,
    address to
  ) external

Transfers ownership of a deposit from the sender to the given recipient

Name
Type
Description

tokenId

uint256

The ID of the token (and the deposit) to transfer

to

address

The new owner of the deposit

  function withdrawToken(
    uint256 tokenId,
    address to,
    bytes data
  ) external

Withdraws a DragonswapV2 LP token tokenId from this contract to the recipient to

Name
Type
Description

tokenId

uint256

The unique identifier of an DragonswapV2 LP token

to

address

The address where the LP token will be sent

data

bytes

An optional data array that will be passed along to the to address via the NFT safeTransferFrom

  function stakeToken(
    struct IDragonswapV2Staker.IncentiveKey key,
    uint256 tokenId
  ) external

Stakes a DragonswapV2 LP token

Name
Type
Description

key

struct IDragonswapV2Staker.IncentiveKey

The key of the incentive for which to stake the NFT

tokenId

uint256

The ID of the token to stake

  function unstakeToken(
    struct IDragonswapV2Staker.IncentiveKey key,
    uint256 tokenId
  ) external

Unstakes a DragonswapV2 LP token

Name
Type
Description

key

struct IDragonswapV2Staker.IncentiveKey

The key of the incentive for which to unstake the NFT

tokenId

uint256

The ID of the token to unstake

  function claimReward(
    contract IERC20Minimal rewardToken,
    address to,
    uint256 amountRequested
  ) external override returns (uint256 reward)

Transfers amountRequested of accrued rewardToken rewards from the contract to the recipient to

Name
Type
Description

rewardToken

contract IERC20Minimal

The token being distributed as a reward

to

address

The address where claimed rewards will be sent to

amountRequested

uint256

The amount of reward tokens to claim. Claims entire reward amount if set to 0.

Name
Type
Description

reward

uint256

The amount of reward tokens claimed

  function getRewardInfo(
    struct IDragonswapV2Staker.IncentiveKey key,
    uint256 tokenId
  ) external view override returns (uint256 reward, uint160 secondsInsideX128)

Calculates the reward amount that will be received for the given stake

Name
Type
Description

key

struct IDragonswapV2Staker.IncentiveKey

The key of the incentive

tokenId

uint256

The ID of the token

Name
Type
Description

reward

uint256

The reward accrued to the NFT for the given incentive thus far

secondsInsideX128

uint160

The seconds inside the tick range

Parameters:

createIncentive

Parameters:

endIncentive

Parameters:

Return Values:

onERC721Received

transferDeposit

Parameters:

withdrawToken

Parameters:

stakeToken

Parameters:

unstakeToken

Parameters:

claimReward

Parameters:

Return Values:

getRewardInfo

Parameters:

Return Values:

💻
📄
DragonswapV2Staker.sol
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​