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

TokenValidationLibrary

Git Source

Author: Quantillon Labs - Nicolas Bellengé - @chewbaccoin

Token-specific validation functions for Quantillon Protocol

Main characteristics:

  • Validation functions specific to token operations
  • Fee and threshold validations
  • Oracle price validations
  • Treasury address validations

Note: security-contact: team@quantillon.money

Functions

validateFee

Validates fee amount against maximum allowed fee

Ensures fees don't exceed protocol limits (typically in basis points)

Notes:

  • security: Prevents excessive fees that could harm users

  • validation: Ensures fees stay within protocol limits

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws AboveLimit if fee exceeds maximum

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateFee(uint256 fee, uint256 maxFee) internal pure;

Parameters

NameTypeDescription
feeuint256The fee amount to validate
maxFeeuint256The maximum allowed fee

validateThreshold

Validates threshold value against maximum limit

Used for liquidation thresholds, margin ratios, etc.

Notes:

  • security: Prevents thresholds that could destabilize the system

  • validation: Ensures thresholds stay within acceptable bounds

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws AboveLimit if threshold exceeds maximum

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateThreshold(uint256 threshold, uint256 maxThreshold) internal pure;

Parameters

NameTypeDescription
thresholduint256The threshold value to validate
maxThresholduint256The maximum allowed threshold

validateThresholdValue

Validates that a value meets minimum threshold requirements

Used for minimum deposits, stakes, withdrawals, etc.

Notes:

  • security: Prevents operations below minimum thresholds

  • validation: Ensures values meet business requirements

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws BelowThreshold if value is below minimum

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: No oracle dependencies

function validateThresholdValue(uint256 value, uint256 threshold) internal pure;

Parameters

NameTypeDescription
valueuint256The value to validate
thresholduint256The minimum required threshold

validateOraclePrice

Validates oracle price data integrity

Ensures oracle price is valid before using in calculations

Notes:

  • security: Prevents use of invalid oracle data that could cause financial losses

  • validation: Ensures oracle price data is valid and recent

  • state-changes: No state changes - pure function

  • events: No events emitted

  • errors: Throws InvalidParameter if oracle price is invalid

  • reentrancy: Not applicable - pure function

  • access: Internal library function

  • oracle: Validates oracle price data integrity

function validateOraclePrice(bool isValid) internal pure;

Parameters

NameTypeDescription
isValidboolWhether the oracle price is valid and recent

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