Quantillon Protocol

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

YieldValidationLibrary

Git Source

Author: Quantillon Labs - Nicolas Bellengé - @chewbaccoin

Yield-specific validation functions for Quantillon Protocol

Main characteristics:

  • Validation functions specific to yield operations
  • Yield shift mechanism validations
  • Slippage protection validations
  • Yield distribution validations

Note: security-contact: team@quantillon.money

Functions

validateYieldShift

Validates yield shift percentage (0-100%)

Ensures yield shift is within valid range of 0-10000 basis points

Notes:

  • security: Prevents invalid yield shifts that could destabilize yield distribution

  • validation: Ensures yield shift is within valid percentage range

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws InvalidParameter if shift exceeds 100%

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateYieldShift(uint256 shift) internal pure;

Parameters

NameTypeDescription
shiftuint256The yield shift percentage to validate (in basis points)

validateAdjustmentSpeed

Validates adjustment speed for yield shift mechanisms

Prevents excessively fast adjustments that could destabilize the system

Notes:

  • security: Prevents rapid adjustments that could destabilize yield mechanisms

  • validation: Ensures adjustment speed stays within safe bounds

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws InvalidParameter if speed exceeds maximum

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateAdjustmentSpeed(uint256 speed, uint256 maxSpeed) internal pure;

Parameters

NameTypeDescription
speeduint256The adjustment speed to validate
maxSpeeduint256The maximum allowed adjustment speed

validateTargetRatio

Validates target ratio for yield distribution mechanisms

Ensures ratio is positive and within acceptable bounds

Notes:

  • security: Prevents invalid ratios that could break yield distribution

  • validation: Ensures ratio is positive and within acceptable bounds

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws InvalidParameter or AboveLimit based on validation

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateTargetRatio(uint256 ratio, uint256 maxRatio) internal pure;

Parameters

NameTypeDescription
ratiouint256The target ratio to validate
maxRatiouint256The maximum allowed ratio

validateSlippage

Validates slippage protection for token swaps/trades

Ensures received amount is within acceptable tolerance of expected

Notes:

  • security: Prevents excessive slippage attacks in yield operations

  • validation: Ensures received amount meets minimum expectations

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws ExcessiveSlippage if slippage exceeds tolerance

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateSlippage(uint256 received, uint256 expected, uint256 tolerance) internal pure;

Parameters

NameTypeDescription
receiveduint256The actual amount received
expecteduint256The expected amount
toleranceuint256The slippage tolerance in basis points

validateTreasuryAddress

Validates treasury address is not zero address

Prevents setting treasury to zero address which could cause loss of funds

Notes:

  • security: Prevents loss of funds by ensuring treasury is properly set

  • validation: Ensures treasury address is valid for fund operations

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws ZeroAddress if treasury is zero address

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateTreasuryAddress(address treasury) internal pure;

Parameters

NameTypeDescription
treasuryaddressThe treasury address to validate

validatePositiveAmount

Validates that an amount is positive (greater than zero)

Essential for token amounts, deposits, withdrawals, etc.

Notes:

  • security: Prevents zero-amount operations that could cause issues

  • validation: Ensures amount is positive for meaningful operations

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws InvalidAmount if amount is zero

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validatePositiveAmount(uint256 amount) internal pure;

Parameters

NameTypeDescription
amountuint256The amount to validate