SpiralLibV3 on Ethereum
Uniswap v4 Hook Contract 0xe3bf665a9545d34d061fa5bd7a0676c81b5aaacc on Ethereum · Custom pricing · Verified contract
- Volume (24h)
- $0
- Value locked (TVL)
- $8.66K
- All-time volume
- $296.20K
- Pools using this hook
- 1
- Swaps (24h)
- 0 (0 traders)
- Total swaps
- 898
What it does
The hook runs a bonding-curve-backed perpetual and borrow system on a Uniswap v4 pool where borrow, long and close flows charge a fixed origination fee sent to the buyback address, and liquidations pay a capped bounty to liquidators.
How it works step by step
- Acts as a library delegate for a Uniswap v4 hook that maps a constant-product bonding curve (realSpiral times V plus realETH equals K) onto concentrated-liquidity bands in the pool
- Seeds liquidity bands via modifyLiquidity, funding single-sided SPIRAL liquidity into the PoolManager
- Implements borrow, leveraged long, atomic close and liquidation flows that remove band liquidity, swap through the pool and take ETH and SPIRAL with PoolManager take, sync and settle calls
- Routes a fixed origination fee (origFeeBps) from borrow and long flows to a spiralBuyback address supplied by the caller
- Refills bands with ETH-only liquidity after swaps and sends liquidation bounties to the liquidator, with the remainder of seized SPIRAL sent to the dead address
- Provides curve math helpers (sqrtPriceAtRealETH, realETHAtSqrtPrice, swapEthForTokenOnCurve, swapSpiralForEthOnCurve) used to price swaps and quotes
- Swap behaviour
- Swaps are executed through the pool by the calling flows; the library's own swap calls are internal leverage, close and liquidation legs, and origination fees are taken from the ETH side on borrow and long, so trades that use these flows pay the origination fee. Plain user swaps are not described in the supplied code.
- Liquidity behaviour
- Liquidity is added and removed by the hook through the PoolManager (seeding bands, removing band liquidity for borrow and long, refilling ETH-only bands). The library itself does not expose external LP add or remove for users; the hook's liquidity callbacks gate access.
- Fee behaviour
- A fixed origination fee of origFeeBps divided by ltvBps of ETH from borrow and long flows is taken to spiralBuyback, with the long path charging the fee on the ETH actually consumed. Liquidation pays a bounty capped at the seized ETH.
- Owner & admin controls
- No admin, owner or pause functions appear in the supplied library code. The proxy is upgradeable and the implementation address is not verified as owned or immutable from this input, so upgrade authority cannot be confirmed here.
Enabled Uniswap v4 callbacks
beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta
beforeInitialize, beforeAddLiquidity and beforeRemoveLiquidity gate who can change pool liquidity; beforeSwap and afterSwap support the swap-driven flows; beforeSwapReturnDelta and afterSwapReturnDelta allow the hook to take or return currency deltas as part of borrow, long, close and liquidation accounting.
Security & trust assessment
Risk level: high (verified source, medium confidence).
Who controls it: Without the upgrade key status, the source gives no direct owner powers; however a proxy upgrade authority would be able to change the logic that controls all borrow, long, close and liquidation funds.
Risk to user funds: The hook can hold ETH and SPIRAL in its own balance, takes origination fees and bounties, and moves SPIRAL and ETH between the PoolManager, the hook and users via these flows, so user and pool funds are exposed to the correctness of this code and to any upgrade authority.
Security findings
- [high] Upgradeable proxy in front of the hook: The hook delegates every call to implementation 0x77b8b31b8a92647fb3b0f1440ae4d07a06f8fd4a; if an upgrade key exists, the implementation logic that moves user and pool funds could be replaced.
- [medium] Hook holds and moves pool funds via return deltas: Borrow, long, close and liquidation flows use take, settle and transfer on ETH and SPIRAL and return deltas, so the hook is a custodian of pool-side value during these operations.
- [medium] Dependence on swap partial fills: Long and close flows account for sqrtPriceLimitX96 partial fills and send residue to recipients; mismatches in accounting would leave tokens or ETH stranded in the hook.
- [info] Liquidations send residue to dead address: Liquidation burns the unsold collateral residue by transferring it to 0xdEaD, which is a deliberate irreversible burn.
Contract details
- Verified source
- Yes (SpiralLibV3)
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Bytecode size
- 23,425 bytes
- Upgradeable proxy
- Yes
- Detected patterns
- erc20, moves-currency, return-delta, upgradeable
Pools using SpiralLibV3
- ETH / SPIRAL (0.00% fee) — 24h volume $0, TVL $8.66K, 0 swaps today