DocsToken and pool
On this page

Token and pool

TokenAMM is an ERC-20 whose whole amount sits in its own constant-product pool against HYPE. A virtual HYPE reserve sets the opening price, so you launch without seeding any HYPE. There are no LP tokens and no owner: nobody, the deploying wallet included, can take the pool's HYPE out except by selling tokens into it. Every trade pays a 1% fee in HYPE to an address fixed at deploy.

#Parameters

Field in the Builder Constructor argument Default Notes
App name name_ the template's title Also the token's name.
Symbol symbol_ TKN Upper case, up to 10 characters.
Total amount of tokens supply one billion 18 decimals. All of it is minted into the pool.
Opening curve (virtual HYPE) virtualHype_ 3 Must be above zero.
(none) feeTo_ your wallet Receives the 1% fee. Fixed forever.

#The curve

Let x be the pool's HYPE side, virtualHype + hypeReserve, and y the tokens in the pool, tokenReserve(). Trades keep the product x × y constant, apart from rounding; the fee is paid out rather than left in the pool.

Buy with buy(minTokens) and HYPE as the value:

  • the fee is 1% of the HYPE sent and goes to the fee address;
  • the rest, in, enters the pool: tokensOut = y × in / (x + in);
  • the call reverts with Slippage if tokensOut is zero or below minTokens.

Sell with sell(tokensIn, minHype). No approval is needed:

  • gross = x × tokensIn / (y + tokensIn), capped at hypeReserve, so a sale is only ever paid from real HYPE that buyers put in, never from the virtual reserve;
  • the fee is 1% of gross and goes to the fee address; you receive the rest;
  • the call reverts with Slippage if what you receive is zero or below minHype.

Price. price() returns the HYPE (in wei) for one whole token, without the fee: (virtualHype + hypeReserve) × 1e18 / tokenReserve. The opening price is virtualHype / supply: with the defaults, 3 HYPE over one billion tokens, or 0.000000003 HYPE per token. The price rises as HYPE comes in and falls as tokens go back.

A worked example: a 10 HYPE buy sends 0.1 HYPE to the fee address and puts 9.9 HYPE into the pool.

#The page

The app page shows the price, a chart of the trades in the last 5,000 blocks of the layer, the HYPE and tokens in the pool, the fixed total and the virtual reserve, and your balance. Before you sign, it quotes the trade with quoteBuy or quoteSell and sets the minimum you accept to 97% of the quote, so a trade that moves more than 3% against the quote reverts.

#Functions

Function Who may call What it does
buy(uint256 minTokens) payable Anyone Buys tokens from the pool.
sell(uint256 tokensIn, uint256 minHype) Anyone Sells tokens into the pool.
quoteBuy(uint256), quoteSell(uint256) Read Tokens or HYPE out, and the fee.
price(), hypeReserve(), tokenReserve(), virtualHype(), feeTo() Read The pool's state.
ERC-20 functions Anyone transfer, approve, balanceOf and the rest, from OpenZeppelin v5.

Event: Trade(trader, buy, hype, tokens, feeHype, price). Errors: Slippage, Zero, TransferFailed, BadVirtual.

#Good to know

  • The fee goes out on every trade. If the fee address could not receive HYPE, every trade would revert. Through the Builder it is your own wallet.
  • There is no LP position to burn because there is none at all: the pool is the token contract itself and has no withdraw function.
  • Tokens sent to the contract with a plain transfer join the pool's token side.