@floorlaunchpad/sdk 0.7.0 → 0.8.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 (105) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/README.md +12 -1
  3. package/dist/abi/evm.gen.js +75 -2
  4. package/dist/abi/functions.gen.js +87 -1
  5. package/dist/abi/solana.gen.js +59 -0
  6. package/dist/client/solana/index.js +25 -6
  7. package/dist/config/generated.js +803 -26374
  8. package/dist/errors.js +20 -1
  9. package/dist/events/types.gen.js +1 -1
  10. package/dist/evm/chains.js +49 -0
  11. package/dist/evm/floor/abi.gen.js +115 -0
  12. package/dist/evm/squid.js +21 -5
  13. package/dist/evm/venues.js +302 -0
  14. package/dist/generated/interface.gen.js +45 -1
  15. package/dist/index.js +7 -0
  16. package/dist/indexer/bodies.js +154 -2
  17. package/dist/indexer/client.js +8 -1
  18. package/dist/indexer/contract.js +78 -11
  19. package/dist/indexer/paths.js +46 -0
  20. package/dist/indexer/read.js +14 -1
  21. package/dist/math/v2/book.js +24 -7
  22. package/dist/math/v2/create.js +1 -1
  23. package/dist/math/v2/escrow.js +205 -0
  24. package/dist/math/v2/office.js +110 -0
  25. package/dist/math/v2/relay.js +263 -96
  26. package/dist/math/v2/team.js +28 -0
  27. package/dist/math/v2/trade.js +3 -1
  28. package/dist/reprice.js +88 -0
  29. package/dist/route/quote.js +16 -0
  30. package/dist/scaledUi.js +113 -0
  31. package/dist/solana/floor/accounts.js +8 -2
  32. package/dist/solana/floor/events.js +56 -1
  33. package/dist/solana/floor/instructions.js +16 -0
  34. package/dist/stockRefresh.js +99 -0
  35. package/dist/ton/consts.generated.js +2 -2
  36. package/dist/ton/gas.js +3 -3
  37. package/dist/v2/claims.js +28 -5
  38. package/dist/v2/devbuy.js +28 -3
  39. package/dist/v2/evm.js +178 -5
  40. package/dist/v2/layouts.js +100 -2
  41. package/dist/v2/office-events.js +127 -0
  42. package/dist/v2/office-evm.js +68 -0
  43. package/dist/v2/office-read.js +182 -0
  44. package/dist/v2/office-solana.js +134 -0
  45. package/dist/v2/office-trade.js +73 -0
  46. package/dist/v2/route-alt.js +1 -0
  47. package/dist/v2/route.js +1 -1
  48. package/dist/v2/solana.js +224 -5
  49. package/dist/v2/solanaSettle.js +2 -0
  50. package/dist/v2/tx/evm.js +51 -1
  51. package/dist/v2/tx/solana.js +3 -3
  52. package/dist/v2/types.js +4 -0
  53. package/docs/aggregator.md +19 -0
  54. package/examples/floor-line.html +1 -1
  55. package/package.json +26 -1
  56. package/src/abi/evm.gen.ts +75 -2
  57. package/src/abi/functions.gen.ts +87 -1
  58. package/src/abi/solana.gen.ts +59 -0
  59. package/src/client/solana/index.ts +25 -6
  60. package/src/config/generated.ts +803 -26374
  61. package/src/errors.ts +20 -1
  62. package/src/events/types.gen.ts +402 -1
  63. package/src/evm/chains.ts +58 -0
  64. package/src/evm/floor/abi.gen.ts +115 -0
  65. package/src/evm/squid.ts +22 -6
  66. package/src/evm/venues.ts +340 -0
  67. package/src/generated/interface.gen.ts +45 -1
  68. package/src/index.ts +7 -0
  69. package/src/indexer/bodies.ts +167 -2
  70. package/src/indexer/client.ts +16 -2
  71. package/src/indexer/contract.ts +84 -12
  72. package/src/indexer/paths.ts +77 -0
  73. package/src/indexer/read.ts +16 -3
  74. package/src/math/v2/book.ts +23 -7
  75. package/src/math/v2/create.ts +1 -1
  76. package/src/math/v2/escrow.ts +213 -0
  77. package/src/math/v2/office.ts +114 -0
  78. package/src/math/v2/relay.ts +269 -96
  79. package/src/math/v2/team.ts +28 -0
  80. package/src/math/v2/trade.ts +3 -1
  81. package/src/reprice.ts +121 -0
  82. package/src/route/quote.ts +16 -0
  83. package/src/scaledUi.ts +123 -0
  84. package/src/solana/floor/accounts.ts +8 -2
  85. package/src/solana/floor/events.ts +57 -2
  86. package/src/solana/floor/instructions.ts +16 -0
  87. package/src/stockRefresh.ts +131 -0
  88. package/src/ton/consts.generated.ts +2 -2
  89. package/src/ton/gas.ts +3 -3
  90. package/src/v2/claims.ts +34 -5
  91. package/src/v2/devbuy.ts +38 -3
  92. package/src/v2/evm.ts +204 -5
  93. package/src/v2/layouts.ts +100 -2
  94. package/src/v2/office-events.ts +133 -0
  95. package/src/v2/office-evm.ts +76 -0
  96. package/src/v2/office-read.ts +264 -0
  97. package/src/v2/office-solana.ts +159 -0
  98. package/src/v2/office-trade.ts +96 -0
  99. package/src/v2/route-alt.ts +1 -0
  100. package/src/v2/route.ts +1 -1
  101. package/src/v2/solana.ts +235 -5
  102. package/src/v2/solanaSettle.ts +2 -0
  103. package/src/v2/tx/evm.ts +51 -1
  104. package/src/v2/tx/solana.ts +5 -3
  105. package/src/v2/types.ts +66 -1
@@ -36,13 +36,17 @@ export const routePath = {
36
36
  quoteChain: (a) => indexerPath.quoteChain(a.launch),
37
37
  devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
38
38
  burns: ({ launch, ...q }) => indexerPath.burns(launch, q),
39
+ deals: (a) => indexerPath.deals(a.launch),
39
40
  launchLocks: (a) => indexerPath.launchLocks(a.launch),
40
41
  marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
41
42
  price: (a) => indexerPath.price(a.launch),
42
43
  raiseSeries: ({ launch, ...q }) => indexerPath.raiseSeries(launch, q),
43
44
  floorSteps: ({ launch, ...q }) => indexerPath.floorSteps(launch, q),
44
45
  launchTraded: (a) => indexerPath.launchTraded(a.launch, a.wallets),
46
+ launchTies: ({ launch, ...q }) => indexerPath.launchTies(launch, q),
45
47
  highs: ({ launch, ...q }) => indexerPath.highs(launch, q),
48
+ mcap: ({ launch, ...q }) => indexerPath.mcap(launch, q),
49
+ held: ({ launch, ...q }) => indexerPath.held(launch, q),
46
50
  candles: (a) => indexerPath.candles(a),
47
51
  candlesMany: (a) => indexerPath.candlesMany(a),
48
52
  candleBundle: ({ launch, ...q }) => indexerPath.candleBundle(launch, q),
@@ -55,9 +59,12 @@ export const routePath = {
55
59
  walletLocks: ({ wallet, ...q }) => indexerPath.walletLocks(wallet, q),
56
60
  claimHistory: ({ wallet, ...q }) => indexerPath.claimHistory(wallet, q),
57
61
  firsts: (a) => indexerPath.firsts(a.wallet),
62
+ walletStats: (a) => indexerPath.walletStats(a.wallet),
63
+ cobuys: ({ wallet, ...q }) => indexerPath.cobuys(wallet, q),
58
64
  firstsMany: (a) => indexerPath.firstsMany(a.wallets),
59
65
  claimView: ({ wallet, ...q }) => indexerPath.claimView(wallet, q),
60
66
  people: ({ wallet, ...q }) => indexerPath.people(wallet, q),
67
+ referralLaunches: ({ wallet, ...q }) => indexerPath.referralLaunches(wallet, q),
61
68
  roles: ({ wallet, ...q }) => indexerPath.roles(wallet, q),
62
69
  handlePlaces: ({ handle, ...q }) => indexerPath.handlePlaces(handle, q),
63
70
  traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
@@ -77,7 +84,7 @@ export const routePath = {
77
84
  health: () => "/health",
78
85
  };
79
86
 
80
- export const DRAIN_NAMES = ["trades", "launchClaims", "memberSold", "burns", "walletTrades", "launches", "search", "marks", "inbox", "positions", "walletLocks", "claimHistory", "people", "roles", "tokenHolders", "tonActivity", "cgHistoricalTrades", "floorRouted", "devBuys", "claimView", "handlePlaces", "positionTotals"] ;
87
+ export const DRAIN_NAMES = ["trades", "launchClaims", "memberSold", "burns", "walletTrades", "launches", "search", "marks", "inbox", "positions", "walletLocks", "claimHistory", "people", "roles", "tokenHolders", "tonActivity", "cgHistoricalTrades", "floorRouted", "devBuys", "claimView", "handlePlaces", "positionTotals", "referralLaunches", "mcap", "held"] ;
81
88
 
82
89
  export function createIndexerClient(opts ) {
83
90
 
@@ -3,8 +3,9 @@
3
3
  import { unknown } from "./decode.js";
4
4
  import * as B from "./bodies.js";
5
5
  import * as P from "./partners.js";
6
- import { CANDLES_MANY_IDS_MAX, CANDLES_MANY_LIMIT_DEFAULT, CANDLES_MANY_ROWS_MAX, FIRSTS_MAX, POSITION_TOTALS_PAGE_MAX, TRADED_WALLETS_MAX, IDS_MAX, LAUNCH_LISTS_QUOTES_MAX, LAUNCH_LISTS_ROWS_MAX, INBOX_PAGE_DEFAULT, INBOX_PAGE_MAX, LAUNCHES_PAGE_DEFAULT, LAUNCHES_PAGE_MAX, LAUNCH_CURSOR_MAX, LAUNCH_SORTS, PEOPLE_PERSON_MAX, PRESET_FILTER_MAX, STREAM_STATE_MAX, WALLET_CURSOR_MAX, WALLET_PAGE_DEFAULT, WALLET_PAGE_MAX } from "./paths.js";
6
+ import { CANDLES_MANY_IDS_MAX, CANDLES_MANY_LIMIT_DEFAULT, CANDLES_MANY_ROWS_MAX, COBUYS_PAGE_DEFAULT, COBUYS_PAGE_MAX, FIRSTS_MAX, TIES_WALLETS_MAX, POSITION_TOTALS_PAGE_MAX, TRADED_WALLETS_MAX, IDS_MAX, LAUNCH_LISTS_QUOTES_MAX, LAUNCH_LISTS_ROWS_MAX, INBOX_PAGE_DEFAULT, INBOX_PAGE_MAX, LAUNCHES_PAGE_DEFAULT, LAUNCHES_PAGE_MAX, LAUNCH_CURSOR_MAX, LAUNCH_SORTS, PEOPLE_PERSON_MAX, PRESET_FILTER_MAX, REFERRAL_LAUNCHES_PAGE_MAX, STREAM_STATE_MAX, WALLET_CURSOR_MAX, WALLET_PAGE_DEFAULT, WALLET_PAGE_MAX, HELD_AT_MAX, HELD_WALLETS_MAX } from "./paths.js";
7
7
  import { SEARCH_PAGE_DEFAULT, SEARCH_PAGE_MAX, SEARCH_Q_MAX } from "./search.js";
8
+ import { PARTNER_QUOTE_UNIT } from "../scaledUi.js";
8
9
 
9
10
  export const UNITS = {
10
11
  site: "raw quote base units, token math units (6 dp), Q64.64 prices, unix s; bigint as decimal strings; USD as decimal strings",
@@ -84,9 +85,10 @@ function site (s ) {
84
85
  const params = [...s.pattern.matchAll(/<(launch|wallet|token|handle)>/g)].map((m) => m[1] );
85
86
  const { v2, ...rest } = s;
86
87
  const aliases = s.aliases ?? (v2 ? [s.pattern.replace(/^\/floor-amm\//, "/floor-amm/v2/")] : []);
87
- return { mount: "chain", query: {}, page: NONE, errors: GATED, gated: true, units: "site", audience: "site", ...rest, params, aliases };
88
+ return { mount: "chain", query: {}, page: NONE, errors: GATED, gated: true, units: "site", quoteUnit: "raw", audience: "site", ...rest, params, aliases };
88
89
  }
89
- function partner (s ) {
90
+
91
+ function partner (s ) {
90
92
  return { mount: "chain", params: [], query: {}, page: NONE, errors: [...GATED, "bad_query"], gated: true, units: "partner", audience: "partner", aliases: [], ...s };
91
93
  }
92
94
 
@@ -209,6 +211,7 @@ export const INDEXER_CONTRACT = {
209
211
  devTrades: site({ pattern: "/floor-amm/launches/<launch>/dev", v2: true, query: { limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...LAUNCH_ERR, "bad_query"], body: B.DEV_TRADES }),
210
212
 
211
213
  burns: site({ pattern: "/floor-amm/launches/<launch>/burns", v2: true, query: { limit: LIMIT(100, 500), before: BEFORE, wallet: { kind: "string", doc: "only this wallet's burns (EVM case-blind; not a wallet on the chain: 400)" } }, page: cursor(100, 500), errors: [...LAUNCH_ERR, "bad_query"], body: B.BURNS }),
214
+ deals: site({ pattern: "/floor-amm/launches/<launch>/deals", v2: true, errors: LAUNCH_ERR, body: B.DEALS }),
212
215
  launchLocks: site({ pattern: "/floor-amm/launches/<launch>/locks", v2: true, errors: LAUNCH_ERR, body: B.LAUNCH_LOCKS }),
213
216
  marks: site({
214
217
  pattern: "/floor-amm/launches/<launch>/marks",
@@ -252,6 +255,19 @@ export const INDEXER_CONTRACT = {
252
255
  errors: [...LAUNCH_ERR, "bad_query"],
253
256
  body: B.LAUNCH_TRADED,
254
257
  }),
258
+
259
+ launchTies: site({
260
+ pattern: "/floor-amm/launches/<launch>/ties",
261
+ v2: true,
262
+ query: {
263
+ wallets: { kind: "list", doc: "the wallets asked, answered in this order", required: true, min: 1, max: TIES_WALLETS_MAX },
264
+ at: { kind: "unix", doc: "the second the ties are read around (a person's first buy, or a deal's Accept)", required: true },
265
+ from: { kind: "unix", doc: "the window's start (absent: at − 7 d)" },
266
+ to: { kind: "unix", doc: "the window's end, inclusive (absent: at + 7 d)" },
267
+ },
268
+ errors: [...LAUNCH_ERR, "bad_query"],
269
+ body: B.LAUNCH_TIES,
270
+ }),
255
271
  highs: site({
256
272
  pattern: "/floor-amm/launches/<launch>/highs",
257
273
  v2: true,
@@ -289,6 +305,38 @@ export const INDEXER_CONTRACT = {
289
305
  errors: [...GATED, "bad_query"],
290
306
  body: B.CANDLES_MANY,
291
307
  }),
308
+
309
+ mcap: site({
310
+ pattern: "/floor-amm/launches/<launch>/mcap",
311
+ v2: true,
312
+ query: {
313
+ interval: { kind: "enum", doc: "the bucket", values: B.MCAP_INTERVALS, default: "1h" },
314
+ from: { kind: "unix", doc: "first bucket's time, inclusive" },
315
+ to: { kind: "unix", doc: "last bucket's time, inclusive (absent: the indexed head)" },
316
+ limit: LIMIT(B.MCAP_PAGE_MAX, B.MCAP_PAGE_MAX),
317
+ before: { kind: "unix", doc: "a page's next: only buckets starting before it" },
318
+ },
319
+ page: cursor(B.MCAP_PAGE_MAX, B.MCAP_PAGE_MAX),
320
+ errors: [...LAUNCH_ERR, "bad_query"],
321
+ body: B.MCAP,
322
+ }),
323
+
324
+ held: site({
325
+ pattern: "/floor-amm/launches/<launch>/held",
326
+ v2: true,
327
+ query: {
328
+ wallets: { kind: "list", doc: "the wallets (EVM case-blind)", required: true, min: 1, max: HELD_WALLETS_MAX },
329
+ at: { kind: "list", doc: "the times (unix s) to read; not with the series' keys", max: HELD_AT_MAX },
330
+ interval: { kind: "enum", doc: "the series' bucket", values: B.MCAP_INTERVALS, default: "1h" },
331
+ from: { kind: "unix", doc: "series: first bucket's time, inclusive" },
332
+ to: { kind: "unix", doc: "series: last bucket's time, inclusive (absent: the indexed head)" },
333
+ limit: LIMIT(B.MCAP_PAGE_MAX, B.MCAP_PAGE_MAX),
334
+ before: { kind: "unix", doc: "series: a page's next: only buckets starting before it" },
335
+ },
336
+ page: cursor(B.MCAP_PAGE_MAX, B.MCAP_PAGE_MAX),
337
+ errors: [...LAUNCH_ERR, "bad_query"],
338
+ body: B.HELD,
339
+ }),
292
340
  candleBundle: site({
293
341
  pattern: "/floor-amm/launches/<launch>/candle-bundle",
294
342
  v2: true,
@@ -350,6 +398,10 @@ export const INDEXER_CONTRACT = {
350
398
  walletLocks: site({ pattern: "/floor-amm/wallets/<wallet>/locks", v2: true, query: WALLET_PAGE_KEYS("opaque, launch create order"), page: WALLET_PAGE, errors: WALLET_ERR, body: B.WALLET_LOCKS }),
351
399
  claimHistory: site({ pattern: "/floor-amm/wallets/<wallet>/claims", query: WALLET_PAGE_KEYS("opaque, newest first"), page: WALLET_PAGE, errors: WALLET_ERR, body: B.CLAIM_HISTORY }),
352
400
  firsts: site({ pattern: "/floor-amm/wallets/<wallet>/firsts", errors: WALLET_ERR, body: B.FIRSTS }),
401
+
402
+ walletStats: site({ pattern: "/floor-amm/wallets/<wallet>/stats", v2: true, errors: WALLET_ERR, body: B.WALLET_STATS }),
403
+
404
+ cobuys: site({ pattern: "/floor-amm/wallets/<wallet>/cobuys", query: { limit: LIMIT(COBUYS_PAGE_DEFAULT, COBUYS_PAGE_MAX) }, page: limit(COBUYS_PAGE_DEFAULT, COBUYS_PAGE_MAX), errors: WALLET_ERR, body: B.COBUYS }),
353
405
  firstsMany: site({ pattern: "/floor-amm/wallets/firsts", query: { wallets: { kind: "list", doc: "the wallets", required: true, min: 1, max: FIRSTS_MAX } }, errors: WALLET_ERR, body: B.FIRSTS_MANY }),
354
406
  claimView: site({ pattern: "/floor-amm/claims/<wallet>", query: WALLET_PAGE_KEYS("a page's next: the last row key (l:<launch>, r:<account>, p:<traderRef>, o:<quote>), string order"), page: WALLET_PAGE, errors: [...WALLET_ERR, "bad_query", "no_reader"], body: B.CLAIM_VIEW }),
355
407
 
@@ -360,6 +412,18 @@ export const INDEXER_CONTRACT = {
360
412
  errors: WALLET_ERR,
361
413
  body: B.PEOPLE,
362
414
  }),
415
+
416
+ referralLaunches: site({
417
+ pattern: "/floor-amm/referrals/<wallet>/launches",
418
+ query: {
419
+ launch: { kind: "string", doc: "only this launch's row (an id or its token)" },
420
+ limit: { kind: "int", doc: "launches a page", min: 1, max: REFERRAL_LAUNCHES_PAGE_MAX, default: WALLET_PAGE_DEFAULT },
421
+ cursor: { kind: "string", doc: "a page's next (opaque, launch create order)", max: WALLET_CURSOR_MAX, without: ["launch"] },
422
+ },
423
+ page: keyset(WALLET_PAGE_DEFAULT, REFERRAL_LAUNCHES_PAGE_MAX),
424
+ errors: [...WALLET_ERR, "unknown_launch"],
425
+ body: B.REFERRAL_LAUNCHES,
426
+ }),
363
427
  roles: site({ pattern: "/floor-amm/roles/<wallet>", query: WALLET_PAGE_KEYS("opaque, a page of launches in create order"), page: WALLET_PAGE, errors: WALLET_ERR, body: B.ROLES }),
364
428
 
365
429
  handlePlaces: site({
@@ -373,6 +437,7 @@ export const INDEXER_CONTRACT = {
373
437
 
374
438
  tokenHolders: partner({
375
439
  pattern: "/floor-amm/holders/<token>",
440
+ quoteUnit: "none",
376
441
  aliases: ["/holders/<token>"],
377
442
  params: ["token"],
378
443
  query: { limit: LIMIT(100, 500), offset: { kind: "int", doc: "rows skipped", min: 0, default: 0 } },
@@ -380,12 +445,13 @@ export const INDEXER_CONTRACT = {
380
445
  errors: [...GATED, "bad_query", "not_found"],
381
446
  body: P.TOKEN_HOLDERS,
382
447
  }),
383
- dexAsset: partner({ pattern: "/v2/dex/asset", aliases: ["/asset"], query: { id: { kind: "string", doc: "a launch's token, or a quote", required: true } }, errors: [...GATED, "bad_query", "not_found", "not_indexed"], body: P.DEX_ASSET }),
384
- dexSummary: partner({ pattern: "/v2/dex/summary", aliases: ["/summary"], query: { id: { kind: "string", doc: "the pair id", required: true } }, errors: [...GATED, "bad_query", "not_found"], body: P.DEX_SUMMARY }),
385
- dexPair: partner({ pattern: "/v2/dex/pair", aliases: ["/pair"], query: { id: { kind: "string", doc: "the pair id", required: true } }, errors: [...GATED, "unknown_launch"], body: P.DEX_PAIR }),
386
- cgPairs: partner({ pattern: "/v2/coingecko/pairs", aliases: ["/coingecko/pairs"], errors: GATED, body: P.CG_PAIRS }),
387
- cgTickers: partner({ pattern: "/v2/coingecko/tickers", aliases: ["/coingecko/tickers"], errors: GATED, body: P.CG_TICKERS }),
448
+ dexAsset: partner({ quoteUnit: PARTNER_QUOTE_UNIT.dexscreener, pattern: "/v2/dex/asset", aliases: ["/asset"], query: { id: { kind: "string", doc: "a launch's token, or a quote", required: true } }, errors: [...GATED, "bad_query", "not_found", "not_indexed"], body: P.DEX_ASSET }),
449
+ dexSummary: partner({ quoteUnit: PARTNER_QUOTE_UNIT.dexscreener, pattern: "/v2/dex/summary", aliases: ["/summary"], query: { id: { kind: "string", doc: "the pair id", required: true } }, errors: [...GATED, "bad_query", "not_found"], body: P.DEX_SUMMARY }),
450
+ dexPair: partner({ quoteUnit: PARTNER_QUOTE_UNIT.dexscreener, pattern: "/v2/dex/pair", aliases: ["/pair"], query: { id: { kind: "string", doc: "the pair id", required: true } }, errors: [...GATED, "unknown_launch"], body: P.DEX_PAIR }),
451
+ cgPairs: partner({ quoteUnit: "none", pattern: "/v2/coingecko/pairs", aliases: ["/coingecko/pairs"], errors: GATED, body: P.CG_PAIRS }),
452
+ cgTickers: partner({ quoteUnit: PARTNER_QUOTE_UNIT.coingecko, pattern: "/v2/coingecko/tickers", aliases: ["/coingecko/tickers"], errors: GATED, body: P.CG_TICKERS }),
388
453
  cgHistoricalTrades: partner({
454
+ quoteUnit: PARTNER_QUOTE_UNIT.coingecko,
389
455
  pattern: "/v2/coingecko/historical_trades",
390
456
  aliases: ["/coingecko/historical_trades", "/historical_trades"],
391
457
  query: {
@@ -401,15 +467,16 @@ export const INDEXER_CONTRACT = {
401
467
  errors: [...GATED, "bad_query", "not_found", "too_many"],
402
468
  body: P.CG_HISTORICAL,
403
469
  }),
404
- llamaTvl: partner({ pattern: "/v2/defillama/tvl", errors: GATED, body: P.LLAMA_TVL }),
470
+ llamaTvl: partner({ quoteUnit: PARTNER_QUOTE_UNIT.defillama, pattern: "/v2/defillama/tvl", errors: GATED, body: P.LLAMA_TVL }),
405
471
  llamaFees: partner({
472
+ quoteUnit: PARTNER_QUOTE_UNIT.defillama,
406
473
  pattern: "/v2/defillama/fees",
407
474
  query: { from: { kind: "unix", doc: "window start, inclusive (with to)" }, to: { kind: "unix", doc: "window end, exclusive (with from)" } },
408
475
  page: { kind: "range", from: "from", to: "to" },
409
476
  body: P.LLAMA_FEES,
410
477
  }),
411
478
 
412
- health: { pattern: "/health", aliases: [], mount: "root", params: [], query: {}, page: NONE, errors: [], gated: false, units: "site", audience: "ops", body: P.HEALTH },
479
+ health: { pattern: "/health", aliases: [], mount: "root", params: [], query: {}, page: NONE, errors: [], gated: false, units: "site", quoteUnit: "none", audience: "ops", body: P.HEALTH },
413
480
  } ;
414
481
 
415
482
  export const ROUTE_NAMES = Object.keys(INDEXER_CONTRACT) ;
@@ -541,7 +608,7 @@ const ROWS_PRODUCT =
541
608
  candlesMany: { list: "ids", max: CANDLES_MANY_ROWS_MAX },
542
609
  };
543
610
 
544
- const TABLE_REQUIRED = new Set (["search", "launchLists", "candlesMany", "raiseSeries", "launchTraded"]);
611
+ const TABLE_REQUIRED = new Set (["search", "launchLists", "candlesMany", "raiseSeries", "launchTraded", "launchTies"]);
545
612
 
546
613
  const BOOLS = { true: true, false: false, 1: true, 0: false };
547
614
 
@@ -24,13 +24,17 @@ export const INDEXER_ROUTES = {
24
24
  quoteChain: { pattern: "/floor-amm/launches/<launch>/chain", keys: [] },
25
25
  devTrades: { pattern: "/floor-amm/launches/<launch>/dev", keys: ["limit"] },
26
26
  burns: { pattern: "/floor-amm/launches/<launch>/burns", keys: ["limit", "before", "wallet"] },
27
+ deals: { pattern: "/floor-amm/launches/<launch>/deals", keys: [] },
27
28
  launchLocks: { pattern: "/floor-amm/launches/<launch>/locks", keys: [] },
28
29
  marks: { pattern: "/floor-amm/launches/<launch>/marks", keys: ["limit", "before"] },
29
30
  price: { pattern: "/floor-amm/launches/<launch>/price", keys: [] },
30
31
  raiseSeries: { pattern: "/floor-amm/launches/<launch>/raise-series", keys: ["step", "from", "to"] },
31
32
  floorSteps: { pattern: "/floor-amm/launches/<launch>/floor-steps", keys: ["from", "to", "points"] },
32
33
  launchTraded: { pattern: "/floor-amm/launches/<launch>/traded", keys: ["wallets"] },
34
+ launchTies: { pattern: "/floor-amm/launches/<launch>/ties", keys: ["wallets", "at", "from", "to"] },
33
35
  highs: { pattern: "/floor-amm/launches/<launch>/highs", keys: ["atLeast", "limit"] },
36
+ mcap: { pattern: "/floor-amm/launches/<launch>/mcap", keys: ["interval", "from", "to", "limit", "before"] },
37
+ held: { pattern: "/floor-amm/launches/<launch>/held", keys: ["wallets", "at", "interval", "from", "to", "limit", "before"] },
34
38
  candleBundle: { pattern: "/floor-amm/launches/<launch>/candle-bundle", keys: ["intervals", "limit"] },
35
39
  candles: { pattern: "/floor-amm/candles", keys: ["launch", "interval", "from", "to", "before", "limit"] },
36
40
  candlesMany: { pattern: "/floor-amm/candles/many", keys: ["ids", "interval", "before", "limit"] },
@@ -43,9 +47,12 @@ export const INDEXER_ROUTES = {
43
47
  walletLocks: { pattern: "/floor-amm/wallets/<wallet>/locks", keys: ["limit", "cursor"] },
44
48
  claimHistory: { pattern: "/floor-amm/wallets/<wallet>/claims", keys: ["limit", "cursor"] },
45
49
  firsts: { pattern: "/floor-amm/wallets/<wallet>/firsts", keys: [] },
50
+ walletStats: { pattern: "/floor-amm/wallets/<wallet>/stats", keys: [] },
51
+ cobuys: { pattern: "/floor-amm/wallets/<wallet>/cobuys", keys: ["limit"] },
46
52
  firstsMany: { pattern: "/floor-amm/wallets/firsts", keys: ["wallets"] },
47
53
  claimView: { pattern: "/floor-amm/claims/<wallet>", keys: ["limit", "cursor"] },
48
54
  people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: ["limit", "cursor", "person"] },
55
+ referralLaunches: { pattern: "/floor-amm/referrals/<wallet>/launches", keys: ["launch", "limit", "cursor"] },
49
56
  roles: { pattern: "/floor-amm/roles/<wallet>", keys: ["limit", "cursor"] },
50
57
  handlePlaces: { pattern: "/floor-amm/handles/<handle>/places", keys: ["limit", "cursor"] },
51
58
  traderBoard: { pattern: "/floor-amm/leaderboards/traders", keys: ["window", "limit"] },
@@ -86,10 +93,29 @@ export const TRADED_WALLETS_MAX = 100;
86
93
 
87
94
  export const POSITION_TOTALS_PAGE_MAX = 100;
88
95
 
96
+ export const HELD_WALLETS_MAX = 100;
97
+ export const HELD_AT_MAX = 200;
98
+
89
99
  export const STREAM_STATE_MAX = 16;
90
100
 
91
101
  export const PEOPLE_PERSON_MAX = 8;
92
102
 
103
+ export const TIES_WALLETS_MAX = 100;
104
+
105
+ export const REFERRAL_LAUNCHES_PAGE_MAX = 100;
106
+
107
+ export const TIES_WINDOW_S = 7 * 86_400;
108
+
109
+ export const TIES_ACTIVE_S = 30 * 86_400;
110
+
111
+ export const TIES_HOLD_DAYS = [7, 30] ;
112
+
113
+ export const COBUY_WINDOW_S = 600;
114
+ export const COBUY_MIN_LAUNCHES = 3;
115
+
116
+ export const COBUYS_PAGE_DEFAULT = 100;
117
+ export const COBUYS_PAGE_MAX = 500;
118
+
93
119
  export function query(q ) {
94
120
  const p = new URLSearchParams();
95
121
  for (const [k, v] of Object.entries(q)) {
@@ -159,6 +185,7 @@ export const indexerPath = {
159
185
  devTrades: (id , q = {}) => launchPath(id, `/dev${query({ limit: q.limit })}`),
160
186
 
161
187
  burns: (id , q = {}) => launchPath(id, `/burns${query({ limit: q.limit, before: q.before, wallet: q.wallet })}`),
188
+ deals: (id ) => launchPath(id, "/deals"),
162
189
  launchLocks: (id ) => launchPath(id, "/locks"),
163
190
  marks: (id , q = {}) => launchPath(id, `/marks${query({ limit: q.limit, before: q.before })}`),
164
191
  price: (id ) => launchPath(id, "/price"),
@@ -170,9 +197,23 @@ export const indexerPath = {
170
197
  return launchPath(id, `/traded${query({ wallets })}`);
171
198
  },
172
199
 
200
+ launchTies: (id , q ) => {
201
+ if (q.wallets.length === 0 || q.wallets.length > TIES_WALLETS_MAX) throw new RangeError(`1..${TIES_WALLETS_MAX} wallets`);
202
+ if (q.from !== undefined && q.to !== undefined && q.from > q.to) throw new RangeError("from > to");
203
+ return launchPath(id, `/ties${query({ wallets: q.wallets, at: q.at, from: q.from, to: q.to })}`);
204
+ },
205
+
173
206
  highs: (id , q = {}) => launchPath(id, `/highs${query({ atLeast: q.atLeast === undefined ? undefined : String(q.atLeast), limit: q.limit })}`),
174
207
 
175
208
  candleBundle: (id , q = {}) => launchPath(id, `/candle-bundle${query({ intervals: q.intervals?.length ? q.intervals : undefined, limit: q.limit })}`),
209
+ mcap: (id , q = {}) => launchPath(id, `/mcap${query({ interval: q.interval, from: q.from, to: q.to, limit: q.limit, before: q.before })}`),
210
+ held: (id , q ) => {
211
+ if (q.wallets.length === 0 || q.wallets.length > HELD_WALLETS_MAX) throw new RangeError(`1..${HELD_WALLETS_MAX} wallets`);
212
+ if (q.at !== undefined) {
213
+ if (q.at.length === 0 || q.at.length > HELD_AT_MAX) throw new RangeError(`1..${HELD_AT_MAX} times`);
214
+ }
215
+ return launchPath(id, `/held${query({ wallets: q.wallets.join(","), at: q.at?.join(","), interval: q.interval, from: q.from, to: q.to, limit: q.limit, before: q.before })}`);
216
+ },
176
217
  candles: (q ) => {
177
218
  if (q.before !== undefined && (q.from !== undefined || q.to !== undefined)) throw new RangeError("before cannot be given with from / to");
178
219
  if (q.limit !== undefined && q.before === undefined) throw new RangeError("limit is read only with before");
@@ -195,6 +236,9 @@ export const indexerPath = {
195
236
 
196
237
  claimHistory: (w , q = {}) => walletPath(w, `/claims${query({ limit: q.limit, cursor: q.cursor })}`),
197
238
  firsts: (w ) => walletPath(w, "/firsts"),
239
+ walletStats: (w ) => walletPath(w, "/stats"),
240
+
241
+ cobuys: (w , q = {}) => walletPath(w, `/cobuys${query({ limit: q.limit })}`),
198
242
  firstsMany: (wallets ) => {
199
243
  if (wallets.length === 0 || wallets.length > FIRSTS_MAX) throw new RangeError(`1..${FIRSTS_MAX} wallets`);
200
244
  return `/floor-amm/wallets/firsts${query({ wallets })}`;
@@ -211,6 +255,8 @@ export const indexerPath = {
211
255
  return `/floor-amm/referrals/${seg(w)}/people${query({ limit: q.limit, cursor: q.cursor, person: q.person })}`;
212
256
  },
213
257
 
258
+ referralLaunches: (w , q = {}) => `/floor-amm/referrals/${seg(w)}/launches${query({ launch: q.launch, limit: q.limit, cursor: q.cursor })}`,
259
+
214
260
  roles: (w , q = {}) => `/floor-amm/roles/${seg(w)}${query({ limit: q.limit, cursor: q.cursor })}`,
215
261
  handlePlaces: (handle , q = {}) => `/floor-amm/handles/${seg(handle)}/places${query({ limit: q.limit, cursor: q.cursor })}`,
216
262
  traderBoard: (q = {}) => `/floor-amm/leaderboards/traders${query({ window: q.window, limit: q.limit })}`,
@@ -9,7 +9,7 @@ import { errorCode } from "./contract.js";
9
9
  export * from "./bodies.js";
10
10
  export { ShapeError, decode } from "./decode.js";
11
11
 
12
- export { FIRSTS_MAX, POSITION_TOTALS_PAGE_MAX, TRADED_WALLETS_MAX, IDS_MAX, INDEXER_ROUTES, LAUNCHES_PAGE_DEFAULT, LAUNCHES_PAGE_MAX, LAUNCH_CURSOR_MAX, LAUNCH_SORTS, PEOPLE_PERSON_MAX, PRESET_FILTER_MAX, STREAM_STATE_MAX, INBOX_PAGE_DEFAULT, INBOX_PAGE_MAX, WALLET_CURSOR_MAX, WALLET_PAGE_DEFAULT, WALLET_PAGE_MAX, indexerPath, query } from "./paths.js";
12
+ export { COBUY_MIN_LAUNCHES, COBUY_WINDOW_S, COBUYS_PAGE_DEFAULT, COBUYS_PAGE_MAX, FIRSTS_MAX, POSITION_TOTALS_PAGE_MAX, TIES_ACTIVE_S, TIES_HOLD_DAYS, TIES_WALLETS_MAX, TIES_WINDOW_S, TRADED_WALLETS_MAX, IDS_MAX, INDEXER_ROUTES, LAUNCHES_PAGE_DEFAULT, LAUNCHES_PAGE_MAX, LAUNCH_CURSOR_MAX, LAUNCH_SORTS, PEOPLE_PERSON_MAX, PRESET_FILTER_MAX, REFERRAL_LAUNCHES_PAGE_MAX, STREAM_STATE_MAX, INBOX_PAGE_DEFAULT, INBOX_PAGE_MAX, WALLET_CURSOR_MAX, WALLET_PAGE_DEFAULT, WALLET_PAGE_MAX, indexerPath, query } from "./paths.js";
13
13
  export { ADDRESS_PREFIX_MIN, SEARCH_PAGE_DEFAULT, SEARCH_PAGE_MAX, SEARCH_PARITY_CORPUS, SEARCH_Q_MAX, SEARCH_SUBSTRING_MIN, searchFold, searchNeedle, searchNeedles, searchServed, searchServedTier, searchTier, searchTierFolded } from "./search.js";
14
14
 
15
15
  export * from "./partners.js";
@@ -89,6 +89,8 @@ export const readQuoteChain = (get , id ) =>
89
89
  export const readDevTrades = (get , id , q = {}) => readRoute(get, indexerPath.devTrades(id, q), B.DEV_TRADES);
90
90
 
91
91
  export const readBurns = (get , id , q = {}) => readRoute(get, indexerPath.burns(id, q), B.BURNS);
92
+
93
+ export const readDeals = (get , id ) => readRoute(get, indexerPath.deals(id), B.DEALS);
92
94
  export const readLaunchLocks = (get , id ) => readRoute(get, indexerPath.launchLocks(id), B.LAUNCH_LOCKS);
93
95
 
94
96
  export const readMarks = (get , id , q = {}) => readRoute(get, indexerPath.marks(id, q), B.MARKS);
@@ -100,12 +102,18 @@ export const readFloorSteps = (get , id , q = {})
100
102
 
101
103
  export const readLaunchTraded = (get , id , wallets ) => readRoute(get, indexerPath.launchTraded(id, wallets), B.LAUNCH_TRADED);
102
104
 
105
+ export const readLaunchTies = (get , id , q ) => readRoute(get, indexerPath.launchTies(id, q), B.LAUNCH_TIES);
106
+
103
107
  export const readPositionTotals = (get , wallet , q = {}) => readRoute(get, indexerPath.positionTotals(wallet, q), B.POSITION_TOTALS);
104
108
 
105
109
  export const readCandles = (get , q ) => readRoute(get, indexerPath.candles(q), B.CANDLES);
106
110
 
107
111
  export const readCandlesMany = (get , q ) => readRoute(get, indexerPath.candlesMany(q), B.CANDLES_MANY);
108
112
  export const readCandleBundle = (get , id , q = {}) => readRoute(get, indexerPath.candleBundle(id, q), B.CANDLE_BUNDLE);
113
+
114
+ export const readMcap = (get , id , q = {}) => readRoute(get, indexerPath.mcap(id, q), B.MCAP);
115
+
116
+ export const readHeld = (get , id , q ) => readRoute(get, indexerPath.held(id, q), B.HELD);
109
117
  export const readHighs = (get , id , q = {}) => readRoute(get, indexerPath.highs(id, q), B.HIGHS);
110
118
 
111
119
  export const readWalletTrades = (get , wallet , q = {}) => readRoute(get, indexerPath.walletTrades(wallet, q), B.WALLET_TRADES);
@@ -119,9 +127,14 @@ export const readClaimHistory = (get , wallet , q = {})
119
127
 
120
128
  export const readClaimView = (get , wallet , q = {}) => readRoute(get, indexerPath.claimView(wallet, q), B.CLAIM_VIEW);
121
129
  export const readFirsts = (get , wallet ) => readRoute(get, indexerPath.firsts(wallet), B.FIRSTS);
130
+ export const readWalletStats = (get , wallet ) => readRoute(get, indexerPath.walletStats(wallet), B.WALLET_STATS);
131
+
132
+ export const readCobuys = (get , wallet , q = {}) => readRoute(get, indexerPath.cobuys(wallet, q), B.COBUYS);
122
133
 
123
134
  export const readFirstsMany = (get , wallets ) => readRoute(get, indexerPath.firstsMany(wallets), B.FIRSTS_MANY);
124
135
  export const readPeople = (get , wallet , q = {}) => readRoute(get, indexerPath.people(wallet, q), B.PEOPLE);
136
+
137
+ export const readReferralLaunches = (get , wallet , q = {}) => readRoute(get, indexerPath.referralLaunches(wallet, q), B.REFERRAL_LAUNCHES);
125
138
  export const readRoles = (get , wallet , q = {}) => readRoute(get, indexerPath.roles(wallet, q), B.ROLES);
126
139
 
127
140
  export const readHandlePlaces = (get , handle , q = {}) => readRoute(get, indexerPath.handlePlaces(handle, q), B.HANDLE_PLACES);
@@ -31,6 +31,9 @@ export const KIND_TAIL = 5;
31
31
 
32
32
   
33
33
 
34
+  
35
+  
36
+
34
37
   
35
38
 
36
39
   
@@ -200,19 +203,31 @@ export const ckMoney = (b ) => sum(b.bandMoney, b.nBands) - sum(b.b
200
203
 
201
204
  export const ckHeld = (b ) => sum(b.bandTokens, b.nBands) + b.ckFloorTokens;
202
205
 
206
+ export const kKeptOf = (b ) => b.kKept ?? 0;
207
+
208
+ export const isK = (b , j ) => j >= b.nC || (j < 32 && ((kKeptOf(b) >>> j) & 1) === 1);
209
+
203
210
  export const kSeg = (b ) => (b.kpot && b.nBands === b.nC + 1 ? b.nC : null);
204
211
 
205
- export const cMoney = (b ) => sum(b.bandMoney, b.nC) - sum(b.bandF, b.nC) + (b.ckAtF - b.kAtF);
212
+ export const cMoney = (b ) => {
213
+ let t = b.ckAtF - b.kAtF;
214
+ for (let i = 0; i < b.nC; i++) if (!isK(b, i)) t += b.bandMoney[i] - b.bandF[i];
215
+ return t;
216
+ };
206
217
 
207
218
  export const kMoney = (b ) => ckMoney(b) - cMoney(b);
208
219
 
209
- export const cHeld = (b ) => sum(b.bandTokens, b.nC) + (b.ckFloorTokens - b.kFloorTokens);
220
+ export const cHeld = (b ) => {
221
+ let t = b.ckFloorTokens - b.kFloorTokens;
222
+ for (let i = 0; i < b.nC; i++) if (!isK(b, i)) t += b.bandTokens[i];
223
+ return t;
224
+ };
210
225
 
211
226
  export const kHeld = (b ) => ckHeld(b) - cHeld(b);
212
227
 
213
228
  export function kHolds(b ) {
214
- const k = kSeg(b);
215
- return k !== null && (b.bandTokens[k] > 0n || b.bandFClaim[k] > 0n);
229
+ for (let i = 0; i < b.nBands; i++) if (isK(b, i) && (b.bandTokens[i] > 0n || b.bandFClaim[i] > 0n)) return true;
230
+ return false;
216
231
  }
217
232
 
218
233
  const bidMoneySum = (b ) => b.floor + sum(b.bandMoney, b.nBands);
@@ -280,6 +295,8 @@ export function checkBook(b ) {
280
295
  if (b.ckAtF > b.floor || b.ckFloorTokens > b.floorTokens) fail("Overflow");
281
296
  if (b.kAtF > b.ckAtF || b.kFloorTokens > b.ckFloorTokens) fail("Overflow");
282
297
  if (b.kpot && b.nBands > b.nC + 1) fail("SqrtRange");
298
+ if (kKeptOf(b) !== 0 && (!b.kpot || kKeptOf(b) >>> b.nC !== 0)) fail("SqrtRange");
299
+ for (let i = 0; i < b.nC; i++) if ((kKeptOf(b) >>> i) & 1 && (b.bandMoney[i] !== 0n || b.bandF[i] !== 0n)) fail("SqrtRange");
283
300
  }
284
301
 
285
302
  function flatUp(b ) {
@@ -606,8 +623,8 @@ export function walkDownAcc(b , tokens , acc , u = new
606
623
  b.bandFClaim[j] = u128(b.bandFClaim[j] + dF);
607
624
  b.bandMoney[j] -= q;
608
625
  b.bandTokens[j] = u64(b.bandTokens[j] + dx);
609
- if (j < b.nC) w.fromC += q;
610
- else w.fromK += q;
626
+ if (isK(b, j)) w.fromK += q;
627
+ else w.fromC += q;
611
628
  b.sqrtP = p2;
612
629
  rem -= dx;
613
630
  w.tokens += dx; w.money += q;
@@ -617,7 +634,7 @@ export function walkDownAcc(b , tokens , acc , u = new
617
634
  b.floor = u128(b.floor + b.bandMoney[j]);
618
635
  b.ckAtF = u128(b.ckAtF + b.bandMoney[j] - b.bandF[j]);
619
636
 
620
- if (kSeg(b) === j) b.kAtF = u128(b.kAtF + b.bandMoney[j] - b.bandF[j]);
637
+ if (b.kpot && isK(b, j)) b.kAtF = u128(b.kAtF + b.bandMoney[j] - b.bandF[j]);
621
638
  b.bandMoney[j] = 0n;
622
639
  b.bandF[j] = 0n;
623
640
  }
@@ -115,7 +115,7 @@ export function teamBuyV2(book , gross , max ) {
115
115
  const take = gross < max ? gross : max;
116
116
  if (take === 0n) {
117
117
  return { gross, net: 0n, refund: gross, tokens: 0n, fees: [0n, 0n, 0n, 0n, 0n], fromResale: 0n, fromFirst: 0n, steps: 0, budgetHit: false, graduatedNow: false, sqrtBefore: book.sqrtP, sqrtAfter: book.sqrtP,
118
- split: { dF: 0n, ckAdd: 0n, ckTake: 0n, cAdd: 0n, kAdd: 0n, cTake: 0n, kTake: 0n, ms: 0n, booked: [0n, 0n, 0n, 0n], sqrtFNew: 0n }, relay: { nC: 0, nK: 0, laidC: 0n, laidK: 0n, atF: 0n, kAtF: 0n, kept: 0 } };
118
+ split: { dF: 0n, ckAdd: 0n, ckTake: 0n, cAdd: 0n, kAdd: 0n, cTake: 0n, kTake: 0n, ms: 0n, booked: [0n, 0n, 0n, 0n], sqrtFNew: 0n }, relay: { nC: 0, nK: 0, laidC: 0n, laidK: 0n, atF: 0n, kAtF: 0n, merges: 0, tiers: 0, tail: false, kept: 0 } };
119
119
  }
120
120
  const r = bookBuy(book, take, 0n);
121
121
  return { ...r, refund: r.refund + gross - take, gross };