@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,152 @@
1
+
2
+
3
+ import { bytesToHex, checksumAddress, decodeAbi, encodeCall, hexToBytes } from "../../evm/abi.ts";
4
+ import type { AbiValue } from "../../evm/abi.ts";
5
+ import { teamSlotHandleId } from "../../handle.ts";
6
+ import { freshRegistryPrice } from "../../registryPrice.ts";
7
+ import type { RegistryPrice } from "../../registryPrice.ts";
8
+ import type { EvmCall } from "../evm.ts";
9
+ import { evmSignature } from "../../generated/index.ts";
10
+
11
+ export { claimV2Call, CLAIM_HOLDER_EVM, CLAIM_KNOWN_V2_EVM, creditBackingCall, optInCall, viewCall, decodeTeamShareOf } from "../evm.ts";
12
+ export type { EvmCall } from "../evm.ts";
13
+ export { traderRefDigest, traderRefAuthDigest, bindHandleDigest, bindHandleAuthDigest } from "../../evm/floor/calls.ts";
14
+ export { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_PAYOUT, CLAIM_TEAM_BUY, CLAIM_SHARE_BOUGHT, MEMBER_WALLET, MEMBER_HANDLE, NATIVE_QUOTE } from "../../evm/floor/iface.ts";
15
+
16
+ export const EVM_V2_TX = {
17
+
18
+ createLaunch: evmSignature("createLaunch"),
19
+
20
+ teamSlotAdd: evmSignature("teamSlotAdd"),
21
+ unlockCreatorBuy: evmSignature("unlockCreatorBuy"),
22
+ claim: evmSignature("claim"),
23
+
24
+ teamShareBuy: evmSignature("teamShareBuy"),
25
+
26
+ setTraderRef: evmSignature("setTraderRef"),
27
+ bindHandle: evmSignature("bindHandle"),
28
+ claimPayoutTo: evmSignature("claimPayoutTo"),
29
+ } as const;
30
+
31
+ export const EVM_V2_TX_VIEWS = {
32
+ traderRef: { sig: evmSignature("traderRef"), ret: ["address[3]"] },
33
+ launchCount: { sig: evmSignature("launchCount"), ret: ["uint256"] },
34
+ predictToken: { sig: evmSignature("predictToken"), ret: ["address"] },
35
+ } as const;
36
+
37
+ const NATIVE = "0x0000000000000000000000000000000000000000";
38
+ const MAX_NAME = 32;
39
+ const MAX_SYMBOL = 10;
40
+ const U128 = (1n << 128n) - 1n;
41
+ const call = (to: string, sig: string, args: AbiValue[], value = 0n): EvmCall => ({ to: checksumAddress(to), data: bytesToHex(encodeCall(sig, args)), value });
42
+ const deadlineOf = (d: bigint | undefined): bigint => d ?? (1n << 256n) - 1n;
43
+
44
+ export interface CreateParamsV2 {
45
+ presetId: number;
46
+
47
+ quote: string;
48
+ name: string;
49
+ symbol: string;
50
+
51
+ creatorBuy?: bigint;
52
+ creatorBuyMinTokens?: bigint;
53
+ sameAddressEverywhere?: boolean;
54
+
55
+ creatorSalt?: string;
56
+
57
+ quoteUsdCentsX64?: bigint;
58
+ }
59
+
60
+ export function createLaunchCallV2(p: {
61
+ floorAmm: string;
62
+ params: CreateParamsV2;
63
+ teamSlotMaxBps: number;
64
+
65
+ createFee: bigint;
66
+ listed: boolean;
67
+
68
+ teamBuyMax?: bigint;
69
+
70
+ registry?: { entry: RegistryPrice; now: bigint };
71
+ }): EvmCall {
72
+ const q = p.params;
73
+ if ("uri" in (q as object)) throw new RangeError("no uri: the token's uri is derived (metadataBase/<token>.json)");
74
+ const enc = new TextEncoder();
75
+ const nl = enc.encode(q.name).length;
76
+ const sl = enc.encode(q.symbol).length;
77
+ if (nl === 0 || sl === 0 || nl > MAX_NAME || sl > MAX_SYMBOL) throw new RangeError("name 1..32, symbol 1..10 bytes (BadArgument)");
78
+ if (!Number.isInteger(q.presetId) || q.presetId <= 0 || q.presetId > 255) throw new RangeError("presetId is a u8 > 0 (id 0 reserved)");
79
+ if (q.presetId === 2) throw new RangeError("preset id 2 is retired");
80
+ const rate = p.teamSlotMaxBps;
81
+ if (!Number.isInteger(rate) || rate < 0 || rate > 0xffff) throw new RangeError("teamSlotMaxBps is a u16");
82
+ const buy = q.creatorBuy ?? 0n;
83
+ const minTok = q.creatorBuyMinTokens ?? 0n;
84
+ if (buy < 0n || minTok < 0n) throw new RangeError("the Team Buy and its minimum are ≥ 0");
85
+ if (buy === 0n && minTok > 0n) throw new RangeError("a minimum without a Team Buy (SlippageExceeded)");
86
+ if (p.teamBuyMax !== undefined && buy > p.teamBuyMax) throw new RangeError(`the Team Buy ${buy} is over the row's share ${p.teamBuyMax} (CreatorBuyTooLarge)`);
87
+ const usd = q.quoteUsdCentsX64 ?? 0n;
88
+ if (p.listed && usd !== 0n) throw new RangeError("a listed quote declares no price (BadArgument)");
89
+ if (!p.listed && (usd === 0n || usd > U128)) throw new RangeError("an unlisted quote declares 0 < price ≤ 2^128 − 1 (BadArgument)");
90
+ if (p.listed && p.registry) freshRegistryPrice(p.registry.entry, p.registry.now);
91
+ const native = q.quote.toLowerCase() === NATIVE;
92
+ const value = !p.listed ? p.createFee : native ? p.createFee + buy : 0n;
93
+ const salt = hexToBytes(q.creatorSalt ?? "0x" + "00".repeat(32));
94
+ if (salt.length !== 32) throw new RangeError("creatorSalt is bytes32");
95
+ return call(
96
+ p.floorAmm,
97
+ EVM_V2_TX.createLaunch,
98
+ [[BigInt(q.presetId), q.quote, q.name, q.symbol, buy, minTok, q.sameAddressEverywhere ?? false, salt, usd, BigInt(rate)]],
99
+ value,
100
+ );
101
+ }
102
+
103
+ export function createApprovalV2(p: { listed: boolean; quote: string; createFee: bigint; creatorBuy?: bigint }): bigint {
104
+ if (p.quote.toLowerCase() === NATIVE) return 0n;
105
+ return (p.listed ? p.createFee : 0n) + (p.creatorBuy ?? 0n);
106
+ }
107
+
108
+ export type SlotMemberEvm = { wallet: string } | { platform: string; handle: string };
109
+
110
+ export function slotMemberKeyEvm(m: SlotMemberEvm): { key: string; kind: number } {
111
+ if ("wallet" in m) return { key: "0x" + "00".repeat(12) + checksumAddress(m.wallet).slice(2).toLowerCase(), kind: 0 };
112
+ return { key: teamSlotHandleId(m.platform, m.handle), kind: 1 };
113
+ }
114
+
115
+ export function teamSlotAddCallV2(p: { floorAmm: string; launchId: bigint; member: SlotMemberEvm; shares: bigint }): EvmCall {
116
+ if (p.shares <= 0n) throw new RangeError("teamSlotAdd: shares > 0 (NothingToDo)");
117
+ const { key, kind } = slotMemberKeyEvm(p.member);
118
+ return call(p.floorAmm, EVM_V2_TX.teamSlotAdd, [p.launchId, hexToBytes(key), BigInt(kind), p.shares, false]);
119
+ }
120
+
121
+ export const unlockCreatorBuyCallV2 = (p: { floorAmm: string; launchId: bigint }): EvmCall => call(p.floorAmm, EVM_V2_TX.unlockCreatorBuy, [p.launchId]);
122
+
123
+ export const EVM_V2_TX_ONE_PRESS = {
124
+ teamShareBuyAndClaim: evmSignature("teamShareBuyAndClaim"),
125
+ } as const;
126
+
127
+ export function teamShareBuyAndClaimCallV2(p: { floorAmm: string; launchId: bigint; deadline?: bigint; amountIn: bigint; minOut: bigint }): EvmCall {
128
+ const amount = p.amountIn;
129
+ if (amount < 0n) throw new RangeError("teamShareBuyAndClaim: amount ≥ 0 (0 = everything owed)");
130
+ return call(p.floorAmm, EVM_V2_TX_ONE_PRESS.teamShareBuyAndClaim, [p.launchId, amount, p.minOut, deadlineOf(p.deadline)]);
131
+ }
132
+
133
+ export function teamShareBuyCallV2(p: { floorAmm: string; launchId: bigint; deadline?: bigint; amountIn: bigint; minOut: bigint }): EvmCall {
134
+ const amount = p.amountIn;
135
+ if (amount <= 0n) throw new RangeError("teamShareBuy: amount > 0");
136
+ return call(p.floorAmm, EVM_V2_TX.teamShareBuy, [p.launchId, amount, p.minOut, deadlineOf(p.deadline)]);
137
+ }
138
+
139
+ export function setTraderRefCallV2(p: { floorAmm: string; trader: string; tiers: readonly [string, string, string]; deadline: bigint; authSig: string; traderSig?: string }): EvmCall {
140
+ return call(p.floorAmm, EVM_V2_TX.setTraderRef, [p.trader, [...p.tiers], p.deadline, hexToBytes(p.authSig), hexToBytes(p.traderSig ?? "0x")]);
141
+ }
142
+
143
+ export function bindHandleCallV2(p: { floorAmm: string; handleId: string; wallet: string; quotes: readonly string[]; deadline: bigint; authSig: string; walletSig?: string }): EvmCall {
144
+ return call(p.floorAmm, EVM_V2_TX.bindHandle, [hexToBytes(p.handleId), p.wallet, [...p.quotes], p.deadline, hexToBytes(p.authSig), hexToBytes(p.walletSig ?? "0x")]);
145
+ }
146
+
147
+ export const claimPayoutToCallV2 = (p: { floorAmm: string; quote: string; to: string }): EvmCall => call(p.floorAmm, EVM_V2_TX.claimPayoutTo, [p.quote, p.to]);
148
+
149
+ export const traderRefDataV2 = (trader: string): string => bytesToHex(encodeCall(EVM_V2_TX_VIEWS.traderRef.sig, [trader]));
150
+ export const decodeTraderRefV2 = (data: string | Uint8Array): string[] => (decodeAbi(EVM_V2_TX_VIEWS.traderRef.ret, data)[0] as string[]).map((a) => checksumAddress(a));
151
+
152
+ export const predictTokenDataV2 = (creator: string, salt: string): string => bytesToHex(encodeCall(EVM_V2_TX_VIEWS.predictToken.sig, [creator, hexToBytes(salt)]));
@@ -0,0 +1,66 @@
1
+
2
+
3
+ import { accountDiscriminator } from "../../solana/instruction.ts";
4
+ import { Reader } from "../../solana/floor/borsh.ts";
5
+ import { decodeGenesisAllocation, decodeGenesisRaise } from "../../solana/floor/accounts.ts";
6
+ import { FLOOR_AMM_PROGRAM_ID, configPda, genesisAllocPda, genesisConvertBandPda, genesisRaisePda } from "../../solana/floor/program.ts";
7
+ import { genesisWalletClaim } from "../../solana/floor/genesis.ts";
8
+ import type { GenesisWalletClaim } from "../../solana/floor/genesis.ts";
9
+
10
+ export { openGenesisLaunchInstructionV2, openGenesisWagmiInstructionV2, claimGenesisInstructionV2, claimGenesisWagmiInstructionV2, sweepGenesisWagmiDustInstructionV2 } from "../genesis.ts";
11
+ export { setGenesisConvertBandInstruction } from "../solana.ts";
12
+ export { contributeGenesisInstruction, contributeGenesisListedInstruction, refundGenesisMigratedInstruction, claimGenesisRefundInstruction, convertGenesisSolInstruction } from "../../solana/floor/instructions.ts";
13
+ export { decodeGenesisRaise, decodeGenesisAllocation } from "../../solana/floor/accounts.ts";
14
+ export { genesisWalletClaim } from "../../solana/floor/genesis.ts";
15
+ export type { GenesisWalletClaim } from "../../solana/floor/genesis.ts";
16
+
17
+ export const GENESIS_CONVERT_BAND_SIZE = 8 + 1 + 16 * 4 + 8;
18
+
19
+ export interface GenesisConvertBand {
20
+ bump: number;
21
+ solPxMin: bigint;
22
+ solPxMax: bigint;
23
+ usdcPxMin: bigint;
24
+ usdcPxMax: bigint;
25
+ updatedAt: bigint;
26
+ }
27
+
28
+ export function decodeGenesisConvertBand(data: Uint8Array): GenesisConvertBand {
29
+ if (data.length !== GENESIS_CONVERT_BAND_SIZE) throw new RangeError(`GenesisConvertBand is ${GENESIS_CONVERT_BAND_SIZE} bytes, got ${data.length}`);
30
+ const d = accountDiscriminator("GenesisConvertBand");
31
+ for (let i = 0; i < 8; i++) if (data[i] !== d[i]) throw new RangeError("not a GenesisConvertBand account");
32
+ const r = new Reader(data.subarray(8));
33
+ return { bump: r.u8(), solPxMin: r.u128(), solPxMax: r.u128(), usdcPxMin: r.u128(), usdcPxMax: r.u128(), updatedAt: r.i64() };
34
+ }
35
+
36
+ export const genesisBandHolds = (b: GenesisConvertBand, solPx: bigint, usdcPx: bigint): boolean =>
37
+ b.solPxMin > 0n && b.usdcPxMin > 0n && solPx >= b.solPxMin && solPx <= b.solPxMax && usdcPx >= b.usdcPxMin && usdcPx <= b.usdcPxMax;
38
+
39
+ export function genesisAccountsV2(p: { wallet?: string; programId?: string }): {
40
+ config: string; genesisRaise: string; convertBand: string; allocation: string | null;
41
+ } {
42
+ const g = p.programId ?? FLOOR_AMM_PROGRAM_ID;
43
+ return {
44
+ config: configPda(g)[0],
45
+ genesisRaise: genesisRaisePda(g)[0],
46
+ convertBand: genesisConvertBandPda(g)[0],
47
+ allocation: p.wallet ? genesisAllocPda(p.wallet, g)[0] : null,
48
+ };
49
+ }
50
+
51
+ export interface GenesisReadV2 {
52
+ raise: Record<string, any>;
53
+ allocation: Record<string, any> | null;
54
+
55
+ claim: GenesisWalletClaim | null;
56
+ band: GenesisConvertBand | null;
57
+ }
58
+
59
+ export function readGenesisV2(p: { raise: Uint8Array; allocation?: Uint8Array | null; band?: Uint8Array | null; now: bigint }): GenesisReadV2 {
60
+ const raise = decodeGenesisRaise(p.raise);
61
+ const allocation = p.allocation ? decodeGenesisAllocation(p.allocation) : null;
62
+ let claim: GenesisWalletClaim | null = null;
63
+ if (allocation && BigInt(raise.raised_final ?? 0n) > 0n) claim = genesisWalletClaim(raise, allocation);
64
+ const band = p.band ? decodeGenesisConvertBand(p.band) : null;
65
+ return { raise, allocation, claim, band };
66
+ }
@@ -0,0 +1,5 @@
1
+
2
+
3
+ export * as solana from "./solana.ts";
4
+ export * as evm from "./evm.ts";
5
+ export * as genesis from "./genesis.ts";
@@ -0,0 +1,140 @@
1
+
2
+
3
+ import { addressBytes, base58Encode } from "../../codec.ts";
4
+ import { teamSlotHandleKey } from "../../handle.ts";
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.ts";
6
+ import type { Instruction } from "../../solana/instruction.ts";
7
+ import { freshRegistryPrice } from "../../registryPrice.ts";
8
+ import type { RegistryPrice } from "../../registryPrice.ts";
9
+ import { CLAIM_HOLDER, CLAIM_KNOWN_WIDE_V2, claimInstructionV2, teamShareBuyInstructionV2 } from "../solana.ts";
10
+ import type { TeamShareBuyBaseV2 } from "../solana.ts";
11
+ import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, WSOL_MINT, associatedTokenAddress } from "../../solana/pda.ts";
12
+ import { createAssociatedTokenAccountIdempotentInstruction } from "../../solana/tx.ts";
13
+ import { configPda as configPdaOf, teamSlotPda as teamSlotPdaOf } from "../../solana/floor/program.ts";
14
+ import { MEMBERS_MAX } from "../layouts.ts";
15
+
16
+ export { createLaunchInstructionV2, teamShareBuyInstructionV2, unlockCreatorBuyInstructionV2, burnTokensInstructionV2, claimInstructionV2, CLAIM_HOLDER, CLAIM_KNOWN_WIDE_V2 } from "../solana.ts";
17
+ export type { CreateArgsV2, ClaimLaunchV2 } from "../solana.ts";
18
+ export { planCreateWithSlot } from "../../solana/floor/create.ts";
19
+ export { createMintAccounts, MAX_NAME_LEN, MAX_SYMBOL_LEN } from "../../solana/floor/instructions.ts";
20
+
21
+ export { teamSlotAddInstruction, bindHandleInstruction, TEAM_SLOT_WALLET, TEAM_SLOT_PENDING_HANDLE } from "../../solana/floor/instructions.ts";
22
+
23
+ export { openTraderRefInstruction, openTraderLinkInstruction, openRefOwedInstruction, rollUpRefsInstruction, clearTraderRefInstruction } from "../../solana/floor/instructions.ts";
24
+ export { registerRoleInstruction, claimsPagePda, decodeClaimsPage, launchesFromRegistry, nextClaimsPage } from "../../solana/floor/registry.ts";
25
+
26
+ export { CLAIM_CREATOR, CLAIM_CREATOR_REF, CLAIM_TEAM_SLOT, CLAIM_TRADER_REF, CLAIM_TEAM_BUY, CLAIM_SHARE_BOUGHT } from "../../solana/floor/instructions.ts";
27
+
28
+ export { configPda, launchPda, teamSlotPda, traderRefPda, traderLinkPda, refOwedPda, quoteEntryPda, presetPda } from "../../solana/floor/program.ts";
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
+ } as const;
47
+
48
+ export interface ClaimWhat {
49
+
50
+ teamFees?: boolean;
51
+
52
+ creatorReferral?: boolean;
53
+
54
+ teamMilestones?: boolean;
55
+
56
+ traderReferral?: boolean;
57
+
58
+ teamBuy?: boolean;
59
+
60
+ teamShareBought?: boolean;
61
+
62
+ holder?: boolean;
63
+ }
64
+
65
+ export function claimTypesV2(w: ClaimWhat): number {
66
+ const t =
67
+ (w.teamFees ? CLAIM_CREATOR : 0) |
68
+ (w.creatorReferral ? CLAIM_CREATOR_REF : 0) |
69
+ (w.teamMilestones ? CLAIM_TEAM_SLOT : 0) |
70
+ (w.traderReferral ? CLAIM_TRADER_REF : 0) |
71
+ (w.teamBuy ? CLAIM_TEAM_BUY : 0) |
72
+ (w.teamShareBought ? CLAIM_SHARE_BOUGHT : 0) |
73
+ (w.holder ? CLAIM_HOLDER : 0);
74
+ if (t === 0) throw new RangeError("claimTypesV2: nothing named (NothingToDo)");
75
+ if ((t & ~CLAIM_KNOWN_WIDE_V2) !== 0) throw new RangeError("claimTypesV2: a bit outside CLAIM_KNOWN_WIDE_V2");
76
+ return t;
77
+ }
78
+
79
+ export type SlotMemberKey = { wallet: string } | { platform: string; handle: string };
80
+
81
+ export function slotMemberKey(m: SlotMemberKey): { key: string; kind: number } {
82
+ if ("wallet" in m) {
83
+ addressBytes(m.wallet);
84
+ return { key: m.wallet, kind: TEAM_SLOT_WALLET };
85
+ }
86
+ return { key: base58Encode(teamSlotHandleKey(m.platform, m.handle)), kind: TEAM_SLOT_PENDING_HANDLE };
87
+ }
88
+
89
+ export function teamSlotAddMemberV2(
90
+ p: Omit<Parameters<typeof teamSlotAddInstruction>[0], "key" | "kind" | "amount" | "payNow"> & { member: SlotMemberKey; shares: bigint },
91
+ ): Instruction {
92
+ if (p.shares <= 0n || p.shares >> 64n !== 0n) throw new RangeError("team_slot_add: shares is a u64 > 0 (NothingToDo)");
93
+ const { key, kind } = slotMemberKey(p.member);
94
+ const { member: _m, shares: _s, ...rest } = p;
95
+ return teamSlotAddInstruction({ ...rest, key, kind, amount: p.shares, payNow: false });
96
+ }
97
+
98
+ export function createFeeV2(p: { listed: true; createFee: bigint; registry?: { entry: RegistryPrice; now: bigint } } | { listed: false; nativeCreateFee: bigint }): { amount: bigint; inQuote: boolean } {
99
+ if (p.listed) {
100
+ if (p.registry) freshRegistryPrice(p.registry.entry, p.registry.now);
101
+ return { amount: p.createFee, inQuote: true };
102
+ }
103
+ return { amount: p.nativeCreateFee, inQuote: false };
104
+ }
105
+
106
+ export function teamBuyCheck(buy: bigint, max: bigint): { buy: bigint; locked: boolean } {
107
+ if (buy < 0n) throw new RangeError("the Team Buy is ≥ 0");
108
+ if (buy > max) throw new RangeError(`the Team Buy ${buy} is over the row's share ${max} (CreatorBuyTooLarge)`);
109
+ return { buy, locked: buy > 0n };
110
+ }
111
+
112
+ export const TEAM_SHARE_BUY_AND_CLAIM_TYPES_V2 = CLAIM_TEAM_SLOT | CLAIM_TEAM_BUY | CLAIM_SHARE_BOUGHT;
113
+
114
+ export function teamShareBuyAndClaimInstructionsV2(
115
+ p: Omit<TeamShareBuyBaseV2, "memberBase"> & {
116
+ amountIn: bigint; minOut: bigint;
117
+ memberBase?: string; quoteTokenProgram: string; config?: string; destination?: string; openMemberBase?: boolean; unwrapSol?: boolean;
118
+
119
+ quoteIsLaunch?: boolean;
120
+ },
121
+ ): Instruction[] {
122
+ const amount = p.amountIn;
123
+ if (amount < 0n || amount >> 64n !== 0n) throw new RangeError("team_share_buy: amount is a u64 (0 = everything owed)");
124
+ const teamSlot = p.teamSlot ?? teamSlotPdaOf(p.launch, p.programId)[0];
125
+ const memberBase = p.memberBase ?? associatedTokenAddress(p.member, p.baseMint, TOKEN_2022_PROGRAM_ID);
126
+ const open = p.openMemberBase ?? p.memberBase === undefined;
127
+ const { quoteTokenProgram, config, destination, openMemberBase: _o, unwrapSol, quoteIsLaunch, ...buy } = p;
128
+ const claim = claimInstructionV2({
129
+ programId: p.programId, hookProgramId: p.hookProgramId, sender: p.member, wallet: p.member, quoteMint: p.quoteMint, quoteTokenProgram,
130
+ destination: destination ?? associatedTokenAddress(p.member, p.quoteMint, quoteTokenProgram), config: config ?? configPdaOf(p.programId)[0],
131
+ refOwed: null, refOwedVault: null, types: TEAM_SHARE_BUY_AND_CLAIM_TYPES_V2,
132
+ unwrap: (unwrapSol ?? true) && p.quoteMint === WSOL_MINT && quoteTokenProgram === TOKEN_PROGRAM_ID, quoteIsLaunch,
133
+ launches: [{ launch: p.launch, quoteVault: p.quoteVault, teamSlot, teamBuy: { baseMint: p.baseMint, tokenVault: p.tokenVault, walletBase: memberBase } }],
134
+ });
135
+ return [
136
+ ...(open ? [createAssociatedTokenAccountIdempotentInstruction({ payer: p.member, owner: p.member, mint: p.baseMint, tokenProgram: TOKEN_2022_PROGRAM_ID })] : []),
137
+ teamShareBuyInstructionV2({ ...buy, teamSlot, memberBase }),
138
+ claim,
139
+ ];
140
+ }
@@ -0,0 +1,284 @@
1
+
2
+
3
+ import { decodeAccountV2 } from "./layouts.ts";
4
+ import { decodeEventDataV2 } from "./events.ts";
5
+
6
+ export interface PresetRowV2Account {
7
+ id: number;
8
+ bump: number;
9
+ enabled: number;
10
+ deleted: number;
11
+ checked: number;
12
+ genesisRow: number;
13
+ padVersion: Uint8Array;
14
+ version: number;
15
+ rowHash: Uint8Array;
16
+ row: Uint8Array;
17
+ padEnd: Uint8Array;
18
+ }
19
+
20
+ export interface LaunchV2Account {
21
+ version: number;
22
+ bump: number;
23
+ status: number;
24
+ graduated: number;
25
+ decimals: number;
26
+ quoteDecimals: number;
27
+ presetId: number;
28
+ ownFees: number;
29
+ msClass: number;
30
+ flags: number;
31
+ nRanges: number;
32
+ nBands: number;
33
+ nC: number;
34
+ teamBuyRule: number;
35
+ listed: number;
36
+ padSlotRate: Uint8Array;
37
+ slotRateBps: number;
38
+ padPresetVersion: Uint8Array;
39
+ presetVersion: number;
40
+ id: bigint;
41
+ createdAt: bigint;
42
+ createdSlot: bigint;
43
+ creatorUnlockAt: bigint;
44
+ baseMint: string;
45
+ quoteMint: string;
46
+ creator: string;
47
+ quoteTokenProgram: string;
48
+ tokenVault: string;
49
+ quoteVault: string;
50
+ presetHash: Uint8Array;
51
+ phiBps: number;
52
+ wcBps: number;
53
+ psiTailBps: number;
54
+ teamBuyShareBps: number;
55
+ teamSlotMaxBps: number;
56
+ platformMsBps: number;
57
+ floorMsBps: number;
58
+ ckBps: number;
59
+ feePpm: number[];
60
+ feeStartPpm: number[];
61
+ bandWidthBps: number[];
62
+ bandShareBps: number[];
63
+ sqrtP0: bigint;
64
+ sqrtP: bigint;
65
+ sqrtF: bigint;
66
+ sqrtLMax: bigint;
67
+ sqrtFeeA: bigint;
68
+ sqrtFeeB: bigint;
69
+ quoteUsdCentsX64: bigint;
70
+ bandEdge: bigint[];
71
+ rngSqrtA: bigint[];
72
+ rngSqrtB: bigint[];
73
+ rngTokens: bigint[];
74
+ rngAskLeft: bigint[];
75
+ rngBack: bigint[];
76
+ rngPlace: bigint[];
77
+ rngMsCapPpm: number[];
78
+ rngThetaBps: number[];
79
+ rngPsiBps: number[];
80
+ rngKind: number[];
81
+ rngClass: number[];
82
+ supply: bigint;
83
+ deadTokens: bigint;
84
+ floor: bigint;
85
+ floorTokens: bigint;
86
+ bandMoney: bigint[];
87
+ bandTokens: bigint[];
88
+ bandF: bigint[];
89
+ bandFClaim: bigint[];
90
+ ckAtF: bigint;
91
+ ckFloorTokens: bigint;
92
+ msBooked: bigint[];
93
+ msPaid: bigint[];
94
+ creatorOwed: bigint;
95
+ platformOwed: bigint;
96
+ cutOwed: bigint;
97
+ holderOwed: bigint;
98
+ slotOwedTotal: bigint;
99
+ slotOwed: bigint[];
100
+ slotWeightPpb: number[];
101
+ creatorRef: string[];
102
+ creatorRefOwed: bigint[];
103
+ teamBuyOwed: bigint[];
104
+ teamBuyClaimed: bigint[];
105
+ slotBoughtOwed: bigint[];
106
+ slotBoughtClaimed: bigint[];
107
+ teamShareBuyDay: bigint;
108
+ windowRaised: bigint;
109
+ raise: bigint;
110
+ volumeBuy: bigint;
111
+ volumeSell: bigint;
112
+ trades: bigint;
113
+ graduatedSlot: bigint;
114
+ creatorLocked: bigint;
115
+ backingCredited: bigint;
116
+ incinerated: bigint;
117
+ lastTs: bigint;
118
+ bookHash: Uint8Array;
119
+ }
120
+
121
+ export interface HolderPositionAccount {
122
+ version: number;
123
+ bump: number;
124
+ ataBump: number;
125
+ pad: Uint8Array;
126
+ launch: string;
127
+ owner: string;
128
+ amount: bigint;
129
+ indexSnap: bigint;
130
+ owed: bigint;
131
+ padEnd: Uint8Array;
132
+ }
133
+
134
+ export interface HolderBookAccount {
135
+ version: number;
136
+ bump: number;
137
+ pad: Uint8Array;
138
+ launch: string;
139
+ mint: string;
140
+ w: bigint;
141
+ index: bigint;
142
+ carry: bigint;
143
+ bookedTotal: bigint;
144
+ paidTotal: bigint;
145
+ padEnd: Uint8Array;
146
+ }
147
+
148
+ export interface DeadMarkAccount {
149
+ version: number;
150
+ bump: number;
151
+ pad: Uint8Array;
152
+ counted: bigint;
153
+ }
154
+
155
+ export interface LaunchCreatedV2EventV2 {
156
+ launch: string;
157
+ mint: string;
158
+ quoteMint: string;
159
+ creator: string;
160
+ id: bigint;
161
+ presetId: number;
162
+ presetVersion: number;
163
+ presetHash: Uint8Array;
164
+ p0X64: bigint;
165
+ raise: bigint;
166
+ windowTokens: bigint;
167
+ creatorBuyTokens: bigint;
168
+ createFee: bigint;
169
+ name: Uint8Array;
170
+ symbol: Uint8Array;
171
+ slot: bigint;
172
+ ts: bigint;
173
+ listed: boolean;
174
+ quoteUsdCentsX64: bigint;
175
+ nativeCreateFee: bigint;
176
+ rowVersion: number;
177
+ sqrtP0: bigint;
178
+ }
179
+
180
+ export interface TradeEventV2 {
181
+ launch: string;
182
+ trader: string;
183
+ isBuy: boolean;
184
+ quoteGross: bigint;
185
+ quoteNet: bigint;
186
+ refund: bigint;
187
+ tokens: bigint;
188
+ fees: bigint[];
189
+ traderRef: bigint;
190
+ fromResale: bigint;
191
+ fromFirst: bigint;
192
+ unfilled: bigint;
193
+ sqrtBefore: bigint;
194
+ sqrtAfter: bigint;
195
+ sqrtF: bigint;
196
+ floor: bigint;
197
+ cushion: bigint;
198
+ sCirc: bigint;
199
+ steps: number;
200
+ budgetHit: boolean;
201
+ slot: bigint;
202
+ ts: bigint;
203
+ kind: number;
204
+ creatorRef: bigint;
205
+ recipient: string;
206
+ bidMoney: bigint;
207
+ msPaid: bigint[];
208
+ }
209
+
210
+ export interface HolderPositionOpenedEventV2 {
211
+ launch: string;
212
+ owner: string;
213
+ amount: bigint;
214
+ }
215
+
216
+ export interface HolderPositionClosedEventV2 {
217
+ launch: string;
218
+ owner: string;
219
+ amount: bigint;
220
+ paid: bigint;
221
+ }
222
+
223
+ export interface HolderIndexRolledEventV2 {
224
+ launch: string;
225
+ index: bigint;
226
+ wMatured: bigint;
227
+ wPending: bigint;
228
+ carry: bigint;
229
+ }
230
+
231
+ export interface DeadSyncedEventV2 {
232
+ launch: string;
233
+ added: bigint;
234
+ deadTokens: bigint;
235
+ sCirc: bigint;
236
+ }
237
+
238
+ export interface GenesisRaiseBoughtEventV2 {
239
+ launch: string;
240
+ trader: string;
241
+ isBuy: boolean;
242
+ quoteGross: bigint;
243
+ quoteNet: bigint;
244
+ refund: bigint;
245
+ tokens: bigint;
246
+ fees: bigint[];
247
+ traderRef: bigint;
248
+ fromResale: bigint;
249
+ fromFirst: bigint;
250
+ unfilled: bigint;
251
+ sqrtBefore: bigint;
252
+ sqrtAfter: bigint;
253
+ sqrtF: bigint;
254
+ floor: bigint;
255
+ cushion: bigint;
256
+ sCirc: bigint;
257
+ steps: number;
258
+ budgetHit: boolean;
259
+ slot: bigint;
260
+ ts: bigint;
261
+ kind: number;
262
+ creatorRef: bigint;
263
+ recipient: string;
264
+ bidMoney: bigint;
265
+ msPaid: bigint[];
266
+ }
267
+
268
+ export type FloorEventV2Typed =
269
+ | { name: "LaunchCreatedV2"; fields: LaunchCreatedV2EventV2 }
270
+ | { name: "Trade"; fields: TradeEventV2 }
271
+ | { name: "HolderPositionOpened"; fields: HolderPositionOpenedEventV2 }
272
+ | { name: "HolderPositionClosed"; fields: HolderPositionClosedEventV2 }
273
+ | { name: "HolderIndexRolled"; fields: HolderIndexRolledEventV2 }
274
+ | { name: "DeadSynced"; fields: DeadSyncedEventV2 }
275
+ | { name: "GenesisRaiseBought"; fields: GenesisRaiseBoughtEventV2 };
276
+
277
+ export const decodePresetRowV2Typed = (d: Uint8Array): PresetRowV2Account => decodeAccountV2("PresetRowV2", d) as PresetRowV2Account;
278
+ export const decodeLaunchV2Typed = (d: Uint8Array): LaunchV2Account => decodeAccountV2("LaunchV2", d) as LaunchV2Account;
279
+ export const decodeHolderPositionTyped = (d: Uint8Array): HolderPositionAccount => decodeAccountV2("HolderPosition", d) as HolderPositionAccount;
280
+ export const decodeHolderBookTyped = (d: Uint8Array): HolderBookAccount => decodeAccountV2("HolderBook", d) as HolderBookAccount;
281
+ export const decodeDeadMarkTyped = (d: Uint8Array): DeadMarkAccount => decodeAccountV2("DeadMark", d) as DeadMarkAccount;
282
+
283
+ export const decodeEventV2Typed = (d: Uint8Array): FloorEventV2Typed | null => decodeEventDataV2(d) as FloorEventV2Typed | null;
284
+ export type { DevBuy, DevBuyRole } from "./devbuy.ts";
package/dist/adapter.d.ts DELETED
@@ -1,28 +0,0 @@
1
- import type { ChainRef } from './chain.js';
2
- import type { Launch, LaunchRef, Quote, Side, TradeParams, UnsignedTx, Amount } from './types.js';
3
- /**
4
- * What a chain package implements. `@floorlaunchpad/sdk-evm` and `@floorlaunchpad/sdk-solana` each export one factory
5
- * that returns this. Reads are network calls; `build*` returns an unsigned transaction and never signs.
6
- */
7
- export interface FloorChainAdapter {
8
- /** The chains this adapter instance serves. */
9
- readonly chains: readonly ChainRef[];
10
- getLaunch(ref: LaunchRef): Promise<Launch>;
11
- /** Paged, newest first. `cursor` is opaque and adapter-specific. */
12
- listLaunches(chain: ChainRef, opts?: {
13
- readonly limit?: number;
14
- readonly cursor?: string;
15
- }): Promise<{
16
- readonly launches: readonly Launch[];
17
- readonly cursor: string | null;
18
- }>;
19
- /**
20
- * `trader` is used where a venue checks the seller's own state: a Solana sell-back before graduation pays the same
21
- * fixed-price amount to any seller, and `trader` is read only to check that their sale position covers `amountIn`.
22
- */
23
- quote(ref: LaunchRef, side: Side, amountIn: Amount, opts?: {
24
- readonly trader?: string;
25
- }): Promise<Quote>;
26
- buildTrade(params: TradeParams): Promise<UnsignedTx>;
27
- }
28
- //# sourceMappingURL=adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAElG;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IACrC,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oEAAoE;IACpE,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAC/K;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACzG,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACtD"}
package/dist/adapter.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=adapter.js.map