@floorlaunchpad/sdk 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  All notable changes to `@floorlaunchpad/sdk`. The version follows semver; while the major number is 0, a minor bump may rename or remove an export and a patch bump never does.
4
4
 
5
+ ## 0.3.2
6
+
7
+ Added:
8
+
9
+ - Indexer: the route `GET /floor-amm/launches/<launch>/member-sold` (also under `/floor-amm/v2/`; `INDEXER_CONTRACT.memberSold`,
10
+ `indexerPath.memberSold`, reader `memberSold`, `readMemberSold`, decoder `MEMBER_SOLD` / `MEMBER_SOLD_ROW`, types
11
+ `MemberSoldBody` / `MemberSoldRow`): every sell by a wallet that held a Team Slot place at that moment, oldest first, as
12
+ `{ indexed, memberSold: [{ launch, member, place, amount, quoteOut, block, timestamp, tx, id }] }`; `place` the lowest place
13
+ the member held, `amount` the tokens sold in the SDK's 6-decimal token units, `quoteOut` the quote paid out in base units,
14
+ `id` `<block>:<txnIndex>:<eventIndex>`. Derived from the trades and the Team Slot; a member who moves the tokens to another
15
+ wallet before selling is not seen.
16
+ - Indexer: the route `GET /floor-amm/launches/<launch>/account` (also under `/floor-amm/v2/`; `INDEXER_CONTRACT.launchAccount`,
17
+ `indexerPath.launchAccount`, reader `launchAccount`, `readLaunchAccount`, decoder `LAUNCH_ACCOUNT`, type `LaunchAccountBody`,
18
+ helper `launchAccountBytes`): a launch's whole `LaunchV2` account read live from the node at the ask (Solana only; EVM answers
19
+ `unknown route`), as `{ indexed, launch, mint, slot, data }` with `slot` the RPC context slot and `data` the account bytes in
20
+ base64. `launchAccountBytes(body)` returns them as a `Uint8Array` (browser and Node) for `decodeLaunchV2`. An account that is
21
+ absent, not owned by the program or not a `LaunchV2` answers `unknown launch`; a failed node read is a 502.
22
+ - `v2Devbuy.memberSoldFromTrade` (with `MemberSold`, `TeamSeat`): the member sale of one v2 `Trade` against a launch's
23
+ Team Slot places, or null. The indexer serves the route above from it.
24
+
25
+ Changed:
26
+
27
+ - `FLOOR_AMM_FROM_BLOCK.hyperevm` (`evm/chains.ts`) is `50398055`, the block FloorAmm was deployed at on HyperEVM (chain 999),
28
+ no longer `null`. FloorAmm is now deployed on all seven EVM chains at `FLOOR_AMM_ADDRESS`
29
+ (`0xF10000bd05c2C01793C6d55F027346469683d225`).
30
+
31
+ No export removed or renamed, no signature changed.
32
+
5
33
  ## 0.3.1
6
34
 
7
35
  Added:
@@ -20,6 +48,9 @@ Added:
20
48
  - Indexer: the route `GET /floor-amm/holders/<token>` (`INDEXER_CONTRACT.tokenHolders`, reader `tokenHolders`): a token's
21
49
  holders, balance descending, `limit` 1..500 (default 100) and `offset`; balances in the SDK's 6-decimal token units on
22
50
  both chains.
51
+ - Indexer: the route `GET /floor-amm/handles/<handleId>/places` (`INDEXER_CONTRACT.handlePlaces`, reader `handlePlaces`,
52
+ `readHandlePlaces`, decoder `HANDLE_PLACES`): the Team Slot places a social handle holds now, bound to a wallet or not, as
53
+ `{ indexed, handle, places: [{ launch, place }] }`; `handleId` is 0x + 64 hex. `PathParam` gains `"handle"`.
23
54
  - Config: `FLOOR_AMM_FROM_BLOCK` (`evm/chains.ts`): the block each EVM chain's FloorAmm was deployed at, `null` where it is
24
55
  not deployed yet.
25
56
  - Docs: `docs/floor-line.md`, a request to integrators to draw the floor line, and `examples/floor-line.html`, a page that draws it from a run of the SDK's math (`examples/gen-floor-line.mjs` makes its data). The npm package ships the page, not the script.
package/README.md CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  The FLOOR Program in TypeScript. It holds the program's math (bit for bit with the Rust crate), quoting, account and event decoders, and transaction builders for Solana and for EVM chains. It has no dependencies and opens no connection: you pass in your own RPC, indexer `get` and send functions.
4
4
 
5
- > **A request: show the floor.** If you route or list FLOOR pools, please show the FLOOR line on the token's price chart and
6
- > the floor price somewhere on the token's page. That is the bare minimum we ask for; anything more is a bonus. It is
7
- > not a requirement, and it is highly appreciated. The field is `floorPriceNative`; the full guide is [docs/floor-line.md](docs/floor-line.md).
5
+ > **One ask: show the FLOOR.** If you chart, list, route or hold FLOOR tokens, please show the FLOOR line on the token's
6
+ > price chart and the FLOOR price on the token's page. That is the minimum we ask for; anything more is a bonus. It is not
7
+ > a requirement, and it is highly appreciated. The field is `floorPriceQuote` in the Partner API (or `sqrtF` on every
8
+ > trade event); the guide, with drop-in chart code, is [docs/floor-line.md](docs/floor-line.md).
8
9
 
9
10
  `npm install @floorlaunchpad/sdk`. Chain-scoped entries over it: `@floorlaunchpad/sdk-evm` and `@floorlaunchpad/sdk-solana`. Apache-2.0.
10
11
 
@@ -27,11 +28,11 @@ Node 22.18 or newer. The package ships compiled JavaScript in `dist/` with the t
27
28
  | A wallet | [docs/wallet.md](docs/wallet.md): decode what a transaction does, read errors, build a claim |
28
29
  | A bot or indexer | [docs/bot.md](docs/bot.md): read launches, follow the stream, decode logs |
29
30
  | A frontend | [docs/frontend.md](docs/frontend.md): the root entry, the indexer readers, the math for display |
30
- | An aggregator or chart that lists FLOOR pools | [docs/floor-line.md](docs/floor-line.md): draw the floor line (a request, not a requirement) |
31
+ | Anyone who shows a FLOOR token: chart, screener, terminal, wallet | [docs/floor-line.md](docs/floor-line.md): show the FLOOR line and the FLOOR price (the one ask) |
31
32
 
32
33
  ## Show the floor on your chart
33
34
 
34
- A launch's floor is the price the program's own money stands behind. Drawing it under the price line shows holders what backs them. [docs/floor-line.md](docs/floor-line.md) says which field to read, how to draw the line and what to watch for (units, burns, the gap between floor and price, graduation). [examples/floor-line.html](examples/floor-line.html) is a working page.
35
+ A launch's floor is the price the program's own money stands behind. Drawing it under the price line shows holders what backs them. [docs/floor-line.md](docs/floor-line.md) says what we ask, which field to read (the Partner API, a trade event or the SDK), how to draw the line in Lightweight Charts, TradingView or plain SVG, and what to watch for (units, burns, the gap between floor and price, graduation). [examples/floor-line.html](examples/floor-line.html) is a working token page with the line, the FLOOR price and every snippet.
35
36
 
36
37
  ## Versions
37
38
 
@@ -110,7 +110,7 @@ export const FLOOR_SALTS = {
110
110
  export const FLOOR_AMM_ADDRESS = "0xF10000bd05c2C01793C6d55F027346469683d225";
111
111
 
112
112
  export const FLOOR_AMM_FROM_BLOCK = {
113
- ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: null,
113
+ ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: 50398055,
114
114
  };
115
115
 
116
116
  const cat = (...h ) => "0x" + h.map((x) => bytesToHex(hexToBytes(x)).slice(2)).join("");
@@ -118,6 +118,8 @@ export const LISTED_LAUNCH = object({
118
118
  backedPpm: nullable(int),
119
119
  volume24hUsd: nullable(decimal),
120
120
  marketCapUsd: nullable(decimal),
121
+
122
+ trendingScore: nullable(big),
121
123
  });
122
124
 
123
125
  export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int });
@@ -245,6 +247,12 @@ export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM) });
245
247
 
246
248
  export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY) });
247
249
 
250
+ export const MEMBER_SOLD_ROW = object({ launch: str, member: str, place: int, amount: big, quoteOut: big, block: int, timestamp: int, tx: str, id: str });
251
+
252
+ export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW) });
253
+
254
+ export const LAUNCH_ACCOUNT = object({ indexed, launch: str, mint: str, slot: int, data: str });
255
+
248
256
  export const CANDLE_INTERVALS = ["1s", "5s", "1m", "5m", "15m", "1h", "4h", "1d"] ;
249
257
 
250
258
  export const CANDLE_INTERVAL_SECS = { "1s": 1, "5s": 5, "1m": 60, "5m": 300, "15m": 900, "1h": 3_600, "4h": 14_400, "1d": 86_400 };
@@ -455,11 +463,19 @@ export const ROLES = object({
455
463
  creatorOf: array(str),
456
464
  creatorRefOf: array(object({ launch: str, tier: int })),
457
465
  teamSlotOf: array(object({ launch: str, place: int })),
466
+
467
+ handleSlotOf: array(object({ launch: str, place: int, handle: str })),
458
468
  holdings: array(object({ launch: str, token: str, amount: big })),
459
469
  }),
460
470
  claimed: record(big),
461
471
  });
462
472
 
473
+ export const HANDLE_PLACES = object({
474
+ indexed,
475
+ handle: str,
476
+ places: array(object({ launch: str, place: int })),
477
+ });
478
+
463
479
  export const TRADER_BOARD = object({
464
480
  indexed,
465
481
  window: oneOf(...TRADER_WINDOWS),
@@ -28,6 +28,8 @@ export const routePath = {
28
28
  trades: ({ launch, ...q }) => indexerPath.trades(launch, q),
29
29
  launchClaims: ({ launch, ...q }) => indexerPath.launchClaims(launch, q),
30
30
  devBuys: (a) => indexerPath.devBuys(a.launch),
31
+ memberSold: (a) => indexerPath.memberSold(a.launch),
32
+ launchAccount: (a) => indexerPath.launchAccount(a.launch),
31
33
  traders: ({ launch, ...q }) => indexerPath.traders(launch, q),
32
34
  quoteChain: (a) => indexerPath.quoteChain(a.launch),
33
35
  devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
@@ -48,6 +50,7 @@ export const routePath = {
48
50
  claimView: (a) => indexerPath.claimView(a.wallet),
49
51
  people: (a) => indexerPath.people(a.wallet),
50
52
  roles: (a) => indexerPath.roles(a.wallet),
53
+ handlePlaces: (a) => indexerPath.handlePlaces(a.handle),
51
54
  traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
52
55
  launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
53
56
  tokenHolders: (a) => `/floor-amm/holders/${encodeURIComponent(need(a.token, "token"))}${query({ limit: a.limit, offset: a.offset })}`,
@@ -71,7 +71,7 @@ const LAUNCH_ERR = [...GATED, "unknown_launch"] ;
71
71
  const WALLET_ERR = [...GATED, "bad_query"] ;
72
72
 
73
73
  function site (s ) {
74
- const params = [...s.pattern.matchAll(/<(launch|wallet|token)>/g)].map((m) => m[1] );
74
+ const params = [...s.pattern.matchAll(/<(launch|wallet|token|handle)>/g)].map((m) => m[1] );
75
75
  const { v2, ...rest } = s;
76
76
  const aliases = s.aliases ?? (v2 ? [s.pattern.replace(/^\/floor-amm\//, "/floor-amm/v2/")] : []);
77
77
  return { mount: "chain", query: {}, page: NONE, errors: GATED, gated: true, units: "site", audience: "site", ...rest, params, aliases };
@@ -140,6 +140,10 @@ export const INDEXER_CONTRACT = {
140
140
  }),
141
141
  launchClaims: site({ pattern: "/floor-amm/launches/<launch>/claims", v2: true, query: { claimer: { kind: "string", doc: "only this claimer's rows" } }, errors: LAUNCH_ERR, body: B.LAUNCH_CLAIMS }),
142
142
  devBuys: site({ pattern: "/floor-amm/launches/<launch>/dev-buys", v2: true, errors: LAUNCH_ERR, body: B.DEV_BUYS }),
143
+
144
+ memberSold: site({ pattern: "/floor-amm/launches/<launch>/member-sold", v2: true, errors: LAUNCH_ERR, body: B.MEMBER_SOLD }),
145
+
146
+ launchAccount: site({ pattern: "/floor-amm/launches/<launch>/account", v2: true, errors: LAUNCH_ERR, body: B.LAUNCH_ACCOUNT }),
143
147
  traders: site({ pattern: "/floor-amm/launches/<launch>/traders", v2: true, query: { window: WINDOW, limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...LAUNCH_ERR, "bad_query"], body: B.LAUNCH_TRADERS }),
144
148
  quoteChain: site({ pattern: "/floor-amm/launches/<launch>/chain", v2: true, errors: LAUNCH_ERR, body: B.QUOTE_CHAIN }),
145
149
  devTrades: site({ pattern: "/floor-amm/launches/<launch>/dev", v2: true, query: { limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...LAUNCH_ERR, "bad_query"], body: B.DEV_TRADES }),
@@ -207,6 +211,8 @@ export const INDEXER_CONTRACT = {
207
211
  people: site({ pattern: "/floor-amm/referrals/<wallet>/people", errors: WALLET_ERR, body: B.PEOPLE }),
208
212
  roles: site({ pattern: "/floor-amm/roles/<wallet>", errors: WALLET_ERR, body: B.ROLES }),
209
213
 
214
+ handlePlaces: site({ pattern: "/floor-amm/handles/<handle>/places", errors: WALLET_ERR, body: B.HANDLE_PLACES }),
215
+
210
216
  traderBoard: site({ pattern: "/floor-amm/leaderboards/traders", v2: true, query: { window: WINDOW, limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...GATED, "bad_query"], body: B.TRADER_BOARD }),
211
217
  launcherBoard: site({ pattern: "/floor-amm/leaderboards/launchers", v2: true, query: { limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...GATED, "bad_query"], body: B.LAUNCHER_BOARD }),
212
218
 
@@ -257,7 +263,7 @@ export function matchRoute(path )
257
263
  const c = INDEXER_CONTRACT[name];
258
264
  for (const pat of [c.pattern, ...c.aliases]) {
259
265
  const keys = [];
260
- const re = new RegExp(`^${pat.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/<(launch|wallet|token)>/g, (_, k ) => (keys.push(k), "([^/]+)"))}$`);
266
+ const re = new RegExp(`^${pat.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/<(launch|wallet|token|handle)>/g, (_, k ) => (keys.push(k), "([^/]+)"))}$`);
261
267
  const m = re.exec(p);
262
268
  if (m === null) continue;
263
269
  const params = {};
@@ -16,6 +16,8 @@ export const INDEXER_ROUTES = {
16
16
  trades: { pattern: "/floor-amm/launches/<launch>/trades", keys: ["limit", "before", "traders"] },
17
17
  launchClaims: { pattern: "/floor-amm/launches/<launch>/claims", keys: ["claimer"] },
18
18
  devBuys: { pattern: "/floor-amm/launches/<launch>/dev-buys", keys: [] },
19
+ memberSold: { pattern: "/floor-amm/launches/<launch>/member-sold", keys: [] },
20
+ launchAccount: { pattern: "/floor-amm/launches/<launch>/account", keys: [] },
19
21
  traders: { pattern: "/floor-amm/launches/<launch>/traders", keys: ["window", "limit"] },
20
22
  quoteChain: { pattern: "/floor-amm/launches/<launch>/chain", keys: [] },
21
23
  devTrades: { pattern: "/floor-amm/launches/<launch>/dev", keys: ["limit"] },
@@ -36,6 +38,7 @@ export const INDEXER_ROUTES = {
36
38
  claimView: { pattern: "/floor-amm/claims/<wallet>", keys: [] },
37
39
  people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: [] },
38
40
  roles: { pattern: "/floor-amm/roles/<wallet>", keys: [] },
41
+ handlePlaces: { pattern: "/floor-amm/handles/<handle>/places", keys: [] },
39
42
  traderBoard: { pattern: "/floor-amm/leaderboards/traders", keys: ["window", "limit"] },
40
43
  launcherBoard: { pattern: "/floor-amm/leaderboards/launchers", keys: ["limit"] },
41
44
  } ;
@@ -93,6 +96,8 @@ export const indexerPath = {
93
96
  trades: (id , q = {}) => launchPath(id, `/trades${query({ limit: q.limit, before: q.before, traders: q.traders?.length ? q.traders : undefined })}`),
94
97
  launchClaims: (id , q = {}) => launchPath(id, `/claims${query({ claimer: q.claimer })}`),
95
98
  devBuys: (id ) => launchPath(id, "/dev-buys"),
99
+ memberSold: (id ) => launchPath(id, "/member-sold"),
100
+ launchAccount: (id ) => launchPath(id, "/account"),
96
101
  traders: (id , q = {}) => launchPath(id, `/traders${query({ window: q.window, limit: q.limit })}`),
97
102
  quoteChain: (id ) => launchPath(id, "/chain"),
98
103
  devTrades: (id , q = {}) => launchPath(id, `/dev${query({ limit: q.limit })}`),
@@ -122,6 +127,7 @@ export const indexerPath = {
122
127
  claimView: (w ) => `/floor-amm/claims/${seg(w)}`,
123
128
  people: (w ) => `/floor-amm/referrals/${seg(w)}/people`,
124
129
  roles: (w ) => `/floor-amm/roles/${seg(w)}`,
130
+ handlePlaces: (handle ) => `/floor-amm/handles/${seg(handle)}/places`,
125
131
  traderBoard: (q = {}) => `/floor-amm/leaderboards/traders${query({ window: q.window, limit: q.limit })}`,
126
132
  launcherBoard: (q = {}) => `/floor-amm/leaderboards/launchers${query({ limit: q.limit })}`,
127
133
  } ;
@@ -66,6 +66,17 @@ export const readTrades = (get , id , q = {})
66
66
  export const readLaunchClaims = (get , id , q = {}) => readRoute(get, indexerPath.launchClaims(id, q), B.LAUNCH_CLAIMS);
67
67
  export const readDevBuys = (get , id ) => readRoute(get, indexerPath.devBuys(id), B.DEV_BUYS);
68
68
 
69
+ export const readMemberSold = (get , id ) => readRoute(get, indexerPath.memberSold(id), B.MEMBER_SOLD);
70
+
71
+ export const readLaunchAccount = (get , id ) => readRoute(get, indexerPath.launchAccount(id), B.LAUNCH_ACCOUNT);
72
+
73
+ export function launchAccountBytes(body ) {
74
+ const bin = atob(body.data);
75
+ const out = new Uint8Array(bin.length);
76
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
77
+ return out;
78
+ }
79
+
69
80
  export const readTraders = (get , id , q = {}) => readRoute(get, indexerPath.traders(id, q), B.LAUNCH_TRADERS);
70
81
  export const readQuoteChain = (get , id ) => readRoute(get, indexerPath.quoteChain(id), B.QUOTE_CHAIN);
71
82
 
@@ -94,6 +105,8 @@ export const readFirstsMany = (get , wallets )
94
105
  export const readPeople = (get , wallet ) => readRoute(get, indexerPath.people(wallet), B.PEOPLE);
95
106
  export const readRoles = (get , wallet ) => readRoute(get, indexerPath.roles(wallet), B.ROLES);
96
107
 
108
+ export const readHandlePlaces = (get , handle ) => readRoute(get, indexerPath.handlePlaces(handle), B.HANDLE_PLACES);
109
+
97
110
  export const readTraderBoard = (get , q = {}) => readRoute(get, indexerPath.traderBoard(q), B.TRADER_BOARD);
98
111
  export const readLauncherBoard = (get , q = {}) => readRoute(get, indexerPath.launcherBoard(q), B.LAUNCHER_BOARD);
99
112
 
package/dist/v2/devbuy.js CHANGED
@@ -35,3 +35,18 @@ export function devBuyFromTrade(t , team , ctx
35
35
  }
36
36
 
37
37
  export const devBuyChangeSinceBps = (d , sqrtNow ) => impactBps(d.priceAfterX64, priceX64(sqrtNow));
38
+
39
+ export function memberSoldFromTrade(
40
+ t ,
41
+ seats ,
42
+ same = (a, b) => a === b,
43
+ ) {
44
+ if (t.isBuy) return null;
45
+ for (const who of t.recipient === undefined ? [t.trader] : [t.trader, t.recipient]) {
46
+ const held = seats.filter((s) => same(s.wallet, who));
47
+ if (held.length === 0) continue;
48
+ const seat = held.reduce((lo, s) => (s.place < lo.place ? s : lo));
49
+ return { launch: t.launch, member: seat.wallet, place: seat.place, amount: t.tokens, quoteOut: t.quoteNet, ...(t.slot === undefined ? {} : { slot: t.slot }) };
50
+ }
51
+ return null;
52
+ }
@@ -1,66 +1,235 @@
1
- # Drawing the floor line
1
+ # Show the FLOOR on your UI
2
2
 
3
- A FLOOR launch has a floor: a price in the quote token that the program's own money stands behind. The bare minimum we ask for is two things: the FLOOR line on the token's price chart, and the floor price somewhere on the token's page. Anything else is a bonus. It is a request, not a requirement, and it is highly appreciated. It costs one extra field and one extra line on the chart.
3
+ **If you list, chart, route or hold FLOOR tokens, please show the FLOOR.** Every FLOOR launch has a floor: a price in
4
+ its quote token that the program's own money stands behind, and that never falls. It is the single most useful number
5
+ a holder of a FLOOR token can see, and right now it is only visible on floor.supply. With your help it can be visible
6
+ wherever the token trades.
4
7
 
5
- [examples/floor-line.html](../examples/floor-line.html) is a working page: a price line, the floor line and the code that fetches and draws it. Open it in a browser.
8
+ It is a request, not a requirement, and it is highly appreciated. It costs one field and one line.
6
9
 
7
- ## What the floor is
10
+ [examples/floor-line.html](../examples/floor-line.html) shows the finished result: a token page with the FLOOR price next to
11
+ the price and the FLOOR line on the chart, a price / market-cap switch, a replay of a launch with a sell-off, and every
12
+ snippet on this page. Open it in a browser. It needs no network and no key.
8
13
 
9
- The program keeps money aside to buy tokens back at a fixed price. That price is the floor: the money in the floor pot divided by the tokens in circulation. A holder is backed by the floor the program's money holds. The floor is not a promise about the market price, and the market price can sit far above it.
14
+ ## What we ask
10
15
 
11
- Three facts shape the line:
16
+ **The minimum: two things.**
12
17
 
13
- - The floor is a price in the launch's quote token (USDC, SOL, ETH or another listed quote), per whole token.
14
- - It never falls in quote terms. Buys can lift it and sells do not lower it.
15
- - It starts when the launch graduates, which is when its flat-priced opening sale sells out. Before then the launch has no floor, and the field reads `0`.
18
+ 1. **The FLOOR line on the token's price chart.** One line, FLOOR orange `#FF6A1A`, 2 px, labelled `FLOOR`, under the
19
+ price.
20
+ 2. **The FLOOR price on the token's page,** next to the price. For example: `FLOOR $0.0189`.
16
21
 
17
- ## Which field to read
22
+ **Anything more is a bonus.** In rough order of how much it helps:
18
23
 
19
- **Partner API.** `GET /v2/dex/summary?id=<pair>` returns `floorPriceNative`, a decimal string in whole quote tokens per whole launch token, next to `priceNative` in the same units. The SDK decodes it as `DEX_SUMMARY` and builds the path as `dexSummary`. Read both fields from the same response so the two lines come from the same moment.
24
+ - How far the price is above the floor, as `% backed` (floor ÷ price) or `price is 1.33× the floor`.
25
+ - A FLOOR column in token lists and screeners.
26
+ - The FLOOR price in a wallet's holding row, next to the holding's value.
27
+ - An alert when the price comes near the floor.
28
+ - A "FLOOR" badge on launches that trade on the FLOOR program.
20
29
 
21
- **SDK, from the indexer.** `readLaunch(get, id)` in `@floorlaunchpad/sdk/indexer/read` returns the launch with `floorX64`. That is a Q64.64 price in quote base units per token math unit. One math unit is a millionth of a token on both chains. To get whole quote per whole token:
30
+ | You are | Show |
31
+ |---|---|
32
+ | A chart site or screener (DexScreener-style) | The line on the chart, the floor price in the pair's stats |
33
+ | A terminal or trading bot UI | The line on the chart, the floor price next to the buy and sell box |
34
+ | An aggregator or swap UI with a token page | The floor price on the token page; the line if you draw a chart |
35
+ | A wallet | The floor price on the token's detail screen |
36
+ | A data API that others build on | The floor as a field on the pair (and on each trade, if you serve trades) |
37
+
38
+ ## Get the number
39
+
40
+ There are three ways. Use the first one you can.
41
+
42
+ ### 1. The FLOOR Partner API (simplest)
43
+
44
+ Base URL `https://floor.supply/api/v1`. Server to server, with a key sent as `Authorization: Bearer <key>` (a key in the
45
+ URL is refused). Ask for a key at contact@floor.supply or on X. The reference is
46
+ <https://floor.supply/developers> and the OpenAPI document is `https://floor.supply/api/v1/openapi.json`. Every answer is
47
+ `{ data, meta }`.
48
+
49
+ | Read | Field | Gives |
50
+ |---|---|---|
51
+ | `GET /launches/{chain}/{token}` | `data.market.floorPriceQuote` | The floor now, whole quote per whole token |
52
+ | | `data.market.floorPriceUsd` | The same in USD at the live rate |
53
+ | | `data.market.priceQuote`, `data.market.backedPct` | The price now, and floor ÷ price as a percentage |
54
+ | `GET /launches/{chain}/{token}/trades` | `data[].floorPriceQuote` | The floor after each trade: the history of the line |
55
+
56
+ `null` means there is no floor yet (the launch is still in Bonding) or the figure was not read. Never draw a `null` as 0.
57
+
58
+ ```js
59
+ // server side: the FLOOR price for the token page
60
+ const r = await fetch(`https://floor.supply/api/v1/launches/${chain}/${token}`, {
61
+ headers: { Authorization: `Bearer ${process.env.FLOOR_API_KEY}` },
62
+ });
63
+ const { data } = await r.json();
64
+ const floor = data.market.floorPriceQuote; // null before graduation
65
+ const price = data.market.priceQuote;
66
+ ```
67
+
68
+ ```js
69
+ // server side: the history of the line, newest trade first (page with meta.nextBefore)
70
+ const t = await fetch(`https://floor.supply/api/v1/launches/${chain}/${token}/trades?limit=100`, {
71
+ headers: { Authorization: `Bearer ${process.env.FLOOR_API_KEY}` },
72
+ });
73
+ const { data: trades, meta } = await t.json();
74
+ const floorPoints = trades
75
+ .filter((x) => x.floorPriceQuote !== null)
76
+ .map((x) => ({ time: x.time, value: x.floorPriceQuote }))
77
+ .reverse(); // oldest first, for a chart
78
+ ```
79
+
80
+ ### 2. From the chain, if you index trades yourself
81
+
82
+ Every trade event carries the floor after the trade, as `sqrtF`:
83
+
84
+ | Chain | Event | Field |
85
+ |---|---|---|
86
+ | EVM | `Trade` on the `FloorAmm` contract | `sqrtF` (`uint128`) |
87
+ | Solana | `TradeV2` from `floor_amm` (an Anchor CPI event) | `sqrt_f` (`u128`) |
88
+
89
+ `sqrtF` is the square root of the floor price in fixed point, with 72 fraction bits. The floor in whole quote per whole
90
+ token is:
91
+
92
+ ```
93
+ floor = sqrtF² × 10^6 ÷ (2^144 × 10^quoteDecimals)
94
+ ```
95
+
96
+ `quoteDecimals` is the quote token's decimals (6 for USDC, 9 for SOL, 18 for ETH). The `10^6` is there because the
97
+ program counts tokens in millionths on both chains. `sqrtF` is `0` until the launch graduates: draw no line then.
98
+
99
+ ```js
100
+ const floorOf = (sqrtF, quoteDecimals) =>
101
+ Number((sqrtF * sqrtF * 10n ** 6n * 10n ** 12n) >> 144n) / 10 ** (quoteDecimals + 12);
102
+ ```
103
+
104
+ Keep the multiplications in `bigint` (or a 256-bit integer); `sqrtF²` does not fit in 128 bits. The `10n ** 12n` keeps
105
+ twelve more digits through the shift. This is exactly what the example page's generator checks against the SDK.
106
+
107
+ ### 3. With the SDK
108
+
109
+ `@floorlaunchpad/sdk` reads the same number from a decoded launch: `priceX64(book.sqrtF)` in
110
+ `@floorlaunchpad/sdk/math/v2/sqrt` gives a Q64.64 price in quote base units per millionth of a token. If you run the FLOOR
111
+ indexer, `readLaunch(get, id)` in `@floorlaunchpad/sdk/indexer/read` returns it as `floorX64`, and the indexer's
112
+ `/v2/dex/summary?id=<pair>` serves it as `floorPriceNative`, next to `priceNative` in the same units. To get whole quote
113
+ per whole token from a Q64.64 value:
22
114
 
23
115
  ```ts
24
116
  const floor = Number((floorX64 * 10n ** 6n * 10n ** 12n) / (1n << 64n)) / 10 ** (quoteDecimals + 12);
25
117
  ```
26
118
 
27
- **SDK, from the chain.** The math reads the same number from a decoded book: `priceX64(book.sqrtF)` (`@floorlaunchpad/sdk/math/v2/sqrt`). `sqrtF` is 0 until the launch has a floor. The example page's numbers come from this math (see the note at the end).
119
+ ## Draw it
120
+
121
+ **The look.** A solid line, 2 px, FLOOR orange `#FF6A1A`, labelled `FLOOR`, with its value on the price axis in the same
122
+ colour. The price stays your usual colour; the floor line goes under it.
123
+
124
+ **The shape.** A step line: it holds its value between trades and steps up at a trade that lifts it. It never steps down
125
+ in quote terms. It starts at graduation; before that there is no point to draw.
126
+
127
+ **The axis.** The same y axis and the same time axis as the price. Do not let the floor line widen the price scale on its
128
+ own: if the floor is far below the visible candles, pin a small `FLOOR` tag to the bottom edge of the chart instead.
28
129
 
29
- ## How to draw it
130
+ **Market-cap mode.** If your chart can show market cap instead of price, multiply the floor by the same supply you
131
+ multiply the price by, so the line stays in the same place under the candles. Keep the label `FLOOR`. Do not call that
132
+ number a market cap of its own.
30
133
 
31
- Draw a horizontal line at the floor value, under the price line, in FLOOR orange `#FF6A1A`, and label it "FLOOR". The line is a step line: it holds its value between trades and moves up at a trade that lifts it. If your chart already has a price line, use the same y axis and the same time axis.
134
+ ### Lightweight Charts (v5)
32
135
 
33
136
  ```js
34
- const s = await (await fetch(`${API}/v2/dex/summary?id=${pair}`)).json();
35
- const price = Number(s.priceNative);
36
- const floor = Number(s.floorPriceNative);
37
- const showFloor = floor > 0 && Number(s.circulatingSupply) > 0;
38
- series.price.update({ time, value: price });
39
- if (showFloor) series.floor.update({ time, value: floor });
137
+ import { createChart, CandlestickSeries, LineSeries, LineType } from "lightweight-charts";
138
+
139
+ const chart = createChart(el, { autoSize: true });
140
+ const candles = chart.addSeries(CandlestickSeries);
141
+ const floorLine = chart.addSeries(LineSeries, {
142
+ color: "#FF6A1A",
143
+ lineWidth: 2,
144
+ lineType: LineType.WithSteps, // holds between trades, steps up
145
+ title: "FLOOR",
146
+ priceLineVisible: false,
147
+ lastValueVisible: true,
148
+ crosshairMarkerVisible: false,
149
+ autoscaleInfoProvider: () => null, // the floor never stretches the price scale
150
+ });
151
+
152
+ candles.setData(ohlc); // your candles, oldest first
153
+ floorLine.setData(floorPoints); // [{ time, value }] from the trades, oldest first; none before graduation
154
+
155
+ // live: on each new trade
156
+ floorLine.update({ time: trade.time, value: trade.floorPriceQuote });
40
157
  ```
41
158
 
42
- ## Pitfalls
159
+ ### TradingView Advanced Charts (the Charting Library)
43
160
 
44
- **Units.** The floor is a price in the quote token. In quote terms it never falls. If you chart in USD, the line moves with the quote token's own USD price. A floor in a falling quote token then falls in dollars, though it has not fallen in the quote. Chart in quote units where you can, and say which units the chart uses where you cannot.
161
+ The simplest version is a locked horizontal line at the current floor, moved when the floor moves:
162
+
163
+ ```js
164
+ const chart = widget.activeChart();
165
+ const id = await chart.createShape(
166
+ { price: floor },
167
+ {
168
+ shape: "horizontal_line",
169
+ lock: true,
170
+ disableSelection: true,
171
+ disableSave: true,
172
+ text: "FLOOR",
173
+ overrides: { linecolor: "#FF6A1A", linewidth: 2, showLabel: true, textcolor: "#FF6A1A", showPrice: true },
174
+ },
175
+ );
176
+
177
+ // when a trade lifts the floor
178
+ chart.getShapeById(id).setPoints([{ price: newFloor }]);
179
+ ```
180
+
181
+ For the full step history, add a custom indicator that plots the floor series from your own trade store, styled as
182
+ above.
183
+
184
+ ### Your own canvas or SVG
185
+
186
+ Walk the trades oldest first. At each trade with a floor, draw a horizontal segment from the previous trade's time at the
187
+ previous floor, then a vertical step up to the new floor. The example page does exactly this in about fifteen lines
188
+ (`floorPath` in its script).
189
+
190
+ ### The FLOOR price on the token page
191
+
192
+ ```html
193
+ <div class="stat">
194
+ <span class="label">FLOOR</span>
195
+ <span class="value" style="color:#FF6A1A">$0.0189</span>
196
+ <span class="note">75% backed</span> <!-- bonus -->
197
+ </div>
198
+ ```
45
199
 
46
- **Read it, do not derive it.** Do not compute the floor from the money in the program and the total supply. The supply the program uses is the live supply, and it changes with every burn, including burns that happen with no trade. Take `floorPriceNative` as the program reports it.
200
+ Before graduation, show `FLOOR —` (or leave the stat out) and, if you like, `Bonding: no floor yet`.
47
201
 
48
- **The gap.** The floor divided by the price can fall as the price rises. This happens once the price is above the end of the launch's sales curve. It also happens in the Tail, the open-ended stretch after the curve ends. The price keeps rising in both, while the floor rises more slowly. The floor itself does not drop. A widening gap between the two lines is how the design works, not a bug in your chart. Do not label it as a loss of backing.
202
+ ## What to get right
49
203
 
50
- **Lifecycle.** Keep the line after graduation and in the Tail. A graduated launch stays on the same program, trades there as before and keeps its floor. Do not stop drawing the floor when the launch graduates, and do not look for it on another venue.
204
+ **Units.** The floor is a price in the quote token, and in quote terms it never falls. If you chart in USD, the line moves
205
+ with the quote token's own USD price: a floor in a falling quote token falls in dollars though it has not fallen in the
206
+ quote. Chart in quote units where you can; where you cannot, say which units the chart uses.
51
207
 
52
- **All tokens burned.** If every token in circulation has been burned, nothing is left to back and the program sends its backing money to the platform. There is no floor to show. Hide the line. Do not plot 0, and do not divide by a zero supply to work one out. A zero `circulatingSupply` in the summary is the signal.
208
+ **Read it, do not derive it.** Do not compute the floor from the money in the program and a supply you hold. The supply
209
+ the program uses is the live supply, and burns change it. Take `floorPriceQuote`, `sqrtF` or `floorPriceNative` as the
210
+ program reports it.
53
211
 
54
- **Before graduation.** A launch that has not graduated has no floor yet and the field reads `0`. Hide the line until it is above zero.
212
+ **The gap.** Once the price is past the end of the launch's sales curve (the Stack), and in the open-ended stretch after it
213
+ (the Tail), the price can rise faster than the floor, so floor ÷ price can fall while both rise. The floor itself does not
214
+ drop. A widening gap is how the design works, not a loss of backing; do not label it as one.
55
215
 
56
- **Caching.** Refresh the floor together with the price. If you cache the price for ten seconds, cache the floor for ten seconds with it, and never keep the floor longer than the price. A floor older than the price can look as if it has fallen behind.
216
+ **Graduation is not a migration.** The first window (Bonding, one flat price) selling out is graduation. The launch stays on
217
+ the same program, with the same pair and address, and the floor starts. Keep drawing the line after graduation and in the
218
+ Tail, and do not look for the token on another venue.
57
219
 
58
- **Words.** Never write that the floor is "guaranteed", and never call it a "floor market cap". Write "backed by the floor the program's money holds".
220
+ **No floor, no line.** Draw nothing before graduation (`null` or `sqrtF = 0`), and hide the line if circulating supply
221
+ reads 0 (every token outside the program burned).
59
222
 
60
- ## The example page
223
+ **Words.** Call it the "FLOOR" or the "floor price". It is what the program's money pays for a token sold into it. It is
224
+ not a promise about the market price, and the market price can sit far above it.
61
225
 
62
- `examples/floor-line.html` draws a simulated launch: a run of buys and sells through the SDK's own math, not a live pool. The source repository holds the small script that makes its data (`examples/gen-floor-line.mjs`), so the page can be rebuilt after a change to the math. The npm package ships the page and not the script.
226
+ ## Checklist
63
227
 
64
- ## Optional extras
228
+ - [ ] The FLOOR price is on the token page, in the quote token or clearly marked as USD.
229
+ - [ ] The FLOOR line is on the chart: `#FF6A1A`, 2 px, a step line, labelled `FLOOR`, under the price.
230
+ - [ ] Nothing is drawn before graduation; `null` is never drawn as 0.
231
+ - [ ] The line keeps its history and keeps going after graduation.
232
+ - [ ] Market-cap mode scales the floor by the same supply as the price, or hides it.
233
+ - [ ] Optional: `% backed`, a list column, a wallet row, an alert.
65
234
 
66
- None of these is asked for. If you want to go further: show the gap between price and floor as a percentage, add the floor to a tooltip or a table of pools, or link a holder to this guide's explanation of what backs the token.
235
+ Shipped it, or stuck? Tell us at contact@floor.supply. We will check it with you and point FLOOR holders to your page.