Skip to the content
A long stone table with an open book, a marble sphere and archive boxes

Reading room

Docs

The mechanism in full, with the maths, the limits and the debts.

01In one page

Tensa is an ERC-20 token on Ethereum that trades against native ETH in one Uniswap V4 pool. A hook on that pool, called the Metric, charges a fee on every swap. The name comes from the tensor, the object that measures how a body is stretched: the Metric measures how far a trade stretches the price from its resting point, and charges for the stretch.

  1. Every trade pays 1%.
  2. A trade that pushes the price away from the anchor pays extra, and the extra grows with the square of the push. A trade back toward the anchor pays only the 1%.
  3. Splitting a trade into pieces inside a block changes nothing. Only trading slower is cheaper.
  4. Fees that arrive in ETH are paid to holders. Fees that arrive in the token are burned.

There is no owner, no admin key, no upgrade path, no team allocation, no presale and no treasury. The whole supply starts in the pool as one locked position. It is a mechanism for moving fees from fast traders to holders and it does nothing else. It promises no return.

Status: built and tested, not deployed. Addresses, the site domain and social accounts are published at launch. Until then every interactive figure on this site is a model.

02The fee

Notation

The pool has constant liquidity, so it is exactly a constant-product curve. Write for its virtual ETH and for its virtual tokens, with . At launch ETH and . The price in ETH per token is . The anchor is a second, slower price , and is the ETH the pool would hold if the price were at the anchor.

The strain is the distance of the price from the anchor on the side a trade is pushing, measured in half the log of the price ratio:

A price 10% under the anchor is a sell-side strain of 0.0527. On the other side of the anchor the strain is negative and counts as zero.

The rule

SideDIVKNEECAPMost the whole fee can be
Sell10.1414%15%
Buy40.123%4%

In words: the first part is 1% of the volume. The second part walks along the path the swap moves the price and, at every step, charges the small volume traded on that step at a rate set by how far the price already is from the anchor. Toward the anchor the rate is zero. Away from it the rate rises in a straight line and then stops at a ceiling. With the base, a sell never pays more than 15% and a buy never more than 4%.

is volume in the currency the fee is taken in, which is the currency the trader did not specify. On the routes ordinary front ends use (exact input), a sell is charged in the ETH it receives and a buy in the tokens it receives.

Closed form

The contract does not approximate the integral. A reserve of a constant-product pool is an exponential of the strain, so the integral has an exact answer. Take a sell charged in ETH. Along the path , so a step of strain trades of ETH, and on the ramp

You can check it by differentiating: the derivative of is . When the fee currency is the reserve that grows along the path instead (a sell charged in tokens, a buy charged in ETH), the same steps give

with that reserve at the anchor. Divide by DIV, start the integral at zero if the path begins on the inward side, and beyond the knee add . That is the whole fee engine. It lives in the library PathFee and is tested against numerical integration of the definition.

RouteFee is taken inThat reserveGoes to
Sell, exact input (tokens in)ETH outshrinksholders
Sell, exact output (ETH out)tokens ingrowsburn
Buy, exact input (ETH in)tokens outshrinksburn
Buy, exact output (tokens out)ETH ingrowsholders

03Splitting changes nothing

Claim. While the anchor is fixed, which it is inside any one block, the total surcharge paid by any sequence of swaps that takes the price in one direction from to equals the surcharge of a single swap from to . It does not matter how many swaps there are or who sends them.

Why. The surcharge of a swap can be written as for one fixed function of the price: the closed form above on the ramp, a straight line in the reserve beyond the knee, a constant on the inward side, and continuous where those meet because the rate itself is continuous. Now chain the pieces:
Every stop in the middle appears once with a plus and once with a minus and cancels. The base fee is 1% of volume and volumes add. And because the fee is taken outside the pool after the swap, it does not bend the path: the pieces of an order end at the same price as the whole order would.

Rounding. Each piece rounds its fee up by a few wei. So N pieces pay the single-swap fee plus at most a few wei each, never less.

No sweet spot near the ceiling. The rate never decreases as the strain grows and it meets the ceiling without a jump, so the fee never falls as a trade gets bigger and there is no size at which stopping short and starting again is cheaper.

Crossing the anchor. A swap that starts on the inward side and ends on the outward side pays nothing extra up to the anchor and the ramp after it.

What this does not say. It is a statement about one block. Between blocks the anchor moves toward the price, so the same sale spread over hours starts each piece from a smaller strain and pays less. That is intended. What is priced is the speed of a move, not the move.

04The square

Start with the price resting on the anchor and move it by a small amount in log price, so the strain goes from 0 to . Expanding the closed form:

Twice the move costs four times the surcharge, until the ceiling flattens the curve. Summed over many moves this is the pool's depth divided by eight, times the realised variance of the log price around its anchor. That quantity is not arbitrary. It is the order of what a constant-product pool gives up to fast traders, known as loss-versus-rebalancing, which Milionis, Moallemi, Roughgarden and Zhang put at per unit of pool value per unit of time. The surcharge asks the trades that create that variance to pay for it. The running total is public on chain as strainPaid().

Check with the 0.2 ETH sell at 20 ETH of depth: ETH, against 0.00100 ETH charged.

05The anchor

The anchor is a follower with a speed limit. Once per block, at the first swap of the block and before anything trades, it steps toward the pool price at that moment, which is where the previous block closed:

Here and are square-root prices, is the time since the last step in seconds, and is 0.075 per hour. In price terms that is at most 15% per hour, or 0.05% per 12-second block. A doubling or halving that lasts is fully absorbed in 4.6 hours.

  • It never overshoots the price and never moves faster than its limit.
  • It does not move inside a block, which is what makes the splitting result exact for everything in a block.
  • Idle time cannot be saved up and spent on a fresh move. The step that opens a block uses the idle time toward the old price, before that block's trades happen.
  • Holding a wick across a block boundary moves the anchor by one block of travel, 0.05%, and costs the wick's own surcharge.
  • It stays inside the liquidity range. A price outside the range carries no information, since nothing can trade there.

The anchor follows the price in both directions at the same speed. One consequence is stated under known limits: after a fast rise the anchor is below the price for hours, and sells back toward it pay the base only.

06One swap, step by step

  1. Before the swap. The Metric steps the anchor if this is the first touch of the block, and notes the price.
  2. The swap. The pool trades with a liquidity-provider fee of zero.
  3. After the swap. The Metric reads the new price and the real amount of the currency the trader did not specify. The base is that amount divided by 100, rounded up. The surcharge is the closed form between the two prices, never more than the ceiling times the volume. On exact-input swaps the fee can never exceed the output.
  4. Settlement. The Metric takes the fee from the pool manager and reports it as its own share of the swap, so an exact-input trader receives less and an exact-output trader pays more. ETH goes straight to the token contract. Tokens are burned in the same call.

Because the fee is computed from the path the pool actually travelled, partial fills at a price limit, multi-step swaps and unusual routers are all charged correctly. A swap that would leave the price above the top of the range is refused.

07The reservoir

ETH that reaches the token contract is first recorded as pending, then joins the reservoir at the next token movement or call to drain(). The reservoir follows one law. Over any span of seconds it releases

to the holders of that span, in proportion to balance. That is 15.4% after one hour, 39.3% after three, 63.2% after six, 86.5% after twelve and 98.2% after twenty-four. The half-life is 4 hours 10 minutes.

Why an exponential and not a fixed six-hour schedule. A fixed schedule has to be restarted whenever new fees arrive, and every restart rule either lets the caller choose the timing or stretches out old money. The exponential law has no memory: , so cutting a span in two releases exactly what the whole span would. It does not matter who calls drain() or how often, and there is no schedule to game.

  • Every token outside the pool manager earns. Tokens inside it, which is the pool's own inventory, earn nothing.
  • The release runs before every balance change, so each interval is paid to the balances that existed during it. A buyer earns from the second they hold. A seller never receives a share of the fee their own sale paid.
  • While less than one whole token is in circulation the reservoir waits, so nobody can collect a backlog with dust.
  • claim() pays the caller, always. Nobody can claim for someone else.

The token contract keeps its books in public, and these hold at all times:

08Where every wei goes

FlowDestination
ETH fee (sell exact-input, buy exact-output)pending, then the reservoir, then holders through claim()
Token fee (buy exact-input, sell exact-output)burned; the total supply falls
ETH sent to the token contract by anyonetreated as an ETH fee
ETH forced onto the token contractadopted by poke() on the token, then as above
ETH that reaches the Metricforwarded to the token contract by poke() on the Metric
Tokens sent to the Metricburned by poke() on the Metric
ETH forced onto the launcher before launchforwarded to the token contract during launch
Launch rounding remainder (under a billionth of a token)burned during launch
ETH in the poolstays in the pool and backs every circulating token along the curve
Rounding in the holders' indexstays in the token contract inside owed, under 1 wei per holder per release
Team, treasury, marketing, liquidity-provider feenone exist

09Parameters

All of these are constants in the bytecode. None can be changed by anyone.

ParameterValueReason
Supply314,159,265
18 decimals
. Minted once. It can only fall.
Base fee1% each wayIncome in quiet markets. Makes a wash trade or a sandwich cost 2% before any surcharge.
Sell rateη, ceiling 14%Total sell fee never above 15%. The ceiling is reached 24.4% under the anchor.
Buy rateη/4, ceiling 3%Buying is charged a quarter as hard as selling. Total never above 4%. The ceiling is reached 27.1% over the anchor.
Anchor speed15% per hour
0.05% per block
Slow enough that a wick cannot drag it, fast enough that a real repricing stops being charged within hours.
Reservoir time constant6 hoursLong enough that one block of holding earns nothing useful, short enough that holders see fees the same day.
Minimum float1 tokenThe reservoir waits while less than this circulates.
Tick spacing10A fine price grid for a single range.
Liquidity-provider fee0There are no outside liquidity providers to pay.
Rangeticks −887,270
to 190,070
One position. Constant liquidity everywhere reachable, which is what makes the path integral exact.
Opening tick190,070Opening market cap 1.7496 ETH.
Hook permissions0x2AC4Before initialize, before add and remove liquidity, before swap, after swap, after-swap return delta.

On the anchor speed. It was chosen from a study of synthetic launch paths, not from a live market. In that study a symmetric 15% per hour anchor collects roughly 1.35% of sell flow and 1.67% of buy flow as surcharge, and leaves a small seller paying more than 3% about 15% of the time. A faster anchor collects less. An anchor that rises quickly and falls slowly collects about twice as much from sellers but charges them a quarter of the time. The symmetric rule was kept because it can be stated in one sentence. It is permanent either way.

10Contracts and functions

Four pieces of code, three deployed addresses. Addresses are published at launch, and all three will be verified so the source can be read at the address itself.

ContractRoleAddress
TensaThe ERC-20 token. Fixed supply, burnable by the holder, keeps the holders' ETH ledger.at launch
MetricThe Uniswap V4 hook: anchor, fee, fee routing. Bound to one pool for good.at launch
OriginThe one-transaction launcher. Inert afterwards. Holds the liquidity position with no function that can touch it.at launch
PathFeeLibrary inside the Metric: the closed-form surcharge and the anchor step.none of its own

Tensa: reading

totalSupply()Tokens in existence. Burned so far is 314,159,265 minus this.
float()Tokens outside the pool manager. These are the tokens that earn.
balanceOf(address)A wallet's tokens.
claimable(address)ETH a wallet could claim right now.
pending()ETH received and not yet in the reservoir.
reservoir()ETH waiting to be released.
owed()ETH released to holders and not yet claimed.
lifetimeInflow(), lifetimeClaimed()Everything ever received, everything ever paid out.
lastDrain()When the reservoir last released.
index()Cumulative ETH per token, scaled by 1036.
vault()The pool manager's address, whose balance earns nothing.
GENESIS_SUPPLY, TAU, MIN_FLOATThe constants: supply at creation, six hours, one token.

Tensa: acting

transfer, approve, transferFromStandard ERC-20. There is no fee on transfers.
claim()Sends the caller their released ETH. Reverts if there is nothing, or if the caller cannot receive ETH.
burn(amount)Destroys the caller's own tokens.
drain()Releases from the reservoir up to now. Anyone may call it. It also runs by itself before every balance change.
poke()Adopts any ETH that was forced onto the contract. Anyone may call it.

Events: Transfer, Approval, Inflow(from, amount), Released(amount, float, index), Claimed(holder, amount).

Metric

anchor()The anchor as stored: square-root price, its logarithm, and when it last moved.
anchorNow()The anchor as the next swap will see it.
marginalRates()The surcharge rate a sell and a buy would start at now, scaled by 1018. One of the two is always zero.
quote(buy, exactIn, amount)Volume, base and surcharge for a swap if it were next in this block, and whether the fee is in ETH. For display. The real charge comes from the real path.
strainPaid()All surcharge ever collected, in ETH and in tokens.
depth()The pool's constant liquidity.
poolKey()The one pool this hook serves.
poke()Steps the anchor to the current block and clears anything that reached the hook by mistake. Anyone may call it. Nothing depends on it being called.
BASE_BPS, PERMISSIONS, TICK_SPACING, TICK_OPEN, TICK_FLOORThe constants: 100, 0x2AC4, 10, 190,070 and −887,270.

Events: Charged(buy, inEth, volume, base, extra) on every swap, AnchorMoved(root, rootLn), DepthSet(depth) once at launch.

Origin

author(), engineCodeHash()Who may launch, and the hash the Metric's code must match.
tokenAddress(), engineAddress(salt)Where the token and the hook will be, before they exist.
seek(from, span)Searches for a salt that gives the hook an address with exactly the right permission bits. Meant for an off-chain call.
launch(engineCode, salt)Creates everything in one transaction. Works once. After that the contract can do nothing.

11Launch

  • One transaction creates the token, creates the hook at an address whose low bits spell its permissions, opens the pool at tick 190,070, and places the entire supply as a single token-only position from the minimum tick up to the opening tick. No ETH goes in.
  • With constant liquidity the pool is a plain constant-product curve with 1.7496 ETH of virtual depth, so the opening market cap is 1.7496 ETH. The market cap is : about 14.3 ETH once 3.25 ETH has gone in, 57 ETH at 8.25 ETH, 229 ETH at 18.25 ETH.
  • The position is held by the launcher directly in the pool manager. There is no position NFT. The launcher has no function that can touch the position, and the hook refuses every later liquidity change from anyone, including zero-liquidity collect calls. The liquidity is locked by construction, not by a promise.
  • Nobody receives tokens at launch. Every token in circulation was bought from the pool.
  • The launch checks itself in the same transaction: the price is the opening price, the hook's depth equals the liquidity placed, circulating supply is zero and the pool manager holds the whole supply. If any check fails, nothing is deployed.
  • The launch can be sniped like any other. The 3% buy ceiling is the only brake on the first buyers.

12Worked examples

A pool with 20 ETH of virtual depth, which is a market cap near 229 ETH with 18.25 ETH really in the pool. The anchor rests on the price.

Sells, fee in ETH, paid to holders

Gross ETH outPrice moveBaseSurchargeTotalEffective
0.1−1.00%0.001000.000250.001251.25%
0.2−1.99%0.002000.001000.003001.50%
0.5−4.94%0.005000.006300.011302.26%
1.0−9.75%0.010000.025430.035433.54%
2.0−19.00%0.020000.103510.123516.18%
3.0−27.75%0.030000.232840.262848.76%
6.0−51.00%0.060000.652840.7128411.88%

Buys, fee in tokens, burned

ETH inPrice moveEffective feeTokens burned
0.1+1.00%1.06%1,452
0.5+5.06%1.31%8,764
1.0+10.25%1.61%21,004
2.0+21.00%2.17%54,277
6.0+69.00%3.25%206,138
  • Split. The 6 ETH sell as three 2 ETH sells in one block: 0.1235 + 0.2893 + 0.3000 = 0.7128 ETH. As one swap: 0.7128 ETH.
  • Patience. The same three sells, each made once the anchor has caught up with the last one (about 1.4, 1.6 and 1.8 hours apart): 0.1235 + 0.1355 + 0.1506 = 0.4095 ETH, which is 6.8% instead of 11.9%. Spread over a day in small pieces the cost approaches 1%.
  • Toward the anchor. Right after that dump, a buyer of any size pays 1% until the price is back at the anchor.
  • A holder. The 6 ETH dump paid 0.7128 ETH. A wallet holding 1% of the circulating supply through the next six hours can claim 0.7128 × 63.2% × 1% = 0.0045 ETH from it, and the rest of its share keeps arriving on the same curve.

13Attacks considered

Each of these has at least one test in the suite. "Disclosed" means the behaviour is real and is listed again under known limits.

AttackWhat happens
SandwichThe front leg moves the price away from the anchor and pays the surcharge on top of 1%. The back leg pays 1%. Against a small order the sandwich loses at every size tested. Against a large order with no price limit it can still profit, as on any AMM. Disclosed.
Flash loansNothing reads an instantaneous balance or price, so there is nothing to borrow against. A flash-sized round trip is the largest outward move possible and pays the capped rate.
Wash trading for rebatesA round trip pays at least 2% into a reservoir shared by all holders over hours. The washer gets back only their own share.
Many walletsThe surcharge belongs to the price path, not the sender. Five wallets pay what one pays. Income is linear in balance.
Donations to the poolThey become fees of the locked position, which nobody can collect. A gift to no one.
Just-in-time liquidityEvery liquidity change after launch is refused.
Dumping to hurt othersThe dumper pays the highest rate, to holders. Until the anchor catches up other sellers pay more and buyers pay 1%. The effect fades at the known anchor speed.
Moving the anchorAt most 0.05% per block toward the previous close. Idle time cannot be banked.
Sniping the reservoirBuying after a large fee and leaving a block later earns 12 seconds out of a six-hour constant, shared, and costs at least 2%.
Slow exitsA seller who spreads an exit over hours pays near the base. Intended. Disclosed.
Rounding dustFees round up, releases and claims round down. Dust stays in the token contract. Nothing collects in the hook or the launcher.
Stuck fundsAnything that reaches the hook is cleared by poke(). Shares of holders that can never claim stay reserved for good. Disclosed.
Contract walletsNo code-size checks anywhere. claim() pays the caller.
Launch snipersThe first blocks are the largest outward move the pool will see, and pay the buy ceiling in burned tokens. Disclosed: the cost in ETH is lower than the headline.
Choosing another routeThe fee is taken on all four routes. Exact-output moves it to the other currency and adds it on top. Disclosed.
Parking the price above the rangeAny swap that would end above the range is refused.
Blocking another holderEvery public function either acts only on the caller or moves time forward the same way for everyone.
Blocking the launchETH forced onto the launcher is forwarded to holders instead of failing a check. Nobody else can create the token or hook at the expected addresses or open the pool first.
Fake pools on the hookThe hook accepts one pool, from the launcher, once.
Uniswap protocol feeIf governance ever turns one on for this pool, traders pay it on top. Disclosed.

14Known limits

These are things the reviews found, or the design implies, that were left as they are. None of them can be fixed after launch.

  1. It only redistributes. Fees move from fast traders to holders. In a flat market holders receive 1% of a small volume and nothing more.
  2. Sells after a run-up pay the base. The anchor climbs at most 15% per hour. A token that multiplies in minutes leaves it far below, and the sell surcharge returns only once the price falls back through the anchor. The surcharge bites on moves away from where the price has recently been, not on every sale after a pump.
  3. A slow exit is cheap. By design. Do not read the 15% ceiling as what large sellers pay.
  4. The buy fee is cheaper in ETH than it looks. It is taken in tokens. A holder who keeps their tokens is short 1% to 4% of them, but someone who buys and sells at once loses less than that in ETH, because the missing tokens were the cheapest on the curve. A 3 ETH buy and immediate sale on the opening pool loses about 2.4% in ETH. There is no profit in such a trip.
  5. Exact-output routes pay less and pay a different sink. There the fee is added on top of the input, so as a share of the gross it is : the ceilings are 13.04% and 3.85% instead of 15% and 4%. At the ceiling a seller who knows this nets about 2.5% more, and that fee is burned instead of going to holders. Charging instead would not add up across pieces and would break the splitting result, so it was left alone.
  6. Large orders without a price limit can be sandwiched, as on any AMM, and a front-run raises the victim's own surcharge as well as their price. Use a slippage limit.
  7. Unclaimable shares. Tokens at a dead address, in a contract that cannot call claim(), in a pool on another venue or in a bridge keep earning ETH that stays in the token contract for good. It is not stolen and the books still balance. To destroy tokens use burn.
  8. No fee off this pool. There is no tax on transfers, so a side pool somewhere else would trade without the Metric's fee.
  9. Exact-output buys lean on the pool manager's ETH. The ETH fee is forwarded a moment before the buyer settles. Mainnet's pool manager holds the ETH of every V4 pool. If it ever held less than the fee, that one swap would revert and nothing else would happen.
  10. quote() is for display. It computes the path in one step, while the pool walks it in several and rounds at each. They agree to a few wei of ETH.
  11. Timing noise in the reservoir. The exponential routine carries a relative error near 10−18, so many small releases can differ from one large one by a few thousand wei on a reservoir of hundreds of ETH. It can never release more than it holds.
  12. A Uniswap protocol fee, if ever enabled for this pool, is paid by traders on top and shifts quote() by up to 0.1%.
  13. The launcher trusts a code hash supplied by whoever deploys it. Read the verified source at the hook's address, not a description of it.
  14. It depends on Uniswap V4 behaving as it does today. The pool manager cannot change. Routers can, and only the Universal Router was tested. Other routers and aggregators may quote badly against a hook that takes its fee from the output. They should fail their own slippage checks, not lose funds.
  15. The maths library has limits. Logarithm and exponential come from a widely used fixed-point library with error near 10−18. A larger hidden error would show up as a mispriced fee, not lost funds: the fee is always capped by the ceiling times the volume.
  16. The constants are forever and were chosen from a model. If 1%, the slopes, the ceilings, 15% per hour or six hours turn out wrong for a live market, nothing can change them.

15Reviews so far

No third-party audit has been done. What follows is the author's own review, the test suite, and one independent pass by an AI reviewer that was given the code and the intended behaviour and nothing else. Treat it as that and no more.

Tests. 113 tests in nine suites: unit tests, fuzz tests including the splitting result on all four routes, eight solvency invariants over tens of thousands of random calls, one test per attack listed above, and twelve tests on a fork of mainnet through the real pool manager, Universal Router and Permit2.

Found and fixed.

  • The launch could have been blocked for good by forcing 1 wei of ETH onto the launcher. The check is gone and such ETH now goes to holders.
  • At launch the price could be walked above the range for free, making first buys very expensive in gas. Swaps that end above the range are now refused.
  • Swaps of a few wei paid no surcharge because a cap rounded down. It rounds up.
  • Index arithmetic that could in theory overflow now uses 512-bit multiplication.

Found and left. Everything under known limits.

Independent pass. No critical, high or medium finding. The reviewer could not steal or lock holder ETH, avoid the fee beyond rounding and the exact-output effect above, move the anchor faster than its limit, or permanently break swaps, transfers or claims. It re-derived the closed form on its own.

Still to come before launch. An outside audit. This section will say when it has happened and where to read it.

16Prior art

Fees that react to volatility are not new, and Tensa did not invent them. This design sits in a family and owes it credit.

  • Clanker's dynamic fee hook. A base fee plus a term proportional to the square of a volatility accumulator, measured against a lagging reference tick, evaluated on the tick where the swap ends, and paid to liquidity providers and the token's creator. The idea of a quadratic charge against a slow reference is theirs first.
  • Nezlobin's directional fee hooks. Fees that differ by the direction of a trade relative to recent price movement.
  • Uniswap's StablePair and Truncated Oracle hooks, and the volatility-fee example hook. A rate-limited price reference, and fees that scale with measured volatility.
  • Loss-versus-rebalancing, by Milionis, Moallemi, Roughgarden and Zhang (2022), for the identity used in section 04.
  • arXiv 2506.02869. Listed in the prior-art check for this project. The author of these docs has not been able to read it, so it is cited by number only and nothing is claimed here about what it says.

What is different here, and only this. The surcharge is the exact integral of the rate along the swap's path, not an end-of-swap estimate, which is what makes it indifferent to splitting. The reference is a speed-limited follower of the previous block's close. Trades toward the reference pay the base only. And because the pool has no outside liquidity providers, the proceeds go to token holders in ETH or are burned. The per-token accounting used to pay holders is standard.

17Words

AnchorThe slow reference price the Metric keeps.
StrainDistance of the price from the anchor, on the side a trade is pushing.
MetricThe fee engine: the Uniswap V4 hook.
OriginThe launcher.
ReservoirHolders' ETH waiting to be released.
FloatTokens in circulation, meaning outside the pool manager.
KneeThe strain at which the rate stops rising: 0.14 for sells, 0.12 for buys.
Exact input, exact outputWhether a trader fixes what they give or what they get. Ordinary front ends fix the input.