@floorlaunchpad/sdk 0.4.1 → 0.7.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.
- package/CHANGELOG.md +219 -18
- package/README.md +0 -2
- package/dist/abi/evm-event-names.js +7 -0
- package/dist/abi/evm.gen.js +6 -0
- package/dist/abi/functions.gen.js +49 -1
- package/dist/abi/solana.gen.js +5 -0
- package/dist/config/generated.js +77 -0
- package/dist/errors.js +2 -2
- package/dist/events/types.gen.js +1 -1
- package/dist/evm/chains.js +32 -24
- package/dist/evm/floor/calls.js +5 -0
- package/dist/evm/router.js +1 -25
- package/dist/evm/squid.js +3 -3
- package/dist/generated/interface.gen.js +48 -43
- package/dist/index.js +1 -0
- package/dist/indexer/bodies.js +137 -2
- package/dist/indexer/client.js +10 -1
- package/dist/indexer/contract.js +65 -6
- package/dist/indexer/paths.js +34 -7
- package/dist/indexer/read.js +12 -3
- package/dist/indexer/stream.js +2 -2
- package/dist/math/v2/book.js +40 -7
- package/dist/math/v2/create.js +1 -1
- package/dist/math/v2/fees.js +30 -4
- package/dist/math/v2/milestones.js +1 -1
- package/dist/math/v2/receipt.js +3 -3
- package/dist/math/v2/relay.js +201 -1
- package/dist/math/v2/rows.js +17 -0
- package/dist/math/v2/split.js +60 -15
- package/dist/math/v2/team.js +14 -1
- package/dist/math/v2/trade.js +16 -8
- package/dist/solana/floor/accounts.js +30 -3
- package/dist/solana/floor/events.js +6 -0
- package/dist/solana/floor/instructions.js +23 -1
- package/dist/solana/floor/program.js +3 -0
- package/dist/ton/addresses.js +36 -0
- package/dist/ton/book-check.js +23 -0
- package/dist/ton/book.js +119 -0
- package/dist/ton/cell.js +542 -0
- package/dist/ton/consts.generated.js +17 -0
- package/dist/ton/content.js +83 -0
- package/dist/ton/gas.js +198 -0
- package/dist/ton/governance.js +401 -0
- package/dist/ton/index.js +18 -0
- package/dist/ton/messages.js +340 -0
- package/dist/ton/ops.js +37 -0
- package/dist/ton/price.js +51 -0
- package/dist/ton/quote-entry.js +116 -0
- package/dist/ton/quote.js +25 -0
- package/dist/ton/reader.js +378 -0
- package/dist/ton/types.js +43 -0
- package/dist/ton/wallet.js +26 -0
- package/dist/v2/events.js +2 -0
- package/dist/v2/evm.js +8 -1
- package/dist/v2/layouts.js +7 -1
- package/dist/v2/router.js +2 -2
- package/dist/v2/solana.js +1 -1
- package/dist/v2/solanaSettle.js +2 -0
- package/dist/v2/tx/evm.js +15 -1
- package/docs/aggregator.md +0 -22
- package/docs/bot.md +0 -8
- package/docs/cursor-pages.md +9 -5
- package/docs/frontend.md +0 -2
- package/docs/ton.md +107 -0
- package/docs/wallet.md +0 -2
- package/examples/floor-line.html +1 -1
- package/package.json +6 -1
- package/src/abi/evm-event-names.ts +7 -0
- package/src/abi/evm.gen.ts +6 -0
- package/src/abi/functions.gen.ts +49 -1
- package/src/abi/solana.gen.ts +5 -0
- package/src/config/generated.ts +77 -0
- package/src/errors.ts +2 -2
- package/src/events/types.gen.ts +57 -1
- package/src/evm/chains.ts +34 -28
- package/src/evm/floor/calls.ts +5 -0
- package/src/evm/router.ts +1 -26
- package/src/evm/squid.ts +3 -3
- package/src/generated/interface.gen.ts +48 -43
- package/src/index.ts +1 -0
- package/src/indexer/bodies.ts +144 -2
- package/src/indexer/client.ts +17 -4
- package/src/indexer/contract.ts +66 -7
- package/src/indexer/paths.ts +62 -7
- package/src/indexer/read.ts +14 -5
- package/src/indexer/stream.ts +4 -4
- package/src/math/v2/book.ts +42 -7
- package/src/math/v2/create.ts +1 -1
- package/src/math/v2/fees.ts +30 -4
- package/src/math/v2/milestones.ts +1 -1
- package/src/math/v2/receipt.ts +7 -3
- package/src/math/v2/relay.ts +208 -1
- package/src/math/v2/rows.ts +17 -0
- package/src/math/v2/split.ts +70 -16
- package/src/math/v2/team.ts +14 -1
- package/src/math/v2/trade.ts +16 -8
- package/src/solana/floor/accounts.ts +30 -3
- package/src/solana/floor/events.ts +6 -0
- package/src/solana/floor/instructions.ts +23 -1
- package/src/solana/floor/program.ts +3 -0
- package/src/ton/addresses.ts +38 -0
- package/src/ton/book-check.ts +24 -0
- package/src/ton/book.ts +136 -0
- package/src/ton/cell.ts +547 -0
- package/src/ton/consts.generated.ts +17 -0
- package/src/ton/content.ts +97 -0
- package/src/ton/gas.ts +209 -0
- package/src/ton/governance.ts +452 -0
- package/src/ton/index.ts +18 -0
- package/src/ton/messages.ts +343 -0
- package/src/ton/ops.ts +37 -0
- package/src/ton/price.ts +54 -0
- package/src/ton/quote-entry.ts +138 -0
- package/src/ton/quote.ts +67 -0
- package/src/ton/reader.ts +420 -0
- package/src/ton/types.ts +201 -0
- package/src/ton/wallet.ts +30 -0
- package/src/v2/events.ts +3 -1
- package/src/v2/evm.ts +10 -1
- package/src/v2/layouts.ts +7 -1
- package/src/v2/router.ts +2 -2
- package/src/v2/solana.ts +1 -1
- package/src/v2/solanaSettle.ts +2 -0
- package/src/v2/tx/evm.ts +15 -1
- package/src/v2/types.ts +14 -1
package/src/indexer/bodies.ts
CHANGED
|
@@ -135,12 +135,27 @@ const LISTED_FIELDS = {
|
|
|
135
135
|
volume24hGross: nullable(big),
|
|
136
136
|
holders: int,
|
|
137
137
|
|
|
138
|
+
holdersChange1h: nullable(int),
|
|
139
|
+
|
|
140
|
+
holdersChange24h: nullable(int),
|
|
141
|
+
|
|
142
|
+
volume1h: nullable(big),
|
|
143
|
+
|
|
144
|
+
volumePrev1h: nullable(big),
|
|
145
|
+
|
|
138
146
|
maxLossPpm: optional(nullable(int)),
|
|
139
147
|
|
|
140
148
|
backedPpm: nullable(int),
|
|
141
149
|
volume24hUsd: nullable(decimal),
|
|
150
|
+
|
|
151
|
+
volume1hUsd: nullable(decimal),
|
|
152
|
+
volumePrev1hUsd: nullable(decimal),
|
|
142
153
|
marketCapUsd: nullable(decimal),
|
|
143
154
|
|
|
155
|
+
athPrice: nullable(big),
|
|
156
|
+
|
|
157
|
+
athPriceUsd: nullable(decimal),
|
|
158
|
+
|
|
144
159
|
trendingScore: nullable(big),
|
|
145
160
|
|
|
146
161
|
change24hBps: optional(nullable(int)),
|
|
@@ -187,6 +202,12 @@ const TRADE_FIELDS = {
|
|
|
187
202
|
export const TRADE = object(TRADE_FIELDS);
|
|
188
203
|
export type Trade = Infer<typeof TRADE>;
|
|
189
204
|
|
|
205
|
+
export const TRADE_REFS = object({ tp: optional(str), t: optional(array(str)), cp: optional(str), c: optional(array(str)) });
|
|
206
|
+
export type TradeRefs = Infer<typeof TRADE_REFS>;
|
|
207
|
+
|
|
208
|
+
export const STREAM_TRADE = object({ ...TRADE_FIELDS, refs: optional(TRADE_REFS) });
|
|
209
|
+
export type StreamTrade = Infer<typeof STREAM_TRADE>;
|
|
210
|
+
|
|
190
211
|
export const PAGED_TRADE = object({ id: str, ...TRADE_FIELDS });
|
|
191
212
|
export type PagedTrade = Infer<typeof PAGED_TRADE>;
|
|
192
213
|
|
|
@@ -306,7 +327,7 @@ export type LaunchClaim = Infer<typeof LAUNCH_CLAIM>;
|
|
|
306
327
|
export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM), next: optional(nullable(str)) });
|
|
307
328
|
export type LaunchClaims = Infer<typeof LAUNCH_CLAIMS>;
|
|
308
329
|
|
|
309
|
-
export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY), next: optional(nullable(str)) });
|
|
330
|
+
export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY), next: optional(nullable(str)), totals: object({ count: int, tokens: big, quote: big }), asOf: nullable(str) });
|
|
310
331
|
export type DevBuys = Infer<typeof DEV_BUYS>;
|
|
311
332
|
|
|
312
333
|
export const MEMBER_SOLD_ROW = object({ launch: str, member: str, place: int, amount: big, quoteOut: big, block: int, timestamp: int, tx: str, id: str });
|
|
@@ -410,6 +431,120 @@ export type DevTrades = Infer<typeof DEV_TRADES>;
|
|
|
410
431
|
export const BURNS = object({ indexed, launch: str, burns: array(object({ id: optional(str), amount: big, block: int, timestamp: int })), program: array(object({ ...BURN_FIELDS, id: optional(str) })), wallet: array(object({ ...BURN_FIELDS, id: optional(str) })), next: optional(nullable(str)) });
|
|
411
432
|
export type Burns = Infer<typeof BURNS>;
|
|
412
433
|
|
|
434
|
+
export const RT_POINTS_MAX = 720;
|
|
435
|
+
|
|
436
|
+
export const RAISE_STEPS = [60, 300, 900, 3_600, 14_400, 86_400] as const;
|
|
437
|
+
|
|
438
|
+
function checked<T>(d: Decoder<T>, ok: (v: T) => string | null): Decoder<T> {
|
|
439
|
+
return (v, p) => {
|
|
440
|
+
const x = d(v, p);
|
|
441
|
+
const why = ok(x);
|
|
442
|
+
if (why !== null) throw new ShapeError(p, why, v);
|
|
443
|
+
return x;
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
const ascending = (xs: readonly { time: number }[], strict: boolean): boolean => xs.every((x, i) => i === 0 || (strict ? x.time > xs[i - 1]!.time : x.time >= xs[i - 1]!.time));
|
|
447
|
+
|
|
448
|
+
export const RAISE_COUNTS = object({
|
|
449
|
+
buys: int,
|
|
450
|
+
sells: int,
|
|
451
|
+
|
|
452
|
+
last: nullable(int),
|
|
453
|
+
|
|
454
|
+
largest: nullable(object({ time: int, amount: big, id: str })),
|
|
455
|
+
|
|
456
|
+
raised: big,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
export const RAISE_SERIES = checked(
|
|
460
|
+
object({
|
|
461
|
+
indexed,
|
|
462
|
+
launch: str,
|
|
463
|
+
from: int,
|
|
464
|
+
to: int,
|
|
465
|
+
step: int,
|
|
466
|
+
points: array(object({ time: int, liveTotal: big })),
|
|
467
|
+
pace: array(object({ time: int, bought: big, sold: big })),
|
|
468
|
+
counts: RAISE_COUNTS,
|
|
469
|
+
total: int,
|
|
470
|
+
first: nullable(str),
|
|
471
|
+
asOf: nullable(str),
|
|
472
|
+
}),
|
|
473
|
+
(b) => (b.points.length > RT_POINTS_MAX ? `at most ${RT_POINTS_MAX} points` : !b.points.every((x, i) => i === 0 || x.time === b.points[i - 1]!.time + b.step) ? "points on the grid, oldest first" : !ascending(b.pace, true) ? "pace oldest first" : null),
|
|
474
|
+
);
|
|
475
|
+
export type RaiseSeries = Infer<typeof RAISE_SERIES>;
|
|
476
|
+
|
|
477
|
+
export const FLOOR_STEP = object({ id: str, block: int, timestamp: int, floorX64: big, floorMoney: nullable(big) });
|
|
478
|
+
|
|
479
|
+
export const FLOOR_STEPS = checked(
|
|
480
|
+
object({
|
|
481
|
+
indexed,
|
|
482
|
+
launch: str,
|
|
483
|
+
from: int,
|
|
484
|
+
to: int,
|
|
485
|
+
points: int,
|
|
486
|
+
steps: array(FLOOR_STEP),
|
|
487
|
+
totals: object({ steps: int, first: nullable(str), last: nullable(str), firstFloorX64: nullable(big), lastFloorX64: nullable(big) }),
|
|
488
|
+
asOf: nullable(str),
|
|
489
|
+
}),
|
|
490
|
+
(b) => (b.points > RT_POINTS_MAX || b.steps.length > b.points ? `at most ${Math.min(b.points, RT_POINTS_MAX)} steps` : !b.steps.every((x, i) => i === 0 || x.timestamp > b.steps[i - 1]!.timestamp) ? "steps oldest first" : b.steps.length > b.totals.steps ? "no more steps than the totals count" : null),
|
|
491
|
+
);
|
|
492
|
+
export type FloorSteps = Infer<typeof FLOOR_STEPS>;
|
|
493
|
+
|
|
494
|
+
export const roundTrip: Decoder<number> = (v, p) => {
|
|
495
|
+
if (typeof v !== "string") throw new ShapeError(p, "a round-trip number string", v);
|
|
496
|
+
const n = Number(v);
|
|
497
|
+
if (!Number.isFinite(n) || String(n) !== v) throw new ShapeError(p, "a round-trip number string", v);
|
|
498
|
+
return n;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
export const POSITION_FOLD = object({
|
|
502
|
+
|
|
503
|
+
held: roundTrip,
|
|
504
|
+
|
|
505
|
+
cost: roundTrip,
|
|
506
|
+
|
|
507
|
+
realised: roundTrip,
|
|
508
|
+
|
|
509
|
+
costSold: roundTrip,
|
|
510
|
+
|
|
511
|
+
uncoveredSold: roundTrip,
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
export const POSITION_TOTALS_ROW = object({
|
|
515
|
+
wallet: str,
|
|
516
|
+
launch: str,
|
|
517
|
+
token: str,
|
|
518
|
+
quote: str,
|
|
519
|
+
fills: int,
|
|
520
|
+
buys: int,
|
|
521
|
+
sells: int,
|
|
522
|
+
bought: big,
|
|
523
|
+
sold: big,
|
|
524
|
+
spent: big,
|
|
525
|
+
received: big,
|
|
526
|
+
teamBuy: big,
|
|
527
|
+
firstTs: nullable(int),
|
|
528
|
+
lastTs: nullable(int),
|
|
529
|
+
asOf: nullable(str),
|
|
530
|
+
quoteDecimals: nullable(int),
|
|
531
|
+
fold: nullable(POSITION_FOLD),
|
|
532
|
+
foldReason: nullable(str),
|
|
533
|
+
});
|
|
534
|
+
export type PositionTotalsRow = Infer<typeof POSITION_TOTALS_ROW>;
|
|
535
|
+
|
|
536
|
+
export const POSITION_TOTALS = checked(
|
|
537
|
+
object({ indexed, wallet: str, positions: array(POSITION_TOTALS_ROW), next: nullable(str) }),
|
|
538
|
+
(b) => (b.positions.some((r) => (r.fold === null) === (r.foldReason === null)) ? "fold or its reason, one of them" : b.positions.some((r) => r.fills !== r.buys + r.sells) ? "fills = buys + sells" : null),
|
|
539
|
+
);
|
|
540
|
+
export type PositionTotals = Infer<typeof POSITION_TOTALS>;
|
|
541
|
+
|
|
542
|
+
export const LAUNCH_TRADED = checked(
|
|
543
|
+
object({ indexed, launch: str, traded: array(object({ wallet: str, traded: bool, firstTs: nullable(int) })), asOf: nullable(str) }),
|
|
544
|
+
(b) => (b.traded.some((r) => r.traded === (r.firstTs === null)) ? "firstTs exactly where traded" : null),
|
|
545
|
+
);
|
|
546
|
+
export type LaunchTraded = Infer<typeof LAUNCH_TRADED>;
|
|
547
|
+
|
|
413
548
|
const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
|
|
414
549
|
|
|
415
550
|
export const TEAM_BUY_LOCK = object({ kind: oneOf("teamBuy"), tokens: big, createdAt: int, unlocked: bool, unlockedAt: nullable(int), unlockAt: nullable(int), locked: big, claimed: big, holders: array(LOCK_HOLDER) });
|
|
@@ -577,10 +712,17 @@ export const FIRSTS_MANY = object({ indexed, wallets: record(FIRSTS_ROW) });
|
|
|
577
712
|
|
|
578
713
|
const PER_QUOTE = array(object({ quote: str, amount: big }));
|
|
579
714
|
|
|
715
|
+
export const PEOPLE_ROLE = object({ kind: oneOf("trader", "creator"), tier: int, via: nullable(str) });
|
|
716
|
+
|
|
580
717
|
export const PEOPLE = object({
|
|
581
718
|
indexed,
|
|
582
719
|
wallet: str,
|
|
583
|
-
people: array(object({ wallet: str, chain: str, roles: array(
|
|
720
|
+
people: array(object({ wallet: str, chain: str, roles: array(PEOPLE_ROLE), earned: PER_QUOTE, teamMilestone: PER_QUOTE, unclaimed: PER_QUOTE })),
|
|
721
|
+
pooled: PER_QUOTE,
|
|
722
|
+
|
|
723
|
+
accountsAt: optional(nullable(int)),
|
|
724
|
+
|
|
725
|
+
og: optional(nullable(object({ from: int, until: int, revoked: bool }))),
|
|
584
726
|
|
|
585
727
|
next: optional(nullable(str)),
|
|
586
728
|
});
|
package/src/indexer/client.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { decode } from "./decode.ts";
|
|
|
4
4
|
import { INDEXER_CONTRACT, clampLimit, pageAsked, routeLimit } from "./contract.ts";
|
|
5
5
|
import type { RouteBody, RouteName } from "./contract.ts";
|
|
6
6
|
import { indexerPath, query } from "./paths.ts";
|
|
7
|
-
import type { CandlesManyQuery, CandlesQuery, LaunchListsQuery, LaunchSearchQuery, LaunchesQuery, Page, StreamQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
|
|
7
|
+
import type { CandlesManyQuery, CandlesQuery, FloorStepsQuery, PositionTotalsQuery, RaiseSeriesQuery, LaunchListsQuery, LaunchSearchQuery, LaunchesQuery, Page, PeopleQuery, StreamQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
|
|
8
8
|
import { IndexerError } from "./read.ts";
|
|
9
9
|
import type { Get } from "./read.ts";
|
|
10
10
|
import type { TraderWindow } from "./bodies.ts";
|
|
@@ -35,10 +35,13 @@ export interface RouteArgs {
|
|
|
35
35
|
traders: L & { window?: TraderWindow; limit?: number };
|
|
36
36
|
quoteChain: L;
|
|
37
37
|
devTrades: L & { limit?: number };
|
|
38
|
-
burns: L & Page;
|
|
38
|
+
burns: L & Page & { wallet?: string };
|
|
39
39
|
launchLocks: L;
|
|
40
40
|
marks: L & Page;
|
|
41
41
|
price: L;
|
|
42
|
+
raiseSeries: L & RaiseSeriesQuery;
|
|
43
|
+
floorSteps: L & FloorStepsQuery;
|
|
44
|
+
launchTraded: L & { wallets: readonly string[] };
|
|
42
45
|
highs: L & { atLeast?: bigint | string; limit?: number };
|
|
43
46
|
candles: CandlesQuery;
|
|
44
47
|
candlesMany: CandlesManyQuery;
|
|
@@ -47,13 +50,14 @@ export interface RouteArgs {
|
|
|
47
50
|
tonActivity: W & Page;
|
|
48
51
|
tonOutcome: W & { queryId: bigint | string };
|
|
49
52
|
positions: W & WalletPage;
|
|
53
|
+
positionTotals: W & PositionTotalsQuery;
|
|
50
54
|
inbox: W & { limit?: number; before?: string };
|
|
51
55
|
walletLocks: W & WalletPage;
|
|
52
56
|
claimHistory: W & WalletPage;
|
|
53
57
|
firsts: W;
|
|
54
58
|
firstsMany: { wallets: readonly string[] };
|
|
55
59
|
claimView: W & WalletPage;
|
|
56
|
-
people: W &
|
|
60
|
+
people: W & PeopleQuery;
|
|
57
61
|
roles: W & WalletPage;
|
|
58
62
|
handlePlaces: { handle: string } & WalletPage;
|
|
59
63
|
traderBoard: { window?: TraderWindow; limit?: number } | void;
|
|
@@ -102,6 +106,9 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
|
|
|
102
106
|
launchLocks: (a) => indexerPath.launchLocks(a.launch),
|
|
103
107
|
marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
|
|
104
108
|
price: (a) => indexerPath.price(a.launch),
|
|
109
|
+
raiseSeries: ({ launch, ...q }) => indexerPath.raiseSeries(launch, q),
|
|
110
|
+
floorSteps: ({ launch, ...q }) => indexerPath.floorSteps(launch, q),
|
|
111
|
+
launchTraded: (a) => indexerPath.launchTraded(a.launch, a.wallets),
|
|
105
112
|
highs: ({ launch, ...q }) => indexerPath.highs(launch, q),
|
|
106
113
|
candles: (a) => indexerPath.candles(a),
|
|
107
114
|
candlesMany: (a) => indexerPath.candlesMany(a),
|
|
@@ -110,6 +117,7 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
|
|
|
110
117
|
tonActivity: ({ wallet, ...q }) => indexerPath.tonActivity(wallet, q),
|
|
111
118
|
tonOutcome: (a) => indexerPath.tonOutcome(a.wallet, a.queryId),
|
|
112
119
|
positions: ({ wallet, ...q }) => indexerPath.positions(wallet, q),
|
|
120
|
+
positionTotals: ({ wallet, ...q }) => indexerPath.positionTotals(wallet, q),
|
|
113
121
|
inbox: ({ wallet, ...q }) => indexerPath.inbox(wallet, q),
|
|
114
122
|
walletLocks: ({ wallet, ...q }) => indexerPath.walletLocks(wallet, q),
|
|
115
123
|
claimHistory: ({ wallet, ...q }) => indexerPath.claimHistory(wallet, q),
|
|
@@ -136,7 +144,7 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
|
|
|
136
144
|
health: () => "/health",
|
|
137
145
|
};
|
|
138
146
|
|
|
139
|
-
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"] as const;
|
|
147
|
+
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"] as const;
|
|
140
148
|
export type DrainName = (typeof DRAIN_NAMES)[number];
|
|
141
149
|
|
|
142
150
|
export type ReadName = Exclude<RouteName, "stream">;
|
|
@@ -178,6 +186,11 @@ export function createIndexerClient(opts: IndexerClientOptions): IndexerClient {
|
|
|
178
186
|
const lim = routeLimit(name)!;
|
|
179
187
|
let args: Record<string, unknown> = { ...a };
|
|
180
188
|
|
|
189
|
+
if (args.person !== undefined) {
|
|
190
|
+
yield await read(name, args);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
181
194
|
if (page.kind === "cursor" && page.optIn !== undefined && args.before === undefined) args = { ...args, before: "" };
|
|
182
195
|
if (page.kind === "keyset" && page.optIn === true && args.limit === undefined && args.cursor === undefined) args = { ...args, limit: lim.default };
|
|
183
196
|
for (let i = 0; i < max; i++) {
|
package/src/indexer/contract.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Decoder } from "./decode.ts";
|
|
|
4
4
|
import { unknown } from "./decode.ts";
|
|
5
5
|
import * as B from "./bodies.ts";
|
|
6
6
|
import * as P from "./partners.ts";
|
|
7
|
-
import { CANDLES_MANY_IDS_MAX, CANDLES_MANY_LIMIT_DEFAULT, CANDLES_MANY_ROWS_MAX, FIRSTS_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, PRESET_FILTER_MAX, STREAM_STATE_MAX, WALLET_CURSOR_MAX, WALLET_PAGE_DEFAULT, WALLET_PAGE_MAX } from "./paths.ts";
|
|
7
|
+
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.ts";
|
|
8
8
|
import { SEARCH_PAGE_DEFAULT, SEARCH_PAGE_MAX, SEARCH_Q_MAX } from "./search.ts";
|
|
9
9
|
|
|
10
10
|
export const UNITS = {
|
|
@@ -100,7 +100,7 @@ export type Pagination =
|
|
|
100
100
|
readonly optIn?: true;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
| { readonly kind: "range"; readonly from: string; readonly to: string; readonly span?: { readonly interval: string; readonly max: number } };
|
|
103
|
+
| { readonly kind: "range"; readonly from: string; readonly to: string; readonly span?: { readonly interval: string; readonly max: number; readonly seconds?: true } };
|
|
104
104
|
|
|
105
105
|
export type PathParam = "launch" | "wallet" | "token" | "handle";
|
|
106
106
|
|
|
@@ -165,6 +165,9 @@ export const INDEXER_CONTRACT = {
|
|
|
165
165
|
launch: { kind: "list", doc: "only these launches' frames (and their quote chains' relatives)" },
|
|
166
166
|
state: { kind: "list", doc: "state frames (the launch whole on each change) for these", max: STREAM_STATE_MAX },
|
|
167
167
|
lastEventId: { kind: "string", doc: "resume after this frame id (EventSource sends Last-Event-ID itself)" },
|
|
168
|
+
seat: { kind: "enum", doc: "relay: the site relay's seat (pipes are refused first)", values: ["relay"] },
|
|
169
|
+
compress: { kind: "bool", doc: "1: compress the stream (zstd, br or gzip as Accept-Encoding allows; relay seats by default)" },
|
|
170
|
+
refs: { kind: "bool", doc: "1: the trade frames carry `refs` (who a trade credited) when a referrer was credited" },
|
|
168
171
|
},
|
|
169
172
|
body: unknown,
|
|
170
173
|
}),
|
|
@@ -267,7 +270,8 @@ export const INDEXER_CONTRACT = {
|
|
|
267
270
|
traders: site({ pattern: "/floor-amm/launches/<launch>/traders", v2: true, query: { window: WINDOW, limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...LAUNCH_ERR, "bad_query"], body: B.LAUNCH_TRADERS }),
|
|
268
271
|
quoteChain: site({ pattern: "/floor-amm/launches/<launch>/chain", v2: true, errors: LAUNCH_ERR, body: B.QUOTE_CHAIN }),
|
|
269
272
|
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 }),
|
|
270
|
-
|
|
273
|
+
|
|
274
|
+
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 }),
|
|
271
275
|
launchLocks: site({ pattern: "/floor-amm/launches/<launch>/locks", v2: true, errors: LAUNCH_ERR, body: B.LAUNCH_LOCKS }),
|
|
272
276
|
marks: site({
|
|
273
277
|
pattern: "/floor-amm/launches/<launch>/marks",
|
|
@@ -278,6 +282,39 @@ export const INDEXER_CONTRACT = {
|
|
|
278
282
|
body: B.MARKS,
|
|
279
283
|
}),
|
|
280
284
|
price: site({ pattern: "/floor-amm/launches/<launch>/price", v2: true, errors: LAUNCH_ERR, body: B.PRICE }),
|
|
285
|
+
|
|
286
|
+
raiseSeries: site({
|
|
287
|
+
pattern: "/floor-amm/launches/<launch>/raise-series",
|
|
288
|
+
v2: true,
|
|
289
|
+
query: {
|
|
290
|
+
step: { kind: "enum", doc: "the grid in seconds", values: B.RAISE_STEPS.map(String), required: true },
|
|
291
|
+
from: { kind: "unix", doc: "the grid's left edge (absent: the launch's open)" },
|
|
292
|
+
to: { kind: "unix", doc: "the right edge (absent: the indexed head's time; never before the last fill)" },
|
|
293
|
+
},
|
|
294
|
+
page: { kind: "range", from: "from", to: "to", span: { interval: "step", max: B.RT_POINTS_MAX, seconds: true } },
|
|
295
|
+
errors: [...LAUNCH_ERR, "bad_query"],
|
|
296
|
+
body: B.RAISE_SERIES,
|
|
297
|
+
}),
|
|
298
|
+
floorSteps: site({
|
|
299
|
+
pattern: "/floor-amm/launches/<launch>/floor-steps",
|
|
300
|
+
v2: true,
|
|
301
|
+
query: {
|
|
302
|
+
from: { kind: "unix", doc: "the window's start (absent: the graduation, else the open)" },
|
|
303
|
+
to: { kind: "unix", doc: "the slices' right edge (absent: the indexed head's time; never before the last step)" },
|
|
304
|
+
points: { kind: "int", doc: "the slices (the last step of each is kept)", min: 1, max: B.RT_POINTS_MAX, default: B.RT_POINTS_MAX },
|
|
305
|
+
},
|
|
306
|
+
page: { kind: "range", from: "from", to: "to" },
|
|
307
|
+
errors: [...LAUNCH_ERR, "bad_query"],
|
|
308
|
+
body: B.FLOOR_STEPS,
|
|
309
|
+
}),
|
|
310
|
+
|
|
311
|
+
launchTraded: site({
|
|
312
|
+
pattern: "/floor-amm/launches/<launch>/traded",
|
|
313
|
+
v2: true,
|
|
314
|
+
query: { wallets: { kind: "list", doc: "the wallets asked, answered in this order", required: true, min: 1, max: TRADED_WALLETS_MAX } },
|
|
315
|
+
errors: [...LAUNCH_ERR, "bad_query"],
|
|
316
|
+
body: B.LAUNCH_TRADED,
|
|
317
|
+
}),
|
|
281
318
|
highs: site({
|
|
282
319
|
pattern: "/floor-amm/launches/<launch>/highs",
|
|
283
320
|
v2: true,
|
|
@@ -352,6 +389,19 @@ export const INDEXER_CONTRACT = {
|
|
|
352
389
|
|
|
353
390
|
positions: site({ pattern: "/floor-amm/wallets/<wallet>/positions", v2: true, query: WALLET_PAGE_KEYS("opaque, launch create order"), page: WALLET_PAGE, errors: WALLET_ERR, body: B.POSITIONS }),
|
|
354
391
|
|
|
392
|
+
positionTotals: site({
|
|
393
|
+
pattern: "/floor-amm/wallets/<wallet>/position-totals",
|
|
394
|
+
v2: true,
|
|
395
|
+
query: {
|
|
396
|
+
launch: { kind: "string", doc: "only this launch's row (an id or its token)" },
|
|
397
|
+
limit: { kind: "int", doc: "launches a page (without launch)", min: 1, max: POSITION_TOTALS_PAGE_MAX, default: POSITION_TOTALS_PAGE_MAX },
|
|
398
|
+
cursor: { kind: "string", doc: "a page's next (opaque, launch create order)", max: WALLET_CURSOR_MAX, without: ["launch"] },
|
|
399
|
+
},
|
|
400
|
+
page: { kind: "keyset", limit: { default: POSITION_TOTALS_PAGE_MAX, max: POSITION_TOTALS_PAGE_MAX }, cursor: "cursor", next: "next", optIn: true },
|
|
401
|
+
errors: [...WALLET_ERR, "unknown_launch"],
|
|
402
|
+
body: B.POSITION_TOTALS,
|
|
403
|
+
}),
|
|
404
|
+
|
|
355
405
|
inbox: site({
|
|
356
406
|
pattern: "/floor-amm/wallets/<wallet>/inbox",
|
|
357
407
|
v2: true,
|
|
@@ -365,7 +415,14 @@ export const INDEXER_CONTRACT = {
|
|
|
365
415
|
firsts: site({ pattern: "/floor-amm/wallets/<wallet>/firsts", errors: WALLET_ERR, body: B.FIRSTS }),
|
|
366
416
|
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 }),
|
|
367
417
|
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 }),
|
|
368
|
-
|
|
418
|
+
|
|
419
|
+
people: site({
|
|
420
|
+
pattern: "/floor-amm/referrals/<wallet>/people",
|
|
421
|
+
query: { ...WALLET_PAGE_KEYS("opaque, referred wallet order"), person: { kind: "list", doc: "only these referred wallets' rows (distinct; no next)", min: 1, max: PEOPLE_PERSON_MAX, without: ["limit", "cursor"] } },
|
|
422
|
+
page: WALLET_PAGE,
|
|
423
|
+
errors: WALLET_ERR,
|
|
424
|
+
body: B.PEOPLE,
|
|
425
|
+
}),
|
|
369
426
|
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 }),
|
|
370
427
|
|
|
371
428
|
handlePlaces: site({
|
|
@@ -522,6 +579,7 @@ export function queryRefusal(name: RouteName, q: URLSearchParams): string | null
|
|
|
522
579
|
}
|
|
523
580
|
case "list": {
|
|
524
581
|
const parts = raw.split(",").filter((s) => s !== "");
|
|
582
|
+
if (k.min !== undefined && parts.length < k.min) return `at least ${k.min} ${key}`;
|
|
525
583
|
if (k.max !== undefined && parts.length > k.max) return `at most ${k.max} ${key}`;
|
|
526
584
|
const it = k.item;
|
|
527
585
|
if (it !== undefined && parts.some((x) => !DIGITS.test(x) || Number(x) < it.min || Number(x) > it.max)) return `each ${key} must be an integer ${it.min}..${it.max}`;
|
|
@@ -562,7 +620,7 @@ const ROWS_PRODUCT: Partial<Record<RouteName, { list: string; max: number }>> =
|
|
|
562
620
|
candlesMany: { list: "ids", max: CANDLES_MANY_ROWS_MAX },
|
|
563
621
|
};
|
|
564
622
|
|
|
565
|
-
const TABLE_REQUIRED: ReadonlySet<RouteName> = new Set<RouteName>(["search", "launchLists", "candlesMany"]);
|
|
623
|
+
const TABLE_REQUIRED: ReadonlySet<RouteName> = new Set<RouteName>(["search", "launchLists", "candlesMany", "raiseSeries", "launchTraded"]);
|
|
566
624
|
|
|
567
625
|
const BOOLS: Readonly<Record<string, boolean>> = { true: true, false: false, 1: true, 0: false };
|
|
568
626
|
|
|
@@ -581,7 +639,8 @@ export function queryBool(name: RouteName, q: URLSearchParams, key: string): boo
|
|
|
581
639
|
export function spanRefusal(name: RouteName, q: URLSearchParams, toDefault?: number): string | null {
|
|
582
640
|
const p: Pagination = INDEXER_CONTRACT[name].page;
|
|
583
641
|
if (p.kind !== "range" || p.span === undefined) return null;
|
|
584
|
-
const
|
|
642
|
+
const key = queryArg(name, q, p.span.interval) ?? "";
|
|
643
|
+
const sec = p.span.seconds === true ? (DIGITS.test(key) && Number(key) > 0 ? Number(key) : undefined) : (B.CANDLE_INTERVAL_SECS as Readonly<Record<string, number>>)[key];
|
|
585
644
|
const fromRaw = q.get(p.from), toRaw = q.get(p.to);
|
|
586
645
|
if (sec === undefined || fromRaw === null || !DIGITS.test(fromRaw)) return null;
|
|
587
646
|
const to = toRaw === null ? toDefault : DIGITS.test(toRaw) ? Number(toRaw) : undefined;
|
|
@@ -589,5 +648,5 @@ export function spanRefusal(name: RouteName, q: URLSearchParams, toDefault?: num
|
|
|
589
648
|
const from = Number(fromRaw);
|
|
590
649
|
if (from > to) return null;
|
|
591
650
|
const bucket = (t: number) => Math.floor(t / sec) * sec;
|
|
592
|
-
return (bucket(to) - bucket(from)) / sec + 1 > p.span.max ? `the range spans more than ${p.span.max} candles` : null;
|
|
651
|
+
return (bucket(to) - bucket(from)) / sec + 1 > p.span.max ? `the range spans more than ${p.span.max} ${p.span.seconds === true ? "points" : "candles"}` : null;
|
|
593
652
|
}
|
package/src/indexer/paths.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface IndexerRoute {
|
|
|
8
8
|
export const INDEXER_ROUTES = {
|
|
9
9
|
head: { pattern: "/floor-amm/head", keys: [] },
|
|
10
10
|
latestBlock: { pattern: "/floor-amm/latest-block", keys: [] },
|
|
11
|
-
stream: { pattern: "/floor-amm/stream", keys: ["launch", "state", "lastEventId"] },
|
|
11
|
+
stream: { pattern: "/floor-amm/stream", keys: ["launch", "state", "lastEventId", "seat", "compress", "refs"] },
|
|
12
12
|
quotes: { pattern: "/floor-amm/quotes", keys: [] },
|
|
13
13
|
summary: { pattern: "/floor-amm/summary", keys: [] },
|
|
14
14
|
floorRouted: { pattern: "/floor-amm/floor-routed", keys: ["limit", "cursor"] },
|
|
@@ -28,10 +28,13 @@ export const INDEXER_ROUTES = {
|
|
|
28
28
|
traders: { pattern: "/floor-amm/launches/<launch>/traders", keys: ["window", "limit"] },
|
|
29
29
|
quoteChain: { pattern: "/floor-amm/launches/<launch>/chain", keys: [] },
|
|
30
30
|
devTrades: { pattern: "/floor-amm/launches/<launch>/dev", keys: ["limit"] },
|
|
31
|
-
burns: { pattern: "/floor-amm/launches/<launch>/burns", keys: ["limit", "before"] },
|
|
31
|
+
burns: { pattern: "/floor-amm/launches/<launch>/burns", keys: ["limit", "before", "wallet"] },
|
|
32
32
|
launchLocks: { pattern: "/floor-amm/launches/<launch>/locks", keys: [] },
|
|
33
33
|
marks: { pattern: "/floor-amm/launches/<launch>/marks", keys: ["limit", "before"] },
|
|
34
34
|
price: { pattern: "/floor-amm/launches/<launch>/price", keys: [] },
|
|
35
|
+
raiseSeries: { pattern: "/floor-amm/launches/<launch>/raise-series", keys: ["step", "from", "to"] },
|
|
36
|
+
floorSteps: { pattern: "/floor-amm/launches/<launch>/floor-steps", keys: ["from", "to", "points"] },
|
|
37
|
+
launchTraded: { pattern: "/floor-amm/launches/<launch>/traded", keys: ["wallets"] },
|
|
35
38
|
highs: { pattern: "/floor-amm/launches/<launch>/highs", keys: ["atLeast", "limit"] },
|
|
36
39
|
candleBundle: { pattern: "/floor-amm/launches/<launch>/candle-bundle", keys: ["intervals", "limit"] },
|
|
37
40
|
candles: { pattern: "/floor-amm/candles", keys: ["launch", "interval", "from", "to", "before", "limit"] },
|
|
@@ -40,13 +43,14 @@ export const INDEXER_ROUTES = {
|
|
|
40
43
|
tonActivity: { pattern: "/floor-amm/wallets/<wallet>/ton-activity", keys: ["limit", "before"] },
|
|
41
44
|
tonOutcome: { pattern: "/floor-amm/wallets/<wallet>/ton-outcome", keys: ["queryId"] },
|
|
42
45
|
positions: { pattern: "/floor-amm/wallets/<wallet>/positions", keys: ["limit", "cursor"] },
|
|
46
|
+
positionTotals: { pattern: "/floor-amm/wallets/<wallet>/position-totals", keys: ["launch", "limit", "cursor"] },
|
|
43
47
|
inbox: { pattern: "/floor-amm/wallets/<wallet>/inbox", keys: ["limit", "before"] },
|
|
44
48
|
walletLocks: { pattern: "/floor-amm/wallets/<wallet>/locks", keys: ["limit", "cursor"] },
|
|
45
49
|
claimHistory: { pattern: "/floor-amm/wallets/<wallet>/claims", keys: ["limit", "cursor"] },
|
|
46
50
|
firsts: { pattern: "/floor-amm/wallets/<wallet>/firsts", keys: [] },
|
|
47
51
|
firstsMany: { pattern: "/floor-amm/wallets/firsts", keys: ["wallets"] },
|
|
48
52
|
claimView: { pattern: "/floor-amm/claims/<wallet>", keys: ["limit", "cursor"] },
|
|
49
|
-
people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: ["limit", "cursor"] },
|
|
53
|
+
people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: ["limit", "cursor", "person"] },
|
|
50
54
|
roles: { pattern: "/floor-amm/roles/<wallet>", keys: ["limit", "cursor"] },
|
|
51
55
|
handlePlaces: { pattern: "/floor-amm/handles/<handle>/places", keys: ["limit", "cursor"] },
|
|
52
56
|
traderBoard: { pattern: "/floor-amm/leaderboards/traders", keys: ["window", "limit"] },
|
|
@@ -55,7 +59,7 @@ export const INDEXER_ROUTES = {
|
|
|
55
59
|
|
|
56
60
|
export type IndexerRouteName = keyof typeof INDEXER_ROUTES;
|
|
57
61
|
|
|
58
|
-
export const LAUNCH_SORTS = ["created", "newest", "volume1h", "volume24h", "volume7d", "volume", "marketCap", "liquidity", "backed", "trades24h", "holders", "change1h", "change24h", "lastTrade", "nearFloor", "trending", "
|
|
62
|
+
export const LAUNCH_SORTS = ["created", "newest", "volume1h", "volume24h", "volume7d", "volume", "marketCap", "liquidity", "backed", "trades24h", "holders", "change1h", "change24h", "lastTrade", "nearFloor", "trending", "holdersChange24h", "standingVolume", "standingMarketCap", "standingBacked", "maxloss"] as const;
|
|
59
63
|
export type LaunchSort = (typeof LAUNCH_SORTS)[number];
|
|
60
64
|
|
|
61
65
|
export const IDS_MAX = 100;
|
|
@@ -86,8 +90,14 @@ export const PRESET_FILTER_MAX = 16;
|
|
|
86
90
|
|
|
87
91
|
export const FIRSTS_MAX = 100;
|
|
88
92
|
|
|
93
|
+
export const TRADED_WALLETS_MAX = 100;
|
|
94
|
+
|
|
95
|
+
export const POSITION_TOTALS_PAGE_MAX = 100;
|
|
96
|
+
|
|
89
97
|
export const STREAM_STATE_MAX = 16;
|
|
90
98
|
|
|
99
|
+
export const PEOPLE_PERSON_MAX = 8;
|
|
100
|
+
|
|
91
101
|
type QueryValue = string | number | boolean | readonly string[] | undefined | null;
|
|
92
102
|
|
|
93
103
|
export function query(q: Record<string, QueryValue>): string {
|
|
@@ -175,6 +185,10 @@ export interface WalletPage {
|
|
|
175
185
|
cursor?: string;
|
|
176
186
|
}
|
|
177
187
|
|
|
188
|
+
export interface PeopleQuery extends WalletPage {
|
|
189
|
+
person?: readonly string[];
|
|
190
|
+
}
|
|
191
|
+
|
|
178
192
|
export interface Page {
|
|
179
193
|
limit?: number;
|
|
180
194
|
|
|
@@ -203,6 +217,24 @@ export interface CandlesQuery {
|
|
|
203
217
|
limit?: number;
|
|
204
218
|
}
|
|
205
219
|
|
|
220
|
+
export interface RaiseSeriesQuery {
|
|
221
|
+
step: number;
|
|
222
|
+
from?: number;
|
|
223
|
+
to?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface PositionTotalsQuery {
|
|
227
|
+
launch?: string;
|
|
228
|
+
limit?: number;
|
|
229
|
+
cursor?: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface FloorStepsQuery {
|
|
233
|
+
from?: number;
|
|
234
|
+
to?: number;
|
|
235
|
+
points?: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
206
238
|
export interface StreamQuery {
|
|
207
239
|
|
|
208
240
|
launch?: readonly string[];
|
|
@@ -210,6 +242,12 @@ export interface StreamQuery {
|
|
|
210
242
|
state?: readonly string[];
|
|
211
243
|
|
|
212
244
|
lastEventId?: string;
|
|
245
|
+
|
|
246
|
+
seat?: "relay";
|
|
247
|
+
|
|
248
|
+
compress?: boolean;
|
|
249
|
+
|
|
250
|
+
refs?: boolean;
|
|
213
251
|
}
|
|
214
252
|
|
|
215
253
|
export const indexerPath = {
|
|
@@ -217,7 +255,7 @@ export const indexerPath = {
|
|
|
217
255
|
latestBlock: (): string => "/floor-amm/latest-block",
|
|
218
256
|
stream: (q: StreamQuery = {}): string => {
|
|
219
257
|
if ((q.state?.length ?? 0) > STREAM_STATE_MAX) throw new RangeError(`at most ${STREAM_STATE_MAX} state ids`);
|
|
220
|
-
return `/floor-amm/stream${query({ launch: q.launch?.length ? q.launch : undefined, state: q.state?.length ? q.state : undefined, lastEventId: q.lastEventId })}`;
|
|
258
|
+
return `/floor-amm/stream${query({ launch: q.launch?.length ? q.launch : undefined, state: q.state?.length ? q.state : undefined, lastEventId: q.lastEventId, seat: q.seat, compress: q.compress === true ? 1 : undefined, refs: q.refs === true ? 1 : undefined })}`;
|
|
221
259
|
},
|
|
222
260
|
quotes: (): string => "/floor-amm/quotes",
|
|
223
261
|
summary: (): string => "/floor-amm/summary",
|
|
@@ -254,10 +292,18 @@ export const indexerPath = {
|
|
|
254
292
|
traders: (id: string, q: { window?: "1h" | "24h" | "7d" | "all"; limit?: number } = {}): string => launchPath(id, `/traders${query({ window: q.window, limit: q.limit })}`),
|
|
255
293
|
quoteChain: (id: string): string => launchPath(id, "/chain"),
|
|
256
294
|
devTrades: (id: string, q: { limit?: number } = {}): string => launchPath(id, `/dev${query({ limit: q.limit })}`),
|
|
257
|
-
|
|
295
|
+
|
|
296
|
+
burns: (id: string, q: Page & { wallet?: string } = {}): string => launchPath(id, `/burns${query({ limit: q.limit, before: q.before, wallet: q.wallet })}`),
|
|
258
297
|
launchLocks: (id: string): string => launchPath(id, "/locks"),
|
|
259
298
|
marks: (id: string, q: Page = {}): string => launchPath(id, `/marks${query({ limit: q.limit, before: q.before })}`),
|
|
260
299
|
price: (id: string): string => launchPath(id, "/price"),
|
|
300
|
+
raiseSeries: (id: string, q: RaiseSeriesQuery): string => launchPath(id, `/raise-series${query({ step: q.step, from: q.from, to: q.to })}`),
|
|
301
|
+
floorSteps: (id: string, q: FloorStepsQuery = {}): string => launchPath(id, `/floor-steps${query({ from: q.from, to: q.to, points: q.points })}`),
|
|
302
|
+
|
|
303
|
+
launchTraded: (id: string, wallets: readonly string[]): string => {
|
|
304
|
+
if (wallets.length === 0 || wallets.length > TRADED_WALLETS_MAX) throw new RangeError(`1..${TRADED_WALLETS_MAX} wallets`);
|
|
305
|
+
return launchPath(id, `/traded${query({ wallets })}`);
|
|
306
|
+
},
|
|
261
307
|
|
|
262
308
|
highs: (id: string, q: { atLeast?: bigint | string; limit?: number } = {}): string => launchPath(id, `/highs${query({ atLeast: q.atLeast === undefined ? undefined : String(q.atLeast), limit: q.limit })}`),
|
|
263
309
|
|
|
@@ -277,6 +323,7 @@ export const indexerPath = {
|
|
|
277
323
|
tonOutcome: (w: string, queryId: bigint | string): string => walletPath(w, `/ton-outcome${query({ queryId: String(queryId) })}`),
|
|
278
324
|
|
|
279
325
|
positions: (w: string, q: WalletPage = {}): string => walletPath(w, `/positions${query({ limit: q.limit, cursor: q.cursor })}`),
|
|
326
|
+
positionTotals: (w: string, q: PositionTotalsQuery = {}): string => walletPath(w, `/position-totals${query({ launch: q.launch, limit: q.limit, cursor: q.cursor })}`),
|
|
280
327
|
|
|
281
328
|
inbox: (w: string, q: { limit?: number; before?: string } = {}): string => walletPath(w, `/inbox${query({ limit: q.limit, before: q.before })}`),
|
|
282
329
|
walletLocks: (w: string, q: WalletPage = {}): string => walletPath(w, `/locks${query({ limit: q.limit, cursor: q.cursor })}`),
|
|
@@ -289,7 +336,15 @@ export const indexerPath = {
|
|
|
289
336
|
},
|
|
290
337
|
claimView: (w: string, q: WalletPage = {}): string => `/floor-amm/claims/${seg(w)}${query({ limit: q.limit, cursor: q.cursor })}`,
|
|
291
338
|
|
|
292
|
-
people: (w: string, q:
|
|
339
|
+
people: (w: string, q: PeopleQuery = {}): string => {
|
|
340
|
+
if (q.person !== undefined) {
|
|
341
|
+
|
|
342
|
+
const canon = q.person.map((w) => (/^0x[0-9a-fA-F]{40}$/.test(w) ? w.toLowerCase() : w));
|
|
343
|
+
if (q.person.length < 1 || q.person.length > PEOPLE_PERSON_MAX || new Set(canon).size !== canon.length) throw new RangeError(`1..${PEOPLE_PERSON_MAX} distinct person wallets`);
|
|
344
|
+
if (q.limit !== undefined || q.cursor !== undefined) throw new RangeError("person cannot be given with limit / cursor");
|
|
345
|
+
}
|
|
346
|
+
return `/floor-amm/referrals/${seg(w)}/people${query({ limit: q.limit, cursor: q.cursor, person: q.person })}`;
|
|
347
|
+
},
|
|
293
348
|
|
|
294
349
|
roles: (w: string, q: WalletPage = {}): string => `/floor-amm/roles/${seg(w)}${query({ limit: q.limit, cursor: q.cursor })}`,
|
|
295
350
|
handlePlaces: (handle: string, q: WalletPage = {}): string => `/floor-amm/handles/${seg(handle)}/places${query({ limit: q.limit, cursor: q.cursor })}`,
|
package/src/indexer/read.ts
CHANGED
|
@@ -6,12 +6,12 @@ import * as B from "./bodies.ts";
|
|
|
6
6
|
import { indexerPath } from "./paths.ts";
|
|
7
7
|
import { errorCode } from "./contract.ts";
|
|
8
8
|
import type { IndexerErrorCode } from "./contract.ts";
|
|
9
|
-
import type { CandlesManyQuery, CandlesQuery, LaunchListsQuery, LaunchSearchQuery, LaunchesQuery, Page, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
|
|
9
|
+
import type { CandlesManyQuery, CandlesQuery, FloorStepsQuery, PositionTotalsQuery, RaiseSeriesQuery, LaunchListsQuery, LaunchSearchQuery, LaunchesQuery, Page, PeopleQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
|
|
10
10
|
|
|
11
11
|
export * from "./bodies.ts";
|
|
12
12
|
export { ShapeError, decode } from "./decode.ts";
|
|
13
13
|
export type { Decoder, Infer } from "./decode.ts";
|
|
14
|
-
export { FIRSTS_MAX, IDS_MAX, INDEXER_ROUTES, LAUNCHES_PAGE_DEFAULT, LAUNCHES_PAGE_MAX, LAUNCH_CURSOR_MAX, LAUNCH_SORTS, 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.ts";
|
|
14
|
+
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.ts";
|
|
15
15
|
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.ts";
|
|
16
16
|
export type { SearchSubject, SearchTier } from "./search.ts";
|
|
17
17
|
export * from "./partners.ts";
|
|
@@ -20,7 +20,7 @@ export { INDEXER_CONTRACT, INDEXER_ERROR_CODES, LIMITS, OPEN_ROUTES, ROUTE_NAMES
|
|
|
20
20
|
export type { IndexerErrorCode, Pagination, PathParam, QueryKey, RouteBody, RouteContract, RouteName, Served, ServedBody, ServedKeys, Units } from "./contract.ts";
|
|
21
21
|
export { DRAIN_NAMES, createIndexerClient, routePath } from "./client.ts";
|
|
22
22
|
export type { DrainName, IndexerClient, IndexerClientOptions, ReadName, RouteArgs } from "./client.ts";
|
|
23
|
-
export type { CandlesManyQuery, CandlesQuery, LaunchListsQuery, IndexerRoute, IndexerRouteName, LaunchSearchQuery, LaunchSort, LaunchesQuery, Page, StreamQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
|
|
23
|
+
export type { CandlesManyQuery, CandlesQuery, FloorStepsQuery, PositionTotalsQuery, RaiseSeriesQuery, LaunchListsQuery, IndexerRoute, IndexerRouteName, LaunchSearchQuery, LaunchSort, LaunchesQuery, Page, PeopleQuery, StreamQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
|
|
24
24
|
|
|
25
25
|
export type LaunchId = string;
|
|
26
26
|
|
|
@@ -97,12 +97,21 @@ export const readTraders = (get: Get, id: LaunchId, q: { window?: B.TraderWindow
|
|
|
97
97
|
export const readQuoteChain = (get: Get, id: LaunchId): Promise<B.QuoteChain> => readRoute(get, indexerPath.quoteChain(id), B.QUOTE_CHAIN);
|
|
98
98
|
|
|
99
99
|
export const readDevTrades = (get: Get, id: LaunchId, q: { limit?: number } = {}): Promise<B.DevTrades> => readRoute(get, indexerPath.devTrades(id, q), B.DEV_TRADES);
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
export const readBurns = (get: Get, id: LaunchId, q: Page & { wallet?: string } = {}): Promise<B.Burns> => readRoute(get, indexerPath.burns(id, q), B.BURNS);
|
|
101
102
|
export const readLaunchLocks = (get: Get, id: LaunchId): Promise<B.LaunchLocks> => readRoute(get, indexerPath.launchLocks(id), B.LAUNCH_LOCKS);
|
|
102
103
|
|
|
103
104
|
export const readMarks = (get: Get, id: LaunchId, q: Page = {}): Promise<B.Marks> => readRoute(get, indexerPath.marks(id, q), B.MARKS);
|
|
104
105
|
export const readPrice = (get: Get, id: LaunchId): Promise<B.Price> => readRoute(get, indexerPath.price(id), B.PRICE);
|
|
105
106
|
|
|
107
|
+
export const readRaiseSeries = (get: Get, id: LaunchId, q: RaiseSeriesQuery): Promise<B.RaiseSeries> => readRoute(get, indexerPath.raiseSeries(id, q), B.RAISE_SERIES);
|
|
108
|
+
|
|
109
|
+
export const readFloorSteps = (get: Get, id: LaunchId, q: FloorStepsQuery = {}): Promise<B.FloorSteps> => readRoute(get, indexerPath.floorSteps(id, q), B.FLOOR_STEPS);
|
|
110
|
+
|
|
111
|
+
export const readLaunchTraded = (get: Get, id: LaunchId, wallets: readonly string[]): Promise<B.LaunchTraded> => readRoute(get, indexerPath.launchTraded(id, wallets), B.LAUNCH_TRADED);
|
|
112
|
+
|
|
113
|
+
export const readPositionTotals = (get: Get, wallet: string, q: PositionTotalsQuery = {}): Promise<B.PositionTotals> => readRoute(get, indexerPath.positionTotals(wallet, q), B.POSITION_TOTALS);
|
|
114
|
+
|
|
106
115
|
export const readCandles = (get: Get, q: CandlesQuery): Promise<B.Candles> => readRoute(get, indexerPath.candles(q), B.CANDLES);
|
|
107
116
|
|
|
108
117
|
export const readCandlesMany = (get: Get, q: CandlesManyQuery): Promise<B.CandlesMany> => readRoute(get, indexerPath.candlesMany(q), B.CANDLES_MANY);
|
|
@@ -122,7 +131,7 @@ export const readClaimView = (get: Get, wallet: string, q: WalletPage = {}): Pro
|
|
|
122
131
|
export const readFirsts = (get: Get, wallet: string): Promise<At & { wallet: string } & B.Firsts> => readRoute(get, indexerPath.firsts(wallet), B.FIRSTS);
|
|
123
132
|
|
|
124
133
|
export const readFirstsMany = (get: Get, wallets: readonly string[]): Promise<At & { wallets: Record<string, B.Firsts> }> => readRoute(get, indexerPath.firstsMany(wallets), B.FIRSTS_MANY);
|
|
125
|
-
export const readPeople = (get: Get, wallet: string, q:
|
|
134
|
+
export const readPeople = (get: Get, wallet: string, q: PeopleQuery = {}): Promise<B.People> => readRoute(get, indexerPath.people(wallet, q), B.PEOPLE);
|
|
126
135
|
export const readRoles = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.Roles> => readRoute(get, indexerPath.roles(wallet, q), B.ROLES);
|
|
127
136
|
|
|
128
137
|
export const readHandlePlaces = (get: Get, handle: string, q: WalletPage = {}): Promise<B.HandlePlaces> => readRoute(get, indexerPath.handlePlaces(handle, q), B.HANDLE_PLACES);
|