HedgerPoolAccountingLibrary
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
| Name | Type | Description |
|---|---|---|
params | HedgerPool.CoreParams | Pool core parameters in storage. |
cfg | HedgerPool.HedgerRiskConfig | Requested 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
| Name | Type | Description |
|---|---|---|
position | HedgerPool.HedgePosition | Active position storage. |
price | uint256 | EUR/USD price with 18 decimals. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | collateral 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
| Name | Type | Description |
|---|---|---|
<none> | string | release 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
| Name | Type | Description |
|---|---|---|
rewardState | HedgerPool.HedgerRewardState | Current hedger reward state. |
rewardTimes | mapping(address => uint256) | Per-hedger accrual clocks. |
pendingWithdrawals | mapping(address => uint256) | Per-hedger withdrawal escrow. |
params | HedgerPool.CoreParams | Pool interest rate configuration. |
totalExposure | uint256 | Pool notional exposure. |
currentTime | uint256 | Canonical protocol time. |
maxRewardPeriod | uint256 | Maximum accrual duration. |
yieldShift | IYieldShift | Trusted yield distributor. |
Returns
| Name | Type | Description |
|---|---|---|
interestDifferential | uint256 | Interest queued for withdrawal. |
yieldShiftRewards | uint256 | Yield paid by YieldShift. |
totalRewards | uint256 | Sum 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
| Name | Type | Description |
|---|---|---|
pendingWithdrawals | mapping(address => uint256) | Per-hedger withdrawal escrow. |
usdc | IERC20 | Pool collateral token. |
recipient | address | Caller-selected payout recipient. |