Quantillon Protocol

YieldShiftCalculationLibrary

Git Source

Title: YieldShiftCalculationLibrary

Author: Quantillon Labs - Nicolas Bellengé - @chewbaccoin

Calculation functions for YieldShift to reduce contract size

Extracted from YieldShift to reduce bytecode size

Note: security-contact: team@quantillon.money

Functions

version

Returns the semantic version of this linked library.

On-chain version of the standalone deployed library; bump per semver on any change. See deployments/{chainId}/versions.json for deployed-address provenance.

Notes:

  • security: No security implications - returns a compile-time constant.

  • validation: No input validation required.

  • state-changes: None - pure function.

  • events: None.

  • errors: None.

  • reentrancy: Not applicable - pure function.

  • access: Public - anyone can read the version.

  • oracle: No oracle dependencies.

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

Returns

NameTypeDescription
<none>stringSemantic version string (e.g. "1.0.0").

calculateOptimalYieldShift

Calculates optimal yield shift based on pool ratio

Calculates optimal yield shift to balance user and hedger pools

Notes:

  • security: No security implications - pure calculation function

  • validation: Input validation handled by calling contract

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: No errors thrown - pure function

  • reentrancy: Not applicable - pure function

  • access: Public function

  • oracle: No oracle dependencies

function calculateOptimalYieldShift(
    uint256 poolRatio,
    uint256 baseYieldShift,
    uint256 maxYieldShift,
    uint256 targetPoolRatio
) external pure returns (uint256 optimalShift);

Parameters

NameTypeDescription
poolRatiouint256Current pool ratio (user/hedger)
baseYieldShiftuint256Base yield shift percentage
maxYieldShiftuint256Maximum yield shift percentage
targetPoolRatiouint256Target pool ratio

Returns

NameTypeDescription
optimalShiftuint256Optimal yield shift percentage

applyGradualAdjustment

Applies gradual adjustment to yield shift

Gradually adjusts yield shift to prevent sudden changes

Notes:

  • security: No security implications - pure calculation function

  • validation: Input validation handled by calling contract

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: No errors thrown - pure function

  • reentrancy: Not applicable - pure function

  • access: Public function

  • oracle: No oracle dependencies

function applyGradualAdjustment(uint256 currentShift, uint256 targetShift, uint256 adjustmentSpeed)
    external
    pure
    returns (uint256 newShift);

Parameters

NameTypeDescription
currentShiftuint256Current yield shift
targetShiftuint256Target yield shift
adjustmentSpeeduint256Adjustment speed (basis points per update)

Returns

NameTypeDescription
newShiftuint256New yield shift after adjustment