Hooks Reference
Explore our GitHub repository containing reference mathematical implementations, in Javascript and Python, for supported Balancer hook types. Designed to assist developers and integrators in understanding the underlying swap calculations, these implementations can be imported as a packages into your project or serve as a reference for your own implementation.
For more details about Balancer V3 Hooks implementation see Hooks Core Concepts.
Supported Hook Types
Stable Surge Hook
- This uses the onComputeDynamicSwapFeePercentage hook.
- Intro blog post.
- Pools with StableSurge hook will be deployed from a dedicated factory.
- Factory Deployment Addresses.
- See SC code implementation here.
- Typescript maths reference
- Python maths reference.
- Maths requires the configurable
maxSurgeFeePercentage
andthresholdPercentage
values which can be fetched and tracked using the following functions and events:
function getMaxSurgeFeePercentage(address pool) external view returns (uint256);
event ThresholdSurgePercentageChanged(address indexed pool, uint256 newSurgeThresholdPercentage);
function getSurgeThresholdPercentage(address pool) external view returns (uint256);
event MaxSurgeFeePercentageChanged(address indexed pool, uint256 newMaxSurgeFeePercentage);
- API Support: Can use the filter:
includeHooks: [STABLE_SURGE]
, to include all pools using this hook type:
query MyQuery {
aggregatorPools(
where: {chainIn: SEPOLIA, includeHooks: [STABLE_SURGE], protocolVersionIn: 3}
) {
address
type
hook {
dynamicData {
maxSurgeFeePercentage
surgeThresholdPercentage
}
}
}
}