Quantillon Protocol

HedgerPoolAccountingLibrary

Git Source

Title: HedgerPoolAccountingLibrary

Existing pool accounting extracted to keep HedgerPool deployable.

Delegatecalled with explicit storage references; owns no storage namespace.

Functions

configure

Validates and applies the existing risk and fee configuration.

Scalar settings outside CoreParams remain assigned by the pool.

Notes:

  • security: Pool wrappers enforce caller authority and storage references.

  • validation: Uses the pool's existing validation rules.

  • state-changes: Updates only the explicitly supplied accounting storage.

  • events: None.

  • errors: Propagates accounting, validation and trusted integration errors.

  • reentrancy: State-changing pool wrappers are nonReentrant except governance configuration.

  • access: Linked library invoked by HedgerPool through delegatecall.

  • oracle: No oracle lookup; prices, where present, are supplied by the caller.

function configure(HedgerPool.CoreParams storage params, HedgerPool.HedgerRiskConfig calldata cfg) external;

Parameters

NameTypeDescription
paramsHedgerPool.CoreParamsPool core parameters in storage.
cfgHedgerPool.HedgerRiskConfigRequested complete risk and fee configuration.

effectiveCollateral

Values the active position using remaining cost and the caller's price.

Floors negative effective collateral at zero; realized history is already in margin.

Notes:

  • security: Read-only helper.

  • validation: No input validation required unless described above.

  • state-changes: None.

  • events: None.

  • errors: None beyond checked arithmetic.

  • reentrancy: No state-changing external calls.

  • access: Linked library helper.

  • oracle: No oracle lookup.

function effectiveCollateral(HedgerPool.HedgePosition storage position, uint256 price)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
positionHedgerPool.HedgePositionActive position storage.
priceuint256EUR/USD price with 18 decimals.

Returns

NameTypeDescription
<none>uint256collateral Effective USDC collateral, floored at zero.

version

Reports the initial library release.

Uses no additional sequential storage slots.

Notes:

  • security: Read-only helper.

  • validation: No input validation required unless described above.

  • state-changes: None.

  • events: None.

  • errors: None beyond checked arithmetic.

  • reentrancy: No state-changing external calls.

  • access: Linked library helper.

  • oracle: No oracle lookup.

function version() external pure returns (string memory);

Returns

NameTypeDescription
<none>stringrelease Semantic version string.

claim

Accrues interest into withdrawal escrow and claims external yield.

Preserves the pool's legacy-clock migration, narrowing casts and pull settlement.

Notes:

  • security: Pool wrappers enforce caller authority and storage references.

  • validation: Uses the pool's existing validation rules.

  • state-changes: Updates only the explicitly supplied accounting storage.

  • events: None.

  • errors: Propagates accounting, validation and trusted integration errors.

  • reentrancy: State-changing pool wrappers are nonReentrant except governance configuration.

  • access: Linked library invoked by HedgerPool through delegatecall.

  • oracle: No oracle lookup; prices, where present, are supplied by the caller.

function claim(
    HedgerPool.HedgerRewardState storage rewardState,
    mapping(address => uint256) storage rewardTimes,
    mapping(address => uint256) storage pendingWithdrawals,
    HedgerPool.CoreParams storage params,
    uint256 totalExposure,
    uint256 currentTime,
    uint256 maxRewardPeriod,
    IYieldShift yieldShift
) external returns (uint256 interestDifferential, uint256 yieldShiftRewards, uint256 totalRewards);

Parameters

NameTypeDescription
rewardStateHedgerPool.HedgerRewardStateCurrent hedger reward state.
rewardTimesmapping(address => uint256)Per-hedger accrual clocks.
pendingWithdrawalsmapping(address => uint256)Per-hedger withdrawal escrow.
paramsHedgerPool.CoreParamsPool interest rate configuration.
totalExposureuint256Pool notional exposure.
currentTimeuint256Canonical protocol time.
maxRewardPerioduint256Maximum accrual duration.
yieldShiftIYieldShiftTrusted yield distributor.

Returns

NameTypeDescription
interestDifferentialuint256Interest queued for withdrawal.
yieldShiftRewardsuint256Yield paid by YieldShift.
totalRewardsuint256Sum of both reward sources.

withdraw

Pays the caller's funded escrow balance to their chosen recipient.

Leaves any unfunded remainder available for a later withdrawal.

Notes:

  • security: Pool wrappers enforce caller authority and storage references.

  • validation: Uses the pool's existing validation rules.

  • state-changes: Reduces caller escrow by funded amount and transfers USDC.

  • events: None.

  • errors: Propagates accounting, validation and trusted integration errors.

  • reentrancy: Invoked from the nonReentrant withdrawal wrapper.

  • access: Linked library invoked by HedgerPool through delegatecall.

  • oracle: No oracle lookup; prices, where present, are supplied by the caller.

function withdraw(mapping(address => uint256) storage pendingWithdrawals, IERC20 usdc, address recipient) external;

Parameters

NameTypeDescription
pendingWithdrawalsmapping(address => uint256)Per-hedger withdrawal escrow.
usdcIERC20Pool collateral token.
recipientaddressCaller-selected payout recipient.