RewardDistributor
Inherits: IRewardDistributor, ReentrancyGuard
Title: RewardDistributor
Distributes staking rewards based on price discrepancy between oracle and Curve EMA.
Receives USDC from SyntheticSplitter.harvestYield() and allocates to StakedToken vaults proportionally based on which token is underperforming relative to theoretical price.
State Variables
DISCREPANCY_THRESHOLD_BPS
Discrepancy threshold for 100% allocation (2% = 200 bps).
uint256 public constant DISCREPANCY_THRESHOLD_BPS = 200
MIN_DISTRIBUTION_INTERVAL
Minimum time between distributions (1 hour).
uint256 public constant MIN_DISTRIBUTION_INTERVAL = 1 hours
CALLER_REWARD_BPS
Reward for calling distributeRewards (0.1% = 10 bps).
uint256 public constant CALLER_REWARD_BPS = 10
USDC_INDEX
USDC index in Curve pool.
uint256 public constant USDC_INDEX = 0
PLDXY_BEAR_INDEX
plDXY-BEAR index in Curve pool.
uint256 public constant PLDXY_BEAR_INDEX = 1
MAX_SWAP_SLIPPAGE_BPS
Maximum slippage for Curve swaps (1% = 100 bps).
uint256 public constant MAX_SWAP_SLIPPAGE_BPS = 100
SPLITTER
SyntheticSplitter contract.
ISyntheticSplitter public immutable SPLITTER
USDC
USDC stablecoin.
IERC20 public immutable USDC
PLDXY_BEAR
plDXY-BEAR token.
IERC20 public immutable PLDXY_BEAR
PLDXY_BULL
plDXY-BULL token.
IERC20 public immutable PLDXY_BULL
STAKED_BEAR
Staked plDXY-BEAR vault.
StakedToken public immutable STAKED_BEAR
STAKED_BULL
Staked plDXY-BULL vault.
StakedToken public immutable STAKED_BULL
CURVE_POOL
Curve USDC/plDXY-BEAR pool.
ICurvePool public immutable CURVE_POOL
ZAP_ROUTER
ZapRouter for acquiring plDXY-BULL.
ZapRouter public immutable ZAP_ROUTER
ORACLE
BasketOracle for theoretical price.
AggregatorV3Interface public immutable ORACLE
CAP
Protocol CAP price (8 decimals).
uint256 public immutable CAP
lastDistributionTime
Timestamp of last distribution.
uint256 public lastDistributionTime
Functions
constructor
Deploys RewardDistributor with all required dependencies.
constructor(
address _splitter,
address _usdc,
address _plDxyBear,
address _plDxyBull,
address _stakedBear,
address _stakedBull,
address _curvePool,
address _zapRouter,
address _oracle
) ;
Parameters
| Name | Type | Description |
|---|---|---|
_splitter | address | SyntheticSplitter contract address. |
_usdc | address | USDC token address. |
_plDxyBear | address | plDXY-BEAR token address. |
_plDxyBull | address | plDXY-BULL token address. |
_stakedBear | address | StakedToken vault for BEAR. |
_stakedBull | address | StakedToken vault for BULL. |
_curvePool | address | Curve USDC/plDXY-BEAR pool. |
_zapRouter | address | ZapRouter for BULL acquisition. |
_oracle | address | BasketOracle for price data. |
distributeRewards
Permissionless function to distribute accumulated USDC rewards.
Calculates price discrepancy, acquires tokens, and donates to vaults.
function distributeRewards() external nonReentrant returns (uint256 callerReward);
Returns
| Name | Type | Description |
|---|---|---|
callerReward | uint256 | Amount of USDC sent to caller as incentive. |
previewDistribution
Preview the distribution without executing.
function previewDistribution()
external
view
returns (uint256 bearPct, uint256 bullPct, uint256 usdcBalance, uint256 callerReward);
Returns
| Name | Type | Description |
|---|---|---|
bearPct | uint256 | Expected percentage to BEAR stakers (basis points). |
bullPct | uint256 | Expected percentage to BULL stakers (basis points). |
usdcBalance | uint256 | Current USDC balance available for distribution. |
callerReward | uint256 | Expected caller reward. |
_calculateSplit
Calculates reward split based on price discrepancy.
function _calculateSplit() internal view returns (uint256 bearPct, uint256 bullPct);
Returns
| Name | Type | Description |
|---|---|---|
bearPct | uint256 | Percentage for BEAR stakers (basis points). |
bullPct | uint256 | Percentage for BULL stakers (basis points). |
_acquireTokens
Acquires tokens using optimal combination of minting and swapping/zapping.
function _acquireTokens(
uint256 totalUsdc,
uint256 bearPct,
uint256 bullPct
) internal returns (uint256 bearAmount, uint256 bullAmount);
Parameters
| Name | Type | Description |
|---|---|---|
totalUsdc | uint256 | Total USDC to convert to tokens. |
bearPct | uint256 | Target BEAR percentage (basis points). |
bullPct | uint256 | Target BULL percentage (basis points). |
Returns
| Name | Type | Description |
|---|---|---|
bearAmount | uint256 | Amount of plDXY-BEAR acquired. |
bullAmount | uint256 | Amount of plDXY-BULL acquired. |
_calculateMintAmount
Converts USDC amount to 18-decimal mint amount.
function _calculateMintAmount(
uint256 usdcAmount
) internal view returns (uint256 mintAmount);
Parameters
| Name | Type | Description |
|---|---|---|
usdcAmount | uint256 | USDC amount (6 decimals). |
Returns
| Name | Type | Description |
|---|---|---|
mintAmount | uint256 | Token amount to mint (18 decimals). |