CenturionDEX
Launch App

Design

Last modified:

The liquidity mining staker design is comprised of one canonical position staking contract, Staker. The technical reference for this contract is here and the source code is here.

Data Structures

struct Incentive {
  uint128 totalRewardUnclaimed;
  uint128 numberOfStakes;
  uint160 totalSecondsClaimedX128;
}
 
struct Deposit {
  address owner;
  uint96 numberOfStakes;
}
 
struct Stake {
  uint160 secondsPerLiquidityInsideInitialX128;
  uint128 liquidity;
}
 
struct IncentiveKey {
        IERC20Minimal rewardToken;
        ICenturionV3Pool pool;
        uint256 startTime;
        uint256 endTime;
        address refundee;
}

State:

ICenturionV3Factory public immutable factory;
INonfungiblePositionManager public immutable nonfungiblePositionManager;
 
/// @dev bytes32 refers to the return value of IncentiveId.compute
mapping(bytes32 => Incentive) public incentives;
 
/// @dev deposits[tokenId] => Deposit
mapping(uint256 => Deposit) public deposits;
 
/// @dev stakes[tokenId][incentiveHash] => Stake
mapping(uint256 => mapping(bytes32 => Stake)) public stakes;
 
/// @dev rewards[rewardToken][msg.sender] => uint256
mapping(address => mapping(address => uint256)) public rewards;

Params:

struct CreateIncentiveParams {
  address rewardToken;
  address pool;
  uint256 startTime;
  uint256 endTime;
  uint128 totalReward;
}
 
struct EndIncentiveParams {
  address creator;
  address rewardToken;
  address pool;
  uint256 startTime;
  uint256 endTime;
}
 

Incentives

createIncentive(CreateIncentiveParams memory params)

createIncentive creates a liquidity mining incentive program. The key used to look up an Incentive is the hash of its immutable properties.

Check:

Effects:

Interaction:

endIncentive(EndIncentiveParams memory params)

endIncentive can be called by anyone to end an Incentive after the endTime has passed, transferring totalRewardUnclaimed of rewardToken back to refundee.

Check:

Effects:

Interactions:

Deposit/Withdraw Token

Interactions

onERC721Received(address, address from, uint256 tokenId, bytes calldata data)

Check:

Effects:

withdrawToken(uint256 tokenId, address to, bytes memory data)

Checks

Effects

Interactions

Stake/Unstake/Rewards

stakeToken

Check:

claimReward

Interactions

unstakeToken

To unstake an NFT, you call unstakeToken, which takes all the same arguments as stake.

Checks

Effects

getRewardInfo