Quantillon Protocol

ISlippageStorage

Git Source

Title: ISlippageStorage

Author: Quantillon Labs - Nicolas Bellengé - @chewbaccoin

Interface for the Quantillon SlippageStorage contract

Stores on-chain slippage data published by an off-chain service. Provides rate-limited writes via WRITER_ROLE and config management via MANAGER_ROLE.

Note: security-contact: team@quantillon.money

Functions

initialize

Initialize the contract

function initialize(
    address admin,
    address writer,
    uint48 minInterval,
    uint16 deviationThreshold,
    address treasury
) external;

Parameters

NameTypeDescription
adminaddressAddress with DEFAULT_ADMIN_ROLE
writeraddressAddress with WRITER_ROLE (publisher service wallet)
minIntervaluint48Minimum seconds between updates (rate limit)
deviationThresholduint16Deviation in bps that bypasses rate limit
treasuryaddressTreasury address for recovery functions

updateSlippage

Publish a new slippage snapshot on-chain

WRITER_ROLE only. Rate-limited: rejects if within minUpdateInterval unless |newWorstCaseBps - lastWorstCaseBps| > deviationThresholdBps.

function updateSlippage(uint128 midPrice, uint128 depthEur, uint16 worstCaseBps, uint16 spreadBps) external;

Parameters

NameTypeDescription
midPriceuint128EUR/USD mid price (18 decimals)
depthEuruint128Total ask depth in EUR (18 decimals)
worstCaseBpsuint16Worst-case slippage across buckets (bps)
spreadBpsuint16Bid-ask spread (bps)

setMinUpdateInterval

Update the minimum interval between updates

function setMinUpdateInterval(uint48 newInterval) external;

Parameters

NameTypeDescription
newIntervaluint48New interval in seconds

setDeviationThreshold

Update the deviation threshold that bypasses rate limit

function setDeviationThreshold(uint16 newThreshold) external;

Parameters

NameTypeDescription
newThresholduint16New threshold in bps

pause

Pause the contract (blocks updateSlippage)

function pause() external;

unpause

Unpause the contract

function unpause() external;

getSlippage

Get the current slippage snapshot

function getSlippage() external view returns (SlippageSnapshot memory snapshot);

Returns

NameTypeDescription
snapshotSlippageSnapshotThe latest SlippageSnapshot struct

getSlippageAge

Get seconds since the last on-chain update

function getSlippageAge() external view returns (uint256 age);

Returns

NameTypeDescription
ageuint256Seconds since last update (0 if never updated)

minUpdateInterval

Get the current minimum update interval

function minUpdateInterval() external view returns (uint48 interval);

Returns

NameTypeDescription
intervaluint48Seconds

deviationThresholdBps

Get the current deviation threshold

function deviationThresholdBps() external view returns (uint16 threshold);

Returns

NameTypeDescription
thresholduint16Bps

recoverToken

Recover ERC20 tokens accidentally sent to the contract

function recoverToken(address token, uint256 amount) external;

Parameters

NameTypeDescription
tokenaddressToken address
amountuint256Amount to recover

recoverETH

Recover ETH accidentally sent to the contract

function recoverETH() external;

Events

SlippageUpdated

Emitted when slippage data is updated on-chain

event SlippageUpdated(uint128 midPrice, uint16 worstCaseBps, uint16 spreadBps, uint128 depthEur, uint48 timestamp);

ConfigUpdated

Emitted when a config parameter is changed

event ConfigUpdated(string indexed param, uint256 oldValue, uint256 newValue);

TreasuryUpdated

Emitted when treasury address is updated

event TreasuryUpdated(address indexed newTreasury);

ETHRecovered

Emitted when ETH is recovered from the contract

event ETHRecovered(address indexed to, uint256 amount);

Structs

SlippageSnapshot

Packed on-chain slippage snapshot (2 storage slots)

struct SlippageSnapshot {
    uint128 midPrice; // EUR/USD mid price (18 decimals)
    uint128 depthEur; // Total ask depth in EUR (18 decimals)
    uint16 worstCaseBps; // Worst-case slippage across buckets (bps)
    uint16 spreadBps; // Bid-ask spread (bps)
    uint48 timestamp; // Block timestamp of update
    uint48 blockNumber; // Block number of update
}