@floorlaunchpad/sdk 0.6.0 → 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 +136 -0
- package/dist/abi/evm-event-names.js +7 -0
- package/dist/abi/evm.gen.js +6 -0
- package/dist/abi/functions.gen.js +48 -0
- package/dist/abi/solana.gen.js +5 -0
- package/dist/errors.js +2 -2
- package/dist/events/types.gen.js +1 -1
- package/dist/evm/chains.js +31 -0
- package/dist/evm/floor/calls.js +5 -0
- package/dist/evm/squid.js +1 -1
- package/dist/generated/interface.gen.js +48 -43
- package/dist/indexer/bodies.js +135 -4
- 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/fees.js +30 -4
- package/dist/math/v2/milestones.js +1 -1
- package/dist/math/v2/receipt.js +3 -3
- package/dist/math/v2/rows.js +17 -0
- package/dist/math/v2/team.js +14 -1
- 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/gas.js +2 -2
- package/dist/v2/events.js +2 -0
- package/dist/v2/evm.js +5 -0
- package/dist/v2/layouts.js +3 -1
- package/dist/v2/solana.js +1 -1
- package/dist/v2/tx/evm.js +15 -1
- package/docs/cursor-pages.md +9 -3
- package/docs/ton.md +1 -1
- package/package.json +1 -1
- package/src/abi/evm-event-names.ts +7 -0
- package/src/abi/evm.gen.ts +6 -0
- package/src/abi/functions.gen.ts +48 -0
- package/src/abi/solana.gen.ts +5 -0
- package/src/errors.ts +2 -2
- package/src/events/types.gen.ts +57 -1
- package/src/evm/chains.ts +31 -0
- package/src/evm/floor/calls.ts +5 -0
- package/src/evm/squid.ts +1 -1
- package/src/generated/interface.gen.ts +48 -43
- package/src/indexer/bodies.ts +142 -4
- 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/fees.ts +30 -4
- package/src/math/v2/milestones.ts +1 -1
- package/src/math/v2/receipt.ts +7 -3
- package/src/math/v2/rows.ts +17 -0
- package/src/math/v2/team.ts +14 -1
- 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/gas.ts +2 -2
- package/src/v2/events.ts +3 -1
- package/src/v2/evm.ts +5 -0
- package/src/v2/layouts.ts +3 -1
- package/src/v2/solana.ts +1 -1
- package/src/v2/tx/evm.ts +15 -1
- package/src/v2/types.ts +11 -1
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);
|
package/src/indexer/stream.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { decode, int, nullable, object, optional, str, unknown } from "./decode.ts";
|
|
4
|
-
import { HEAD, LIVE_LAUNCH,
|
|
5
|
-
import type { Head, Launch,
|
|
4
|
+
import { HEAD, LIVE_LAUNCH, STREAM_TRADE } from "./bodies.ts";
|
|
5
|
+
import type { Head, Launch, StreamTrade } from "./bodies.ts";
|
|
6
6
|
import { indexerPath } from "./paths.ts";
|
|
7
7
|
import type { StreamQuery } from "./paths.ts";
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ const RESET = object({ reason: str, head: HEAD });
|
|
|
16
16
|
export type StreamFrame =
|
|
17
17
|
| { event: "hello"; data: { head: Head; window: number; oldest: string | null; epoch?: string } }
|
|
18
18
|
| { event: "head"; data: { block: number; age: number } }
|
|
19
|
-
| { event: "trade"; id: string; data:
|
|
19
|
+
| { event: "trade"; id: string; data: StreamTrade }
|
|
20
20
|
| { event: "launch"; data: { launch: Launch } }
|
|
21
21
|
| { event: "launchGone"; data: { launch: string; gone: true } }
|
|
22
22
|
| { event: "state"; data: { launch: string; mint: string; block: number; ts: number | null; seq: number; state: Launch } }
|
|
@@ -36,7 +36,7 @@ export function decodeStreamFrame(event: string, data: unknown, id?: string): St
|
|
|
36
36
|
return { event, data: decode(HEAD_SEEN, data) };
|
|
37
37
|
case "trade":
|
|
38
38
|
if (id === undefined) return null;
|
|
39
|
-
return { event, id, data: decode(
|
|
39
|
+
return { event, id, data: decode(STREAM_TRADE, data) };
|
|
40
40
|
case "launch": {
|
|
41
41
|
const d = data as { launch?: unknown; gone?: unknown } | null;
|
|
42
42
|
if (d !== null && typeof d === "object" && d.gone === true) return { event: "launchGone", data: { launch: str(d.launch, "launch"), gone: true } };
|
package/src/math/v2/fees.ts
CHANGED
|
@@ -101,9 +101,28 @@ export function netFromGross(gross: bigint, ppm: readonly number[]): bigint {
|
|
|
101
101
|
return net;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export const TRADER_REF_BPS: readonly [number, number, number] = [
|
|
104
|
+
export const TRADER_REF_BPS: readonly [number, number, number] = [2_400, 420, 180];
|
|
105
105
|
|
|
106
|
-
export const CREATOR_REF_BPS: readonly [number, number, number] = [
|
|
106
|
+
export const CREATOR_REF_BPS: readonly [number, number, number] = [800, 140, 60];
|
|
107
|
+
|
|
108
|
+
export const TRADER_REF_OG_BPS: readonly [number, number, number] = [4_000, 700, 300];
|
|
109
|
+
|
|
110
|
+
export const CREATOR_REF_OG_BPS: readonly [number, number, number] = [2_400, 420, 180];
|
|
111
|
+
|
|
112
|
+
export const OG_WINDOW_SECS = 15_811_200n;
|
|
113
|
+
|
|
114
|
+
export const OG_MAX = 100;
|
|
115
|
+
const OG_U64_MAX = (1n << 64n) - 1n;
|
|
116
|
+
|
|
117
|
+
export const ogUntil = (from: bigint): bigint => (from === 0n ? 0n : from + OG_WINDOW_SECS > OG_U64_MAX ? OG_U64_MAX : from + OG_WINDOW_SECS);
|
|
118
|
+
|
|
119
|
+
export const ogLive = (until: bigint, now: bigint): boolean => now < until;
|
|
120
|
+
|
|
121
|
+
export const ogLaunch = (from: bigint, until: bigint, createdAt: bigint, now: bigint): boolean =>
|
|
122
|
+
from !== 0n && from <= createdAt && createdAt < until && now < until;
|
|
123
|
+
|
|
124
|
+
export const tierBps = (bps: readonly number[], ogBps: readonly number[], og: readonly boolean[]): number[] =>
|
|
125
|
+
[0, 1, 2].map((i) => (og[i] ? ogBps[i]! : bps[i]!));
|
|
107
126
|
|
|
108
127
|
export function slices(fee: bigint, present: readonly boolean[], bps: readonly number[]): [bigint[], bigint] {
|
|
109
128
|
const out = [0n, 0n, 0n];
|
|
@@ -117,5 +136,12 @@ export function slices(fee: bigint, present: readonly boolean[], bps: readonly n
|
|
|
117
136
|
}
|
|
118
137
|
return [out, left];
|
|
119
138
|
}
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
const NO_OG: readonly boolean[] = [false, false, false];
|
|
140
|
+
|
|
141
|
+
export const platformLegsOg = (platform: bigint, traderPresent: readonly boolean[], og: readonly boolean[]): [bigint[], bigint] =>
|
|
142
|
+
slices(platform, traderPresent, tierBps(TRADER_REF_BPS, TRADER_REF_OG_BPS, og));
|
|
143
|
+
|
|
144
|
+
export const creatorLegsOg = (creator: bigint, creatorPresent: readonly boolean[], og: readonly boolean[]): [bigint[], bigint] =>
|
|
145
|
+
slices(creator, creatorPresent, tierBps(CREATOR_REF_BPS, CREATOR_REF_OG_BPS, og));
|
|
146
|
+
export const platformLegs = (platform: bigint, traderPresent: readonly boolean[]): [bigint[], bigint] => platformLegsOg(platform, traderPresent, NO_OG);
|
|
147
|
+
export const creatorLegs = (creator: bigint, creatorPresent: readonly boolean[]): [bigint[], bigint] => creatorLegsOg(creator, creatorPresent, NO_OG);
|
|
@@ -32,7 +32,7 @@ export interface TeamSplit {
|
|
|
32
32
|
|
|
33
33
|
export function teamSplit(amount: bigint, levelsPresent: readonly [boolean, boolean, boolean]): TeamSplit {
|
|
34
34
|
const tenth = amount / 10n;
|
|
35
|
-
const w = [
|
|
35
|
+
const w = [80n, 14n, 6n];
|
|
36
36
|
const referrers: [bigint, bigint, bigint] = [0n, 0n, 0n];
|
|
37
37
|
let paid = 0n;
|
|
38
38
|
for (let i = 0; i < 3; i++) {
|
package/src/math/v2/receipt.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Book } from "./book.ts";
|
|
|
5
5
|
import { bestBidPriceX64V2, dexLiquidityV2, nextBuyPriceX64, stackViewV2 } from "./display.ts";
|
|
6
6
|
import type { LaunchStageV2 } from "./display.ts";
|
|
7
7
|
import { FEE_LEGS, LEG_BACKING, LEG_FLOOR, LEG_HOLDER, LEG_PLATFORM, LEG_TEAM, feeTotal } from "./fees.ts";
|
|
8
|
-
import {
|
|
8
|
+
import { creatorLegsOgV2, platformLegsOgV2, splitMembersV2 } from "./team.ts";
|
|
9
9
|
import { bookBuy, bookSell } from "./trade.ts";
|
|
10
10
|
import type { BookBuy, BookSell } from "./trade.ts";
|
|
11
11
|
import { U64_MAX, U128_MAX } from "./wide.ts";
|
|
@@ -106,6 +106,10 @@ export interface FeePartsOpts {
|
|
|
106
106
|
|
|
107
107
|
creatorRefs?: readonly boolean[];
|
|
108
108
|
|
|
109
|
+
traderOg?: readonly boolean[];
|
|
110
|
+
|
|
111
|
+
creatorOg?: readonly boolean[];
|
|
112
|
+
|
|
109
113
|
slotWeights?: readonly number[];
|
|
110
114
|
}
|
|
111
115
|
export function feePartsV2(fees: readonly bigint[], opts: FeePartsOpts = {}): FeePartsV2 {
|
|
@@ -113,8 +117,8 @@ export function feePartsV2(fees: readonly bigint[], opts: FeePartsOpts = {}): Fe
|
|
|
113
117
|
const none = [false, false, false];
|
|
114
118
|
const team = fees[LEG_TEAM];
|
|
115
119
|
const platform = fees[LEG_PLATFORM];
|
|
116
|
-
const [teamCreatorRefs, teamRest] =
|
|
117
|
-
const [platformTraderRefs, platformBucket] =
|
|
120
|
+
const [teamCreatorRefs, teamRest] = creatorLegsOgV2(team, opts.creatorRefs ?? none, opts.creatorOg ?? none);
|
|
121
|
+
const [platformTraderRefs, platformBucket] = platformLegsOgV2(platform, opts.traderRefs ?? none, opts.traderOg ?? none);
|
|
118
122
|
const w = opts.slotWeights;
|
|
119
123
|
const split = w !== undefined && w.some((x) => x !== 0);
|
|
120
124
|
const [teamMembers, teamDust] = split ? splitMembersV2(teamRest, w) : [Array(w?.length ?? 10).fill(0n) as bigint[], 0n];
|
package/src/math/v2/rows.ts
CHANGED
|
@@ -283,6 +283,23 @@ export function wagmi(): Row {
|
|
|
283
283
|
return wagmiAt(WAGMI_THETA_BPS)!;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
export const WAGMI70_ID = 7;
|
|
287
|
+
export const WAGMI70_PHI_BPS = 7_000;
|
|
288
|
+
export const STEP_WAGMI70_X100 = 111;
|
|
289
|
+
export const WAGMI70_THETA_BPS = 6_092;
|
|
290
|
+
export const WAGMI70_END_USD = 413_510_000n;
|
|
291
|
+
export function wagmi70(): Row {
|
|
292
|
+
return {
|
|
293
|
+
...wagmiBase(),
|
|
294
|
+
id: WAGMI70_ID,
|
|
295
|
+
name: "wagmi-70",
|
|
296
|
+
phiBps: WAGMI70_PHI_BPS,
|
|
297
|
+
climbStepX100: STEP_WAGMI70_X100,
|
|
298
|
+
thetaBps: WAGMI70_THETA_BPS,
|
|
299
|
+
stacks: [st(WAGMI70_END_USD, WAGMI_SPEC_MILESTONES[0])],
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
286
303
|
export const FLOOR_GENESIS_PHI_BPS = 5_000;
|
|
287
304
|
|
|
288
305
|
export function floorGenesis(): Row {
|
package/src/math/v2/team.ts
CHANGED
|
@@ -9,10 +9,23 @@ export const WEIGHT_ONE = 1_000_000_000n;
|
|
|
9
9
|
|
|
10
10
|
export const CREATOR_BUY_LOCK_SECS = 86_400n;
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
CREATOR_REF_BPS,
|
|
14
|
+
CREATOR_REF_OG_BPS,
|
|
15
|
+
OG_MAX,
|
|
16
|
+
OG_WINDOW_SECS,
|
|
17
|
+
TRADER_REF_BPS,
|
|
18
|
+
TRADER_REF_OG_BPS,
|
|
19
|
+
ogLaunch,
|
|
20
|
+
ogLive,
|
|
21
|
+
ogUntil,
|
|
22
|
+
tierBps,
|
|
23
|
+
} from "./fees.ts";
|
|
13
24
|
|
|
14
25
|
export { platformLegs as platformLegsV2, creatorLegs as creatorLegsV2 } from "./fees.ts";
|
|
15
26
|
|
|
27
|
+
export { platformLegsOg as platformLegsOgV2, creatorLegsOg as creatorLegsOgV2 } from "./fees.ts";
|
|
28
|
+
|
|
16
29
|
const u128 = (x: bigint): bigint => (x < 0n || x > U128_MAX ? fail("Overflow") : x);
|
|
17
30
|
const members = (n: number, what: string): void => {
|
|
18
31
|
if (n !== MAX_MEMBERS) throw new RangeError(`${what}: ${n} entries, want ${MAX_MEMBERS}`);
|
|
@@ -90,14 +90,34 @@ export const TRADER_REF: Layout = [
|
|
|
90
90
|
["revoked", "u8"],
|
|
91
91
|
|
|
92
92
|
["pad0", "bytes:5"],
|
|
93
|
-
|
|
93
|
+
|
|
94
|
+
["og_until", "u64[3]"],
|
|
94
95
|
];
|
|
95
96
|
|
|
96
97
|
export const TRADER_LINK: Layout = [
|
|
97
98
|
["wallet", "pubkey"],
|
|
98
99
|
["tiers", "pubkey[3]"],
|
|
99
100
|
["bump", "u8"],
|
|
100
|
-
|
|
101
|
+
|
|
102
|
+
["og_until", "bytes:24"],
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
export const OG_USER: Layout = [
|
|
106
|
+
["referrer", "pubkey"],
|
|
107
|
+
["from", "i64"],
|
|
108
|
+
["until", "i64"],
|
|
109
|
+
["bump", "u8"],
|
|
110
|
+
["revoked", "u8"],
|
|
111
|
+
["pad0", "bytes:6"],
|
|
112
|
+
["reserved", "bytes:32"],
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
export const OG_COUNT: Layout = [
|
|
116
|
+
["count", "u16"],
|
|
117
|
+
["bump", "u8"],
|
|
118
|
+
["pad0", "bytes:5"],
|
|
119
|
+
["total", "u64"],
|
|
120
|
+
["reserved", "bytes:16"],
|
|
101
121
|
];
|
|
102
122
|
|
|
103
123
|
export const REF_OWED: Layout = [
|
|
@@ -209,7 +229,7 @@ export const GENESIS_ALLOC_WAGMI_CLAIMED = 8;
|
|
|
209
229
|
|
|
210
230
|
const NESTED: Record<string, Layout> = { SlotMember: SLOT_MEMBER };
|
|
211
231
|
|
|
212
|
-
export const LAYOUTS = { Config: CONFIG, QuoteEntry: QUOTE_ENTRY, TeamSlot: TEAM_SLOT, SlotMember: SLOT_MEMBER, TraderRef: TRADER_REF, TraderLink: TRADER_LINK, RefOwed: REF_OWED, GenesisRaise: GENESIS_RAISE, GenesisAllocation: GENESIS_ALLOCATION } as const;
|
|
232
|
+
export const LAYOUTS = { Config: CONFIG, QuoteEntry: QUOTE_ENTRY, TeamSlot: TEAM_SLOT, SlotMember: SLOT_MEMBER, TraderRef: TRADER_REF, TraderLink: TRADER_LINK, RefOwed: REF_OWED, OgUser: OG_USER, OgCount: OG_COUNT, GenesisRaise: GENESIS_RAISE, GenesisAllocation: GENESIS_ALLOCATION } as const;
|
|
213
233
|
|
|
214
234
|
function scalarSize(t: string): number {
|
|
215
235
|
switch (t) {
|
|
@@ -367,6 +387,13 @@ export const decodeTeamSlot = (d: Uint8Array) => decodeAccount("TeamSlot", d);
|
|
|
367
387
|
export const decodeTraderRef = (d: Uint8Array) => decodeAccount("TraderRef", d);
|
|
368
388
|
export const decodeTraderLink = (d: Uint8Array) => decodeAccount("TraderLink", d);
|
|
369
389
|
export const decodeRefOwed = (d: Uint8Array) => decodeAccount("RefOwed", d);
|
|
390
|
+
export const decodeOgUser = (d: Uint8Array) => decodeAccount("OgUser", d);
|
|
391
|
+
export const decodeOgCount = (d: Uint8Array) => decodeAccount("OgCount", d);
|
|
392
|
+
|
|
393
|
+
export function traderLinkOgUntil(ogUntil: Uint8Array): [bigint, bigint, bigint] {
|
|
394
|
+
const v = new DataView(ogUntil.buffer, ogUntil.byteOffset, ogUntil.byteLength);
|
|
395
|
+
return [v.getBigUint64(0, true), v.getBigUint64(8, true), v.getBigUint64(16, true)];
|
|
396
|
+
}
|
|
370
397
|
export const decodeGenesisRaise = (d: Uint8Array) => decodeAccount("GenesisRaise", d);
|
|
371
398
|
export const decodeGenesisAllocation = (d: Uint8Array) => decodeAccount("GenesisAllocation", d);
|
|
372
399
|
|
|
@@ -31,6 +31,12 @@ export const EVENTS: Record<string, [string, T][]> = {
|
|
|
31
31
|
TraderLinkOpened: S(["trader", "pubkey"], ["tiers", "pubkey[3]"]),
|
|
32
32
|
|
|
33
33
|
TraderRefCleared: S(["trader", "pubkey"], ["records", "u16"]),
|
|
34
|
+
|
|
35
|
+
OgUserSet: S(["referrer", "pubkey"], ["from", "i64"], ["until", "i64"], ["count", "u16"]),
|
|
36
|
+
|
|
37
|
+
OgUserRevoked: S(["referrer", "pubkey"], ["until", "i64"], ["count", "u16"]),
|
|
38
|
+
|
|
39
|
+
OgSynced: S(["referrer", "pubkey"], ["records", "u16"]),
|
|
34
40
|
CreatorBuyUnlocked: S(["launch", "pubkey"], ["creator", "pubkey"], ["tokens", "u64"], ["members", "u64[10]?"], ["paid", "u64?"]),
|
|
35
41
|
RefOwedOpened: S(["referrer", "pubkey"], ["quoteMint", "pubkey"]),
|
|
36
42
|
RefsRolled: S(["quoteMint", "pubkey"], ["traderRefs", "u16"], ["amount", "u64"]),
|