@floorlaunchpad/sdk 0.1.1 → 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.
Files changed (298) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/LICENSE +201 -60
  3. package/README.md +54 -24
  4. package/dist/abi/evm-event-names.js +12 -0
  5. package/dist/abi/evm.gen.js +130 -0
  6. package/dist/abi/functions.gen.js +144 -0
  7. package/dist/abi/index.js +17 -0
  8. package/dist/abi/solana.gen.js +130 -0
  9. package/dist/burn.js +21 -0
  10. package/dist/client/evm/index.js +191 -0
  11. package/dist/client/index.js +19 -0
  12. package/dist/client/solana/index.js +259 -0
  13. package/dist/client/types.js +5 -0
  14. package/dist/codec.js +77 -0
  15. package/dist/config/codeHash.js +9 -0
  16. package/dist/config/generated.js +803 -0
  17. package/dist/config/index.js +49 -0
  18. package/dist/config/registry.gen.js +118 -0
  19. package/dist/config/solana-genesis.js +7 -0
  20. package/dist/ed25519.js +31 -0
  21. package/dist/errors.js +249 -0
  22. package/dist/events/index.js +40 -0
  23. package/dist/events/types.gen.js +3 -0
  24. package/dist/evm/abi.js +283 -0
  25. package/dist/evm/balances.js +26 -0
  26. package/dist/evm/chains.js +148 -0
  27. package/dist/evm/floor/abi.gen.js +195 -0
  28. package/dist/evm/floor/calls.js +230 -0
  29. package/dist/evm/floor/create.js +49 -0
  30. package/dist/evm/floor/events.js +41 -0
  31. package/dist/evm/floor/iface.js +44 -0
  32. package/dist/evm/items.js +209 -0
  33. package/dist/evm/keccak.js +118 -0
  34. package/dist/evm/multicall.js +30 -0
  35. package/dist/evm/router.js +184 -0
  36. package/dist/evm/squid.js +107 -0
  37. package/dist/evm/zap.js +128 -0
  38. package/dist/fixtures.js +53 -0
  39. package/dist/generated/index.js +28 -0
  40. package/dist/generated/interface.gen.js +146 -0
  41. package/dist/handle.js +22 -0
  42. package/dist/index.js +93 -7
  43. package/dist/indexer/bodies.js +473 -0
  44. package/dist/indexer/client.js +105 -0
  45. package/dist/indexer/contract.js +358 -0
  46. package/dist/indexer/decode.js +97 -0
  47. package/dist/indexer/partners.js +105 -0
  48. package/dist/indexer/paths.js +127 -0
  49. package/dist/indexer/read.js +109 -0
  50. package/dist/indexer/stream.js +71 -0
  51. package/dist/lock.js +16 -0
  52. package/dist/math/fixed.js +154 -0
  53. package/dist/math/genesis.js +39 -0
  54. package/dist/math/index.js +20 -0
  55. package/dist/math/u256.js +49 -0
  56. package/dist/math/v2/ask.js +162 -0
  57. package/dist/math/v2/book.js +607 -0
  58. package/dist/math/v2/circulating.js +62 -0
  59. package/dist/math/v2/create.js +122 -0
  60. package/dist/math/v2/display.js +208 -0
  61. package/dist/math/v2/error.js +17 -0
  62. package/dist/math/v2/feasibility.js +174 -0
  63. package/dist/math/v2/fees.js +121 -0
  64. package/dist/math/v2/holders.js +105 -0
  65. package/dist/math/v2/milestones.js +40 -0
  66. package/dist/math/v2/pow.js +69 -0
  67. package/dist/math/v2/preset.js +151 -0
  68. package/dist/math/v2/receipt.js +108 -0
  69. package/dist/math/v2/relay.js +217 -0
  70. package/dist/math/v2/rows.js +365 -0
  71. package/dist/math/v2/split.js +111 -0
  72. package/dist/math/v2/sqrt.js +84 -0
  73. package/dist/math/v2/supply.js +21 -0
  74. package/dist/math/v2/team.js +75 -0
  75. package/dist/math/v2/trade.js +126 -0
  76. package/dist/math/v2/wide.js +51 -0
  77. package/dist/quote.js +6 -0
  78. package/dist/registryPrice.js +23 -0
  79. package/dist/route/edge-jupiter.js +42 -0
  80. package/dist/route/edge.js +11 -0
  81. package/dist/route/graph.js +51 -0
  82. package/dist/route/path.js +75 -0
  83. package/dist/route/quote.js +15 -0
  84. package/dist/route-jupiter.js +35 -0
  85. package/dist/route.js +8 -0
  86. package/dist/sha256.js +61 -0
  87. package/dist/solana/alt.js +18 -0
  88. package/dist/solana/floor/accounts.js +392 -0
  89. package/dist/solana/floor/borsh.js +66 -0
  90. package/dist/solana/floor/create.js +65 -0
  91. package/dist/solana/floor/events.js +144 -0
  92. package/dist/solana/floor/genesis.js +91 -0
  93. package/dist/solana/floor/genesisList.js +68 -0
  94. package/dist/solana/floor/instructions.js +448 -0
  95. package/dist/solana/floor/metadata.js +198 -0
  96. package/dist/solana/floor/mint.js +206 -0
  97. package/dist/solana/floor/program.js +64 -0
  98. package/dist/solana/floor/registry.js +83 -0
  99. package/dist/solana/instruction.js +49 -0
  100. package/dist/solana/pda.js +88 -0
  101. package/dist/solana/tx.js +138 -0
  102. package/dist/v2/burnPreview.js +35 -0
  103. package/dist/v2/circulating.js +11 -0
  104. package/dist/v2/claimAllEvm.js +70 -0
  105. package/dist/v2/claims-evm.js +120 -0
  106. package/dist/v2/claims.js +218 -0
  107. package/dist/v2/dead.js +21 -0
  108. package/dist/v2/devbuy.js +37 -0
  109. package/dist/v2/events.js +115 -0
  110. package/dist/v2/evm.js +299 -0
  111. package/dist/v2/evmReads.js +76 -0
  112. package/dist/v2/genesis.js +76 -0
  113. package/dist/v2/layouts.js +217 -0
  114. package/dist/v2/market-evm.js +74 -0
  115. package/dist/v2/presetRowEvm.js +45 -0
  116. package/dist/v2/press.js +106 -0
  117. package/dist/v2/quoteMint.js +52 -0
  118. package/dist/v2/receipt-tx.js +149 -0
  119. package/dist/v2/route-alt.js +114 -0
  120. package/dist/v2/route.js +389 -0
  121. package/dist/v2/router.js +22 -0
  122. package/dist/v2/solana.js +391 -0
  123. package/dist/v2/solanaSettle.js +97 -0
  124. package/dist/v2/tx/evm.js +126 -0
  125. package/dist/v2/tx/genesis.js +47 -0
  126. package/dist/v2/tx/index.js +5 -0
  127. package/dist/v2/tx/solana.js +118 -0
  128. package/dist/v2/types.js +13 -0
  129. package/docs/aggregator.md +61 -0
  130. package/docs/bot.md +50 -0
  131. package/docs/floor-line.md +66 -0
  132. package/docs/frontend.md +29 -0
  133. package/docs/wallet.md +54 -0
  134. package/examples/floor-line.html +104 -0
  135. package/package.json +429 -32
  136. package/src/abi/evm-event-names.ts +12 -0
  137. package/src/abi/evm.gen.ts +139 -0
  138. package/src/abi/functions.gen.ts +154 -0
  139. package/src/abi/index.ts +30 -0
  140. package/src/abi/solana.gen.ts +140 -0
  141. package/src/burn.ts +37 -0
  142. package/src/client/evm/index.ts +199 -0
  143. package/src/client/index.ts +23 -0
  144. package/src/client/solana/index.ts +260 -0
  145. package/src/client/types.ts +162 -0
  146. package/src/codec.ts +77 -0
  147. package/src/config/codeHash.ts +9 -0
  148. package/src/config/generated.ts +803 -0
  149. package/src/config/index.ts +93 -0
  150. package/src/config/registry.gen.ts +118 -0
  151. package/src/config/solana-genesis.ts +7 -0
  152. package/src/ed25519.ts +31 -0
  153. package/src/errors.ts +270 -0
  154. package/src/events/index.ts +44 -0
  155. package/src/events/types.gen.ts +842 -0
  156. package/src/evm/abi.ts +292 -0
  157. package/src/evm/balances.ts +26 -0
  158. package/src/evm/chains.ts +171 -0
  159. package/src/evm/floor/abi.gen.ts +195 -0
  160. package/src/evm/floor/calls.ts +247 -0
  161. package/src/evm/floor/create.ts +68 -0
  162. package/src/evm/floor/events.ts +51 -0
  163. package/src/evm/floor/iface.ts +45 -0
  164. package/src/evm/items.ts +252 -0
  165. package/src/evm/keccak.ts +118 -0
  166. package/src/evm/multicall.ts +43 -0
  167. package/src/evm/router.ts +209 -0
  168. package/src/evm/squid.ts +138 -0
  169. package/src/evm/zap.ts +152 -0
  170. package/src/fixtures.ts +53 -0
  171. package/src/generated/index.ts +29 -0
  172. package/src/generated/interface.gen.ts +153 -0
  173. package/src/handle.ts +22 -0
  174. package/src/index.ts +93 -6
  175. package/src/indexer/bodies.ts +528 -0
  176. package/src/indexer/client.ts +180 -0
  177. package/src/indexer/contract.ts +419 -0
  178. package/src/indexer/decode.ts +109 -0
  179. package/src/indexer/partners.ts +115 -0
  180. package/src/indexer/paths.ts +190 -0
  181. package/src/indexer/read.ts +119 -0
  182. package/src/indexer/stream.ts +83 -0
  183. package/src/lock.ts +16 -0
  184. package/src/math/fixed.ts +154 -0
  185. package/src/math/genesis.ts +39 -0
  186. package/src/math/index.ts +24 -0
  187. package/src/math/u256.ts +49 -0
  188. package/src/math/v2/ask.ts +218 -0
  189. package/src/math/v2/book.ts +660 -0
  190. package/src/math/v2/circulating.ts +69 -0
  191. package/src/math/v2/create.ts +139 -0
  192. package/src/math/v2/display.ts +250 -0
  193. package/src/math/v2/error.ts +19 -0
  194. package/src/math/v2/feasibility.ts +200 -0
  195. package/src/math/v2/fees.ts +121 -0
  196. package/src/math/v2/holders.ts +124 -0
  197. package/src/math/v2/milestones.ts +51 -0
  198. package/src/math/v2/pow.ts +71 -0
  199. package/src/math/v2/preset.ts +189 -0
  200. package/src/math/v2/receipt.ts +162 -0
  201. package/src/math/v2/relay.ts +235 -0
  202. package/src/math/v2/rows.ts +412 -0
  203. package/src/math/v2/split.ts +160 -0
  204. package/src/math/v2/sqrt.ts +86 -0
  205. package/src/math/v2/supply.ts +27 -0
  206. package/src/math/v2/team.ts +75 -0
  207. package/src/math/v2/trade.ts +145 -0
  208. package/src/math/v2/wide.ts +52 -0
  209. package/src/quote.ts +6 -0
  210. package/src/registryPrice.ts +28 -0
  211. package/src/route/edge-jupiter.ts +71 -0
  212. package/src/route/edge.ts +22 -0
  213. package/src/route/graph.ts +77 -0
  214. package/src/route/path.ts +84 -0
  215. package/src/route/quote.ts +46 -0
  216. package/src/route-jupiter.ts +36 -0
  217. package/src/route.ts +8 -0
  218. package/src/sha256.ts +61 -0
  219. package/src/solana/alt.ts +25 -0
  220. package/src/solana/floor/accounts.ts +395 -0
  221. package/src/solana/floor/borsh.ts +66 -0
  222. package/src/solana/floor/create.ts +89 -0
  223. package/src/solana/floor/events.ts +151 -0
  224. package/src/solana/floor/genesis.ts +111 -0
  225. package/src/solana/floor/genesisList.ts +75 -0
  226. package/src/solana/floor/instructions.ts +504 -0
  227. package/src/solana/floor/metadata.ts +246 -0
  228. package/src/solana/floor/mint.ts +242 -0
  229. package/src/solana/floor/program.ts +64 -0
  230. package/src/solana/floor/registry.ts +96 -0
  231. package/src/solana/instruction.ts +61 -0
  232. package/src/solana/pda.ts +91 -0
  233. package/src/solana/tx.ts +143 -0
  234. package/src/v2/burnPreview.ts +52 -0
  235. package/src/v2/circulating.ts +22 -0
  236. package/src/v2/claimAllEvm.ts +97 -0
  237. package/src/v2/claims-evm.ts +179 -0
  238. package/src/v2/claims.ts +288 -0
  239. package/src/v2/dead.ts +21 -0
  240. package/src/v2/devbuy.ts +55 -0
  241. package/src/v2/events.ts +131 -0
  242. package/src/v2/evm.ts +349 -0
  243. package/src/v2/evmReads.ts +121 -0
  244. package/src/v2/genesis.ts +80 -0
  245. package/src/v2/layouts.ts +219 -0
  246. package/src/v2/market-evm.ts +95 -0
  247. package/src/v2/presetRowEvm.ts +54 -0
  248. package/src/v2/press.ts +124 -0
  249. package/src/v2/quoteMint.ts +63 -0
  250. package/src/v2/receipt-tx.ts +251 -0
  251. package/src/v2/route-alt.ts +114 -0
  252. package/src/v2/route.ts +494 -0
  253. package/src/v2/router.ts +22 -0
  254. package/src/v2/solana.ts +439 -0
  255. package/src/v2/solanaSettle.ts +117 -0
  256. package/src/v2/tx/evm.ts +152 -0
  257. package/src/v2/tx/genesis.ts +66 -0
  258. package/src/v2/tx/index.ts +5 -0
  259. package/src/v2/tx/solana.ts +140 -0
  260. package/src/v2/types.ts +284 -0
  261. package/dist/adapter.d.ts +0 -28
  262. package/dist/adapter.d.ts.map +0 -1
  263. package/dist/adapter.js +0 -2
  264. package/dist/adapter.js.map +0 -1
  265. package/dist/chain.d.ts +0 -23
  266. package/dist/chain.d.ts.map +0 -1
  267. package/dist/chain.js +0 -25
  268. package/dist/chain.js.map +0 -1
  269. package/dist/client.d.ts +0 -26
  270. package/dist/client.d.ts.map +0 -1
  271. package/dist/client.js +0 -43
  272. package/dist/client.js.map +0 -1
  273. package/dist/dex-adapter.d.ts +0 -228
  274. package/dist/dex-adapter.d.ts.map +0 -1
  275. package/dist/dex-adapter.js +0 -407
  276. package/dist/dex-adapter.js.map +0 -1
  277. package/dist/index.d.ts +0 -7
  278. package/dist/index.d.ts.map +0 -1
  279. package/dist/index.js.map +0 -1
  280. package/dist/quotes.d.ts +0 -12
  281. package/dist/quotes.d.ts.map +0 -1
  282. package/dist/quotes.gen.d.ts +0 -8
  283. package/dist/quotes.gen.d.ts.map +0 -1
  284. package/dist/quotes.gen.js +0 -2170
  285. package/dist/quotes.gen.js.map +0 -1
  286. package/dist/quotes.js +0 -24
  287. package/dist/quotes.js.map +0 -1
  288. package/dist/types.d.ts +0 -111
  289. package/dist/types.d.ts.map +0 -1
  290. package/dist/types.js +0 -2
  291. package/dist/types.js.map +0 -1
  292. package/src/adapter.ts +0 -20
  293. package/src/chain.ts +0 -39
  294. package/src/client.ts +0 -41
  295. package/src/dex-adapter.ts +0 -477
  296. package/src/quotes.gen.ts +0 -2170
  297. package/src/quotes.ts +0 -29
  298. package/src/types.ts +0 -115
@@ -0,0 +1,5 @@
1
+
2
+
3
+ export * as solana from "./solana.js";
4
+ export * as evm from "./evm.js";
5
+ export * as genesis from "./genesis.js";
@@ -0,0 +1,118 @@
1
+
2
+
3
+ import { addressBytes, base58Encode } from "../../codec.js";
4
+ import { teamSlotHandleKey } from "../../handle.js";
5
+ import { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_SHARE_BOUGHT, CLAIM_TEAM_BUY, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, TEAM_SLOT_PENDING_HANDLE, TEAM_SLOT_WALLET, teamSlotAddInstruction } from "../../solana/floor/instructions.js";
6
+
7
+ import { freshRegistryPrice } from "../../registryPrice.js";
8
+
9
+ import { CLAIM_HOLDER, CLAIM_KNOWN_WIDE_V2, claimInstructionV2, teamShareBuyInstructionV2 } from "../solana.js";
10
+
11
+ import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, WSOL_MINT, associatedTokenAddress } from "../../solana/pda.js";
12
+ import { createAssociatedTokenAccountIdempotentInstruction } from "../../solana/tx.js";
13
+ import { configPda as configPdaOf, teamSlotPda as teamSlotPdaOf } from "../../solana/floor/program.js";
14
+ import { MEMBERS_MAX } from "../layouts.js";
15
+
16
+ export { createLaunchInstructionV2, teamShareBuyInstructionV2, unlockCreatorBuyInstructionV2, burnTokensInstructionV2, claimInstructionV2, CLAIM_HOLDER, CLAIM_KNOWN_WIDE_V2 } from "../solana.js";
17
+
18
+ export { planCreateWithSlot } from "../../solana/floor/create.js";
19
+ export { createMintAccounts, MAX_NAME_LEN, MAX_SYMBOL_LEN } from "../../solana/floor/instructions.js";
20
+
21
+ export { teamSlotAddInstruction, bindHandleInstruction, TEAM_SLOT_WALLET, TEAM_SLOT_PENDING_HANDLE } from "../../solana/floor/instructions.js";
22
+
23
+ export { openTraderRefInstruction, openTraderLinkInstruction, openRefOwedInstruction, rollUpRefsInstruction, clearTraderRefInstruction } from "../../solana/floor/instructions.js";
24
+ export { registerRoleInstruction, claimsPagePda, decodeClaimsPage, launchesFromRegistry, nextClaimsPage } from "../../solana/floor/registry.js";
25
+
26
+ export { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_TEAM_BUY, CLAIM_SHARE_BOUGHT } from "../../solana/floor/instructions.js";
27
+
28
+ export { configPda, launchPda, teamSlotPda, traderRefPda, traderLinkPda, refOwedPda, quoteEntryPda, presetPda } from "../../solana/floor/program.js";
29
+
30
+ export const TEAM_SLOT_MEMBERS_MAX = MEMBERS_MAX;
31
+
32
+ export const SOLANA_V2_TX = {
33
+ create_launch: { file: "v2/instructions/create.rs", struct: "CreateLaunchV2", args: "args: CreateArgs" },
34
+ team_share_buy: { file: "v2/instructions/team_share.rs", struct: "TeamShareBuyV2", args: "amount: u64, min_tokens_out: u64" },
35
+ unlock_creator_buy: { file: "instructions/platform.rs", struct: "UnlockCreatorBuy", args: "" },
36
+ burn_tokens: { file: "v2/instructions/burn.rs", struct: "BurnTokensV2", args: "place: u8, team_amount: u64, wallet_amount: u64" },
37
+ team_slot_add: { file: "instructions/team_slot.rs", struct: "TeamSlotPayment", args: "key: Pubkey, kind: u8, amount: u64, pay_now: bool" },
38
+ bind_handle: { file: "instructions/team_slot.rs", struct: "BindHandle", args: "index: u8, handle: [u8; 32], wallet: Pubkey" },
39
+ open_trader_ref: { file: "instructions/referrals.rs", struct: "OpenTraderRef", args: "trader: Pubkey, tiers: [Pubkey; 3]" },
40
+ open_trader_link: { file: "instructions/referrals.rs", struct: "OpenTraderLink", args: "trader: Pubkey, tiers: [Pubkey; 3]" },
41
+ open_ref_owed: { file: "instructions/referrals.rs", struct: "OpenRefOwed", args: "referrer: Pubkey" },
42
+ roll_up_refs: { file: "instructions/referrals.rs", struct: "RollUpRefs", args: "trader_refs: u8" },
43
+ clear_trader_ref: { file: "instructions/referrals.rs", struct: "ClearTraderRef", args: "" },
44
+ claim: { file: "instructions/claim.rs", struct: "Claim", args: "wallet: Pubkey, types: u8, launches: u8" },
45
+ claim_wide: { file: "instructions/claim.rs", struct: "Claim", args: "wallet: Pubkey, types: u16, launches: u8" },
46
+ } ;
47
+
48
+ export function claimTypesV2(w ) {
49
+ const t =
50
+ (w.teamFees ? CLAIM_CREATOR : 0) |
51
+ (w.creatorReferral ? CLAIM_CREATOR_REF : 0) |
52
+ (w.teamMilestones ? CLAIM_TEAM_SLOT : 0) |
53
+ (w.traderReferral ? CLAIM_TRADER_REF : 0) |
54
+ (w.teamBuy ? CLAIM_TEAM_BUY : 0) |
55
+ (w.teamShareBought ? CLAIM_SHARE_BOUGHT : 0) |
56
+ (w.holder ? CLAIM_HOLDER : 0);
57
+ if (t === 0) throw new RangeError("claimTypesV2: nothing named (NothingToDo)");
58
+ if ((t & ~CLAIM_KNOWN_WIDE_V2) !== 0) throw new RangeError("claimTypesV2: a bit outside CLAIM_KNOWN_WIDE_V2");
59
+ return t;
60
+ }
61
+
62
+ export function slotMemberKey(m ) {
63
+ if ("wallet" in m) {
64
+ addressBytes(m.wallet);
65
+ return { key: m.wallet, kind: TEAM_SLOT_WALLET };
66
+ }
67
+ return { key: base58Encode(teamSlotHandleKey(m.platform, m.handle)), kind: TEAM_SLOT_PENDING_HANDLE };
68
+ }
69
+
70
+ export function teamSlotAddMemberV2(
71
+ p ,
72
+ ) {
73
+ if (p.shares <= 0n || p.shares >> 64n !== 0n) throw new RangeError("team_slot_add: shares is a u64 > 0 (NothingToDo)");
74
+ const { key, kind } = slotMemberKey(p.member);
75
+ const { member: _m, shares: _s, ...rest } = p;
76
+ return teamSlotAddInstruction({ ...rest, key, kind, amount: p.shares, payNow: false });
77
+ }
78
+
79
+ export function createFeeV2(p ) {
80
+ if (p.listed) {
81
+ if (p.registry) freshRegistryPrice(p.registry.entry, p.registry.now);
82
+ return { amount: p.createFee, inQuote: true };
83
+ }
84
+ return { amount: p.nativeCreateFee, inQuote: false };
85
+ }
86
+
87
+ export function teamBuyCheck(buy , max ) {
88
+ if (buy < 0n) throw new RangeError("the Team Buy is ≥ 0");
89
+ if (buy > max) throw new RangeError(`the Team Buy ${buy} is over the row's share ${max} (CreatorBuyTooLarge)`);
90
+ return { buy, locked: buy > 0n };
91
+ }
92
+
93
+ export const TEAM_SHARE_BUY_AND_CLAIM_TYPES_V2 = CLAIM_TEAM_SLOT | CLAIM_TEAM_BUY | CLAIM_SHARE_BOUGHT;
94
+
95
+ export function teamShareBuyAndClaimInstructionsV2(
96
+ p
97
+
98
+ ,
99
+ ) {
100
+ const amount = p.amountIn;
101
+ if (amount < 0n || amount >> 64n !== 0n) throw new RangeError("team_share_buy: amount is a u64 (0 = everything owed)");
102
+ const teamSlot = p.teamSlot ?? teamSlotPdaOf(p.launch, p.programId)[0];
103
+ const memberBase = p.memberBase ?? associatedTokenAddress(p.member, p.baseMint, TOKEN_2022_PROGRAM_ID);
104
+ const open = p.openMemberBase ?? p.memberBase === undefined;
105
+ const { quoteTokenProgram, config, destination, openMemberBase: _o, unwrapSol, quoteIsLaunch, ...buy } = p;
106
+ const claim = claimInstructionV2({
107
+ programId: p.programId, hookProgramId: p.hookProgramId, sender: p.member, wallet: p.member, quoteMint: p.quoteMint, quoteTokenProgram,
108
+ destination: destination ?? associatedTokenAddress(p.member, p.quoteMint, quoteTokenProgram), config: config ?? configPdaOf(p.programId)[0],
109
+ refOwed: null, refOwedVault: null, types: TEAM_SHARE_BUY_AND_CLAIM_TYPES_V2,
110
+ unwrap: (unwrapSol ?? true) && p.quoteMint === WSOL_MINT && quoteTokenProgram === TOKEN_PROGRAM_ID, quoteIsLaunch,
111
+ launches: [{ launch: p.launch, quoteVault: p.quoteVault, teamSlot, teamBuy: { baseMint: p.baseMint, tokenVault: p.tokenVault, walletBase: memberBase } }],
112
+ });
113
+ return [
114
+ ...(open ? [createAssociatedTokenAccountIdempotentInstruction({ payer: p.member, owner: p.member, mint: p.baseMint, tokenProgram: TOKEN_2022_PROGRAM_ID })] : []),
115
+ teamShareBuyInstructionV2({ ...buy, teamSlot, memberBase }),
116
+ claim,
117
+ ];
118
+ }
@@ -0,0 +1,13 @@
1
+
2
+
3
+ import { decodeAccountV2 } from "./layouts.js";
4
+ import { decodeEventDataV2 } from "./events.js";
5
+
6
+ export const decodePresetRowV2Typed = (d ) => decodeAccountV2("PresetRowV2", d) ;
7
+ export const decodeLaunchV2Typed = (d ) => decodeAccountV2("LaunchV2", d) ;
8
+ export const decodeHolderPositionTyped = (d ) => decodeAccountV2("HolderPosition", d) ;
9
+ export const decodeHolderBookTyped = (d ) => decodeAccountV2("HolderBook", d) ;
10
+ export const decodeDeadMarkTyped = (d ) => decodeAccountV2("DeadMark", d) ;
11
+
12
+ export const decodeEventV2Typed = (d ) => decodeEventDataV2(d) ;
13
+
@@ -0,0 +1,61 @@
1
+ # Aggregator quickstart
2
+
3
+ You want to route a swap through a FLOOR Program launch: find the path, price it, and get something to sign. The SDK does the routing and building. You supply the pool list, the per-launch quote and the signing.
4
+
5
+ A launch trades against the program from its first block. There is no separate pool to deploy, so a launch token is a route hop like any other coin.
6
+
7
+ ## 1. Find a path
8
+
9
+ ```ts
10
+ import { findRouteV2 } from "@floorlaunchpad/sdk/v2/route";
11
+
12
+ const path = findRouteV2(pools, fromCoin, toCoin);
13
+ ```
14
+
15
+ `pools` is a list of `PoolV2` entries, one per launch (the type keeps its name, but a launch has no pool: each entry is a launch that trades against the program). Each has its chain (`"solana"` or `"evm"`), the launch token, the coin it trades against (its quote coin, such as SOL or USDC), and the launch state your quoter reads. On EVM each pool also carries its `launchId`. An outside leg, such as a swap on another venue between two coins, is an "edge" hop that you price yourself.
16
+
17
+ ## 2. Quote it
18
+
19
+ ```ts
20
+ import { quoteRouteV2 } from "@floorlaunchpad/sdk/v2/route";
21
+
22
+ const q = quoteRouteV2({
23
+ path,
24
+ amountIn: 1_000_000n,
25
+ slippageBps: 50,
26
+ quote: (launch, side, amountIn) => myQuoter(launch, side, amountIn), // returns { out, ... } for one hop
27
+ });
28
+ // q.amountOut, and q.hops[i].minOut for each hop
29
+ ```
30
+
31
+ The hop quoter is yours: it runs the program's math on a copy of the launch state and returns what one hop pays. `slippageBps` is 0 to 10,000 (100 % is allowed; every minimum is still at least 1). A path that trades the same launch token twice, or has no hop on a FLOOR launch, is refused with a `RangeError`. `findRouteV2` throws a `NoRouteError` (exported from `@floorlaunchpad/sdk/route`) when there is no path. When the path includes an outside leg, use `quoteRouteEdgeV2` and pass an `edge` function that prices it.
32
+
33
+ ## 3. Build the transaction
34
+
35
+ Solana returns instructions. You give the trader, the quote, and the trader's balance of every coin on the path before the trade. Use `0n` for a coin the trader holds none of. A missing entry throws, so a route never spends a balance you did not mean to:
36
+
37
+ ```ts
38
+ import { routeInstructionsV2, routeTransactionsV2 } from "@floorlaunchpad/sdk/v2/route";
39
+
40
+ const ixs = routeInstructionsV2({ trader, quote: q, balances });
41
+ // or, split across transactions when one will not fit:
42
+ const txs = routeTransactionsV2({ trader, quote: q, balances, lookupTables });
43
+ ```
44
+
45
+ EVM returns calldata. `evmRouteCallV2` builds one call to the router; `evmHopCallsV2` builds one call per hop for a caller that sends them in turn:
46
+
47
+ ```ts
48
+ import { evmRouteCallV2 } from "@floorlaunchpad/sdk/v2/route";
49
+
50
+ const call = evmRouteCallV2(q, { router, to: recipient, deadline });
51
+ // { to, data, ... }: send it from the trader's wallet
52
+ ```
53
+
54
+ ## Things to know
55
+
56
+ - The SDK never sends or signs. It returns instructions or calldata.
57
+ - Fees are added on top of the amount in and come out of the quote you build the call from. Do not subtract them again.
58
+ - Every launch trades from its first block and neither buys nor sells can be paused. A hop that fails does so because of the amount or the slippage bound, not a switch.
59
+ - Amounts are `bigint` in the coin's smallest unit on both chains.
60
+
61
+ See also: [README](../README.md), [bot guide](bot.md) for reading launches to build your pool list.
package/docs/bot.md ADDED
@@ -0,0 +1,50 @@
1
+ # Bot and indexer quickstart
2
+
3
+ You want to watch launches and trades, keep your own copy of the data, or react to events. The SDK gives you typed readers for an indexer and decoders for raw chain data. It opens no connection itself.
4
+
5
+ ## Read an indexer
6
+
7
+ Pass a `get`: a function from a path to `{ status, body }`. It can be `fetch`, a proxy, or a cache.
8
+
9
+ ```ts
10
+ import { readLaunches, readLaunch, readTrades, type Get } from "@floorlaunchpad/sdk/indexer/read";
11
+
12
+ const get: Get = async (path) => {
13
+ const r = await fetch(`${INDEXER}${path}`);
14
+ return { status: r.status, body: await r.json() };
15
+ };
16
+
17
+ const { launch } = await readLaunch(get, "42");
18
+ const page = await readTrades(get, launch.id, { limit: 100 });
19
+ ```
20
+
21
+ Pages carry a `next` cursor; pass it as `before` for the next page, and stop when it is `null`. Amounts are `bigint`. A non-200 answer throws an `IndexerError` (`notReady` while the indexer catches up, `unknownLaunch` for an id it does not know). A body of the wrong shape throws a `ShapeError` that names the field.
22
+
23
+ ## Follow the live stream
24
+
25
+ ```ts
26
+ import { parseStreamFrames, streamPath } from "@floorlaunchpad/sdk/indexer/stream";
27
+
28
+ let rest = "";
29
+ // feed each text chunk from your server-sent-events connection to path streamPath()
30
+ const { frames, rest: left } = parseStreamFrames(rest + chunk);
31
+ rest = left;
32
+ ```
33
+
34
+ `parseStreamFrames` returns the complete frames and the unfinished tail; keep the tail for the next chunk.
35
+
36
+ ## Decode chain data yourself
37
+
38
+ For raw logs and accounts, skip the indexer: `decodeLogV2` (EVM logs) and `decodeEventData` (Solana events) decode events; `@floorlaunchpad/sdk/v2/layouts` decodes Solana accounts. Every decoder is exact and throws on a length mismatch.
39
+
40
+ ## Trade
41
+
42
+ A bot that trades builds the same transactions as an aggregator: see [docs/aggregator.md](aggregator.md). Run the quote against fresh launch state just before you send, and set `slippageBps` for the time between the quote and the block.
43
+
44
+ ## Things to know
45
+
46
+ - Neither buys nor sells can be paused, so a bot that stops quoting is not waiting on a switch.
47
+ - Launch ids are the pool's id: a uint256 decimal string on EVM, the `Launch` account address on Solana. A token address also works for reads.
48
+ - The SDK never signs or sends.
49
+
50
+ See also: [README](../README.md).
@@ -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,29 @@
1
+ # Frontend quickstart
2
+
3
+ You want a page that lists launches, quotes a trade and builds the transaction for the wallet to sign. The package runs in a browser: no dependencies, no network calls of its own, no code at import.
4
+
5
+ ## Import from the root
6
+
7
+ ```ts
8
+ import { v2Route, indexerRead, mathV2Display } from "@floorlaunchpad/sdk";
9
+ ```
10
+
11
+ The root entry exposes each module as a namespace, and a bundler keeps only the ones you use. If you want the smallest possible import, name the module: `@floorlaunchpad/sdk/indexer/read`.
12
+
13
+ ## Show data
14
+
15
+ Read from your indexer with an injected `get` (see [bot guide](bot.md)). Launch reads come back with `bigint` amounts; format them at the edge of the page, not before.
16
+
17
+ `@floorlaunchpad/sdk/math/v2/display` and the other `math/v2` modules hold the figures the page shows. They use the same integer math as the program, so the number on the page is the number the program pays.
18
+
19
+ ## Quote and build
20
+
21
+ Use the routing functions in [docs/aggregator.md](aggregator.md). For a single launch, find a one-hop path, quote it with `slippageBps` from the user's setting, and pass the result to `routeInstructionsV2` (Solana) or `evmRouteCallV2` (EVM). The wallet signs what you return.
22
+
23
+ ## Things to know
24
+
25
+ - Route modules in `src/route` and `src/v2/route.ts` contain no host names, so a strict content security policy does not trip on them. Anything that talks to a hosted service is in `route-jupiter.ts` and is opt-in.
26
+ - Keep the quote fresh: re-quote when the user changes the amount and just before they sign.
27
+ - Chain choice happens once, at the edge. Past that point the same quote and build calls work on both chains.
28
+
29
+ See also: [README](../README.md), [wallet guide](wallet.md).
package/docs/wallet.md ADDED
@@ -0,0 +1,54 @@
1
+ # Wallet quickstart
2
+
3
+ You want to show a person what a transaction will do, explain why one failed, and let them claim what they are owed. The SDK decodes; you display.
4
+
5
+ ## Read what happened
6
+
7
+ A Solana transaction's program log carries events. Decode one data blob at a time:
8
+
9
+ ```ts
10
+ import { decodeEventData } from "@floorlaunchpad/sdk/solana/floor/events";
11
+
12
+ const ev = decodeEventData(bytes); // { name, fields } or null when it is not a FLOOR event
13
+ ```
14
+
15
+ On EVM, decode a log from the FloorAmm contract:
16
+
17
+ ```ts
18
+ import { decodeLogV2 } from "@floorlaunchpad/sdk/v2/evm";
19
+
20
+ const ev = decodeLogV2({ topics, data }); // { name, fields } or null
21
+ ```
22
+
23
+ Both decoders are exact. A body with bytes left over, or too few, throws rather than guess, so a wallet never shows a half-read event as a real one. A log that is not a FLOOR event returns `null`.
24
+
25
+ ## Explain a failure
26
+
27
+ ```ts
28
+ import { decodeErrorV2 } from "@floorlaunchpad/sdk/v2/evm";
29
+
30
+ const name = decodeErrorV2(revertData); // the custom error's name, or null
31
+ ```
32
+
33
+ Show the name and your own plain wording for it. The SDK gives you the identifier, not a sentence.
34
+
35
+ ## Claim
36
+
37
+ The program has one claim for everything a wallet is owed: the creator's fee share (Team Fees), referral shares, a Team Buy, and holder rewards. The claim takes bits that say which kinds to collect.
38
+
39
+ ```ts
40
+ import { claimV2Call } from "@floorlaunchpad/sdk/v2/evm";
41
+
42
+ const call = claimV2Call({ floorAmm, wallet, types: bits, quotes: [quoteCoin] });
43
+ // { to, data }: the wallet signs and sends it
44
+ ```
45
+
46
+ To list what a wallet can claim first, use the indexer's claim view (`readClaimView` in `@floorlaunchpad/sdk/indexer/read`) and show the amounts before you build the call. Holder rewards on EVM need the holder to opt in to the token first (`optInCall`).
47
+
48
+ ## Things to know
49
+
50
+ - Amounts are `bigint` in the coin's smallest unit.
51
+ - The SDK builds no claim lookup table on Solana; it only records a wallet's own table.
52
+ - Nothing here signs. You pass the result to your own signer.
53
+
54
+ See also: [README](../README.md), [frontend guide](frontend.md).
@@ -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>