@floorlaunchpad/sdk 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +20 -5
  3. package/dist/abi/evm.gen.js +1 -1
  4. package/dist/abi/solana.gen.js +1 -1
  5. package/dist/client/evm/index.js +16 -2
  6. package/dist/client/solana/index.js +19 -7
  7. package/dist/config/generated.js +26864 -402
  8. package/dist/config/registry.gen.js +33 -2
  9. package/dist/evm/chains.js +9 -1
  10. package/dist/evm/floor/abi.gen.js +1 -1
  11. package/dist/evm/floor/events.js +9 -1
  12. package/dist/evm/floor/legacy-events.js +25 -0
  13. package/dist/indexer/bodies.js +106 -16
  14. package/dist/indexer/client.js +35 -12
  15. package/dist/indexer/contract.js +138 -28
  16. package/dist/indexer/partners.js +3 -2
  17. package/dist/indexer/paths.js +63 -25
  18. package/dist/indexer/read.js +38 -13
  19. package/dist/indexer/search.js +130 -0
  20. package/dist/indexer/stack-edge.js +35 -0
  21. package/dist/indexer/stream.js +70 -23
  22. package/dist/math/v2/split.js +11 -3
  23. package/dist/solana/floor/events.js +1 -1
  24. package/dist/solana/floor/genesis.js +9 -3
  25. package/dist/solana/floor/instructions.js +14 -5
  26. package/dist/solana/floor/registry.js +4 -0
  27. package/dist/v2/devbuy.js +15 -0
  28. package/dist/v2/solana.js +17 -2
  29. package/dist/v2/tx/solana.js +1 -1
  30. package/docs/bot.md +36 -1
  31. package/docs/cursor-pages.md +56 -0
  32. package/docs/floor-line.md +208 -34
  33. package/examples/floor-line.html +373 -76
  34. package/package.json +1 -1
  35. package/src/abi/evm.gen.ts +1 -1
  36. package/src/abi/solana.gen.ts +1 -1
  37. package/src/client/evm/index.ts +16 -2
  38. package/src/client/solana/index.ts +19 -7
  39. package/src/client/types.ts +1 -1
  40. package/src/config/generated.ts +26864 -402
  41. package/src/config/index.ts +9 -2
  42. package/src/config/registry.gen.ts +33 -2
  43. package/src/events/types.gen.ts +2 -1
  44. package/src/evm/chains.ts +9 -1
  45. package/src/evm/floor/abi.gen.ts +1 -1
  46. package/src/evm/floor/events.ts +11 -1
  47. package/src/evm/floor/legacy-events.ts +27 -0
  48. package/src/indexer/bodies.ts +117 -16
  49. package/src/indexer/client.ts +54 -26
  50. package/src/indexer/contract.ts +158 -30
  51. package/src/indexer/partners.ts +3 -2
  52. package/src/indexer/paths.ts +86 -25
  53. package/src/indexer/read.ts +44 -15
  54. package/src/indexer/search.ts +138 -0
  55. package/src/indexer/stack-edge.ts +46 -0
  56. package/src/indexer/stream.ts +78 -24
  57. package/src/math/v2/split.ts +11 -3
  58. package/src/solana/floor/events.ts +1 -1
  59. package/src/solana/floor/genesis.ts +8 -2
  60. package/src/solana/floor/instructions.ts +13 -5
  61. package/src/solana/floor/registry.ts +4 -0
  62. package/src/v2/devbuy.ts +33 -0
  63. package/src/v2/solana.ts +20 -3
  64. package/src/v2/tx/solana.ts +1 -1
@@ -8,7 +8,7 @@ import { LEG_BACKING, LEG_FLOOR, LEG_HOLDER, LEG_PLATFORM, LEG_TEAM } from "../.
8
8
  import { priceImpactV2, quoteSellImpactV2 } from "../../math/v2/receipt.ts";
9
9
  import { sCirc } from "../../math/v2/supply.ts";
10
10
  import { CLAIM_SHARE_BOUGHT, CLAIM_TEAM_BUY, CLAIM_TRADER_REF } from "../../solana/floor/instructions.ts";
11
- import { FLOOR_AMM_PROGRAM_ID, configPda, launchPda, refOwedPda, refOwedVault, teamSlotPda, traderRefEscrow, traderRefPda } from "../../solana/floor/program.ts";
11
+ import { FLOOR_AMM_PROGRAM_ID, configPda, launchPda, refOwedPda, refOwedVault, teamSlotPda, traderLinkPda, traderRefEscrow, traderRefPda } from "../../solana/floor/program.ts";
12
12
  import { MAX_COMPUTE_UNIT_LIMIT, computeUnitLimitInstruction } from "../../solana/instruction.ts";
13
13
  import type { Instruction } from "../../solana/instruction.ts";
14
14
  import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, WSOL_MINT, associatedTokenAddress } from "../../solana/pda.ts";
@@ -99,14 +99,23 @@ export function createSolanaClient(opts: FloorClientOptions<"solana">): FloorCli
99
99
  return { address, l };
100
100
  }
101
101
 
102
- async function tradeAccounts(address: string, l: LaunchV2Account, trader: string, baseOwner: string, quoteOwner: string): Promise<TradeAccountsV2 & { programId: string; hookProgramId: string }> {
102
+ async function quoteIsLaunchOf(l: LaunchV2Account): Promise<boolean> {
103
+ if (l.quoteTokenProgram !== TOKEN_2022_PROGRAM_ID) return false;
104
+ const a = await get(launchPda(l.quoteMint, pid)[0]);
105
+ return a !== null && a.owner === pid;
106
+ }
107
+
108
+ async function tradeAccounts(address: string, l: LaunchV2Account, trader: string, baseOwner: string, quoteOwner: string, isBuy: boolean): Promise<TradeAccountsV2 & { programId: string; hookProgramId: string }> {
103
109
  const ref = traderRefPda(trader, l.quoteMint, pid)[0];
104
- const hasRef = (await get(ref)) !== null;
110
+ const linked = (await get(traderLinkPda(trader, pid)[0])) !== null;
111
+ const hasRef = linked || (await get(ref)) !== null;
112
+ const out = isBuy ? baseOwner : quoteOwner;
105
113
  return {
106
114
  programId: pid, hookProgramId: hid, trader, launch: address, baseMint: l.baseMint, quoteMint: l.quoteMint, tokenVault: l.tokenVault, quoteVault: l.quoteVault,
107
115
  traderBase: associatedTokenAddress(baseOwner, l.baseMint, TOKEN_2022_PROGRAM_ID), traderQuote: associatedTokenAddress(quoteOwner, l.quoteMint, l.quoteTokenProgram),
108
116
  quoteTokenProgram: l.quoteTokenProgram, traderRef: hasRef ? ref : null, escrow: hasRef ? traderRefEscrow(ref, l.quoteMint, l.quoteTokenProgram) : null,
109
- baseOwner, quoteOwner,
117
+ baseOwner, quoteOwner, quoteIsLaunch: await quoteIsLaunchOf(l),
118
+ ...(linked ? { user: trader, recipient: out !== trader ? out : null } : {}),
110
119
  };
111
120
  }
112
121
 
@@ -188,7 +197,7 @@ export function createSolanaClient(opts: FloorClientOptions<"solana">): FloorCli
188
197
  if (p.amountIn <= 0n) throw bad("amountIn must be > 0");
189
198
  const { address, l } = await launchOf(p.launch);
190
199
  const owner = p.recipient ?? p.trader;
191
- const a = await tradeAccounts(address, l, p.trader, owner, p.trader);
200
+ const a = await tradeAccounts(address, l, p.trader, owner, p.trader, true);
192
201
 
193
202
  const hasPosition = owner !== p.trader || (await get(holderPositionPda(address, owner, hid)[0])) !== null;
194
203
  const wsol = await wsolLegs(l, p.trader, p.trader);
@@ -206,7 +215,7 @@ export function createSolanaClient(opts: FloorClientOptions<"solana">): FloorCli
206
215
  if (p.tokensIn <= 0n) throw bad("tokensIn must be > 0");
207
216
  const { address, l } = await launchOf(p.launch);
208
217
  const to = p.recipient ?? p.trader;
209
- const a = await tradeAccounts(address, l, p.trader, p.trader, to);
218
+ const a = await tradeAccounts(address, l, p.trader, p.trader, to, false);
210
219
  const wsol = await wsolLegs(l, to, p.trader);
211
220
  const instructions: Instruction[] = [
212
221
  computeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT),
@@ -221,10 +230,12 @@ export function createSolanaClient(opts: FloorClientOptions<"solana">): FloorCli
221
230
  const tok = (p.types & (CLAIM_TEAM_BUY | CLAIM_SHARE_BOUGHT)) !== 0;
222
231
  const launches: ClaimLaunchV2[] = [];
223
232
  let qtp: string | null = null;
233
+ let qIsLaunch = false;
224
234
  for (const mint of p.launches) {
225
235
  const { address, l } = await launchOf(mint);
226
236
  if (l.quoteMint !== p.quote) throw bad(`launch ${mint} trades in ${l.quoteMint}, not ${p.quote}`);
227
237
  qtp = l.quoteTokenProgram;
238
+ qIsLaunch = await quoteIsLaunchOf(l);
228
239
  const slot = teamSlotPda(address, pid)[0];
229
240
  launches.push({
230
241
  launch: address, quoteVault: l.quoteVault, teamSlot: (await get(slot)) !== null ? slot : null, baseMint: l.baseMint,
@@ -235,12 +246,13 @@ export function createSolanaClient(opts: FloorClientOptions<"solana">): FloorCli
235
246
  const m = await get(p.quote);
236
247
  if (m === null) throw new FloorError("BadAccount", `no quote mint ${p.quote}`, { source: "sdk" });
237
248
  qtp = m.owner;
249
+ qIsLaunch = await quoteIsLaunchOf({ quoteMint: p.quote, quoteTokenProgram: qtp } as LaunchV2Account);
238
250
  }
239
251
  const ro = (p.types & CLAIM_TRADER_REF) !== 0 ? refOwedPda(p.wallet, p.quote, pid)[0] : null;
240
252
  const claim = claimInstructionV2({
241
253
  ...ids, sender: p.wallet, wallet: p.wallet, quoteMint: p.quote, quoteTokenProgram: qtp, destination: associatedTokenAddress(p.wallet, p.quote, qtp),
242
254
  config: configPda(pid)[0], refOwed: ro, refOwedVault: ro ? refOwedVault(ro, p.quote, qtp) : null, types: p.types, launches,
243
- unwrap: p.quote === WSOL_MINT && qtp === TOKEN_PROGRAM_ID,
255
+ unwrap: p.quote === WSOL_MINT && qtp === TOKEN_PROGRAM_ID, quoteIsLaunch: qIsLaunch,
244
256
  });
245
257
  return { family: "solana", instructions: [computeUnitLimitInstruction(CLAIM_COMPUTE_UNIT_LIMIT_V2), claim] };
246
258
  }),
@@ -4,7 +4,7 @@ import type { Instruction } from "../solana/instruction.ts";
4
4
  import type { EvmCall } from "../v2/evm.ts";
5
5
  import type { FloorError } from "../errors.ts";
6
6
 
7
- export type FloorFamily = "solana" | "evm";
7
+ export type FloorFamily = "solana" | "evm" | "ton";
8
8
 
9
9
  export interface SolanaChain {
10
10
  family: "solana";