Skip to content

Put several fee rights in one token

A Pons fee right, a pools.trade fee NFT and v4 positions in one token: predictToken, the Pons door, then tokenize.

On this page

One revenue token can take its income from several fee rights at once, each a stream of its own: here a Pons fee right, a pools.trade fee NFT and Uniswap v4 positions, minted together with a market in one tokenize call. The doors for outside fee rights are made first, for the token's address before the token exists.

In the app

  1. Open /tokenize, then By id and its Combine streams card. Add each fee right: the pools.trade fee NFT with its vault and id, the Pons fee right with its Pons token, and the Uniswap v4 positions with their ids. Your wallet opens the same card with what it lists ticked, and the Pons and Long tabs are the same card for one fee right each.
  2. Set the terms. The card shows Hookr's leg for these streams.
  3. With a Pons or Long fee right among the streams, the first send reads Make their doors: it makes each door for the token's address and hands the fee right to it, skipping what is in place already. Then press Tokenize the streams: the wallet sends the approvals still missing, the fee NFT's and the positions', then tokenize.

The calls

  1. Fix the terms first. predictToken(creator, t) gives the token's address, worked out from the creator, the termsHash and the token's terms; the recipients, the amounts, the streams and the market do not move it.
  2. The Pons door: create(revenueToken, memecoin) on the Pons door factory, from the launch's creator fee recipient, then transferCreatorFeeRecipient(memecoin, door) on the Pons launch factory. A move of the fee right that Pons already has pending blocks the mint with SourceRevocationPending until it lapses or is cancelled.
  3. approve(feebAdapterFactory, tokenId) on the fee NFT's vault, and setApprovalForAll(positionDoorFactory, true) on the PositionManager, or a permit in s.positionPermits.
  4. tokenize(t, s, m). The tokenizer checks every outside door: that it names this token, holds its fee right, has no move of it pending, has not ended and, if its end is dated, ends at least 7 days from now, does not count the revenue token itself among the currencies it pays, and asks a gas stipend of 100,000 to 12,000,000. It makes a door for the fee NFT and one for the v4 positions on the Hookr hook and one for the rest, adds every door to the token, mints and opens the market. With s.listAssets set it lists the currencies the streams pay, while there is room.

The token made here has a door for each stream: the fee NFT door, the v4 position door or doors, the Pons door, and the market's family door and Rules ledger. streams(token, start, count) lists each with how it ends: the Pons stream as one Pons can move away, the others as forever.

In code

With client.ts and abis.ts:

import { createWalletClient, http, keccak256, parseUnits, toHex, zeroAddress, type Address } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { robinhood } from "viem/chains";
import { client, FOREVER, RULES, TOKENIZER } from "./client";
import { feeNftVaultAbi, launchFeeAbi, ponsDoorFactoryAbi, ponsLaunchFactoryAbi, positionManagerAbi, tokenizerAbi } from "./abis";

const creator = privateKeyToAccount(process.env.CREATOR_KEY as `0x${string}`);
const wallet = createWalletClient({ account: creator, chain: robinhood, transport: http() });
const mined = (hash: `0x${string}`) => client.waitForTransactionReceipt({ hash });

const MEMECOIN: Address = "0x…"; // a Pons launch quoted in ETH, whose creator fee recipient you are
const VAULT: Address = "0x…"; // the pools.trade vault
const FEE_NFT = 123456n; // your fee NFT
const POSITIONS = [111n]; // your Uniswap v4 positions

// 1. The terms come first: the token's address follows from the creator, the termsHash and the terms.
const supply = parseUnits("1000000000", 18);
const seed = parseUnits("5000000", 18);
const terms = {
  name: "Example Several Revenue",
  symbol: "rSEVERAL",
  supply,
  streamSeconds: 86_400,
  tipBps: 100,
  assets: [],
  recipients: [creator.address],
  amounts: [supply - seed],
  termsHash: keccak256(toHex("rSEVERAL: Pons, a fee NFT and v4 positions")),
  streamManager: creator.address,
  openStreams: false,
};
const revenueToken = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "predictToken", args: [creator.address, terms] });

// 2. The Pons door, made for that address, then the Pons fee right handed to it.
const ponsFactory = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "ponsAdapterFactory" });
const made = await client.simulateContract({ account: creator, address: ponsFactory, abi: ponsDoorFactoryAbi, functionName: "create", args: [revenueToken, MEMECOIN] });
await mined(await wallet.writeContract(made.request));
const ponsDoor = made.result;
const ponsLaunchFactory = await client.readContract({ address: ponsFactory, abi: ponsDoorFactoryAbi, functionName: "launchFactory" });
await mined(await wallet.writeContract({ address: ponsLaunchFactory, abi: ponsLaunchFactoryAbi, functionName: "transferCreatorFeeRecipient", args: [MEMECOIN, ponsDoor] }));

// 3. The fee NFT and the positions may move, each to its door factory.
const feebFactory = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "feebAdapterFactory" });
await mined(await wallet.writeContract({ address: VAULT, abi: feeNftVaultAbi, functionName: "approve", args: [feebFactory, FEE_NFT] }));
const [positionManager, doorFactory] = await Promise.all([
  client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "positionManager" }),
  client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "positionDoorFactory" }),
]);
await mined(await wallet.writeContract({ address: positionManager, abi: positionManagerAbi, functionName: "setApprovalForAll", args: [doorFactory, true] }));

// 4. One call locks every fee right, adds its door to the token, mints and opens the market. Everything is locked for good.
const sqrt = (n: bigint) => {
  let x = n;
  let y = (x + 1n) / 2n;
  while (y < x) [x, y] = [y, (y + n / y) / 2n];
  return x;
};
const market = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "defaultMarket", args: [RULES, revenueToken, zeroAddress, sqrt(1_000_000n << 192n), seed] });
const launcher = await client.readContract({ address: TOKENIZER, abi: tokenizerAbi, functionName: "launcher" });
const [launchFee] = await client.readContract({ address: launcher, abi: launchFeeAbi, functionName: "launchFee" });
const streams = {
  launchParams: "0x" as const,
  families: [],
  rules: [],
  feebs: [{ vault: VAULT, tokenId: FEE_NFT }],
  positionIds: POSITIONS,
  positionPermits: [],
  v3PositionIds: [],
  v3Permits: [],
  revenueTokens: [],
  sources: [ponsDoor], // the outside doors, each made for this token
  unlockBlock: FOREVER, // the market's family
  unlockAt: FOREVER, // the fee NFT and position doors
  listAssets: true, // list the currencies these streams pay, while there is room
};
const { request } = await client.simulateContract({
  account: creator,
  address: TOKENIZER,
  abi: tokenizerAbi,
  functionName: "tokenize",
  args: [terms, streams, market],
  value: launchFee,
});
await mined(await wallet.writeContract(request));

StreamParams also takes a launch, as the encoded LaunchParams with every royalty pointed at the predicted token, Hookr families you hand to the tokenizer, Rules ledgers that already credit the token, Uniswap v3 positions with their v3 permits, and shares of other revenue tokens; the walkthrough leaves them empty. With a launch, the call carries the launch's budgets and fee as Launch a token with a revenue token shows, and unlockBlock locks the launch's family as well as the market's. unlockAt is the term of the doors that count seconds.

Before the mint

Until a token holds the Pons door as one of its doors, the wallet that made it can take the fee right back with abort() on the door: Ways in.

Fee

A Pons fee right, a fee NFT and positions off the Hookr hook pay Hookr nothing through it, so each of their doors carries Hookr's leg of 5%, taken from what it delivers at each sync. The market and positions on the Hookr hook carry none. The recipients share the whole supply less the market's seed.