@floorlaunchpad/sdk 0.3.1 → 0.3.2
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 +31 -0
- package/README.md +6 -5
- package/dist/evm/chains.js +1 -1
- package/dist/indexer/bodies.js +16 -0
- package/dist/indexer/client.js +3 -0
- package/dist/indexer/contract.js +8 -2
- package/dist/indexer/paths.js +6 -0
- package/dist/indexer/read.js +13 -0
- package/dist/v2/devbuy.js +15 -0
- package/docs/floor-line.md +203 -34
- package/examples/floor-line.html +373 -76
- package/package.json +1 -1
- package/src/evm/chains.ts +1 -1
- package/src/indexer/bodies.ts +19 -0
- package/src/indexer/client.ts +6 -0
- package/src/indexer/contract.ts +9 -3
- package/src/indexer/paths.ts +6 -0
- package/src/indexer/read.ts +13 -0
- package/src/v2/devbuy.ts +33 -0
package/src/indexer/contract.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type Pagination =
|
|
|
83
83
|
|
|
84
84
|
| { readonly kind: "range"; readonly from: string; readonly to: string; readonly span?: { readonly interval: string; readonly max: number } };
|
|
85
85
|
|
|
86
|
-
export type PathParam = "launch" | "wallet" | "token";
|
|
86
|
+
export type PathParam = "launch" | "wallet" | "token" | "handle";
|
|
87
87
|
|
|
88
88
|
export interface RouteContract<T = unknown> {
|
|
89
89
|
readonly pattern: string;
|
|
@@ -116,7 +116,7 @@ const WALLET_ERR = [...GATED, "bad_query"] as const;
|
|
|
116
116
|
type Spec<T> = Omit<RouteContract<T>, "aliases" | "mount" | "params" | "query" | "page" | "errors" | "gated" | "units" | "audience"> & Partial<RouteContract<T>>;
|
|
117
117
|
|
|
118
118
|
function site<T>(s: Spec<T> & { v2?: boolean }): RouteContract<T> {
|
|
119
|
-
const params = [...s.pattern.matchAll(/<(launch|wallet|token)>/g)].map((m) => m[1] as PathParam);
|
|
119
|
+
const params = [...s.pattern.matchAll(/<(launch|wallet|token|handle)>/g)].map((m) => m[1] as PathParam);
|
|
120
120
|
const { v2, ...rest } = s;
|
|
121
121
|
const aliases = s.aliases ?? (v2 ? [s.pattern.replace(/^\/floor-amm\//, "/floor-amm/v2/")] : []);
|
|
122
122
|
return { mount: "chain", query: {}, page: NONE, errors: GATED, gated: true, units: "site", audience: "site", ...rest, params, aliases };
|
|
@@ -185,6 +185,10 @@ export const INDEXER_CONTRACT = {
|
|
|
185
185
|
}),
|
|
186
186
|
launchClaims: site({ pattern: "/floor-amm/launches/<launch>/claims", v2: true, query: { claimer: { kind: "string", doc: "only this claimer's rows" } }, errors: LAUNCH_ERR, body: B.LAUNCH_CLAIMS }),
|
|
187
187
|
devBuys: site({ pattern: "/floor-amm/launches/<launch>/dev-buys", v2: true, errors: LAUNCH_ERR, body: B.DEV_BUYS }),
|
|
188
|
+
|
|
189
|
+
memberSold: site({ pattern: "/floor-amm/launches/<launch>/member-sold", v2: true, errors: LAUNCH_ERR, body: B.MEMBER_SOLD }),
|
|
190
|
+
|
|
191
|
+
launchAccount: site({ pattern: "/floor-amm/launches/<launch>/account", v2: true, errors: LAUNCH_ERR, body: B.LAUNCH_ACCOUNT }),
|
|
188
192
|
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 }),
|
|
189
193
|
quoteChain: site({ pattern: "/floor-amm/launches/<launch>/chain", v2: true, errors: LAUNCH_ERR, body: B.QUOTE_CHAIN }),
|
|
190
194
|
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 }),
|
|
@@ -252,6 +256,8 @@ export const INDEXER_CONTRACT = {
|
|
|
252
256
|
people: site({ pattern: "/floor-amm/referrals/<wallet>/people", errors: WALLET_ERR, body: B.PEOPLE }),
|
|
253
257
|
roles: site({ pattern: "/floor-amm/roles/<wallet>", errors: WALLET_ERR, body: B.ROLES }),
|
|
254
258
|
|
|
259
|
+
handlePlaces: site({ pattern: "/floor-amm/handles/<handle>/places", errors: WALLET_ERR, body: B.HANDLE_PLACES }),
|
|
260
|
+
|
|
255
261
|
traderBoard: site({ pattern: "/floor-amm/leaderboards/traders", v2: true, query: { window: WINDOW, limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...GATED, "bad_query"], body: B.TRADER_BOARD }),
|
|
256
262
|
launcherBoard: site({ pattern: "/floor-amm/leaderboards/launchers", v2: true, query: { limit: LIMIT(100, 500) }, page: limit(100, 500), errors: [...GATED, "bad_query"], body: B.LAUNCHER_BOARD }),
|
|
257
263
|
|
|
@@ -306,7 +312,7 @@ export function matchRoute(path: string): { name: RouteName; params: Partial<Rec
|
|
|
306
312
|
const c: RouteContract = INDEXER_CONTRACT[name];
|
|
307
313
|
for (const pat of [c.pattern, ...c.aliases]) {
|
|
308
314
|
const keys: PathParam[] = [];
|
|
309
|
-
const re = new RegExp(`^${pat.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/<(launch|wallet|token)>/g, (_, k: PathParam) => (keys.push(k), "([^/]+)"))}$`);
|
|
315
|
+
const re = new RegExp(`^${pat.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/<(launch|wallet|token|handle)>/g, (_, k: PathParam) => (keys.push(k), "([^/]+)"))}$`);
|
|
310
316
|
const m = re.exec(p);
|
|
311
317
|
if (m === null) continue;
|
|
312
318
|
const params: Partial<Record<PathParam, string>> = {};
|
package/src/indexer/paths.ts
CHANGED
|
@@ -21,6 +21,8 @@ export const INDEXER_ROUTES = {
|
|
|
21
21
|
trades: { pattern: "/floor-amm/launches/<launch>/trades", keys: ["limit", "before", "traders"] },
|
|
22
22
|
launchClaims: { pattern: "/floor-amm/launches/<launch>/claims", keys: ["claimer"] },
|
|
23
23
|
devBuys: { pattern: "/floor-amm/launches/<launch>/dev-buys", keys: [] },
|
|
24
|
+
memberSold: { pattern: "/floor-amm/launches/<launch>/member-sold", keys: [] },
|
|
25
|
+
launchAccount: { pattern: "/floor-amm/launches/<launch>/account", keys: [] },
|
|
24
26
|
traders: { pattern: "/floor-amm/launches/<launch>/traders", keys: ["window", "limit"] },
|
|
25
27
|
quoteChain: { pattern: "/floor-amm/launches/<launch>/chain", keys: [] },
|
|
26
28
|
devTrades: { pattern: "/floor-amm/launches/<launch>/dev", keys: ["limit"] },
|
|
@@ -41,6 +43,7 @@ export const INDEXER_ROUTES = {
|
|
|
41
43
|
claimView: { pattern: "/floor-amm/claims/<wallet>", keys: [] },
|
|
42
44
|
people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: [] },
|
|
43
45
|
roles: { pattern: "/floor-amm/roles/<wallet>", keys: [] },
|
|
46
|
+
handlePlaces: { pattern: "/floor-amm/handles/<handle>/places", keys: [] },
|
|
44
47
|
traderBoard: { pattern: "/floor-amm/leaderboards/traders", keys: ["window", "limit"] },
|
|
45
48
|
launcherBoard: { pattern: "/floor-amm/leaderboards/launchers", keys: ["limit"] },
|
|
46
49
|
} as const satisfies Record<string, IndexerRoute>;
|
|
@@ -156,6 +159,8 @@ export const indexerPath = {
|
|
|
156
159
|
trades: (id: string, q: TradesQuery = {}): string => launchPath(id, `/trades${query({ limit: q.limit, before: q.before, traders: q.traders?.length ? q.traders : undefined })}`),
|
|
157
160
|
launchClaims: (id: string, q: { claimer?: string } = {}): string => launchPath(id, `/claims${query({ claimer: q.claimer })}`),
|
|
158
161
|
devBuys: (id: string): string => launchPath(id, "/dev-buys"),
|
|
162
|
+
memberSold: (id: string): string => launchPath(id, "/member-sold"),
|
|
163
|
+
launchAccount: (id: string): string => launchPath(id, "/account"),
|
|
159
164
|
traders: (id: string, q: { window?: "1h" | "24h" | "7d" | "all"; limit?: number } = {}): string => launchPath(id, `/traders${query({ window: q.window, limit: q.limit })}`),
|
|
160
165
|
quoteChain: (id: string): string => launchPath(id, "/chain"),
|
|
161
166
|
devTrades: (id: string, q: { limit?: number } = {}): string => launchPath(id, `/dev${query({ limit: q.limit })}`),
|
|
@@ -185,6 +190,7 @@ export const indexerPath = {
|
|
|
185
190
|
claimView: (w: string): string => `/floor-amm/claims/${seg(w)}`,
|
|
186
191
|
people: (w: string): string => `/floor-amm/referrals/${seg(w)}/people`,
|
|
187
192
|
roles: (w: string): string => `/floor-amm/roles/${seg(w)}`,
|
|
193
|
+
handlePlaces: (handle: string): string => `/floor-amm/handles/${seg(handle)}/places`,
|
|
188
194
|
traderBoard: (q: { window?: "1h" | "24h" | "7d" | "all"; limit?: number } = {}): string => `/floor-amm/leaderboards/traders${query({ window: q.window, limit: q.limit })}`,
|
|
189
195
|
launcherBoard: (q: { limit?: number } = {}): string => `/floor-amm/leaderboards/launchers${query({ limit: q.limit })}`,
|
|
190
196
|
} as const satisfies Record<IndexerRouteName, (...a: never[]) => string>;
|
package/src/indexer/read.ts
CHANGED
|
@@ -76,6 +76,17 @@ export const readTrades = (get: Get, id: LaunchId, q: TradesQuery = {}): Promise
|
|
|
76
76
|
export const readLaunchClaims = (get: Get, id: LaunchId, q: { claimer?: string } = {}): Promise<At & { claims: B.LaunchClaim[] }> => readRoute(get, indexerPath.launchClaims(id, q), B.LAUNCH_CLAIMS);
|
|
77
77
|
export const readDevBuys = (get: Get, id: LaunchId): Promise<B.DevBuys> => readRoute(get, indexerPath.devBuys(id), B.DEV_BUYS);
|
|
78
78
|
|
|
79
|
+
export const readMemberSold = (get: Get, id: LaunchId): Promise<B.MemberSoldBody> => readRoute(get, indexerPath.memberSold(id), B.MEMBER_SOLD);
|
|
80
|
+
|
|
81
|
+
export const readLaunchAccount = (get: Get, id: LaunchId): Promise<B.LaunchAccountBody> => readRoute(get, indexerPath.launchAccount(id), B.LAUNCH_ACCOUNT);
|
|
82
|
+
|
|
83
|
+
export function launchAccountBytes(body: { data: string }): Uint8Array {
|
|
84
|
+
const bin = atob(body.data);
|
|
85
|
+
const out = new Uint8Array(bin.length);
|
|
86
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
|
|
79
90
|
export const readTraders = (get: Get, id: LaunchId, q: { window?: B.TraderWindow; limit?: number } = {}): Promise<B.LaunchTraders> => readRoute(get, indexerPath.traders(id, q), B.LAUNCH_TRADERS);
|
|
80
91
|
export const readQuoteChain = (get: Get, id: LaunchId): Promise<B.QuoteChain> => readRoute(get, indexerPath.quoteChain(id), B.QUOTE_CHAIN);
|
|
81
92
|
|
|
@@ -104,6 +115,8 @@ export const readFirstsMany = (get: Get, wallets: readonly string[]): Promise<At
|
|
|
104
115
|
export const readPeople = (get: Get, wallet: string): Promise<B.People> => readRoute(get, indexerPath.people(wallet), B.PEOPLE);
|
|
105
116
|
export const readRoles = (get: Get, wallet: string): Promise<B.Roles> => readRoute(get, indexerPath.roles(wallet), B.ROLES);
|
|
106
117
|
|
|
118
|
+
export const readHandlePlaces = (get: Get, handle: string): Promise<B.HandlePlaces> => readRoute(get, indexerPath.handlePlaces(handle), B.HANDLE_PLACES);
|
|
119
|
+
|
|
107
120
|
export const readTraderBoard = (get: Get, q: { window?: B.TraderWindow; limit?: number } = {}): Promise<B.TraderBoard> => readRoute(get, indexerPath.traderBoard(q), B.TRADER_BOARD);
|
|
108
121
|
export const readLauncherBoard = (get: Get, q: { limit?: number } = {}): Promise<B.LauncherBoard> => readRoute(get, indexerPath.launcherBoard(q), B.LAUNCHER_BOARD);
|
|
109
122
|
|
package/src/v2/devbuy.ts
CHANGED
|
@@ -53,3 +53,36 @@ export function devBuyFromTrade(t: TradeEventV2, team: DevTeam, ctx: { teamBuy?:
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export const devBuyChangeSinceBps = (d: DevBuy, sqrtNow: bigint): bigint => impactBps(d.priceAfterX64, priceX64(sqrtNow));
|
|
56
|
+
|
|
57
|
+
export interface TeamSeat {
|
|
58
|
+
place: number;
|
|
59
|
+
wallet: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface MemberSold {
|
|
63
|
+
launch: string;
|
|
64
|
+
|
|
65
|
+
member: string;
|
|
66
|
+
|
|
67
|
+
place: number;
|
|
68
|
+
|
|
69
|
+
amount: bigint;
|
|
70
|
+
|
|
71
|
+
quoteOut: bigint;
|
|
72
|
+
slot?: bigint;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function memberSoldFromTrade(
|
|
76
|
+
t: Pick<TradeEventV2, "launch" | "trader" | "isBuy" | "tokens" | "quoteNet"> & { recipient?: string; slot?: bigint },
|
|
77
|
+
seats: readonly TeamSeat[],
|
|
78
|
+
same: (a: string, b: string) => boolean = (a, b) => a === b,
|
|
79
|
+
): MemberSold | null {
|
|
80
|
+
if (t.isBuy) return null;
|
|
81
|
+
for (const who of t.recipient === undefined ? [t.trader] : [t.trader, t.recipient]) {
|
|
82
|
+
const held = seats.filter((s) => same(s.wallet, who));
|
|
83
|
+
if (held.length === 0) continue;
|
|
84
|
+
const seat = held.reduce((lo, s) => (s.place < lo.place ? s : lo));
|
|
85
|
+
return { launch: t.launch, member: seat.wallet, place: seat.place, amount: t.tokens, quoteOut: t.quoteNet, ...(t.slot === undefined ? {} : { slot: t.slot }) };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|