@floorlaunchpad/sdk 0.3.0 → 0.3.1

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.
@@ -21,7 +21,7 @@ function commit(dst , src ) {
21
21
  Object.assign(dst, src);
22
22
  }
23
23
 
24
- function buyOn(book , side , gross , minTokens , walkSteps ) {
24
+ function buyOn(book , side , gross , minTokens , walkSteps , keep = true) {
25
25
  const ppm = feesNow(book);
26
26
  const budget = netFromGross(gross, ppm);
27
27
  if (budget === 0n) fail("NothingToDo");
@@ -63,11 +63,11 @@ function buyOn(book , side , gross , minTokens , walkSte
63
63
  steps: walked.steps, budgetHit: walked.budgetHit, graduatedNow: walked.graduatedNow, sqrtBefore: book.sqrtP, sqrtAfter: w.sqrtP,
64
64
  split: sp, relay: rl,
65
65
  };
66
- commit(book, w);
66
+ if (keep) commit(book, w);
67
67
  return r;
68
68
  }
69
69
 
70
- function sellOn(book , side , tokens , minOut ) {
70
+ function sellOn(book , side , tokens , minOut , keep = true) {
71
71
  if (tokens === 0n) fail("NothingToDo");
72
72
  const ppm = feesNow(book);
73
73
  const w = cloneBook(book);
@@ -86,7 +86,7 @@ function sellOn(book , side , tokens , minOut )
86
86
  tokensIn: tokens, unfilled: tokens - walked.tokens, gross: walked.money, fees, out, steps: walked.steps, sqrtBefore: book.sqrtP, sqrtAfter: w.sqrtP,
87
87
  fromF: walked.fromF, fromK: walked.fromK, fromC: walked.fromC, relay: rl,
88
88
  };
89
- commit(book, w);
89
+ if (keep) commit(book, w);
90
90
  return r;
91
91
  }
92
92
 
@@ -99,8 +99,8 @@ export function sell(book , row , sup , tokens , min
99
99
  }
100
100
 
101
101
  export const quoteBuy = (book , row , sup , gross , walkSteps = MAX_WALK_STEPS) =>
102
- buy(cloneBook(book), row, sup, gross, 0n, { walkSteps });
103
- export const quoteSell = (book , row , sup , tokens ) => sell(cloneBook(book), row, sup, tokens, 0n);
102
+ buyOn(book, { row, sup }, gross, 0n, walkSteps, false);
103
+ export const quoteSell = (book , row , sup , tokens ) => sellOn(book, { row, sup }, tokens, 0n, false);
104
104
 
105
105
  export function buyMinTokens(b , row , sup , gross , slippageBps , walkSteps = MAX_WALK_STEPS) {
106
106
  const less = buyLessIn(gross, slippageBps);
@@ -122,5 +122,5 @@ export function bookSell(book , tokens , minOut ) {
122
122
  return sellOn(book, null, tokens, minOut);
123
123
  }
124
124
 
125
- export const quoteBookBuy = (book , gross , walkSteps = MAX_WALK_STEPS) => bookBuy(cloneBook(book), gross, 0n, walkSteps);
126
- export const quoteBookSell = (book , tokens ) => bookSell(cloneBook(book), tokens, 0n);
125
+ export const quoteBookBuy = (book , gross , walkSteps = MAX_WALK_STEPS) => buyOn(book, null, gross, 0n, walkSteps, false);
126
+ export const quoteBookSell = (book , tokens ) => sellOn(book, null, tokens, 0n, false);
@@ -122,7 +122,9 @@ export const GENESIS_RAISE = [
122
122
 
123
123
  ["preset_id", "u8"],
124
124
  ["opened", "u8"],
125
- ["pad1", "bytes:6"],
125
+
126
+ ["public_open", "u8"],
127
+ ["pad1", "bytes:5"],
126
128
  ["cap", "u64"],
127
129
  ["ends_at", "i64"],
128
130
  ["migrated_refunded", "u64"],
@@ -73,6 +73,10 @@ export const EVENTS = {
73
73
  BurnsSynced: S(["launch", "pubkey"], ["incinerated", "u64"], ["supply", "u64"], ["sOut", "u64"], ["floorAfterX64", "u128"], ["slot", "u64"]),
74
74
 
75
75
  TokensBurned: S(["launch", "pubkey"], ["wallet", "pubkey"], ["role", "u8"], ["place", "u8"], ["fromTeamBuy", "u64"], ["fromWallet", "u64"], ["balanceBefore", "u64"], ["owedAfter", "u64"], ["split", "u64[10]"], ["supply", "u64"], ["sOut", "u64"], ["floorAfterX64", "u128"], ["slot", "u64"], ["fromShareBought", "u64?"]),
76
+
77
+ GenesisPublicStarted: S(["signer", "pubkey"], ["at", "i64"]),
78
+
79
+ GenesisEndSet: S(["signer", "pubkey"], ["oldEndsAt", "i64"], ["newEndsAt", "i64"]),
76
80
  };
77
81
 
78
82
  export const SWEPT_BURN = 0;
@@ -253,6 +253,19 @@ export function setGenesisListRootInstruction(p
253
253
  return ix("set_genesis_list_root", [RS(p.authority), R(p.config), W(p.genesisRaise)], (w) => w.bytes(p.listRoot), p);
254
254
  }
255
255
 
256
+ export const GENESIS_NO_END = (1n << 63n) - 1n;
257
+
258
+ export function startGenesisPublicInstruction(p ) {
259
+ const g = pid(p);
260
+ return ix("start_genesis_public", [RS(p.authority), R(p.config ?? configPda(g)[0]), W(p.genesisRaise ?? genesisRaisePda(g)[0])], none, p);
261
+ }
262
+
263
+ export function setGenesisEndInstruction(p ) {
264
+ if (p.endsAt < 0n || p.endsAt > GENESIS_NO_END) throw new RangeError(`setGenesisEndInstruction: endsAt ${p.endsAt} is not an i64 ≥ 0`);
265
+ const g = pid(p);
266
+ return ix("set_genesis_end", [RS(p.authority), R(p.config ?? configPda(g)[0]), W(p.genesisRaise ?? genesisRaisePda(g)[0])], (w) => w.u64(p.endsAt), p);
267
+ }
268
+
256
269
  export function setGenesisPresetInstruction(p ) {
257
270
  return ix("set_genesis_preset", [RS(p.authority), R(p.config), W(p.genesisRaise), R(p.preset)], (w) => w.u8(p.presetId), p);
258
271
  }
@@ -0,0 +1,22 @@
1
+
2
+
3
+ export function isDustRefund(gross , refund , budgetHit ) {
4
+ return refund > 0n && !budgetHit && refund * 1_000_000n <= gross;
5
+ }
6
+
7
+ export function carriesNoRefund(gross , refund , budgetHit ) {
8
+ return refund === 0n || isDustRefund(gross, refund, budgetHit);
9
+ }
10
+
11
+ export const GAS_FLAT = { buy: 700_000, sell: 750_000 } ;
12
+
13
+ export const GAS_PER_STEP = { buy: 40_000, sell: 40_000 } ;
14
+
15
+ export const GAS_FLAT_STEPS = 4;
16
+
17
+ export const GAS_MAX = 1_500_000;
18
+
19
+ export function gasFor(side , steps ) {
20
+ const extra = Math.max(0, Math.trunc(steps) - GAS_FLAT_STEPS);
21
+ return Math.min(GAS_MAX, GAS_FLAT[side] + extra * GAS_PER_STEP[side]);
22
+ }
@@ -0,0 +1,66 @@
1
+ # Drawing the floor line
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.
4
+
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.
6
+
7
+ ## What the floor is
8
+
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.
10
+
11
+ Three facts shape the line:
12
+
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`.
16
+
17
+ ## Which field to read
18
+
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.
20
+
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:
22
+
23
+ ```ts
24
+ const floor = Number((floorX64 * 10n ** 6n * 10n ** 12n) / (1n << 64n)) / 10 ** (quoteDecimals + 12);
25
+ ```
26
+
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).
28
+
29
+ ## How to draw it
30
+
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.
32
+
33
+ ```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 });
40
+ ```
41
+
42
+ ## Pitfalls
43
+
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.
45
+
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.
47
+
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.
49
+
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.
51
+
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.
53
+
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.
55
+
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.
57
+
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".
59
+
60
+ ## The example page
61
+
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.
63
+
64
+ ## Optional extras
65
+
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.
@@ -0,0 +1,104 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>FLOOR line example</title>
7
+ <style>
8
+ :root { --bg:#000000; --panel:#101113; --text:#F4F5F7; --muted:#9AA3B2; --price:#8EA0BC; --floor:#FF6A1A; --grid:#23262B; }
9
+ * { box-sizing: border-box; }
10
+ body { margin:0; background:var(--bg); color:var(--text); font:15px/1.5 system-ui, sans-serif; }
11
+ main { max-width:1100px; margin:0 auto; padding:24px 16px 48px; }
12
+ h1 { font-size:20px; margin:0 0 4px; }
13
+ p.run { margin:0 0 16px; color:var(--muted); }
14
+ .grid { display:grid; grid-template-columns:minmax(0,3fr) minmax(0,2fr); gap:16px; }
15
+ @media (max-width:800px) { .grid { grid-template-columns:minmax(0,1fr); } }
16
+ .panel { background:var(--panel); border-radius:8px; padding:16px; min-width:0; }
17
+ .legend { display:flex; gap:16px; margin-bottom:8px; flex-wrap:wrap; }
18
+ .legend span::before { content:""; display:inline-block; width:18px; height:3px; margin-right:6px; vertical-align:middle; background:currentColor; }
19
+ .legend .p { color:var(--price); } .legend .f { color:var(--floor); }
20
+ svg { width:100%; height:auto; display:block; }
21
+ pre { margin:0; overflow:auto; font:13px/1.5 ui-monospace, Menlo, monospace; white-space:pre; }
22
+ h2 { font-size:15px; margin:0 0 8px; }
23
+ .read { margin-top:8px; color:var(--muted); min-height:1.5em; }
24
+ .read b { color:var(--text); font-weight:600; }
25
+ input[type=range] { width:100%; }
26
+ </style>
27
+ </head>
28
+ <body>
29
+ <main>
30
+ <h1>Drawing the floor line</h1>
31
+ <p class="run" id="run"></p>
32
+ <div class="grid">
33
+ <div class="panel">
34
+ <div class="legend"><span class="p">Price</span><span class="f">FLOOR</span></div>
35
+ <svg id="chart" viewBox="0 0 640 360" role="img" aria-label="Price and floor line over the run"></svg>
36
+ <input id="at" type="range" min="0" value="0" aria-label="Move through the run">
37
+ <div class="read" id="read"></div>
38
+ </div>
39
+ <div class="panel">
40
+ <h2>The code that draws it</h2>
41
+ <pre>// one fetch gives price and floor together
42
+ const s = await (await fetch(
43
+ `${API}/v2/dex/summary?id=${pair}`)).json();
44
+ const price = Number(s.priceNative);
45
+ const floor = Number(s.floorPriceNative);
46
+
47
+ // hide the floor until the launch has one,
48
+ // and when every token has been burned
49
+ const hasFloor = floor &gt; 0 &amp;&amp;
50
+ Number(s.circulatingSupply) &gt; 0;
51
+
52
+ priceLine.push({ time, value: price });
53
+ if (hasFloor) {
54
+ floorLine.push({ time, value: floor });
55
+ }
56
+ // draw floorLine under priceLine:
57
+ // colour #FF6A1A, label "FLOOR"</pre>
58
+ </div>
59
+ </div>
60
+ </main>
61
+ <script>
62
+ const DATA = /*DATA*/{"run":"A simulated launch with a USDC quote at $1: 64 buys, then 6 small sells","quoteDecimals":6,"series":[{"i":0,"price":0.01,"floor":null,"graduated":false,"side":"open"},{"i":1,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":2,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":3,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":4,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":5,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":6,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":7,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":8,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":9,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":10,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":11,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":12,"price":0.01,"floor":null,"graduated":false,"side":"buy"},{"i":13,"price":0.01022274,"floor":0.01,"graduated":true,"side":"buy"},{"i":14,"price":0.01045981,"floor":0.01,"graduated":true,"side":"buy"},{"i":15,"price":0.01069961,"floor":0.01,"graduated":true,"side":"buy"},{"i":16,"price":0.01092692,"floor":0.01,"graduated":true,"side":"buy"},{"i":17,"price":0.01110845,"floor":0.01,"graduated":true,"side":"buy"},{"i":18,"price":0.0112915,"floor":0.01,"graduated":true,"side":"buy"},{"i":19,"price":0.01147605,"floor":0.01,"graduated":true,"side":"buy"},{"i":20,"price":0.0116621,"floor":0.01,"graduated":true,"side":"buy"},{"i":21,"price":0.01184832,"floor":0.01,"graduated":true,"side":"buy"},{"i":22,"price":0.0119884,"floor":0.01,"graduated":true,"side":"buy"},{"i":23,"price":0.01212932,"floor":0.01,"graduated":true,"side":"buy"},{"i":24,"price":0.01227106,"floor":0.01,"graduated":true,"side":"buy"},{"i":25,"price":0.01284634,"floor":0.01,"graduated":true,"side":"buy"},{"i":26,"price":0.01329322,"floor":0.01,"graduated":true,"side":"buy"},{"i":27,"price":0.01373598,"floor":0.01030198,"graduated":true,"side":"buy"},{"i":28,"price":0.01414542,"floor":0.01060907,"graduated":true,"side":"buy"},{"i":29,"price":0.01448348,"floor":0.01086261,"graduated":true,"side":"buy"},{"i":30,"price":0.01482555,"floor":0.01111917,"graduated":true,"side":"buy"},{"i":31,"price":0.01517165,"floor":0.01137874,"graduated":true,"side":"buy"},{"i":32,"price":0.01545607,"floor":0.01159206,"graduated":true,"side":"buy"},{"i":33,"price":0.0157178,"floor":0.01178835,"graduated":true,"side":"buy"},{"i":34,"price":0.01598174,"floor":0.01198631,"graduated":true,"side":"buy"},{"i":35,"price":0.01624789,"floor":0.01218592,"graduated":true,"side":"buy"},{"i":36,"price":0.01651626,"floor":0.0123872,"graduated":true,"side":"buy"},{"i":37,"price":0.01674282,"floor":0.01255712,"graduated":true,"side":"buy"},{"i":38,"price":0.01694468,"floor":0.01270851,"graduated":true,"side":"buy"},{"i":39,"price":0.01714776,"floor":0.01286082,"graduated":true,"side":"buy"},{"i":40,"price":0.01735205,"floor":0.01301404,"graduated":true,"side":"buy"},{"i":41,"price":0.01755756,"floor":0.01316817,"graduated":true,"side":"buy"},{"i":42,"price":0.01776429,"floor":0.01332322,"graduated":true,"side":"buy"},{"i":43,"price":0.01797224,"floor":0.01347918,"graduated":true,"side":"buy"},{"i":44,"price":0.01815632,"floor":0.01361724,"graduated":true,"side":"buy"},{"i":45,"price":0.01831214,"floor":0.01373411,"graduated":true,"side":"buy"},{"i":46,"price":0.01846863,"floor":0.01385147,"graduated":true,"side":"buy"},{"i":47,"price":0.0186258,"floor":0.01396935,"graduated":true,"side":"buy"},{"i":48,"price":0.01878363,"floor":0.01408772,"graduated":true,"side":"buy"},{"i":49,"price":0.01926116,"floor":0.01444587,"graduated":true,"side":"buy"},{"i":50,"price":0.01972843,"floor":0.01479632,"graduated":true,"side":"buy"},{"i":51,"price":0.02009085,"floor":0.01506814,"graduated":true,"side":"buy"},{"i":52,"price":0.0204566,"floor":0.01534245,"graduated":true,"side":"buy"},{"i":53,"price":0.02082566,"floor":0.01561925,"graduated":true,"side":"buy"},{"i":54,"price":0.02119805,"floor":0.01589854,"graduated":true,"side":"buy"},{"i":55,"price":0.02153399,"floor":0.01615049,"graduated":true,"side":"buy"},{"i":56,"price":0.02181455,"floor":0.01636091,"graduated":true,"side":"buy"},{"i":57,"price":0.02209694,"floor":0.0165727,"graduated":true,"side":"buy"},{"i":58,"price":0.02238115,"floor":0.01678586,"graduated":true,"side":"buy"},{"i":59,"price":0.0226672,"floor":0.0170004,"graduated":true,"side":"buy"},{"i":60,"price":0.02295507,"floor":0.0172163,"graduated":true,"side":"buy"},{"i":61,"price":0.02324477,"floor":0.01743358,"graduated":true,"side":"buy"},{"i":62,"price":0.02347823,"floor":0.01760867,"graduated":true,"side":"buy"},{"i":63,"price":0.02369538,"floor":0.01777153,"graduated":true,"side":"buy"},{"i":64,"price":0.02391353,"floor":0.01793515,"graduated":true,"side":"buy"},{"i":65,"price":0.02389484,"floor":0.01793515,"graduated":true,"side":"sell"},{"i":66,"price":0.02387622,"floor":0.01793515,"graduated":true,"side":"sell"},{"i":67,"price":0.02385767,"floor":0.01793515,"graduated":true,"side":"sell"},{"i":68,"price":0.02383919,"floor":0.01793515,"graduated":true,"side":"sell"},{"i":69,"price":0.02382078,"floor":0.01793515,"graduated":true,"side":"sell"},{"i":70,"price":0.02380243,"floor":0.01793515,"graduated":true,"side":"sell"}]}/*END*/;
63
+ const W = 640, H = 360, L = 52, R = 12, T = 12, B = 28;
64
+ const pts = DATA.series;
65
+ const max = Math.max(...pts.map((p) => p.price)) * 1.05;
66
+ const min = Math.min(...pts.map((p) => p.floor ?? p.price)) * 0.95;
67
+ const x = (i) => L + (i / (pts.length - 1)) * (W - L - R);
68
+ const y = (v) => T + (1 - (v - min) / (max - min)) * (H - T - B);
69
+ const NS = "http://www.w3.org/2000/svg";
70
+ const svg = document.getElementById("chart");
71
+ const el = (tag, attrs, text) => { const e = document.createElementNS(NS, tag); for (const k in attrs) e.setAttribute(k, attrs[k]); if (text) e.textContent = text; svg.appendChild(e); return e; };
72
+ document.getElementById("run").textContent = DATA.run + ". The numbers come from the SDK's own math, not from a live pool.";
73
+
74
+ for (let k = 0; k <= 4; k++) {
75
+ const v = min + ((max - min) * k) / 4;
76
+ el("line", { x1: L, x2: W - R, y1: y(v), y2: y(v), stroke: "#23262B" });
77
+ el("text", { x: L - 6, y: y(v) + 4, "text-anchor": "end", fill: "#9AA3B2", "font-size": 11 }, v.toFixed(4));
78
+ }
79
+ el("text", { x: L, y: H - 6, fill: "#9AA3B2", "font-size": 11 }, "trades, in order");
80
+ // the price line, then the floor line under it (a step line: it holds between trades)
81
+ const priceD = pts.map((p, i) => `${i ? "L" : "M"}${x(i)},${y(p.price)}`).join("");
82
+ let floorD = "", pen = false, prev = null;
83
+ pts.forEach((p, i) => {
84
+ if (p.floor === null) { pen = false; return; }
85
+ floorD += pen ? `L${x(i)},${y(prev)}L${x(i)},${y(p.floor)}` : `M${x(i)},${y(p.floor)}`;
86
+ pen = true; prev = p.floor;
87
+ });
88
+ el("path", { d: priceD, fill: "none", stroke: "#8EA0BC", "stroke-width": 2 });
89
+ el("path", { d: floorD, fill: "none", stroke: "#FF6A1A", "stroke-width": 2 });
90
+ const last = pts[pts.length - 1];
91
+ el("text", { x: W - R - 4, y: y(last.floor) + 16, "text-anchor": "end", fill: "#FF6A1A", "font-size": 12 }, "FLOOR");
92
+ const mark = el("line", { y1: T, y2: H - B, stroke: "#F4F5F7", "stroke-opacity": 0.4 });
93
+
94
+ const at = document.getElementById("at"), read = document.getElementById("read");
95
+ at.max = pts.length - 1; at.value = pts.length - 1;
96
+ function show() {
97
+ const p = pts[+at.value];
98
+ mark.setAttribute("x1", x(+at.value)); mark.setAttribute("x2", x(+at.value));
99
+ read.innerHTML = `Trade ${p.i} (${p.side}): price <b>${p.price}</b>, ` + (p.floor === null ? "no floor yet (the launch has not graduated)" : `floor <b>${p.floor}</b>, ${(100 * p.floor / p.price).toFixed(1)}% of the price`) + ", in USDC per token.";
100
+ }
101
+ at.addEventListener("input", show); show();
102
+ </script>
103
+ </body>
104
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floorlaunchpad/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The FLOOR Program in TypeScript: the math, the quoter, decoders, PDAs and instruction builders for Solana and EVM",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -12,6 +12,7 @@
12
12
  "dist",
13
13
  "src/**/*.ts",
14
14
  "docs",
15
+ "examples",
15
16
  "CHANGELOG.md"
16
17
  ],
17
18
  "exports": {
@@ -54,6 +54,8 @@ export const SOLANA_EVENT_SCHEMAS: readonly SolanaEventSchema[] = [
54
54
  { name: "GenesisListRootSet", discriminator: "85037264ea1a3265", source: "v1", fields: [["signer","pubkey"],["oldRoot","bytes:32"],["newRoot","bytes:32"]] },
55
55
  { name: "BurnsSynced", discriminator: "cfb2d288fed64590", source: "v1", fields: [["launch","pubkey"],["incinerated","u64"],["supply","u64"],["sOut","u64"],["floorAfterX64","u128"],["slot","u64"]] },
56
56
  { name: "TokensBurned", discriminator: "e6ff2271e235e309", source: "v1", fields: [["launch","pubkey"],["wallet","pubkey"],["role","u8"],["place","u8"],["fromTeamBuy","u64"],["fromWallet","u64"],["balanceBefore","u64"],["owedAfter","u64"],["split","u64[10]"],["supply","u64"],["sOut","u64"],["floorAfterX64","u128"],["slot","u64"],["fromShareBought","u64?"]] },
57
+ { name: "GenesisPublicStarted", discriminator: "0f963d81be5c82af", source: "v1", fields: [["signer","pubkey"],["at","i64"]] },
58
+ { name: "GenesisEndSet", discriminator: "2fc250f230dedba2", source: "v1", fields: [["signer","pubkey"],["oldEndsAt","i64"],["newEndsAt","i64"]] },
57
59
  { name: "LaunchCreatedV2", discriminator: "4c0e9eb9ef6b568e", source: "v2", fields: [["launch","pubkey"],["mint","pubkey"],["quoteMint","pubkey"],["creator","pubkey"],["id","u64"],["presetId","u8"],["presetVersion","u32"],["presetHash","bytes:32"],["p0X64","u128"],["raise","u64"],["windowTokens","u64"],["creatorBuyTokens","u64"],["createFee","u64"],["name","bytes:32"],["symbol","bytes:10"],["slot","u64"],["ts","i64"],["listed","bool"],["quoteUsdCentsX64","u128"],["nativeCreateFee","u64"],["rowVersion","u8"],["sqrtP0","u128"]] },
58
60
  { name: "Trade", discriminator: "18feda98fd2b1251", source: "v2", fields: [["launch","pubkey"],["trader","pubkey"],["isBuy","bool"],["quoteGross","u64"],["quoteNet","u64"],["refund","u64"],["tokens","u64"],["fees","u64[5]"],["traderRef","u64"],["fromResale","u64"],["fromFirst","u64"],["unfilled","u64"],["sqrtBefore","u128"],["sqrtAfter","u128"],["sqrtF","u128"],["floor","u64"],["cushion","u64"],["sCirc","u64"],["steps","u8"],["budgetHit","bool"],["slot","u64"],["ts","i64"],["kind","u8"],["creatorRef","u64"],["recipient","pubkey"],["bidMoney","u64"],["msPaid","u64[4]"]] },
59
61
  { name: "HolderPositionOpened", discriminator: "86a0f22128a8ddac", source: "v2", fields: [["launch","pubkey"],["owner","pubkey"],["amount","u64"]] },