@floorlaunchpad/sdk 0.1.0 → 0.3.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.
Files changed (292) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/LICENSE +201 -60
  3. package/README.md +45 -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 +128 -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 +746 -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 +144 -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/zap.js +128 -0
  37. package/dist/fixtures.js +53 -0
  38. package/dist/generated/index.js +28 -0
  39. package/dist/generated/interface.gen.js +146 -0
  40. package/dist/handle.js +22 -0
  41. package/dist/index.js +91 -7
  42. package/dist/indexer/bodies.js +473 -0
  43. package/dist/indexer/client.js +104 -0
  44. package/dist/indexer/contract.js +349 -0
  45. package/dist/indexer/decode.js +97 -0
  46. package/dist/indexer/partners.js +100 -0
  47. package/dist/indexer/paths.js +127 -0
  48. package/dist/indexer/read.js +109 -0
  49. package/dist/indexer/stream.js +71 -0
  50. package/dist/lock.js +16 -0
  51. package/dist/math/fixed.js +154 -0
  52. package/dist/math/genesis.js +39 -0
  53. package/dist/math/index.js +20 -0
  54. package/dist/math/u256.js +49 -0
  55. package/dist/math/v2/ask.js +162 -0
  56. package/dist/math/v2/book.js +607 -0
  57. package/dist/math/v2/circulating.js +62 -0
  58. package/dist/math/v2/create.js +122 -0
  59. package/dist/math/v2/display.js +208 -0
  60. package/dist/math/v2/error.js +17 -0
  61. package/dist/math/v2/feasibility.js +174 -0
  62. package/dist/math/v2/fees.js +121 -0
  63. package/dist/math/v2/holders.js +105 -0
  64. package/dist/math/v2/milestones.js +40 -0
  65. package/dist/math/v2/pow.js +69 -0
  66. package/dist/math/v2/preset.js +151 -0
  67. package/dist/math/v2/receipt.js +108 -0
  68. package/dist/math/v2/relay.js +217 -0
  69. package/dist/math/v2/rows.js +365 -0
  70. package/dist/math/v2/split.js +111 -0
  71. package/dist/math/v2/sqrt.js +84 -0
  72. package/dist/math/v2/supply.js +21 -0
  73. package/dist/math/v2/team.js +75 -0
  74. package/dist/math/v2/trade.js +126 -0
  75. package/dist/math/v2/wide.js +51 -0
  76. package/dist/quote.js +6 -0
  77. package/dist/registryPrice.js +23 -0
  78. package/dist/route/edge-jupiter.js +42 -0
  79. package/dist/route/edge.js +11 -0
  80. package/dist/route/graph.js +51 -0
  81. package/dist/route/path.js +75 -0
  82. package/dist/route/quote.js +15 -0
  83. package/dist/route-jupiter.js +35 -0
  84. package/dist/route.js +8 -0
  85. package/dist/sha256.js +61 -0
  86. package/dist/solana/alt.js +18 -0
  87. package/dist/solana/floor/accounts.js +390 -0
  88. package/dist/solana/floor/borsh.js +66 -0
  89. package/dist/solana/floor/create.js +65 -0
  90. package/dist/solana/floor/events.js +140 -0
  91. package/dist/solana/floor/genesis.js +91 -0
  92. package/dist/solana/floor/genesisList.js +68 -0
  93. package/dist/solana/floor/instructions.js +435 -0
  94. package/dist/solana/floor/metadata.js +198 -0
  95. package/dist/solana/floor/mint.js +206 -0
  96. package/dist/solana/floor/program.js +64 -0
  97. package/dist/solana/floor/registry.js +83 -0
  98. package/dist/solana/instruction.js +49 -0
  99. package/dist/solana/pda.js +88 -0
  100. package/dist/solana/tx.js +138 -0
  101. package/dist/v2/burnPreview.js +35 -0
  102. package/dist/v2/circulating.js +11 -0
  103. package/dist/v2/claimAllEvm.js +70 -0
  104. package/dist/v2/claims-evm.js +120 -0
  105. package/dist/v2/claims.js +218 -0
  106. package/dist/v2/dead.js +21 -0
  107. package/dist/v2/devbuy.js +37 -0
  108. package/dist/v2/events.js +115 -0
  109. package/dist/v2/evm.js +299 -0
  110. package/dist/v2/evmReads.js +76 -0
  111. package/dist/v2/genesis.js +76 -0
  112. package/dist/v2/layouts.js +217 -0
  113. package/dist/v2/market-evm.js +74 -0
  114. package/dist/v2/presetRowEvm.js +45 -0
  115. package/dist/v2/press.js +106 -0
  116. package/dist/v2/quoteMint.js +52 -0
  117. package/dist/v2/receipt-tx.js +149 -0
  118. package/dist/v2/route-alt.js +114 -0
  119. package/dist/v2/route.js +389 -0
  120. package/dist/v2/solana.js +391 -0
  121. package/dist/v2/solanaSettle.js +97 -0
  122. package/dist/v2/tx/evm.js +126 -0
  123. package/dist/v2/tx/genesis.js +47 -0
  124. package/dist/v2/tx/index.js +5 -0
  125. package/dist/v2/tx/solana.js +118 -0
  126. package/dist/v2/types.js +13 -0
  127. package/docs/aggregator.md +61 -0
  128. package/docs/bot.md +50 -0
  129. package/docs/frontend.md +29 -0
  130. package/docs/wallet.md +54 -0
  131. package/package.json +428 -32
  132. package/src/abi/evm-event-names.ts +12 -0
  133. package/src/abi/evm.gen.ts +139 -0
  134. package/src/abi/functions.gen.ts +154 -0
  135. package/src/abi/index.ts +30 -0
  136. package/src/abi/solana.gen.ts +138 -0
  137. package/src/burn.ts +37 -0
  138. package/src/client/evm/index.ts +199 -0
  139. package/src/client/index.ts +23 -0
  140. package/src/client/solana/index.ts +260 -0
  141. package/src/client/types.ts +162 -0
  142. package/src/codec.ts +77 -0
  143. package/src/config/codeHash.ts +9 -0
  144. package/src/config/generated.ts +746 -0
  145. package/src/config/index.ts +91 -0
  146. package/src/config/registry.gen.ts +118 -0
  147. package/src/config/solana-genesis.ts +7 -0
  148. package/src/ed25519.ts +31 -0
  149. package/src/errors.ts +270 -0
  150. package/src/events/index.ts +44 -0
  151. package/src/events/types.gen.ts +831 -0
  152. package/src/evm/abi.ts +292 -0
  153. package/src/evm/balances.ts +26 -0
  154. package/src/evm/chains.ts +167 -0
  155. package/src/evm/floor/abi.gen.ts +195 -0
  156. package/src/evm/floor/calls.ts +247 -0
  157. package/src/evm/floor/create.ts +68 -0
  158. package/src/evm/floor/events.ts +51 -0
  159. package/src/evm/floor/iface.ts +45 -0
  160. package/src/evm/items.ts +252 -0
  161. package/src/evm/keccak.ts +118 -0
  162. package/src/evm/multicall.ts +43 -0
  163. package/src/evm/router.ts +209 -0
  164. package/src/evm/zap.ts +152 -0
  165. package/src/fixtures.ts +53 -0
  166. package/src/generated/index.ts +29 -0
  167. package/src/generated/interface.gen.ts +153 -0
  168. package/src/handle.ts +22 -0
  169. package/src/index.ts +91 -6
  170. package/src/indexer/bodies.ts +528 -0
  171. package/src/indexer/client.ts +178 -0
  172. package/src/indexer/contract.ts +410 -0
  173. package/src/indexer/decode.ts +109 -0
  174. package/src/indexer/partners.ts +109 -0
  175. package/src/indexer/paths.ts +190 -0
  176. package/src/indexer/read.ts +119 -0
  177. package/src/indexer/stream.ts +83 -0
  178. package/src/lock.ts +16 -0
  179. package/src/math/fixed.ts +154 -0
  180. package/src/math/genesis.ts +39 -0
  181. package/src/math/index.ts +24 -0
  182. package/src/math/u256.ts +49 -0
  183. package/src/math/v2/ask.ts +218 -0
  184. package/src/math/v2/book.ts +660 -0
  185. package/src/math/v2/circulating.ts +69 -0
  186. package/src/math/v2/create.ts +139 -0
  187. package/src/math/v2/display.ts +250 -0
  188. package/src/math/v2/error.ts +19 -0
  189. package/src/math/v2/feasibility.ts +200 -0
  190. package/src/math/v2/fees.ts +121 -0
  191. package/src/math/v2/holders.ts +124 -0
  192. package/src/math/v2/milestones.ts +51 -0
  193. package/src/math/v2/pow.ts +71 -0
  194. package/src/math/v2/preset.ts +189 -0
  195. package/src/math/v2/receipt.ts +162 -0
  196. package/src/math/v2/relay.ts +235 -0
  197. package/src/math/v2/rows.ts +412 -0
  198. package/src/math/v2/split.ts +160 -0
  199. package/src/math/v2/sqrt.ts +86 -0
  200. package/src/math/v2/supply.ts +27 -0
  201. package/src/math/v2/team.ts +75 -0
  202. package/src/math/v2/trade.ts +145 -0
  203. package/src/math/v2/wide.ts +52 -0
  204. package/src/quote.ts +6 -0
  205. package/src/registryPrice.ts +28 -0
  206. package/src/route/edge-jupiter.ts +71 -0
  207. package/src/route/edge.ts +22 -0
  208. package/src/route/graph.ts +77 -0
  209. package/src/route/path.ts +84 -0
  210. package/src/route/quote.ts +46 -0
  211. package/src/route-jupiter.ts +36 -0
  212. package/src/route.ts +8 -0
  213. package/src/sha256.ts +61 -0
  214. package/src/solana/alt.ts +25 -0
  215. package/src/solana/floor/accounts.ts +393 -0
  216. package/src/solana/floor/borsh.ts +66 -0
  217. package/src/solana/floor/create.ts +89 -0
  218. package/src/solana/floor/events.ts +147 -0
  219. package/src/solana/floor/genesis.ts +111 -0
  220. package/src/solana/floor/genesisList.ts +75 -0
  221. package/src/solana/floor/instructions.ts +491 -0
  222. package/src/solana/floor/metadata.ts +246 -0
  223. package/src/solana/floor/mint.ts +242 -0
  224. package/src/solana/floor/program.ts +64 -0
  225. package/src/solana/floor/registry.ts +96 -0
  226. package/src/solana/instruction.ts +61 -0
  227. package/src/solana/pda.ts +91 -0
  228. package/src/solana/tx.ts +143 -0
  229. package/src/v2/burnPreview.ts +52 -0
  230. package/src/v2/circulating.ts +22 -0
  231. package/src/v2/claimAllEvm.ts +97 -0
  232. package/src/v2/claims-evm.ts +179 -0
  233. package/src/v2/claims.ts +288 -0
  234. package/src/v2/dead.ts +21 -0
  235. package/src/v2/devbuy.ts +55 -0
  236. package/src/v2/events.ts +131 -0
  237. package/src/v2/evm.ts +349 -0
  238. package/src/v2/evmReads.ts +121 -0
  239. package/src/v2/genesis.ts +80 -0
  240. package/src/v2/layouts.ts +219 -0
  241. package/src/v2/market-evm.ts +95 -0
  242. package/src/v2/presetRowEvm.ts +54 -0
  243. package/src/v2/press.ts +124 -0
  244. package/src/v2/quoteMint.ts +63 -0
  245. package/src/v2/receipt-tx.ts +251 -0
  246. package/src/v2/route-alt.ts +114 -0
  247. package/src/v2/route.ts +494 -0
  248. package/src/v2/solana.ts +439 -0
  249. package/src/v2/solanaSettle.ts +117 -0
  250. package/src/v2/tx/evm.ts +152 -0
  251. package/src/v2/tx/genesis.ts +66 -0
  252. package/src/v2/tx/index.ts +5 -0
  253. package/src/v2/tx/solana.ts +140 -0
  254. package/src/v2/types.ts +284 -0
  255. package/dist/adapter.d.ts +0 -28
  256. package/dist/adapter.d.ts.map +0 -1
  257. package/dist/adapter.js +0 -2
  258. package/dist/adapter.js.map +0 -1
  259. package/dist/chain.d.ts +0 -23
  260. package/dist/chain.d.ts.map +0 -1
  261. package/dist/chain.js +0 -25
  262. package/dist/chain.js.map +0 -1
  263. package/dist/client.d.ts +0 -26
  264. package/dist/client.d.ts.map +0 -1
  265. package/dist/client.js +0 -43
  266. package/dist/client.js.map +0 -1
  267. package/dist/dex-adapter.d.ts +0 -228
  268. package/dist/dex-adapter.d.ts.map +0 -1
  269. package/dist/dex-adapter.js +0 -407
  270. package/dist/dex-adapter.js.map +0 -1
  271. package/dist/index.d.ts +0 -7
  272. package/dist/index.d.ts.map +0 -1
  273. package/dist/index.js.map +0 -1
  274. package/dist/quotes.d.ts +0 -12
  275. package/dist/quotes.d.ts.map +0 -1
  276. package/dist/quotes.gen.d.ts +0 -8
  277. package/dist/quotes.gen.d.ts.map +0 -1
  278. package/dist/quotes.gen.js +0 -2170
  279. package/dist/quotes.gen.js.map +0 -1
  280. package/dist/quotes.js +0 -24
  281. package/dist/quotes.js.map +0 -1
  282. package/dist/types.d.ts +0 -111
  283. package/dist/types.d.ts.map +0 -1
  284. package/dist/types.js +0 -2
  285. package/dist/types.js.map +0 -1
  286. package/src/adapter.ts +0 -20
  287. package/src/chain.ts +0 -39
  288. package/src/client.ts +0 -41
  289. package/src/dex-adapter.ts +0 -477
  290. package/src/quotes.gen.ts +0 -2170
  291. package/src/quotes.ts +0 -29
  292. 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,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).