Docs / Contract reference⌄

Reference

Contract reference

Two contracts: KolanHook, the Uniswap v4 hook that holds the liquidity and the windows, and KolanToken, the token it deploys. Neither has an owner or an upgrade path.

Addresses#

On Ethereum. Each address opens on etherscan.io.

Parameters#

Fixed in the hook's constructor, for good.

NameShipped valueMeaning
TAX_BPS100The tax on the ETH side of every swap and window, in basis points. Ceiling 500
REFERENCE_PREMIUM0.05 ETHThe premium that buys BASE_WINDOW
BASE_WINDOW6 hours
MIN_WINDOW30 minutesThe shortest window; a premium too small for it is refused
MAX_WINDOW7 daysThe longest; premium past it is refunded
MAX_PREMIUM_BPS3000The most a premium may be, of the ETH a purchase spends
DEVReceives the tax, in ETH
TOKENThe token, its whole supply minted to the hook

Buying and closing#

buy(address recipient, uint256 premium, uint256 minTokens, uint256 deadline) payable returns (uint256 id, uint256 tokens)
Opens a window for recipient. The value pays the ETH to spend, 1% tax on it, the premium, and a 1,000 wei rounding allowance; whatever is not used is refunded. Reverts with TooFewTokens under minTokens.
cancel(uint256 id)the owner, before expiry
Undoes the window: every wei of its ETH back to the owner, the tokens back into the pool, the premium spent buying tokens back to burn.
accept(uint256 id)the owner at any time, anyone after expiry
Keeps the window: the tokens to the owner, the ETH into the pool, the premium spent buying tokens back to burn.
claimDev() returns (uint256 amount)anyone
Pays the tax owed to DEV, in ETH.
launch(int24 tick) payablethe launcher, once
Opens the pool at tick and puts the whole supply in it. Nobody else can open a pool on this hook.

Views#

quote(uint256 eth) view returns (uint256 tokens, uint256 cost)
What a window spending eth would take out of the pool now, and what it would cost.
windowFor(uint256 premium) view returns (uint256)
Seconds a premium buys, before the floor and the ceiling.
windows(uint256 id) view returns (address owner, uint40 expiry, uint8 cuts, uint96 eth, uint96 tokens, uint64 premium)
A window still held. A closed window reads as zero.
cutsOf(uint256 id) view returns (Cut[])
Where a window's tokens came from: the ranges it took out of the pool.
held() view returns (uint128 eth, uint128 tokens)
ETH (with premiums) and tokens held for every open window.
segments(int24 lower) view / hint() view
The hook's positions, as a chain in tick order, and where it last changed.
poolKey() view / poolId() view / devOwed() view / windowCount() view
The pool, and the counters.

Events#

event Launched(PoolId indexed id, int24 tick, uint128 liquidity, uint256 tokens);
event Taxed(address indexed payer, uint256 fee);
event DevPaid(address indexed dev, uint256 amount);
event WindowOpened(uint256 indexed id, address indexed owner, uint256 eth, uint256 tokens,
                   uint256 premium, uint256 expiry, int24 lower, int24 upper);
event WindowClosed(uint256 indexed id, address indexed owner, bool kept, bool backInPlace, uint256 burned);

Errors a buyer can meet#

ErrorMeaning
TooFewTokensThe price moved past your tolerance
TooLateThe transaction waited past its deadline
PremiumTooLowThe premium buys less than MIN_WINDOW
PremiumTooHighThe premium is more than MAX_PREMIUM_BPS of what the purchase spends
NothingToBuyThe amount is too small to take anything out of the pool
WindowExpiredUndo after the expiry: the window can only be kept now
WindowStillOpenSomeone other than the owner tried to keep a window still running
NotOwnerSomeone other than the owner tried to undo

KolanToken#

A plain ERC-20 with a fixed supply, minted once to the hook in its constructor. Nothing can mint more; anyone can burn their own, which is how premiums burn what they buy back.