Quantillon Protocol

StakingYieldLibrary

Git Source

Title: StakingYieldLibrary

External (linked) library holding the stQEURO yield-distribution split, extracted from QuantillonVault to keep that contract under the EIP-170 24,576-byte runtime limit.

Called via delegatecall from QuantillonVault, so external calls (adapter harvest, USDC transfers) execute in the vault's context (address(this) == vault). The vault performs the stQEURO credit and event emission; this library realizes the yield, computes the hedger / staker / treasury split, and routes the hedger and treasury shares.

Constants

BPS_DENOMINATOR

uint256 private constant BPS_DENOMINATOR = 10000

Functions

harvestAndSplit

Harvests adapter yield and splits it: hedger funding first, residual by staked ratio, remainder to treasury; routes the hedger and treasury shares in USDC.

The caller (vault) credits userShare into stQEURO and emits the distribution event.

Notes:

  • security: Runs under the vault's nonReentrant/pause guards via delegatecall.

  • validation: Caller validates vault id, adapter, and access control.

  • state-changes: Moves USDC out of the vault to hedger recipient and treasury.

  • events: None; the vault emits VaultYieldDistributed.

  • errors: Reverts on adapter or transfer failures.

  • reentrancy: Caller-guarded.

  • access: Internal protocol use (linked library).

  • oracle: No oracle dependency in this library.

function harvestAndSplit(DistributeParams memory p)
    external
    returns (uint256 realizedYield, uint256 hedgerShare, uint256 userShare, uint256 treasuryShare);

Parameters

NameTypeDescription
pDistributeParamsDistribution inputs read from vault storage.

Returns

NameTypeDescription
realizedYielduint256Total USDC yield realized from the adapter (6 decimals).
hedgerShareuint256USDC routed to the hedger recipient (6 decimals).
userShareuint256USDC the vault must credit into stQEURO (6 decimals).
treasuryShareuint256USDC routed to the treasury (6 decimals).

Structs

DistributeParams

Inputs for harvestAndSplit, read from vault storage by the caller.

struct DistributeParams {
    address adapter;
    address stToken;
    address qeuro;
    address usdc;
    address treasury;
    address hedgerRecipient;
    uint256 principalUsdc;
    uint256 fundingRateAnnualBps;
    uint256 lastHarvest;
}

Properties

NameTypeDescription
adapteraddressExternal staking vault adapter for the vault id.
stTokenaddressstQEURO share token for the vault id (zero if unregistered).
qeuroaddressQEURO token (for circulating supply).
usdcaddressUSDC token used for hedger/treasury routing.
treasuryaddressProtocol treasury (treasury share + hedger fallback recipient).
hedgerRecipientaddressHedger funding recipient (falls back to treasury when zero).
principalUsdcuint256Tracked principal deployed to the vault (hedger notional, 6 decimals).
fundingRateAnnualBpsuint256Annualized hedger funding rate in basis points.
lastHarvestuint256Timestamp of the previous distribution (0 = first call, no hedger accrual).