FLOOR / SDK

SDK

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

ModuleWhat
@floor/sdk/quoteQuote a buy or a sell against a launch’s state: tokens, refund, rates, Marketcap Milestones, the floor after
@floor/sdk/mathThe program’s math in TypeScript, bit for bit with its own test vectors
@floor/sdk/evm/floor/marketRead a launch’s state on EVM in one eth_call
@floor/sdk/evm/floor/callsFloorAmm calls: buy, sell, approve, create, claim
@floor/sdk/evm/floor/eventsDecode FloorAmm and zap logs
@floor/sdk/evm/floor/abi.genThe FloorAmm, token and zap ABIs
@floor/sdk/solana/floor/programThe program id and every PDA
@floor/sdk/solana/floor/marketA Launch account to the quoter’s state
@floor/sdk/solana/floor/instructionsEvery instruction: buy, sell, create, claim, the Team Slot
@floor/sdk/solana/floor/eventsDecode the program’s events

Chains

ChainProgram
Solana7TFse4fPC383KWiSTHXfdRrNBSzLWpsB8VNF9TJFLooR
EthereumNot deployed yet
BSCNot deployed yet
HyperEVMNot deployed yet
Robinhood ChainNot deployed yet
ArcNot deployed yet
BaseNot deployed yet
ArbitrumNot 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.

FieldWhat
tokensOutThe tokens the buy takes out of the program
chargedThe quote spent
refundThe quote the buy could not spend, returned
graduatesThis buy sells the window out and graduates the launch
floorAfterX64The floor after the buy
ratesThe fee rates the buy pays
milestonesThe 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 net

Buy 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
approveCall to 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.

BitPays
1The creator’s Team Share, with no Team Slot
2Creator referrals
4A Team Slot member’s Team Share
8Trader referrals
32Extra fee legs
64A payout that failed earlier (EVM)
128The 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

FeePaid on
Backing FeeEvery buy and sell, into the launch’s floor
Team ShareEvery buy and sell, to the Team Slot
Platform feeEvery buy and sell
$FLOOR feeEvery 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

codeWhen
ZeroThe amount is zero
OverflowThe amount is wider than the chain takes
SlippageExceededThe quote is below the minimum out
NothingToBuyThe buy would take no tokens
OutOfReachAn exact-out amount the launch cannot reach
EVM reverts
decodeFloorError names a FloorAmm revert and its arguments.