@floorlaunchpad/sdk 0.3.1 → 0.4.0
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 +97 -0
- package/README.md +20 -5
- package/dist/abi/evm.gen.js +1 -1
- package/dist/abi/solana.gen.js +1 -1
- package/dist/client/evm/index.js +16 -2
- package/dist/client/solana/index.js +19 -7
- package/dist/config/generated.js +26864 -402
- package/dist/config/registry.gen.js +33 -2
- package/dist/evm/chains.js +9 -1
- package/dist/evm/floor/abi.gen.js +1 -1
- package/dist/evm/floor/events.js +9 -1
- package/dist/evm/floor/legacy-events.js +25 -0
- package/dist/indexer/bodies.js +106 -16
- package/dist/indexer/client.js +35 -12
- package/dist/indexer/contract.js +138 -28
- package/dist/indexer/partners.js +3 -2
- package/dist/indexer/paths.js +63 -25
- package/dist/indexer/read.js +38 -13
- package/dist/indexer/search.js +130 -0
- package/dist/indexer/stack-edge.js +35 -0
- package/dist/indexer/stream.js +70 -23
- package/dist/math/v2/split.js +11 -3
- package/dist/solana/floor/events.js +1 -1
- package/dist/solana/floor/genesis.js +9 -3
- package/dist/solana/floor/instructions.js +14 -5
- package/dist/solana/floor/registry.js +4 -0
- package/dist/v2/devbuy.js +15 -0
- package/dist/v2/solana.js +17 -2
- package/dist/v2/tx/solana.js +1 -1
- package/docs/bot.md +36 -1
- package/docs/cursor-pages.md +56 -0
- package/docs/floor-line.md +208 -34
- package/examples/floor-line.html +373 -76
- package/package.json +1 -1
- package/src/abi/evm.gen.ts +1 -1
- package/src/abi/solana.gen.ts +1 -1
- package/src/client/evm/index.ts +16 -2
- package/src/client/solana/index.ts +19 -7
- package/src/client/types.ts +1 -1
- package/src/config/generated.ts +26864 -402
- package/src/config/index.ts +9 -2
- package/src/config/registry.gen.ts +33 -2
- package/src/events/types.gen.ts +2 -1
- package/src/evm/chains.ts +9 -1
- package/src/evm/floor/abi.gen.ts +1 -1
- package/src/evm/floor/events.ts +11 -1
- package/src/evm/floor/legacy-events.ts +27 -0
- package/src/indexer/bodies.ts +117 -16
- package/src/indexer/client.ts +54 -26
- package/src/indexer/contract.ts +158 -30
- package/src/indexer/partners.ts +3 -2
- package/src/indexer/paths.ts +86 -25
- package/src/indexer/read.ts +44 -15
- package/src/indexer/search.ts +138 -0
- package/src/indexer/stack-edge.ts +46 -0
- package/src/indexer/stream.ts +78 -24
- package/src/math/v2/split.ts +11 -3
- package/src/solana/floor/events.ts +1 -1
- package/src/solana/floor/genesis.ts +8 -2
- package/src/solana/floor/instructions.ts +13 -5
- package/src/solana/floor/registry.ts +4 -0
- package/src/v2/devbuy.ts +33 -0
- package/src/v2/solana.ts +20 -3
- package/src/v2/tx/solana.ts +1 -1
package/docs/floor-line.md
CHANGED
|
@@ -1,66 +1,240 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Show the FLOOR on your UI
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
8
|
+
It is a request, not a requirement, and it is highly appreciated. It costs one field and one line.
|
|
6
9
|
|
|
7
|
-
|
|
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
|
-
|
|
14
|
+
## What we ask
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
**The minimum: two things.**
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
22
|
+
**Anything more is a bonus.** In rough order of how much it helps:
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
- The Max Loss: how far the price can fall to the floor, `1 − floor ÷ price` as a percentage before fees (`Max Loss 25%`), 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
|
-
|
|
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.maxLossPct` | The price now, and the Max Loss (1 − floor ÷ price, before fees) 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
|
-
|
|
119
|
+
If you draw candles from the FLOOR indexer, you need no second read: every candle of `readCandles(get, { launch, interval })`
|
|
120
|
+
carries `floorX64`, the floor at that bucket's close, in the same Q64.64 units. Draw one floor point per candle. It is
|
|
121
|
+
`null` where a bucket has none and absent from an indexer older than SDK 0.4.0, so fall back to the launch's own
|
|
122
|
+
`floorX64` then.
|
|
123
|
+
|
|
124
|
+
## Draw it
|
|
125
|
+
|
|
126
|
+
**The look.** A solid line, 2 px, FLOOR orange `#FF6A1A`, labelled `FLOOR`, with its value on the price axis in the same
|
|
127
|
+
colour. The price stays your usual colour; the floor line goes under it.
|
|
128
|
+
|
|
129
|
+
**The shape.** A step line: it holds its value between trades and steps up at a trade that lifts it. It never steps down
|
|
130
|
+
in quote terms. It starts at graduation; before that there is no point to draw.
|
|
131
|
+
|
|
132
|
+
**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
|
|
133
|
+
own: if the floor is far below the visible candles, pin a small `FLOOR` tag to the bottom edge of the chart instead.
|
|
28
134
|
|
|
29
|
-
|
|
135
|
+
**Market-cap mode.** If your chart can show market cap instead of price, multiply the floor by the same supply you
|
|
136
|
+
multiply the price by, so the line stays in the same place under the candles. Keep the label `FLOOR`. Do not call that
|
|
137
|
+
number a market cap of its own.
|
|
30
138
|
|
|
31
|
-
|
|
139
|
+
### Lightweight Charts (v5)
|
|
32
140
|
|
|
33
141
|
```js
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
142
|
+
import { createChart, CandlestickSeries, LineSeries, LineType } from "lightweight-charts";
|
|
143
|
+
|
|
144
|
+
const chart = createChart(el, { autoSize: true });
|
|
145
|
+
const candles = chart.addSeries(CandlestickSeries);
|
|
146
|
+
const floorLine = chart.addSeries(LineSeries, {
|
|
147
|
+
color: "#FF6A1A",
|
|
148
|
+
lineWidth: 2,
|
|
149
|
+
lineType: LineType.WithSteps, // holds between trades, steps up
|
|
150
|
+
title: "FLOOR",
|
|
151
|
+
priceLineVisible: false,
|
|
152
|
+
lastValueVisible: true,
|
|
153
|
+
crosshairMarkerVisible: false,
|
|
154
|
+
autoscaleInfoProvider: () => null, // the floor never stretches the price scale
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
candles.setData(ohlc); // your candles, oldest first
|
|
158
|
+
floorLine.setData(floorPoints); // [{ time, value }] from the trades, oldest first; none before graduation
|
|
159
|
+
|
|
160
|
+
// live: on each new trade
|
|
161
|
+
floorLine.update({ time: trade.time, value: trade.floorPriceQuote });
|
|
40
162
|
```
|
|
41
163
|
|
|
42
|
-
|
|
164
|
+
### TradingView Advanced Charts (the Charting Library)
|
|
43
165
|
|
|
44
|
-
|
|
166
|
+
The simplest version is a locked horizontal line at the current floor, moved when the floor moves:
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
const chart = widget.activeChart();
|
|
170
|
+
const id = await chart.createShape(
|
|
171
|
+
{ price: floor },
|
|
172
|
+
{
|
|
173
|
+
shape: "horizontal_line",
|
|
174
|
+
lock: true,
|
|
175
|
+
disableSelection: true,
|
|
176
|
+
disableSave: true,
|
|
177
|
+
text: "FLOOR",
|
|
178
|
+
overrides: { linecolor: "#FF6A1A", linewidth: 2, showLabel: true, textcolor: "#FF6A1A", showPrice: true },
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// when a trade lifts the floor
|
|
183
|
+
chart.getShapeById(id).setPoints([{ price: newFloor }]);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
For the full step history, add a custom indicator that plots the floor series from your own trade store, styled as
|
|
187
|
+
above.
|
|
188
|
+
|
|
189
|
+
### Your own canvas or SVG
|
|
190
|
+
|
|
191
|
+
Walk the trades oldest first. At each trade with a floor, draw a horizontal segment from the previous trade's time at the
|
|
192
|
+
previous floor, then a vertical step up to the new floor. The example page does exactly this in about fifteen lines
|
|
193
|
+
(`floorPath` in its script).
|
|
194
|
+
|
|
195
|
+
### The FLOOR price on the token page
|
|
196
|
+
|
|
197
|
+
```html
|
|
198
|
+
<div class="stat">
|
|
199
|
+
<span class="label">FLOOR</span>
|
|
200
|
+
<span class="value" style="color:#FF6A1A">$0.0189</span>
|
|
201
|
+
<span class="note">Max Loss 25%</span> <!-- bonus -->
|
|
202
|
+
</div>
|
|
203
|
+
```
|
|
45
204
|
|
|
46
|
-
|
|
205
|
+
Before graduation, show `FLOOR —` (or leave the stat out) and, if you like, `Bonding: no floor yet`.
|
|
47
206
|
|
|
48
|
-
|
|
207
|
+
## What to get right
|
|
49
208
|
|
|
50
|
-
**
|
|
209
|
+
**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
|
|
210
|
+
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
|
|
211
|
+
quote. Chart in quote units where you can; where you cannot, say which units the chart uses.
|
|
51
212
|
|
|
52
|
-
**
|
|
213
|
+
**Read it, do not derive it.** Do not compute the floor from the money in the program and a supply you hold. The supply
|
|
214
|
+
the program uses is the live supply, and burns change it. Take `floorPriceQuote`, `sqrtF` or `floorPriceNative` as the
|
|
215
|
+
program reports it.
|
|
53
216
|
|
|
54
|
-
**
|
|
217
|
+
**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
|
|
218
|
+
(the Tail), the price can rise faster than the floor, so floor ÷ price can fall while both rise. The floor itself does not
|
|
219
|
+
drop. A widening gap is how the design works, not a loss of backing; do not label it as one.
|
|
55
220
|
|
|
56
|
-
**
|
|
221
|
+
**Graduation is not a migration.** The first window (Bonding, one flat price) selling out is graduation. The launch stays on
|
|
222
|
+
the same program, with the same pair and address, and the floor starts. Keep drawing the line after graduation and in the
|
|
223
|
+
Tail, and do not look for the token on another venue.
|
|
57
224
|
|
|
58
|
-
**
|
|
225
|
+
**No floor, no line.** Draw nothing before graduation (`null` or `sqrtF = 0`), and hide the line if circulating supply
|
|
226
|
+
reads 0 (every token outside the program burned).
|
|
59
227
|
|
|
60
|
-
|
|
228
|
+
**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
|
|
229
|
+
not a promise about the market price, and the market price can sit far above it.
|
|
61
230
|
|
|
62
|
-
|
|
231
|
+
## Checklist
|
|
63
232
|
|
|
64
|
-
|
|
233
|
+
- [ ] The FLOOR price is on the token page, in the quote token or clearly marked as USD.
|
|
234
|
+
- [ ] The FLOOR line is on the chart: `#FF6A1A`, 2 px, a step line, labelled `FLOOR`, under the price.
|
|
235
|
+
- [ ] Nothing is drawn before graduation; `null` is never drawn as 0.
|
|
236
|
+
- [ ] The line keeps its history and keeps going after graduation.
|
|
237
|
+
- [ ] Market-cap mode scales the floor by the same supply as the price, or hides it.
|
|
238
|
+
- [ ] Optional: the Max Loss, a list column, a wallet row, an alert.
|
|
65
239
|
|
|
66
|
-
|
|
240
|
+
Shipped it, or stuck? Tell us at contact@floor.supply. We will check it with you and point FLOOR holders to your page.
|