Getting started
Package
- Package
@floor/sdk- Status
- Not released yet. This page describes the first release.
- Covers
- FLOOR on Solana and on every EVM chain: read a launch, quote, buy, sell, create and claim.
- Dependencies
- None. Bring your own RPC client and wallet.
- Amounts
- Bigints in base units. A price or a floor is Q64.64 per base unit.
Modules
| Module | What |
|---|---|
@floor/sdk/quote | Quote a buy or a sell against a launch’s state: tokens, refund, rates, Marketcap Milestones, the floor after |
@floor/sdk/math | The program’s math in TypeScript, bit for bit with its own test vectors |
@floor/sdk/evm/floor/market | Read a launch’s state on EVM in one eth_call |
@floor/sdk/evm/floor/calls | FloorAmm calls: buy, sell, approve, create, claim |
@floor/sdk/evm/floor/events | Decode FloorAmm and zap logs |
@floor/sdk/evm/floor/abi.gen | The FloorAmm, token and zap ABIs |
@floor/sdk/solana/floor/program | The program id and every PDA |
@floor/sdk/solana/floor/market | A Launch account to the quoter’s state |
@floor/sdk/solana/floor/instructions | Every instruction: buy, sell, create, claim, the Team Slot |
@floor/sdk/solana/floor/events | Decode the program’s events |
Chains
| Chain | Program |
|---|---|
| Solana | 7TFse4fPC383KWiSTHXfdRrNBSzLWpsB8VNF9TJFLooR |
| Ethereum | Not deployed yet |
| BSC | Not deployed yet |
| HyperEVM | Not deployed yet |
| Robinhood Chain | Not deployed yet |
| Arc | Not deployed yet |
| Base | Not deployed yet |
| Arbitrum | Not deployed yet |
On EVM the program is FloorAmm, at one address on every chain once it is deployed.
Reading
Read on EVM
readLaunch answers a launch’s state and the token’s live supply, every view read at one block.
- ethCall
- Your RPC client: one eth_call in, its result out.
- displayFloor
- The floor, the bid, the price and the tokens outside the program.
TypeScript
import { readLaunch } from '@floor/sdk/evm/floor/market';
import { displayFloor } from '@floor/sdk/quote';
// publicClient: a viem PublicClient. floorAmm: the chain's FloorAmm address.
// launchId: the launch's id (a bigint).
const ethCall = async (c) => (await publicClient.call({ to: c.to, data: c.data })).data ?? '0x';
// Every view at one block, in one eth_call (Multicall3).
const { launch, liveSupply } = await readLaunch(ethCall, floorAmm, launchId);
const { floorX64, priceX64, sOut } = displayFloor(launch);Read on Solana
A launch is one Launch account at launchPda(baseMint). launchFromAccount turns its bytes into the quoter’s state.
- liveSupplyOf
- The supply the program trades on, burns counted.
TypeScript
import { launchPda } from '@floor/sdk/solana/floor/program';
import { launchFromAccount, liveSupplyOf } from '@floor/sdk/solana/floor/market';
// accountData(address): the account's bytes from your RPC.
// baseMint: the launch's token mint. mintSupply: that mint's supply.
const [launchAddress] = launchPda(baseMint);
const data = await accountData(launchAddress);
const launch = launchFromAccount(data);
const liveSupply = liveSupplyOf(data, mintSupply);Trading
Quote
quoteBuy and quoteSell run the program’s own math on a launch’s state. The same math runs on chain, so a quote on fresh state is what the trade does.
| Field | What |
|---|---|
tokensOut | The tokens the buy takes out of the program |
charged | The quote spent |
refund | The quote the buy could not spend, returned |
graduates | This buy sells the window out and graduates the launch |
floorAfterX64 | The floor after the buy |
rates | The fee rates the buy pays |
milestones | The Marketcap Milestones inside its price |
TypeScript
import { quoteBuy, quoteSell } from '@floor/sdk/quote';
// launch, liveSupply: read as above. Amounts are bigints in base units.
const buy = quoteBuy(launch, 10n ** 16n, { liveSupply });
buy.tokensOut; // what the buy takes out of the program
buy.refund; // quote a buy cannot spend, returned
buy.graduates; // this buy sells the window out
buy.rates; // the fees it pays
buy.milestones; // the Marketcap Milestones inside its price
const sell = quoteSell(launch, buy.tokensOut, { liveSupply });
sell.quoteOut; // the seller's netBuy on EVM
buyCall and sellCall answer one call each: an address, data and a value. They never sign.
- Native coin
- The amount rides as the call’s value.
- Token
approveCallto FloorAmm first.- Minimum out
- Required. A buy below it reverts.
TypeScript
import { approveCall, buyCall } from '@floor/sdk/evm/floor/calls';
// walletClient: a viem WalletClient. quote: the launch's quote token,
// or the zero address for the chain's native coin.
const amountIn = 10n ** 16n;
const q = quoteBuy(launch, amountIn, { liveSupply });
const calls = [
...(quote === '0x0000000000000000000000000000000000000000' ? [] : [approveCall(quote, floorAmm, amountIn)]),
buyCall({ floorAmm, quote, launchId, amountIn, minTokensOut: (q.tokensOut * 99n) / 100n, to: walletClient.account.address }),
];
for (const c of calls) await walletClient.sendTransaction({ to: c.to, data: c.data, value: c.value });Buy on Solana
buyInstruction, sellInstruction and buyFromBalanceInstruction answer one instruction each.
- wSOL
- A SOL launch’s quote is wrapped SOL in the trader’s token account.
- buy_from_balance
- Spends the quote account’s balance above a set amount, so a router can chain a swap into a buy.
TypeScript
import { buyInstruction } from '@floor/sdk/solana/floor/instructions';
// accounts: the trade's accounts (TradeAccounts): the trader, the launch, its mints,
// the program's vaults and the trader's token accounts.
const amount = 1_000_000_000n; // 1 SOL
const q = quoteBuy(launch, amount, { liveSupply });
const ix = buyInstruction({ ...accounts, amount, minTokensOut: (q.tokensOut * 99n) / 100n });
// Add ix to a transaction, sign it and send it with your Solana client.Claim
One claim pays what a wallet is owed, chosen by type bits.
| Bit | Pays |
|---|---|
| 1 | The creator’s Team Share, with no Team Slot |
| 2 | Creator referrals |
| 4 | A Team Slot member’s Team Share |
| 8 | Trader referrals |
| 32 | Extra fee legs |
| 64 | A payout that failed earlier (EVM) |
| 128 | The Team Buy, after its 1-day lock |
TypeScript
import { claimCall } from '@floor/sdk/evm/floor/calls';
// types: the claim bits to pay. quotes: the quote tokens to pay out in.
const c = claimCall({ floorAmm, wallet: walletClient.account.address, types: 4 | 128, quotes });
await walletClient.sendTransaction({ to: c.to, data: c.data, value: c.value });Reference
Fees
| Fee | Paid on |
|---|---|
| Backing Fee | Every buy and sell, into the launch’s floor |
| Team Share | Every buy and sell, to the Team Slot |
| Platform fee | Every buy and sell |
| $FLOOR fee | Every buy and sell |
- Curves
- Each fee and each Marketcap Milestone follows its own curve on market cap, copied from the launch’s preset.
- Before graduation
- A window trade pays the Platform fee and the $FLOOR fee, 0.50% each.
- Marketcap Milestones
- Inside the price of a buy on the way up. Not a fee.
Errors
| code | When |
|---|---|
Zero | The amount is zero |
Overflow | The amount is wider than the chain takes |
SlippageExceeded | The quote is below the minimum out |
NothingToBuy | The buy would take no tokens |
OutOfReach | An exact-out amount the launch cannot reach |
- EVM reverts
decodeFloorErrornames a FloorAmm revert and its arguments.